Skip to content

Commit 845477f

Browse files
committed
For -internal mode, if format has internal mask, test it
We do this by dropping last letter of wordlist and add -mask=?w?a See #23
1 parent e87755d commit 845477f

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

jtrts.pl

+27-12
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
if (defined $opts{internal} && $opts{internal} > 0) { doInternalMode(); unlink_restore(); }
6969
if (defined $opts{restore} && $opts{restore} > 0) { doRestoreMode(); unlink_restore(); }
7070
filterPatterns();
71-
process(0);
71+
process(0, 0);
7272
cleanup();
7373
unlink_restore();
7474
displaySummary();
@@ -854,7 +854,7 @@ sub exit_cause {
854854
}
855855

856856
sub process {
857-
my $skip = shift(@_);
857+
my ($skip, $int_mask) = @_;
858858
my $pot = "tst-.pot";
859859
my $pot_opt = "";
860860
my $line_num = 0;
@@ -895,6 +895,9 @@ sub process {
895895
$dict_name = "--incremental=" . substr($ar[5],10);
896896
} else {
897897
$dict_name = "--wordlist=$ar[5].dic";
898+
if ($int_mask) {
899+
$dict_name .= " --mask=?w?a";
900+
}
898901
}
899902
my $cmd = "$cmd_head $ar[6]";
900903
unless (-e $ar[6]) { next LINE; }
@@ -1300,7 +1303,7 @@ sub is_hash_salted {
13001303
return $details[11] > 0;
13011304
}
13021305
sub build_self_test_files {
1303-
my $type = $_[0];
1306+
my ($type, $int_mask) = @_;
13041307
my $cnt = 0;
13051308
my $mangle = does_hash_split_unifies_case($type);
13061309
my $cmd = "$JOHN_EXE -format=$type -list=format-tests $show_pass_thru 2>/dev/null";
@@ -1311,24 +1314,34 @@ sub build_self_test_files {
13111314
open (FILE2, "> tst-.dic") || die "problem creating tst-.dic\n";
13121315
# output some long format 'tester' input words. We might improve this with time.
13131316
# sizes I could see: 55, 56, 64, 65, 80, 81, 119, 120, 125, 126 bytes long.
1314-
print FILE2 "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n";
1315-
print FILE2 "123456789012345678901234567890123456789012345678901234567\n";
1316-
print FILE2 "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n";
1317+
if (!$int_mask) {
1318+
print FILE2 "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n";
1319+
print FILE2 "123456789012345678901234567890123456789012345678901234567\n";
1320+
print FILE2 "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n";
1321+
}
13171322
foreach my $line (@ar1) {
13181323
my @dtls = split("\t", $line);
13191324
if (scalar (@dtls) >= 3) {
13201325
if ($dtls[2] !~ m/:/) { $dtls[2] = "vec_" . $dtls[1] . ":" . $dtls[2]; }
1321-
print FILE1 $dtls[2]."\n";
1322-
if (defined $dtls[3]) { print FILE2 $dtls[3]; }
1326+
if ($int_mask) {
1327+
if (defined $dtls[3] && length($dtls[3])) {
1328+
$cnt++;
1329+
print FILE1 $dtls[2]."\n";
1330+
print FILE2 substr($dtls[3], 0, -1);
1331+
}
1332+
} else {
1333+
$cnt++;
1334+
print FILE1 $dtls[2]."\n";
1335+
print FILE2 defined $dtls[3] ? $dtls[3] : "";
1336+
}
13231337
print FILE2 "\n";
1324-
if ($cnt < 3) {
1338+
if ($cnt < 3 && !$int_mask) {
13251339
print FILE2 "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234\n";
13261340
}
13271341
if (defined $opts{case_mangle} && $opts{case_mangle} > 0) {
13281342
print FILE1 PossiblyCaseMangle($dtls[2], "uprcase", not $mangle);
13291343
print FILE1 PossiblyCaseMangle($dtls[2], "lowcase", not $mangle);
13301344
}
1331-
$cnt += 1;
13321345
}
13331346
}
13341347
close(FILE2); close(FILE1);
@@ -1404,8 +1417,10 @@ sub doInternalMode {
14041417
if (scalar(@match) == 0) { $doit = 0; }
14051418

14061419
if ($doit == 1) {
1420+
my $int_mask = `$JOHN_EXE --format=$type $show_pass_thru --list=format-all-details 2>/dev/null | grep "Internal mask generation"`;
1421+
$int_mask = (defined $int_mask && $int_mask =~ m/yes/i) ? 1 : 0;
14071422
# first, build our dictionary/input files
1408-
my $cnt = build_self_test_files($type);
1423+
my $cnt = build_self_test_files($type, $int_mask);
14091424
# build the @tstdata array with 1 element
14101425
if (does_hash_split_unifies_case($type)) {
14111426
my $cnt3 = $cnt*3;
@@ -1415,7 +1430,7 @@ sub doInternalMode {
14151430
}
14161431
ScreenOutV("Preparing to run internal for type: $type\n");
14171432
ScreenOutV("tstdata = @tstdata\n\n");
1418-
process(1);
1433+
process(1, $int_mask);
14191434
}
14201435
}
14211436

0 commit comments

Comments
 (0)