From 0c0bba9776c2184de9de7f5d28bdfdbb89756070 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Tue, 13 Apr 2004 19:46:13 +0000 Subject: [PATCH] 2-key 3DES KAT. --- fips/des/fingerprint.sha1 | 2 +- fips/des/fips_des_selftest.c | 44 ++++++++++++++++++++++++++++++++++++ fips/fingerprint.sha1 | 2 +- fips/fips.c | 2 +- 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/fips/des/fingerprint.sha1 b/fips/des/fingerprint.sha1 index 1a26e57a0f..89968240e0 100644 --- a/fips/des/fingerprint.sha1 +++ b/fips/des/fingerprint.sha1 @@ -1,5 +1,5 @@ HMAC-SHA1(fips_des_enc.c)= ea89417ba58c148c3d72d29438cd0bedc2315f7f HMAC-SHA1(asm/fips-dx86-elf.s)= 2f85e8e86806c92ee4c12cf5354e19eccf6ed47d -HMAC-SHA1(fips_des_selftest.c)= 65498d95dcb502f6b506dd8804771c3d0de17f81 +HMAC-SHA1(fips_des_selftest.c)= af1ad8d10a0f0567d48fcffd6f45b7b050f6dcb5 HMAC-SHA1(fips_set_key.c)= e55cabd0cbe5cd17710e11270d9594c0d7237064 HMAC-SHA1(fips_des_locl.h)= 7053848e884df47f06de9f2248380b92e58ef4e5 diff --git a/fips/des/fips_des_selftest.c b/fips/des/fips_des_selftest.c index 79943af9e0..f2c9ad5b24 100644 --- a/fips/des/fips_des_selftest.c +++ b/fips/des/fips_des_selftest.c @@ -73,6 +73,28 @@ static struct }, }; +static struct + { + DES_cblock key1; + DES_cblock key2; + unsigned char plaintext[8]; + unsigned char ciphertext[8]; + } tests2[]= + { + { + { 0x7c,0x4f,0x6e,0xf7,0xa2,0x04,0x16,0xec }, + { 0x0b,0x6b,0x7c,0x9e,0x5e,0x19,0xa7,0xc4 }, + { 0x06,0xa7,0xd8,0x79,0xaa,0xce,0x69,0xef }, + { 0x4c,0x11,0x17,0x55,0xbf,0xc4,0x4e,0xfd } + }, + { + { 0x5d,0x9e,0x01,0xd3,0x25,0xc7,0x3e,0x34 }, + { 0x01,0x16,0x7c,0x85,0x23,0xdf,0xe0,0x68 }, + { 0x9c,0x50,0x09,0x0f,0x5e,0x7d,0x69,0x7e }, + { 0xd2,0x0b,0x18,0xdf,0xd9,0x0d,0x9e,0xff }, + } + }; + static struct { DES_cblock key1; @@ -123,6 +145,28 @@ int FIPS_selftest_des() } } + /* Encrypt/decrypt with 2-key 3DES and compare to known answers */ + for(n=0 ; n < 2 ; ++n) + { + DES_key_schedule key1, key2; + unsigned char buf[8]; + + DES_set_key(&tests2[n].key1,&key1); + DES_set_key(&tests2[n].key2,&key2); + DES_ecb2_encrypt(tests2[n].plaintext,buf,&key1,&key2,1); + if(memcmp(buf,tests2[n].ciphertext,sizeof buf)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DES,FIPS_R_SELFTEST_FAILED); + return 0; + } + DES_ecb2_encrypt(tests2[n].ciphertext,buf,&key1,&key2,0); + if(memcmp(buf,tests2[n].plaintext,sizeof buf)) + { + FIPSerr(FIPS_F_FIPS_SELFTEST_DES,FIPS_R_SELFTEST_FAILED); + return 0; + } + } + /* Encrypt/decrypt with 3DES and compare to known answers */ for(n=0 ; n < 2 ; ++n) { diff --git a/fips/fingerprint.sha1 b/fips/fingerprint.sha1 index 30502c2dfe..56adb13b20 100644 --- a/fips/fingerprint.sha1 +++ b/fips/fingerprint.sha1 @@ -1,4 +1,4 @@ -HMAC-SHA1(fips.c)= 7d28c5e09fa4e217f8618d63303e944a67cdff44 +HMAC-SHA1(fips.c)= 28c5bb3a276b1536327eb61b496b8c02a574c279 HMAC-SHA1(fips_err_wrapper.c)= d3e2be316062510312269e98f964cb87e7577898 HMAC-SHA1(fips.h)= 30200a267be0bed23d4a93a9e242e181e0ee2b44 HMAC-SHA1(fips_err.h)= f4203a47100a815c21cf3a97092f91a595938f7c diff --git a/fips/fips.c b/fips/fips.c index c3f677217c..d0a432f568 100644 --- a/fips/fips.c +++ b/fips/fips.c @@ -105,7 +105,7 @@ static int FIPS_check_exe(const char *path) HMAC_Final(&hmac,mdbuf,&n); BIO_snprintf(p2,sizeof p2,"%s.sha1",path); f=fopen(p2,"rb"); - if(!f || !fread(buf,1,20,f) != 20) + if(!f || fread(buf,1,20,f) != 20) { fclose(f); FIPSerr(FIPS_F_FIPS_CHECK_EXE,FIPS_R_CANNOT_READ_EXE_DIGEST); -- 2.25.1