From 9c2fcb789e104053fd66aa6443dfdc1859339b80 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Thu, 18 Dec 2003 17:21:18 +0000 Subject: [PATCH] Make OFB MCT work. --- fips/des/fips_desmovs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fips/des/fips_desmovs.c b/fips/des/fips_desmovs.c index 027cb3d3ad..f46a309e92 100644 --- a/fips/des/fips_desmovs.c +++ b/fips/des/fips_desmovs.c @@ -267,6 +267,7 @@ void do_mct(char *amode, { int i,imode; unsigned char nk[4*8]; /* longest key+8 */ + unsigned char text0[8]; for (imode=0 ; imode < 6 ; ++imode) if(!strcmp(amode,t_mode[imode])) @@ -277,12 +278,15 @@ void do_mct(char *amode, exit(1); } + memcpy(text0,text,8); + for(i=0 ; i < 400 ; ++i) { int j; int n; EVP_CIPHER_CTX ctx; int kp=akeysz/64; + unsigned char old_iv[8]; fprintf(rfp,"\nCOUNT = %d\n",i); if(kp == 1) @@ -304,7 +308,6 @@ void do_mct(char *amode, for(j=0 ; j < 10000 ; ++j) { - unsigned char old_iv[8]; unsigned char old_text[8]; memcpy(old_text,text,8); @@ -327,8 +330,8 @@ void do_mct(char *amode, /* accumulate material for the next key */ shiftin(nk,text,Sizes[imode]); /* DebugValue("nk",nk,8); */ - if(dir && (imode == CFB1 || imode == CFB8 || imode == CFB64 - || imode == CBC)) + if((dir && (imode == CFB1 || imode == CFB8 || imode == CFB64 + || imode == CBC)) || imode == OFB) memcpy(text,old_iv,8); if(!dir && (imode == CFB1 || imode == CFB8 || imode == CFB64)) @@ -350,6 +353,13 @@ void do_mct(char *amode, if(numkeys < 2) memcpy(&akey[8],akey,8); memcpy(ivec,ctx.iv,8); + + /* pointless exercise - the final text doesn't depend on the + initial text in OFB mode, so who cares what it is? (Who + designed these tests?) */ + if(imode == OFB) + for(n=0 ; n < 8 ; ++n) + text[n]=text0[n]^old_iv[n]; } } -- 2.25.1