crypto: inside-secure - Added AES-CFB support
authorPascal van Leeuwen <pascalvanl@gmail.com>
Fri, 30 Aug 2019 07:52:31 +0000 (09:52 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 5 Sep 2019 04:37:29 +0000 (14:37 +1000)
This patch adds support for AES in 128 bit cipher feedback mode (AES-CFB).

Signed-off-by: Pascal van Leeuwen <pvanleeuwen@verimatrix.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/inside-secure/safexcel.c
drivers/crypto/inside-secure/safexcel.h
drivers/crypto/inside-secure/safexcel_cipher.c

index 46cdcbeb122bf61068f23867177d360cfc48f392..3196cb30e1b5fec374e74030f88cc171c8aa75c8 100644 (file)
@@ -981,6 +981,7 @@ static struct safexcel_alg_template *safexcel_algs[] = {
        &safexcel_alg_cbc_des3_ede,
        &safexcel_alg_ecb_aes,
        &safexcel_alg_cbc_aes,
+       &safexcel_alg_cfb_aes,
        &safexcel_alg_ctr_aes,
        &safexcel_alg_md5,
        &safexcel_alg_sha1,
index c6f93ec88c84a47e56e1a82ad47a2f5f2129c678..6f781ed1f0a5a4f82e2a7b83c9ca77b0f839e98b 100644 (file)
@@ -336,6 +336,7 @@ struct safexcel_context_record {
 /* control1 */
 #define CONTEXT_CONTROL_CRYPTO_MODE_ECB                (0 << 0)
 #define CONTEXT_CONTROL_CRYPTO_MODE_CBC                (1 << 0)
+#define CONTEXT_CONTROL_CRYPTO_MODE_CFB                (5 << 0)
 #define CONTEXT_CONTROL_CRYPTO_MODE_CTR_LOAD   (6 << 0)
 #define CONTEXT_CONTROL_CRYPTO_MODE_XTS                (7 << 0)
 #define CONTEXT_CONTROL_CRYPTO_MODE_XCM                ((6 << 0) | BIT(17))
@@ -767,6 +768,7 @@ extern struct safexcel_alg_template safexcel_alg_ecb_des3_ede;
 extern struct safexcel_alg_template safexcel_alg_cbc_des3_ede;
 extern struct safexcel_alg_template safexcel_alg_ecb_aes;
 extern struct safexcel_alg_template safexcel_alg_cbc_aes;
+extern struct safexcel_alg_template safexcel_alg_cfb_aes;
 extern struct safexcel_alg_template safexcel_alg_ctr_aes;
 extern struct safexcel_alg_template safexcel_alg_md5;
 extern struct safexcel_alg_template safexcel_alg_sha1;
index 7091b6086e2e97e42d0a165e3733cbce84fbb6db..4e06c61f9ff98c9233b48abaa30851ce34398ffe 100644 (file)
@@ -1136,6 +1136,42 @@ struct safexcel_alg_template safexcel_alg_cbc_aes = {
        },
 };
 
+static int safexcel_skcipher_aes_cfb_cra_init(struct crypto_tfm *tfm)
+{
+       struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
+
+       safexcel_skcipher_cra_init(tfm);
+       ctx->alg  = SAFEXCEL_AES;
+       ctx->mode = CONTEXT_CONTROL_CRYPTO_MODE_CFB;
+       return 0;
+}
+
+struct safexcel_alg_template safexcel_alg_cfb_aes = {
+       .type = SAFEXCEL_ALG_TYPE_SKCIPHER,
+       .algo_mask = SAFEXCEL_ALG_AES | SAFEXCEL_ALG_AES_XFB,
+       .alg.skcipher = {
+               .setkey = safexcel_skcipher_aes_setkey,
+               .encrypt = safexcel_encrypt,
+               .decrypt = safexcel_decrypt,
+               .min_keysize = AES_MIN_KEY_SIZE,
+               .max_keysize = AES_MAX_KEY_SIZE,
+               .ivsize = AES_BLOCK_SIZE,
+               .base = {
+                       .cra_name = "cfb(aes)",
+                       .cra_driver_name = "safexcel-cfb-aes",
+                       .cra_priority = SAFEXCEL_CRA_PRIORITY,
+                       .cra_flags = CRYPTO_ALG_ASYNC |
+                                    CRYPTO_ALG_KERN_DRIVER_ONLY,
+                       .cra_blocksize = 1,
+                       .cra_ctxsize = sizeof(struct safexcel_cipher_ctx),
+                       .cra_alignmask = 0,
+                       .cra_init = safexcel_skcipher_aes_cfb_cra_init,
+                       .cra_exit = safexcel_skcipher_cra_exit,
+                       .cra_module = THIS_MODULE,
+               },
+       },
+};
+
 static int safexcel_skcipher_aesctr_setkey(struct crypto_skcipher *ctfm,
                                           const u8 *key, unsigned int len)
 {