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,
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)
* [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 */
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]={
{"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]={
&(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" */
&(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" */
&(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 */
#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
ms_smartcard_login 648
ms_upn 649
aes_128_cfb1 650
+aes_192_cfb1 651
+aes_256_cfb1 652
# 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
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
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);
#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"};
/* 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)
{
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);
}
}
--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 */
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;
}
}
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;
}
}
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;
}
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;
}