diff --git a/tools/test_modules/m26610.pm b/tools/test_modules/m26610.pm index 71f2d05b0..f49e75ffa 100644 --- a/tools/test_modules/m26610.pm +++ b/tools/test_modules/m26610.pm @@ -36,8 +36,29 @@ sub module_generate_hash my $iv_bin = pack ("H*", $iv); + my $pt = ""; - my $pt = "[{\"type\":\"HD Key Tree\",\"data\":{\"mnemonic\":[112,97,121,109,101,110,116,32,117,112,115,101,116,32,109,101,116,97,108,32,99,104,97,112,116,101,114,32,114,117,110,32,97,100,109,105,116,32,109,101,97,115,117,114,101,32,114,101,109,105,110,100,32,115,117,112,112,108,121,32,104,111,112,101,32,101,110,101,109,121,32,104,101,100,103,101,104,111,103],\"numberOfAccounts\":1,\"hdPath\":\"m/44'/60'/0'/0\"}}]"; + if (! defined ($ct)) + { + $pt = "[{\"type\":\"HD Key Tree\",\"data\":{\"mnemonic\":[112,97,121,109,101,110,116,32,117,112,115,101,116,32,109,101,116,97,108,32,99,104,97,112,116,101,114,32,114,117,110,32,97,100,109,105,116,32,109,101,97,115,117,114,101,32,114,101,109,105,110,100,32,115,117,112,112,108,121,32,104,111,112,101,32,101,110,101,109,121,32,104,101,100,103,101,104,111,103],\"numberOfAccounts\":1,\"hdPath\":\"m/44'/60'/0'/0\"}}]"; + } + else # verify / decrypt + { + my $ct_bin = pack ("H*", $ct); + + my $aes = Crypt::AuthEnc::GCM->new ("AES", $key, $iv_bin); + + $pt = $aes->decrypt_add ($ct_bin); + + if ($pt =~ m/^[ -~]*$/) # is_valid_printable_32 () + { + # ok + } + else + { + $pt = ""; # fake + } + } $pt = substr ($pt, 0, $ct_len);