From f36f90e898788b3d69f4caa8c822f71482c4ce1b Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 27 Feb 2023 09:25:03 +0000 Subject: [PATCH] Add missing unicode conversion to unit test for new plugin 31200 --- tools/test_modules/m31200.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/test_modules/m31200.pm b/tools/test_modules/m31200.pm index a80d6f7d8..59ce280e8 100644 --- a/tools/test_modules/m31200.pm +++ b/tools/test_modules/m31200.pm @@ -11,6 +11,7 @@ use warnings; use Crypt::PBKDF2; use Digest::SHA qw (sha1); use Crypt::CBC; +use Encode; sub module_constraints { [[0, 256], [32, 32], [-1, -1], [-1, -1], [-1, -1]] } @@ -30,7 +31,9 @@ sub module_generate_hash my $salt_bin = pack ("H*", $salt); - my $pbkdf2key = $pbkdf2->PBKDF2 ($salt_bin, $word); + my $word_utf16le = encode ("UTF-16LE", $word); + + my $pbkdf2key = $pbkdf2->PBKDF2 ($salt_bin, $word_utf16le); my $key = substr ($pbkdf2key, 0, 32); my $iv = substr ($pbkdf2key, 32, 16); @@ -75,7 +78,7 @@ sub module_generate_hash my $ct_bin = $aes_cbc->encrypt ($pt); - my $hash = sprintf ('$vbk$*%s*%d*%s', pack ("H*", $salt_bin), $iter, pack ("H*", $ct_bin)); + my $hash = sprintf ('$vbk$*%s*%d*%s', unpack ("H*", $salt_bin), $iter, unpack ("H*", $ct_bin)); return $hash; }