From: Ben Laurie Date: Tue, 29 Jul 2003 17:05:16 +0000 (+0000) Subject: AES CFB8. X-Git-Tag: OpenSSL_0_9_7c~46 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f3b2ea53e28ffed640ff9a929676b233d9b94837;p=oweals%2Fopenssl.git AES CFB8. --- diff --git a/crypto/aes/aes.h b/crypto/aes/aes.h index 4ac943e9a8..5e177a3dd8 100644 --- a/crypto/aes/aes.h +++ b/crypto/aes/aes.h @@ -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); diff --git a/crypto/aes/aes_cfb.c b/crypto/aes/aes_cfb.c index bd61aa8229..31d7e2dd77 100644 --- a/crypto/aes/aes_cfb.c +++ b/crypto/aes/aes_cfb.c @@ -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); + } + diff --git a/crypto/evp/c_allc.c b/crypto/evp/c_allc.c index 3e22b7b424..65b3fd9766 100644 --- a/crypto/evp/c_allc.c +++ b/crypto/evp/c_allc.c @@ -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()); diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c index 3d994c9b98..e45b6b3268 100644 --- a/crypto/evp/e_aes.c +++ b/crypto/evp/e_aes.c @@ -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) diff --git a/crypto/evp/evptests.txt b/crypto/evp/evptests.txt index 169c6ec1eb..772aa18f49 100644 --- a/crypto/evp/evptests.txt +++ b/crypto/evp/evptests.txt @@ -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 diff --git a/crypto/objects/obj_dat.h b/crypto/objects/obj_dat.h index 0b2bd2af1d..91f59da366 100644 --- a/crypto/objects/obj_dat.h +++ b/crypto/objects/obj_dat.h @@ -62,12 +62,12 @@ * [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 */ diff --git a/crypto/objects/obj_mac.h b/crypto/objects/obj_mac.h index ee967a74d4..0dc69f910e 100644 --- a/crypto/objects/obj_mac.h +++ b/crypto/objects/obj_mac.h @@ -2024,6 +2024,21 @@ #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 diff --git a/crypto/objects/obj_mac.num b/crypto/objects/obj_mac.num index d0e3f1a4fc..c675abaa60 100644 --- a/crypto/objects/obj_mac.num +++ b/crypto/objects/obj_mac.num @@ -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 diff --git a/crypto/objects/objects.txt b/crypto/objects/objects.txt index 94c29fc972..44ceace090 100644 --- a/crypto/objects/objects.txt +++ b/crypto/objects/objects.txt @@ -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 diff --git a/fips/aes/fips_aesavs.c b/fips/aes/fips_aesavs.c index 94bcaf2a40..914a442a48 100644 --- a/fips/aes/fips_aesavs.c +++ b/fips/aes/fips_aesavs.c @@ -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);