Add the missing parts for DES CFB1 and CFB8.
[openssl.git] / crypto / evp / e_aes.c
index bf7c45f..bd6c0a3 100644 (file)
@@ -86,17 +86,35 @@ IMPLEMENT_BLOCK_CIPHER(aes_256, ks, AES, EVP_AES_KEY,
                       EVP_CIPHER_get_asn1_iv,
                       NULL)
 
+#define IMPLEMENT_AES_CFBR(ksize,cbits)        IMPLEMENT_CFBR(aes,AES,EVP_AES_KEY,ks,ksize,cbits,16)
+
+IMPLEMENT_AES_CFBR(128,1)
+IMPLEMENT_AES_CFBR(192,1)
+IMPLEMENT_AES_CFBR(256,1)
+
+IMPLEMENT_AES_CFBR(128,8)
+IMPLEMENT_AES_CFBR(192,8)
+IMPLEMENT_AES_CFBR(256,8)
+
 static int aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
-                  const unsigned char *iv, int enc) {
+                  const unsigned char *iv, int enc)
+       {
+       int ret;
 
        if ((ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_CFB_MODE
            || (ctx->cipher->flags & EVP_CIPH_MODE) == EVP_CIPH_OFB_MODE
            || enc) 
-               AES_set_encrypt_key(key, ctx->key_len * 8, ctx->cipher_data);
+               ret=AES_set_encrypt_key(key, ctx->key_len * 8, ctx->cipher_data);
        else
-               AES_set_decrypt_key(key, ctx->key_len * 8, ctx->cipher_data);
+               ret=AES_set_decrypt_key(key, ctx->key_len * 8, ctx->cipher_data);
+
+       if(ret < 0)
+               {
+               EVPerr(EVP_F_AES_INIT_KEY,EVP_R_AES_KEY_SETUP_FAILED);
+               return 0;
+               }
 
        return 1;
-}
+       }
 
 #endif