提交 288fe07a 编写于 作者: D Dr. Stephen Henson

Fix 3DES Monte Carlo test file output which previously outputted

extra bogus lines. Update fipsalgtest.pl to tolerate the old format.
上级 7fdcb457
...@@ -177,7 +177,6 @@ static void do_mct(char *amode, ...@@ -177,7 +177,6 @@ static void do_mct(char *amode,
printf("Unrecognized mode: %s\n", amode); printf("Unrecognized mode: %s\n", amode);
EXIT(1); EXIT(1);
} }
for(i=0 ; i < 400 ; ++i) for(i=0 ; i < 400 ; ++i)
{ {
int j; int j;
...@@ -277,7 +276,7 @@ static int proc_file(char *rqfile, char *rspfile) ...@@ -277,7 +276,7 @@ static int proc_file(char *rqfile, char *rspfile)
char atest[100] = ""; char atest[100] = "";
int akeysz=0; int akeysz=0;
unsigned char iVec[20], aKey[40]; unsigned char iVec[20], aKey[40];
int dir = -1, err = 0, step = 0; int dir = -1, err = 0, step = 0, echo = 1;
unsigned char plaintext[2048]; unsigned char plaintext[2048];
unsigned char ciphertext[2048]; unsigned char ciphertext[2048];
char *rp; char *rp;
...@@ -383,6 +382,8 @@ static int proc_file(char *rqfile, char *rspfile) ...@@ -383,6 +382,8 @@ static int proc_file(char *rqfile, char *rspfile)
n = strlen(xp+1)-1; n = strlen(xp+1)-1;
strncpy(amode, xp+1, n); strncpy(amode, xp+1, n);
amode[n] = '\0'; amode[n] = '\0';
if (!strcmp(atest, "Monte"))
echo = 0;
/* amode[3] = '\0'; */ /* amode[3] = '\0'; */
if (VERBOSE) if (VERBOSE)
printf("Test=%s, Mode=%s\n",atest,amode); printf("Test=%s, Mode=%s\n",atest,amode);
...@@ -439,8 +440,8 @@ static int proc_file(char *rqfile, char *rspfile) ...@@ -439,8 +440,8 @@ static int proc_file(char *rqfile, char *rspfile)
numkeys=atoi(ibuf+10); numkeys=atoi(ibuf+10);
break; break;
} }
if (echo)
fputs(ibuf, rfp); fputs(ibuf, rfp);
if(!fips_strncasecmp(ibuf,"KEY = ",6)) if(!fips_strncasecmp(ibuf,"KEY = ",6))
{ {
akeysz=64; akeysz=64;
...@@ -495,7 +496,8 @@ static int proc_file(char *rqfile, char *rspfile) ...@@ -495,7 +496,8 @@ static int proc_file(char *rqfile, char *rspfile)
break; break;
case 3: /* IV = xxxx */ case 3: /* IV = xxxx */
fputs(ibuf, rfp); if (echo)
fputs(ibuf, rfp);
if (fips_strncasecmp(ibuf, "IV = ", 5) != 0) if (fips_strncasecmp(ibuf, "IV = ", 5) != 0)
{ {
printf("Missing IV\n"); printf("Missing IV\n");
...@@ -516,7 +518,8 @@ static int proc_file(char *rqfile, char *rspfile) ...@@ -516,7 +518,8 @@ static int proc_file(char *rqfile, char *rspfile)
break; break;
case 4: /* PLAINTEXT = xxxx */ case 4: /* PLAINTEXT = xxxx */
fputs(ibuf, rfp); if (echo)
fputs(ibuf, rfp);
if (fips_strncasecmp(ibuf, "PLAINTEXT = ", 12) != 0) if (fips_strncasecmp(ibuf, "PLAINTEXT = ", 12) != 0)
{ {
printf("Missing PLAINTEXT\n"); printf("Missing PLAINTEXT\n");
...@@ -558,7 +561,8 @@ static int proc_file(char *rqfile, char *rspfile) ...@@ -558,7 +561,8 @@ static int proc_file(char *rqfile, char *rspfile)
break; break;
case 5: /* CIPHERTEXT = xxxx */ case 5: /* CIPHERTEXT = xxxx */
fputs(ibuf, rfp); if (echo)
fputs(ibuf, rfp);
if (fips_strncasecmp(ibuf, "CIPHERTEXT = ", 13) != 0) if (fips_strncasecmp(ibuf, "CIPHERTEXT = ", 13) != 0)
{ {
printf("Missing KEY\n"); printf("Missing KEY\n");
......
...@@ -1090,6 +1090,7 @@ sub cmp_file { ...@@ -1090,6 +1090,7 @@ sub cmp_file {
my ( $tname, $rsp, $tst ) = @_; my ( $tname, $rsp, $tst ) = @_;
my ( $rspf, $tstf ); my ( $rspf, $tstf );
my ( $rspline, $tstline ); my ( $rspline, $tstline );
my $monte = 0;
if ( !open( $rspf, $rsp ) ) { if ( !open( $rspf, $rsp ) ) {
print STDERR "ERROR: can't open request file $rsp\n"; print STDERR "ERROR: can't open request file $rsp\n";
return 0; return 0;
...@@ -1098,6 +1099,7 @@ sub cmp_file { ...@@ -1098,6 +1099,7 @@ sub cmp_file {
print STDERR "ERROR: can't open output file $tst\n"; print STDERR "ERROR: can't open output file $tst\n";
return 0; return 0;
} }
$monte = 1 if ($rsp =~ /Monte[123]/);
for ( ; ; ) { for ( ; ; ) {
$rspline = next_line($rspf); $rspline = next_line($rspf);
$tstline = next_line($tstf); $tstline = next_line($tstf);
...@@ -1105,6 +1107,21 @@ sub cmp_file { ...@@ -1105,6 +1107,21 @@ sub cmp_file {
print STDERR "DEBUG: $tname file comparison OK\n" if $debug; print STDERR "DEBUG: $tname file comparison OK\n" if $debug;
return 1; return 1;
} }
# Workaround for old broken DES3 MCT format which added bogus
# extra lines: after [ENCRYPT] or [DECRYPT] skip until first
# COUNT line.
if ($monte) {
if ($rspline =~ /CRYPT/) {
do {
$rspline = next_line($rspf);
} while (defined($rspline) && $rspline !~ /COUNT/);
}
if ($tstline =~ /CRYPT/) {
do {
$tstline = next_line($tstf);
} while (defined($tstline) && $tstline !~ /COUNT/);
}
}
if ( !defined($rspline) ) { if ( !defined($rspline) ) {
print STDERR "ERROR: $tname EOF on $rsp\n"; print STDERR "ERROR: $tname EOF on $rsp\n";
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册