From: Matt Caswell <matt@openssl.org>
Date: Mon, 8 Apr 2019 16:13:01 +0000 (+0100)
Subject: Implement AES CFB ciphers in the default provider
X-Git-Tag: openssl-3.0.0-alpha1~2155
X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=75dd6d64f1f3afd6fda024d8d91bc2a216bbfcf9;p=oweals%2Fopenssl.git

Implement AES CFB ciphers in the default provider

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8700)
---

diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index dd7bf9b7da..160c04b57c 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -148,6 +148,15 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
         case NID_aes_256_ofb128:
         case NID_aes_192_ofb128:
         case NID_aes_128_ofb128:
+        case NID_aes_256_cfb128:
+        case NID_aes_192_cfb128:
+        case NID_aes_128_cfb128:
+        case NID_aes_256_cfb1:
+        case NID_aes_192_cfb1:
+        case NID_aes_128_cfb1:
+        case NID_aes_256_cfb8:
+        case NID_aes_192_cfb8:
+        case NID_aes_128_cfb8:
             break;
         default:
             goto legacy;
diff --git a/providers/common/ciphers/aes.c b/providers/common/ciphers/aes.c
index 1f3a4136eb..a7af6a6773 100644
--- a/providers/common/ciphers/aes.c
+++ b/providers/common/ciphers/aes.c
@@ -205,6 +205,19 @@ IMPLEMENT_new_ctx(ofb, OFB, 256)
 IMPLEMENT_new_ctx(ofb, OFB, 192)
 IMPLEMENT_new_ctx(ofb, OFB, 128)
 
+/* CFB */
+IMPLEMENT_new_params(cfb, CFB)
+IMPLEMENT_new_params(cfb1, CFB)
+IMPLEMENT_new_params(cfb8, CFB)
+IMPLEMENT_new_ctx(cfb, CFB, 256)
+IMPLEMENT_new_ctx(cfb, CFB, 192)
+IMPLEMENT_new_ctx(cfb, CFB, 128)
+IMPLEMENT_new_ctx(cfb1, CFB, 256)
+IMPLEMENT_new_ctx(cfb1, CFB, 192)
+IMPLEMENT_new_ctx(cfb1, CFB, 128)
+IMPLEMENT_new_ctx(cfb8, CFB, 256)
+IMPLEMENT_new_ctx(cfb8, CFB, 192)
+IMPLEMENT_new_ctx(cfb8, CFB, 128)
 
 static void aes_freectx(void *vctx)
 {
@@ -338,3 +351,14 @@ IMPLEMENT_block_funcs(cbc, 128, 16)
 IMPLEMENT_stream_funcs(ofb, 256, 16)
 IMPLEMENT_stream_funcs(ofb, 192, 16)
 IMPLEMENT_stream_funcs(ofb, 128, 16)
+
+/* CFB */
+IMPLEMENT_stream_funcs(cfb, 256, 16)
+IMPLEMENT_stream_funcs(cfb, 192, 16)
+IMPLEMENT_stream_funcs(cfb, 128, 16)
+IMPLEMENT_stream_funcs(cfb1, 256, 16)
+IMPLEMENT_stream_funcs(cfb1, 192, 16)
+IMPLEMENT_stream_funcs(cfb1, 128, 16)
+IMPLEMENT_stream_funcs(cfb8, 256, 16)
+IMPLEMENT_stream_funcs(cfb8, 192, 16)
+IMPLEMENT_stream_funcs(cfb8, 128, 16)
diff --git a/providers/common/include/internal/provider_algs.h b/providers/common/include/internal/provider_algs.h
index 9bc9ba2c10..40d7eca304 100644
--- a/providers/common/include/internal/provider_algs.h
+++ b/providers/common/include/internal/provider_algs.h
@@ -20,3 +20,12 @@ extern const OSSL_DISPATCH aes128cbc_functions[];
 extern const OSSL_DISPATCH aes256ofb_functions[];
 extern const OSSL_DISPATCH aes192ofb_functions[];
 extern const OSSL_DISPATCH aes128ofb_functions[];
+extern const OSSL_DISPATCH aes256cfb_functions[];
+extern const OSSL_DISPATCH aes192cfb_functions[];
+extern const OSSL_DISPATCH aes128cfb_functions[];
+extern const OSSL_DISPATCH aes256cfb1_functions[];
+extern const OSSL_DISPATCH aes192cfb1_functions[];
+extern const OSSL_DISPATCH aes128cfb1_functions[];
+extern const OSSL_DISPATCH aes256cfb8_functions[];
+extern const OSSL_DISPATCH aes192cfb8_functions[];
+extern const OSSL_DISPATCH aes128cfb8_functions[];
diff --git a/providers/default/defltprov.c b/providers/default/defltprov.c
index 24c10addfe..54b3b8c9ad 100644
--- a/providers/default/defltprov.c
+++ b/providers/default/defltprov.c
@@ -65,6 +65,15 @@ static const OSSL_ALGORITHM deflt_ciphers[] = {
     { "AES-256-OFB", "default=yes", aes256ofb_functions },
     { "AES-192-OFB", "default=yes", aes192ofb_functions },
     { "AES-128-OFB", "default=yes", aes128ofb_functions },
+    { "AES-256-CFB", "default=yes", aes256cfb_functions },
+    { "AES-192-CFB", "default=yes", aes192cfb_functions },
+    { "AES-128-CFB", "default=yes", aes128cfb_functions },
+    { "AES-256-CFB1", "default=yes", aes256cfb1_functions },
+    { "AES-192-CFB1", "default=yes", aes192cfb1_functions },
+    { "AES-128-CFB1", "default=yes", aes128cfb1_functions },
+    { "AES-256-CFB8", "default=yes", aes256cfb8_functions },
+    { "AES-192-CFB8", "default=yes", aes192cfb8_functions },
+    { "AES-128-CFB8", "default=yes", aes128cfb8_functions },
     { NULL, NULL, NULL }
 };