AES CFB8.
authorBen Laurie <ben@openssl.org>
Tue, 29 Jul 2003 17:05:16 +0000 (17:05 +0000)
committerBen Laurie <ben@openssl.org>
Tue, 29 Jul 2003 17:05:16 +0000 (17:05 +0000)
crypto/aes/aes.h
crypto/aes/aes_cfb.c
crypto/evp/c_allc.c
crypto/evp/e_aes.c
crypto/evp/evptests.txt
crypto/objects/obj_dat.h
crypto/objects/obj_mac.h
crypto/objects/obj_mac.num
crypto/objects/objects.txt
fips/aes/fips_aesavs.c

index 4ac943e9a8435d55a67ef5fd1a6a95d9b04f9826..5e177a3dd8f8f427b2bd361baeb628de4c71675c 100644 (file)
@@ -98,6 +98,9 @@ void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
 void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
        const unsigned long length, const AES_KEY *key,
        unsigned char *ivec, int *num, const int enc);
+void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
+       const unsigned long length, const AES_KEY *key,
+       unsigned char *ivec, int *num, const int enc);
 void AES_cfbr_encrypt_block(const unsigned char *in,unsigned char *out,
                            const int nbits,const AES_KEY *key,
                            unsigned char *ivec,const int enc);
index bd61aa8229a6c369724c13527c33144b6e24c757..31d7e2dd77d2f2a13db95f78cf76cd3be1734ad6 100644 (file)
@@ -222,6 +222,7 @@ void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
     {
     unsigned int n;
     unsigned char c[1],d[1];
+
     assert(in && out && key && ivec && num);
     assert(*num == 0);
 
@@ -234,3 +235,16 @@ void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
        }
     }
 
+void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
+                     const unsigned long length, const AES_KEY *key,
+                     unsigned char *ivec, int *num, const int enc)
+    {
+    unsigned int n;
+
+    assert(in && out && key && ivec && num);
+    assert(*num == 0);
+
+    for(n=0 ; n < length ; ++n)
+       AES_cfbr_encrypt_block(&in[n],&out[n],8,key,ivec,enc);
+    }
+
index 3e22b7b424628160ba343983d0f1410d9f42e140..65b3fd9766416701a45e6483564b39e3c6fd3cfb 100644 (file)
@@ -151,6 +151,7 @@ void OpenSSL_add_all_ciphers(void)
        EVP_add_cipher(EVP_aes_128_cbc());
        EVP_add_cipher(EVP_aes_128_cfb());
        EVP_add_cipher(EVP_aes_128_cfb1());
+       EVP_add_cipher(EVP_aes_128_cfb8());
        EVP_add_cipher(EVP_aes_128_ofb());
 #if 0
        EVP_add_cipher(EVP_aes_128_ctr());
index 3d994c9b98a300120817022590af186065a2500e..e45b6b326876b52a89353f0ecf8976f5038101d1 100644 (file)
@@ -96,15 +96,10 @@ IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY,
 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,
-                    0, aes_init_key, NULL, 
-                    EVP_CIPHER_set_asn1_iv,
-                    EVP_CIPHER_get_asn1_iv,
-                    NULL)
-     */
+
+IMPLEMENT_CFBR(128,8)
+IMPLEMENT_CFBR(192,8)
+IMPLEMENT_CFBR(256,8)
 
 static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
                   const unsigned char *iv, int enc)
index 169c6ec1ebf4db26a9e4779de062125c4687d114..772aa18f49fe9f84b01288fe50ccefe803edf116 100644 (file)
@@ -140,6 +140,54 @@ AES-128-CFB1*8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f
 
 # TODO: CFB1-AES192 and 256
 
+# CFB8-AES128.Encrypt
+
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6b:3b:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0102030405060708090a0b0c0d0e0f3b:c1:79:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:02030405060708090a0b0c0d0e0f3b79:be:42:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:030405060708090a0b0c0d0e0f3b7942:e2:4c:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0405060708090a0b0c0d0e0f3b79424c:2e:9c:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:05060708090a0b0c0d0e0f3b79424c9c:40:0d:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:060708090a0b0c0d0e0f3b79424c9c0d:9f:d4:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0708090a0b0c0d0e0f3b79424c9c0dd4:96:36:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:08090a0b0c0d0e0f3b79424c9c0dd436:e9:ba:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:090a0b0c0d0e0f3b79424c9c0dd436ba:3d:ce:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0a0b0c0d0e0f3b79424c9c0dd436bace:7e:9e:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0b0c0d0e0f3b79424c9c0dd436bace9e:11:0e:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0c0d0e0f3b79424c9c0dd436bace9e0e:73:d4:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0d0e0f3b79424c9c0dd436bace9e0ed4:93:58:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0e0f3b79424c9c0dd436bace9e0ed458:17:6a:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0f3b79424c9c0dd436bace9e0ed4586a:2a:4f:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:3b79424c9c0dd436bace9e0ed4586a4f:ae:32:1
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:79424c9c0dd436bace9e0ed4586a4f32:2d:b9:1
+# all of the above packed into one
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6bc1bee22e409f96e93d7e117393172aae2d:3b79424c9c0dd436bace9e0ed4586a4f32b9:1
+
+# CFB8-AES128.Decrypt
+
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6b:3b:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0102030405060708090a0b0c0d0e0f3b:c1:79:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:02030405060708090a0b0c0d0e0f3b79:be:42:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:030405060708090a0b0c0d0e0f3b7942:e2:4c:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0405060708090a0b0c0d0e0f3b79424c:2e:9c:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:05060708090a0b0c0d0e0f3b79424c9c:40:0d:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:060708090a0b0c0d0e0f3b79424c9c0d:9f:d4:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0708090a0b0c0d0e0f3b79424c9c0dd4:96:36:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:08090a0b0c0d0e0f3b79424c9c0dd436:e9:ba:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:090a0b0c0d0e0f3b79424c9c0dd436ba:3d:ce:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0a0b0c0d0e0f3b79424c9c0dd436bace:7e:9e:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0b0c0d0e0f3b79424c9c0dd436bace9e:11:0e:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0c0d0e0f3b79424c9c0dd436bace9e0e:73:d4:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0d0e0f3b79424c9c0dd436bace9e0ed4:93:58:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0e0f3b79424c9c0dd436bace9e0ed458:17:6a:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:0f3b79424c9c0dd436bace9e0ed4586a:2a:4f:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:3b79424c9c0dd436bace9e0ed4586a4f:ae:32:0
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:79424c9c0dd436bace9e0ed4586a4f32:2d:b9:0
+# all of the above packed into one
+AES-128-CFB8:2b7e151628aed2a6abf7158809cf4f3c:000102030405060708090a0b0c0d0e0f:6bc1bee22e409f96e93d7e117393172aae2d:3b79424c9c0dd436bace9e0ed4586a4f32b9:0
+
+# TODO: 192 and 256 bit keys
+
 # For all CFB128 encrypts and decrypts, the transformed sequence is
 #   AES-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec
 # CFB128-AES128.Encrypt 
index 0b2bd2af1d4b45e6d0e2d5abf66fd3957a969663..91f59da366b40ba33aa1d4adff0510ec59034075 100644 (file)
  * [including the GNU Public Licence.]
  */
 
-#define NUM_NID 653
-#define NUM_SN 646
-#define NUM_LN 646
-#define NUM_OBJ 620
+#define NUM_NID 656
+#define NUM_SN 649
+#define NUM_LN 649
+#define NUM_OBJ 623
 
-static unsigned char lvalues[4473]={
+static unsigned char lvalues[4491]={
 0x00,                                        /* [  0] OBJ_undef */
 0x2A,0x86,0x48,0x86,0xF7,0x0D,               /* [  1] OBJ_rsadsi */
 0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,          /* [  7] OBJ_pkcs */
@@ -688,6 +688,9 @@ static unsigned char lvalues[4473]={
 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 */
+0x29,0x01,0x01,0x85,0x1A,0x06,               /* [4472] OBJ_aes_128_cfb8 */
+0x29,0x01,0x01,0x85,0x1A,0x07,               /* [4478] OBJ_aes_192_cfb8 */
+0x29,0x01,0x01,0x85,0x1A,0x08,               /* [4484] OBJ_aes_256_cfb8 */
 };
 
 static ASN1_OBJECT nid_objs[NUM_NID]={
@@ -1734,6 +1737,9 @@ static ASN1_OBJECT nid_objs[NUM_NID]={
 {"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},
+{"AES-128-CFB8","aes-128-cfb8",NID_aes_128_cfb8,6,&(lvalues[4472]),0},
+{"AES-192-CFB8","aes-192-cfb8",NID_aes_192_cfb8,6,&(lvalues[4478]),0},
+{"AES-256-CFB8","aes-256-cfb8",NID_aes_256_cfb8,6,&(lvalues[4484]),0},
 };
 
 static ASN1_OBJECT *sn_objs[NUM_SN]={
@@ -1741,16 +1747,19 @@ static ASN1_OBJECT *sn_objs[NUM_SN]={
 &(nid_objs[419]),/* "AES-128-CBC" */
 &(nid_objs[421]),/* "AES-128-CFB" */
 &(nid_objs[650]),/* "AES-128-CFB1" */
+&(nid_objs[653]),/* "AES-128-CFB8" */
 &(nid_objs[418]),/* "AES-128-ECB" */
 &(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[654]),/* "AES-192-CFB8" */
 &(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[655]),/* "AES-256-CFB8" */
 &(nid_objs[426]),/* "AES-256-ECB" */
 &(nid_objs[428]),/* "AES-256-OFB" */
 &(nid_objs[91]),/* "BF-CBC" */
@@ -2495,16 +2504,19 @@ static ASN1_OBJECT *ln_objs[NUM_LN]={
 &(nid_objs[419]),/* "aes-128-cbc" */
 &(nid_objs[421]),/* "aes-128-cfb" */
 &(nid_objs[650]),/* "aes-128-cfb1" */
+&(nid_objs[653]),/* "aes-128-cfb8" */
 &(nid_objs[418]),/* "aes-128-ecb" */
 &(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[654]),/* "aes-192-cfb8" */
 &(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[655]),/* "aes-256-cfb8" */
 &(nid_objs[426]),/* "aes-256-ecb" */
 &(nid_objs[428]),/* "aes-256-ofb" */
 &(nid_objs[376]),/* "algorithm" */
@@ -3250,6 +3262,9 @@ static ASN1_OBJECT *obj_objs[NUM_OBJ]={
 &(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[653]),/* OBJ_aes_128_cfb8                 1 1 1 1 666 6 */
+&(nid_objs[654]),/* OBJ_aes_192_cfb8                 1 1 1 1 666 7 */
+&(nid_objs[655]),/* OBJ_aes_256_cfb8                 1 1 1 1 666 8 */
 &(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 ee967a74d4c2c1ded5a71919739ea84f09f26636..0dc69f910eef68f920dfc3a77852afb48911a07b 100644 (file)
 #define NID_aes_256_cfb1               652
 #define OBJ_aes_256_cfb1               1L,1L,1L,1L,666L,5L
 
+#define SN_aes_128_cfb8                "AES-128-CFB8"
+#define LN_aes_128_cfb8                "aes-128-cfb8"
+#define NID_aes_128_cfb8               653
+#define OBJ_aes_128_cfb8               1L,1L,1L,1L,666L,6L
+
+#define SN_aes_192_cfb8                "AES-192-CFB8"
+#define LN_aes_192_cfb8                "aes-192-cfb8"
+#define NID_aes_192_cfb8               654
+#define OBJ_aes_192_cfb8               1L,1L,1L,1L,666L,7L
+
+#define SN_aes_256_cfb8                "AES-256-CFB8"
+#define LN_aes_256_cfb8                "aes-256-cfb8"
+#define NID_aes_256_cfb8               655
+#define OBJ_aes_256_cfb8               1L,1L,1L,1L,666L,8L
+
 #define SN_hold_instruction_code               "holdInstructionCode"
 #define LN_hold_instruction_code               "Hold Instruction Code"
 #define NID_hold_instruction_code              430
index d0e3f1a4fcdaddb708e77665fe9fc929f494b4e6..c675abaa6044116b7557a0af3ae94dd3d095fd80 100644 (file)
@@ -650,3 +650,6 @@ ms_upn              649
 aes_128_cfb1           650
 aes_192_cfb1           651
 aes_256_cfb1           652
+aes_128_cfb8           653
+aes_192_cfb8           654
+aes_256_cfb8           655
index 94c29fc972299a64d202f94f8d091144c5bc0dd8..44ceace090c2162da5691537be867fe2a626961d 100644 (file)
@@ -686,6 +686,9 @@ aes 44                      : AES-256-CFB           : aes-256-cfb
 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
+1 1 1 1 666 6          : AES-128-CFB8          : aes-128-cfb8
+1 1 1 1 666 7          : AES-192-CFB8          : aes-192-cfb8
+1 1 1 1 666 8          : AES-256-CFB8          : aes-256-cfb8
 
 # Hold instruction CRL entry extension
 !Cname hold-instruction-code
index 94bcaf2a40978c2de95afd25ed7f9acb18ea8f4c..914a442a48849efe8736692c88c6663a91f533b6 100644 (file)
@@ -49,6 +49,8 @@ int AESTest(EVP_CIPHER_CTX *ctx,
        kt = 4000;
     else if(!strcasecmp(amode,"CFB1"))
        kt=5000;
+    else if(!strcasecmp(amode,"CFB8"))
+       kt=6000;
     else
        {
        printf("Unknown mode: %s\n", amode);
@@ -111,6 +113,15 @@ int AESTest(EVP_CIPHER_CTX *ctx,
            case 5256:
                cipher=EVP_aes_256_cfb1();
                break;
+           case 6128:
+               cipher=EVP_aes_128_cfb8();
+               break;
+           case 6192:
+               cipher=EVP_aes_192_cfb8();
+               break;
+           case 6256:
+               cipher=EVP_aes_256_cfb8();
+               break;
            default:
                printf("Didn't handle mode %d\n",kt);
                exit(1);