The rest of the keysizes for CFB1, working AES AVS test for CFB1.
authorBen Laurie <ben@openssl.org>
Tue, 29 Jul 2003 13:24:27 +0000 (13:24 +0000)
committerBen Laurie <ben@openssl.org>
Tue, 29 Jul 2003 13:24:27 +0000 (13:24 +0000)
crypto/evp/e_aes.c
crypto/objects/obj_dat.h
crypto/objects/obj_mac.h
crypto/objects/obj_mac.num
crypto/objects/objects.txt
fips/aes/Makefile.ssl
fips/aes/fips_aesavs.c

index 542240f7eb090e3a9a518365324730eb23258d3b..3d994c9b98a300120817022590af186065a2500e 100644 (file)
@@ -84,6 +84,19 @@ IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY,
                       EVP_CIPHER_get_asn1_iv,
                       NULL)
 
+#define IMPLEMENT_CFBR(keysize,cbits) \
+       BLOCK_CIPHER_func_cfb(aes_##keysize,AES,cbits,EVP_AES_KEY,ks) \
+       BLOCK_CIPHER_def_cfb(aes_##keysize,EVP_AES_KEY, \
+                            NID_aes_##keysize, keysize/8, 16, cbits, \
+                            0, aes_init_key, NULL, \
+                            EVP_CIPHER_set_asn1_iv, \
+                            EVP_CIPHER_get_asn1_iv, \
+                            NULL)
+
+IMPLEMENT_CFBR(128,1)
+IMPLEMENT_CFBR(192,1)
+IMPLEMENT_CFBR(256,1)
+     /*
 BLOCK_CIPHER_func_cfb(aes_128,AES,1,EVP_AES_KEY,ks)
 BLOCK_CIPHER_def_cfb(aes_128,EVP_AES_KEY,
                     NID_aes_128, 16, 16, 1,
@@ -91,6 +104,7 @@ BLOCK_CIPHER_def_cfb(aes_128,EVP_AES_KEY,
                     EVP_CIPHER_set_asn1_iv,
                     EVP_CIPHER_get_asn1_iv,
                     NULL)
+     */
 
 static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
                   const unsigned char *iv, int enc)
index e83a9abc466d224e641b0789476607f044479a04..0b2bd2af1d4b45e6d0e2d5abf66fd3957a969663 100644 (file)
  * [including the GNU Public Licence.]
  */
 
-#define NUM_NID 651
-#define NUM_SN 644
-#define NUM_LN 644
-#define NUM_OBJ 618
+#define NUM_NID 653
+#define NUM_SN 646
+#define NUM_LN 646
+#define NUM_OBJ 620
 
-static unsigned char lvalues[4461]={
+static unsigned char lvalues[4473]={
 0x00,                                        /* [  0] OBJ_undef */
 0x2A,0x86,0x48,0x86,0xF7,0x0D,               /* [  1] OBJ_rsadsi */
 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,          /* [  7] OBJ_pkcs */
@@ -686,6 +686,8 @@ static unsigned char lvalues[4461]={
 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x14,0x02,0x02,/* [4434] OBJ_ms_smartcard_login */
 0x2B,0x06,0x01,0x04,0x01,0x82,0x37,0x14,0x02,0x03,/* [4444] OBJ_ms_upn */
 0x29,0x01,0x01,0x85,0x1A,0x03,               /* [4454] OBJ_aes_128_cfb1 */
+0x29,0x01,0x01,0x85,0x1A,0x04,               /* [4460] OBJ_aes_192_cfb1 */
+0x29,0x01,0x01,0x85,0x1A,0x05,               /* [4466] OBJ_aes_256_cfb1 */
 };
 
 static ASN1_OBJECT nid_objs[NUM_NID]={
@@ -1730,6 +1732,8 @@ static ASN1_OBJECT nid_objs[NUM_NID]={
 {"msUPN","Microsoft Universal Principal Name",NID_ms_upn,10,
        &(lvalues[4444]),0},
 {"AES-128-CFB1","aes-128-cfb1",NID_aes_128_cfb1,6,&(lvalues[4454]),0},
+{"AES-192-CFB1","aes-192-cfb1",NID_aes_192_cfb1,6,&(lvalues[4460]),0},
+{"AES-256-CFB1","aes-256-cfb1",NID_aes_256_cfb1,6,&(lvalues[4466]),0},
 };
 
 static ASN1_OBJECT *sn_objs[NUM_SN]={
@@ -1741,10 +1745,12 @@ static ASN1_OBJECT *sn_objs[NUM_SN]={
 &(nid_objs[420]),/* "AES-128-OFB" */
 &(nid_objs[423]),/* "AES-192-CBC" */
 &(nid_objs[425]),/* "AES-192-CFB" */
+&(nid_objs[651]),/* "AES-192-CFB1" */
 &(nid_objs[422]),/* "AES-192-ECB" */
 &(nid_objs[424]),/* "AES-192-OFB" */
 &(nid_objs[427]),/* "AES-256-CBC" */
 &(nid_objs[429]),/* "AES-256-CFB" */
+&(nid_objs[652]),/* "AES-256-CFB1" */
 &(nid_objs[426]),/* "AES-256-ECB" */
 &(nid_objs[428]),/* "AES-256-OFB" */
 &(nid_objs[91]),/* "BF-CBC" */
@@ -2493,10 +2499,12 @@ static ASN1_OBJECT *ln_objs[NUM_LN]={
 &(nid_objs[420]),/* "aes-128-ofb" */
 &(nid_objs[423]),/* "aes-192-cbc" */
 &(nid_objs[425]),/* "aes-192-cfb" */
+&(nid_objs[651]),/* "aes-192-cfb1" */
 &(nid_objs[422]),/* "aes-192-ecb" */
 &(nid_objs[424]),/* "aes-192-ofb" */
 &(nid_objs[427]),/* "aes-256-cbc" */
 &(nid_objs[429]),/* "aes-256-cfb" */
+&(nid_objs[652]),/* "aes-256-cfb1" */
 &(nid_objs[426]),/* "aes-256-ecb" */
 &(nid_objs[428]),/* "aes-256-ofb" */
 &(nid_objs[376]),/* "algorithm" */
@@ -3240,6 +3248,8 @@ static ASN1_OBJECT *obj_objs[NUM_OBJ]={
 &(nid_objs[124]),/* OBJ_rle_compression              1 1 1 1 666 1 */
 &(nid_objs[125]),/* OBJ_zlib_compression             1 1 1 1 666 2 */
 &(nid_objs[650]),/* OBJ_aes_128_cfb1                 1 1 1 1 666 3 */
+&(nid_objs[651]),/* OBJ_aes_192_cfb1                 1 1 1 1 666 4 */
+&(nid_objs[652]),/* OBJ_aes_256_cfb1                 1 1 1 1 666 5 */
 &(nid_objs[ 1]),/* OBJ_rsadsi                       1 2 840 113549 */
 &(nid_objs[185]),/* OBJ_X9cm                         1 2 840 10040 4 */
 &(nid_objs[127]),/* OBJ_id_pkix                      1 3 6 1 5 5 7 */
index a72957276f1d5ae7a644e825ef9b2ab67b72a988..ee967a74d4c2c1ded5a71919739ea84f09f26636 100644 (file)
 #define NID_aes_128_cfb1               650
 #define OBJ_aes_128_cfb1               1L,1L,1L,1L,666L,3L
 
+#define SN_aes_192_cfb1                "AES-192-CFB1"
+#define LN_aes_192_cfb1                "aes-192-cfb1"
+#define NID_aes_192_cfb1               651
+#define OBJ_aes_192_cfb1               1L,1L,1L,1L,666L,4L
+
+#define SN_aes_256_cfb1                "AES-256-CFB1"
+#define LN_aes_256_cfb1                "aes-256-cfb1"
+#define NID_aes_256_cfb1               652
+#define OBJ_aes_256_cfb1               1L,1L,1L,1L,666L,5L
+
 #define SN_hold_instruction_code               "holdInstructionCode"
 #define LN_hold_instruction_code               "Hold Instruction Code"
 #define NID_hold_instruction_code              430
index 932b323c000f0783b8c862034a0de1825e4f53b5..d0e3f1a4fcdaddb708e77665fe9fc929f494b4e6 100644 (file)
@@ -648,3 +648,5 @@ international_organizations         647
 ms_smartcard_login             648
 ms_upn         649
 aes_128_cfb1           650
+aes_192_cfb1           651
+aes_256_cfb1           652
index f796c6c7f387b5855773fc05c8dee959e1f6c968..94c29fc972299a64d202f94f8d091144c5bc0dd8 100644 (file)
@@ -684,6 +684,8 @@ aes 44                      : AES-256-CFB           : aes-256-cfb
 # There are no OIDs for these modes...
 
 1 1 1 1 666 3          : AES-128-CFB1          : aes-128-cfb1
+1 1 1 1 666 4          : AES-192-CFB1          : aes-192-cfb1
+1 1 1 1 666 5          : AES-256-CFB1          : aes-256-cfb1
 
 # Hold instruction CRL entry extension
 !Cname hold-instruction-code
index 6d3181afc2e257fd5302d33c2aa6aca179c47517..f96ee99c1770647526205892806904be450bf584 100644 (file)
@@ -67,7 +67,7 @@ tags:
 
 tests:
 
-fips_aesavs: fips_aesavs.o
+fips_aesavs: fips_aesavs.o ../../libcrypto.a
        $(CC) $(CFLAGS) -o fips_aesavs fips_aesavs.o ../../libcrypto.a
 
 fips_test: top
index d54018e4b1028e5e3f2f13e45a22660f59bf9680..6cec69d408caea04407804e54d39b6674b75b40e 100644 (file)
@@ -105,6 +105,12 @@ int AESTest(EVP_CIPHER_CTX *ctx,
            case 5128:
                cipher=EVP_aes_128_cfb1();
                break;
+           case 5192:
+               cipher=EVP_aes_192_cfb1();
+               break;
+           case 5256:
+               cipher=EVP_aes_256_cfb1();
+               break;
            default:
                printf("Didn't handle mode %d\n",kt);
                exit(1);
@@ -207,16 +213,22 @@ void PrintValue(char *tag, unsigned char *val, int len)
 #endif
 }
 
-void OutputValue(char *tag, unsigned char *val, int len, FILE *rfp)
-{
-  char obuf[2048];
-  int olen;
-  olen = bin2hex(val, len, obuf);
-  fprintf(rfp, "%s = %.*s\n", tag, olen, obuf);
+void OutputValue(char *tag, unsigned char *val, int len, FILE *rfp,int bitmode)
+    {
+    char obuf[2048];
+    int olen;
+
+    if(bitmode)
+       fprintf(rfp,"%s = %d\n",tag,val[0] ? 1 : 0);
+    else
+       {
+       olen = bin2hex(val, len, obuf);
+       fprintf(rfp, "%s = %.*s\n", tag, olen, obuf);
+       }
 #if VERBOSE
-  printf("%s = %.*s\n", tag, olen, obuf);
+    printf("%s = %.*s\n", tag, olen, obuf);
 #endif
-}
+    }
 
 /*-----------------------------------------------*/
 char *t_tag[2] = {"PLAINTEXT", "CIPHERTEXT"};
@@ -276,11 +288,12 @@ int do_mct(char *amode,
        /* printf("Iteration %d\n", i); */
        if (i > 0)
            {
-           OutputValue("KEY", key[i], nkeysz, rfp);
+           OutputValue("KEY",key[i],nkeysz,rfp,0);
            if (imode != ECB)  /* ECB */
-               OutputValue("IV", iv[i], AES_BLOCK_SIZE, rfp);
+               OutputValue("IV",iv[i],AES_BLOCK_SIZE,rfp,0);
            /* Output Ciphertext | Plaintext */
-           OutputValue(t_tag[dir^1], (dir)? ptext[0]: ctext[0], len, rfp);
+           OutputValue(t_tag[dir^1],dir ? ptext[0] : ctext[0],len,rfp,
+                       imode == CFB1);
            }
        for (j = 0; j < 1000; ++j)
            {
@@ -373,6 +386,9 @@ int do_mct(char *amode,
            case CFB1:
                if(j == 0)
                    {
+                   /* compensate for wrong endianness of input file */
+                   if(i == 0)
+                       ptext[0][0]<<=7;
                    ret=AESTest(&ctx,amode,akeysz,key[i],iv[i],dir,
                                (char*)ptext[j], ctext[j], len);
                    }
@@ -403,10 +419,8 @@ int do_mct(char *amode,
            }
        --j; /* reset to last of range */
        /* Output Ciphertext | Plaintext */
-       if(imode == CFB1)
-           fprintf(rfp,"%s = %d\n",t_tag[dir],(dir?ctext[j]:ptext[j])[0]&1);
-       else
-           OutputValue(t_tag[dir], (dir)?ctext[j]:ptext[j], len, rfp);
+       OutputValue(t_tag[dir],dir ? ctext[j] : ptext[j],len,rfp,
+                   imode == CFB1);
        fprintf(rfp, "\n");  /* add separator */
 
        /* Compute next KEY */
@@ -493,7 +507,7 @@ int do_mct(char *amode,
            case CFB1:
                for(n1=0,n2=127 ; n1 < 128 ; ++n1,--n2)
                    sb(iv[i+1],n1,gb(ctext[j-n2],0));
-               ptext[0][0]=ctext[j-128][0]&1;
+               ptext[0][0]=ctext[j-128][0]&0x80;
                break;
                }
            }
@@ -518,7 +532,7 @@ int do_mct(char *amode,
            case CFB1:
                for(n1=0,n2=127 ; n1 < 128 ; ++n1,--n2)
                    sb(iv[i+1],n1,gb(ptext[j-n2],0));
-               ctext[0][0]=ptext[j-128][0]&1;
+               ctext[0][0]=ptext[j-128][0]&0x80;
                break;
                }
            }
@@ -759,7 +773,7 @@ int proc_file(char *rqfile)
                  ret = AESTest(&ctx, amode, akeysz, aKey, iVec, 
                                dir,  /* 0 = decrypt, 1 = encrypt */
                                plaintext, ciphertext, len);
-                 OutputValue("CIPHERTEXT", ciphertext, len, rfp);
+                 OutputValue("CIPHERTEXT",ciphertext,len,rfp,0);
                }
              step = 6;
            }
@@ -793,7 +807,8 @@ int proc_file(char *rqfile)
                  ret = AESTest(&ctx, amode, akeysz, aKey, iVec, 
                                dir,  /* 0 = decrypt, 1 = encrypt */
                                plaintext, ciphertext, len);
-                 OutputValue("PLAINTEXT", (unsigned char*)plaintext, len, rfp);
+                 OutputValue("PLAINTEXT",(unsigned char *)plaintext,len,rfp,
+                             0);
                }
              step = 6;
            }