Skip to content

Commit

Permalink
Test module variable scope fix
Browse files Browse the repository at this point in the history
  • Loading branch information
brandoncasaba committed Apr 16, 2019
1 parent 61ac3e3 commit 5adb941
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
30 changes: 15 additions & 15 deletions tools/test_modules/m19800.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ sub module_generate_hash

my $b_ke = $cbc->encrypt ($b_nfolded2, $b_key_bytes, $b_iv);

my $cleartext_ticket = '68c8459f3f10c851b8827118bb459c6e301aa011180f323031'.
'32313131363134323835355aa10502030c28a2';
my $cleartext_ticket = '';
my $check_correct = 0;

if (defined $enc_timestamp)
{
Expand Down Expand Up @@ -119,19 +119,19 @@ sub module_generate_hash

$check_correct = ($checksum eq byte2hex(substr $b_checksum, 0, 12));
}
if ($check_correct != 1)
{
# fake/wrong ticket (otherwise if we just decrypt/encrypt we end
#up with false positives all the time)
$cleartext_ticket = '68c8459f3f10c851b8827118bb459c6e301aa011180f323031'.
'32313131363134323835355aa10502030c28a2';
# we have what is required to compute checksum
$checksum = hmac_sha1 (hex2byte($cleartext_ticket), $b_ki);

$checksum = byte2hex(substr $checksum, 0, 12);
}
}

if ($check_correct != 1)
{
# fake/wrong ticket (otherwise if we just decrypt/encrypt we end
#up with false positives all the time)
$cleartext_ticket = '68c8459f3f10c851b8827118bb459c6e301aa011180f323031'.
'32313131363134323835355aa10502030c28a2';

# we have what is required to compute checksum
$checksum = hmac_sha1 (hex2byte($cleartext_ticket), $b_ki);

$checksum = byte2hex(substr $checksum, 0, 12);
}

# CTS Encrypt our new block
Expand Down
31 changes: 16 additions & 15 deletions tools/test_modules/m19900.pm
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ sub module_generate_hash
my $b_ke = $cbc->encrypt ($b_nfolded2, $b_key_bytes, $b_iv);

$b_ke = $b_ke . $cbc->encrypt ($b_ke, $b_key_bytes, $b_iv);
my $cleartext_ticket = '68c8459f3f10c851b8827118bb459c6e301aa011180f323031'.
'32313131363134323835355aa10502030c28a2';

my $cleartext_ticket = '';
my $check_correct = 0;

if (defined $enc_timestamp)
{
Expand Down Expand Up @@ -123,21 +124,21 @@ sub module_generate_hash

$check_correct = ($checksum eq byte2hex(substr $b_checksum, 0, 12));
}

if ($check_correct != 1)
{
# fake/wrong ticket (otherwise if we just decrypt/encrypt we end
#up with false positives all the time)
$cleartext_ticket = '68c8459f3f10c851b8827118bb459c6e301aa011180f323031'.
'32313131363134323835355aa10502030c28a2';

# we have what is required to compute checksum
$checksum = hmac_sha1 (hex2byte($cleartext_ticket), $b_ki);

$checksum = byte2hex(substr $checksum, 0, 12);
}
}

if ($check_correct != 1)
{
# fake/wrong ticket (otherwise if we just decrypt/encrypt we end
#up with false positives all the time)
$cleartext_ticket = '68c8459f3f10c851b8827118bb459c6e301aa011180f323031'.
'32313131363134323835355aa10502030c28a2';

# we have what is required to compute checksum
$checksum = hmac_sha1 (hex2byte($cleartext_ticket), $b_ki);

$checksum = byte2hex(substr $checksum, 0, 12);
}

# CTS Encrypt our new block
my $len_cleartext_last_block = length($cleartext_ticket)%32;
my $cleartext_last_block = substr $cleartext_ticket, -$len_cleartext_last_block;
Expand Down

0 comments on commit 5adb941

Please sign in to comment.