]> git.baikalelectronics.ru Git - kernel.git/commitdiff
crypto: inside-secure - Added support for authenc HMAC-SHA2/DES-CBC
authorPascal van Leeuwen <pascalvanl@gmail.com>
Fri, 13 Sep 2019 20:04:46 +0000 (22:04 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 4 Oct 2019 15:06:09 +0000 (01:06 +1000)
This patch adds support for the authenc(hmac(sha224),cbc(des)),
authenc(hmac(sha256),cbc(des)), authenc(hmac(sha384),cbc(des))
and authenc(hmac(sha512),cbc(des)) aead's

changes since v1:
- nothing

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 36523dd74599b3e5d6fe8c04e2d4c25e2dacd0a9..094b581c194ef5f8df13cc1e53a0f09ad1a7796d 100644 (file)
@@ -1200,6 +1200,10 @@ static struct safexcel_alg_template *safexcel_algs[] = {
        &safexcel_alg_authenc_hmac_sha224_cbc_des3_ede,
        &safexcel_alg_authenc_hmac_sha512_cbc_des3_ede,
        &safexcel_alg_authenc_hmac_sha384_cbc_des3_ede,
+       &safexcel_alg_authenc_hmac_sha256_cbc_des,
+       &safexcel_alg_authenc_hmac_sha224_cbc_des,
+       &safexcel_alg_authenc_hmac_sha512_cbc_des,
+       &safexcel_alg_authenc_hmac_sha384_cbc_des,
 };
 
 static int safexcel_register_algorithms(struct safexcel_crypto_priv *priv)
index b1703e322ab87764fca3a51c70d752e988e2d396..9522594cd3a4e6cf3c7d5e3936f6df77fc2d88d1 100644 (file)
@@ -906,5 +906,9 @@ extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des3_ed
 extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des3_ede;
 extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des3_ede;
 extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des3_ede;
+extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des;
+extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des;
+extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des;
+extern struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des;
 
 #endif
index 0803b0ba233c144bcd87cc851c89be6293fc018f..6c3fdd650ecc7ca6aa4a10929cd992801c18bd85 100644 (file)
@@ -2016,6 +2016,142 @@ struct safexcel_alg_template safexcel_alg_authenc_hmac_sha1_cbc_des = {
        },
 };
 
+static int safexcel_aead_sha256_des_cra_init(struct crypto_tfm *tfm)
+{
+       struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
+
+       safexcel_aead_sha256_cra_init(tfm);
+       ctx->alg = SAFEXCEL_DES; /* override default */
+       return 0;
+}
+
+struct safexcel_alg_template safexcel_alg_authenc_hmac_sha256_cbc_des = {
+       .type = SAFEXCEL_ALG_TYPE_AEAD,
+       .algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_256,
+       .alg.aead = {
+               .setkey = safexcel_aead_setkey,
+               .encrypt = safexcel_aead_encrypt,
+               .decrypt = safexcel_aead_decrypt,
+               .ivsize = DES_BLOCK_SIZE,
+               .maxauthsize = SHA256_DIGEST_SIZE,
+               .base = {
+                       .cra_name = "authenc(hmac(sha256),cbc(des))",
+                       .cra_driver_name = "safexcel-authenc-hmac-sha256-cbc-des",
+                       .cra_priority = SAFEXCEL_CRA_PRIORITY,
+                       .cra_flags = CRYPTO_ALG_ASYNC |
+                                    CRYPTO_ALG_KERN_DRIVER_ONLY,
+                       .cra_blocksize = DES_BLOCK_SIZE,
+                       .cra_ctxsize = sizeof(struct safexcel_cipher_ctx),
+                       .cra_alignmask = 0,
+                       .cra_init = safexcel_aead_sha256_des_cra_init,
+                       .cra_exit = safexcel_aead_cra_exit,
+                       .cra_module = THIS_MODULE,
+               },
+       },
+};
+
+static int safexcel_aead_sha224_des_cra_init(struct crypto_tfm *tfm)
+{
+       struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
+
+       safexcel_aead_sha224_cra_init(tfm);
+       ctx->alg = SAFEXCEL_DES; /* override default */
+       return 0;
+}
+
+struct safexcel_alg_template safexcel_alg_authenc_hmac_sha224_cbc_des = {
+       .type = SAFEXCEL_ALG_TYPE_AEAD,
+       .algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_256,
+       .alg.aead = {
+               .setkey = safexcel_aead_setkey,
+               .encrypt = safexcel_aead_encrypt,
+               .decrypt = safexcel_aead_decrypt,
+               .ivsize = DES_BLOCK_SIZE,
+               .maxauthsize = SHA224_DIGEST_SIZE,
+               .base = {
+                       .cra_name = "authenc(hmac(sha224),cbc(des))",
+                       .cra_driver_name = "safexcel-authenc-hmac-sha224-cbc-des",
+                       .cra_priority = SAFEXCEL_CRA_PRIORITY,
+                       .cra_flags = CRYPTO_ALG_ASYNC |
+                                    CRYPTO_ALG_KERN_DRIVER_ONLY,
+                       .cra_blocksize = DES_BLOCK_SIZE,
+                       .cra_ctxsize = sizeof(struct safexcel_cipher_ctx),
+                       .cra_alignmask = 0,
+                       .cra_init = safexcel_aead_sha224_des_cra_init,
+                       .cra_exit = safexcel_aead_cra_exit,
+                       .cra_module = THIS_MODULE,
+               },
+       },
+};
+
+static int safexcel_aead_sha512_des_cra_init(struct crypto_tfm *tfm)
+{
+       struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
+
+       safexcel_aead_sha512_cra_init(tfm);
+       ctx->alg = SAFEXCEL_DES; /* override default */
+       return 0;
+}
+
+struct safexcel_alg_template safexcel_alg_authenc_hmac_sha512_cbc_des = {
+       .type = SAFEXCEL_ALG_TYPE_AEAD,
+       .algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_512,
+       .alg.aead = {
+               .setkey = safexcel_aead_setkey,
+               .encrypt = safexcel_aead_encrypt,
+               .decrypt = safexcel_aead_decrypt,
+               .ivsize = DES_BLOCK_SIZE,
+               .maxauthsize = SHA512_DIGEST_SIZE,
+               .base = {
+                       .cra_name = "authenc(hmac(sha512),cbc(des))",
+                       .cra_driver_name = "safexcel-authenc-hmac-sha512-cbc-des",
+                       .cra_priority = SAFEXCEL_CRA_PRIORITY,
+                       .cra_flags = CRYPTO_ALG_ASYNC |
+                                    CRYPTO_ALG_KERN_DRIVER_ONLY,
+                       .cra_blocksize = DES_BLOCK_SIZE,
+                       .cra_ctxsize = sizeof(struct safexcel_cipher_ctx),
+                       .cra_alignmask = 0,
+                       .cra_init = safexcel_aead_sha512_des_cra_init,
+                       .cra_exit = safexcel_aead_cra_exit,
+                       .cra_module = THIS_MODULE,
+               },
+       },
+};
+
+static int safexcel_aead_sha384_des_cra_init(struct crypto_tfm *tfm)
+{
+       struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
+
+       safexcel_aead_sha384_cra_init(tfm);
+       ctx->alg = SAFEXCEL_DES; /* override default */
+       return 0;
+}
+
+struct safexcel_alg_template safexcel_alg_authenc_hmac_sha384_cbc_des = {
+       .type = SAFEXCEL_ALG_TYPE_AEAD,
+       .algo_mask = SAFEXCEL_ALG_DES | SAFEXCEL_ALG_SHA2_512,
+       .alg.aead = {
+               .setkey = safexcel_aead_setkey,
+               .encrypt = safexcel_aead_encrypt,
+               .decrypt = safexcel_aead_decrypt,
+               .ivsize = DES_BLOCK_SIZE,
+               .maxauthsize = SHA384_DIGEST_SIZE,
+               .base = {
+                       .cra_name = "authenc(hmac(sha384),cbc(des))",
+                       .cra_driver_name = "safexcel-authenc-hmac-sha384-cbc-des",
+                       .cra_priority = SAFEXCEL_CRA_PRIORITY,
+                       .cra_flags = CRYPTO_ALG_ASYNC |
+                                    CRYPTO_ALG_KERN_DRIVER_ONLY,
+                       .cra_blocksize = DES_BLOCK_SIZE,
+                       .cra_ctxsize = sizeof(struct safexcel_cipher_ctx),
+                       .cra_alignmask = 0,
+                       .cra_init = safexcel_aead_sha384_des_cra_init,
+                       .cra_exit = safexcel_aead_cra_exit,
+                       .cra_module = THIS_MODULE,
+               },
+       },
+};
+
 static int safexcel_aead_sha1_ctr_cra_init(struct crypto_tfm *tfm)
 {
        struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm);