crypto: talitos - add new crypto modes
authorLEROY Christophe <christophe.leroy@c-s.fr>
Tue, 1 Dec 2015 11:44:15 +0000 (12:44 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 4 Dec 2015 14:29:56 +0000 (22:29 +0800)
This patch adds the following algorithms to the talitos driver:
* ecb(aes)
* ctr(aes)
* ecb(des)
* cbc(des)
* ecb(des3_ede)

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/talitos.c
drivers/crypto/talitos.h

index ab3389881af7a1bb5c3d9ca749303d35d940ac7a..a0d4a08313ae895d1595428a6e70f4c1c528b6d4 100644 (file)
@@ -2322,6 +2322,22 @@ static struct talitos_alg_template driver_algs[] = {
                                     DESC_HDR_MODE1_MDEU_MD5_HMAC,
        },
        /* ABLKCIPHER algorithms. */
+       {       .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
+               .alg.crypto = {
+                       .cra_name = "ecb(aes)",
+                       .cra_driver_name = "ecb-aes-talitos",
+                       .cra_blocksize = AES_BLOCK_SIZE,
+                       .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
+                                    CRYPTO_ALG_ASYNC,
+                       .cra_ablkcipher = {
+                               .min_keysize = AES_MIN_KEY_SIZE,
+                               .max_keysize = AES_MAX_KEY_SIZE,
+                               .ivsize = AES_BLOCK_SIZE,
+                       }
+               },
+               .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
+                                    DESC_HDR_SEL0_AESU,
+       },
        {       .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
                .alg.crypto = {
                        .cra_name = "cbc(aes)",
@@ -2339,6 +2355,73 @@ static struct talitos_alg_template driver_algs[] = {
                                     DESC_HDR_SEL0_AESU |
                                     DESC_HDR_MODE0_AESU_CBC,
        },
+       {       .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
+               .alg.crypto = {
+                       .cra_name = "ctr(aes)",
+                       .cra_driver_name = "ctr-aes-talitos",
+                       .cra_blocksize = AES_BLOCK_SIZE,
+                       .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
+                                    CRYPTO_ALG_ASYNC,
+                       .cra_ablkcipher = {
+                               .min_keysize = AES_MIN_KEY_SIZE,
+                               .max_keysize = AES_MAX_KEY_SIZE,
+                               .ivsize = AES_BLOCK_SIZE,
+                       }
+               },
+               .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
+                                    DESC_HDR_SEL0_AESU |
+                                    DESC_HDR_MODE0_AESU_CTR,
+       },
+       {       .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
+               .alg.crypto = {
+                       .cra_name = "ecb(des)",
+                       .cra_driver_name = "ecb-des-talitos",
+                       .cra_blocksize = DES_BLOCK_SIZE,
+                       .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
+                                    CRYPTO_ALG_ASYNC,
+                       .cra_ablkcipher = {
+                               .min_keysize = DES_KEY_SIZE,
+                               .max_keysize = DES_KEY_SIZE,
+                               .ivsize = DES_BLOCK_SIZE,
+                       }
+               },
+               .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
+                                    DESC_HDR_SEL0_DEU,
+       },
+       {       .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
+               .alg.crypto = {
+                       .cra_name = "cbc(des)",
+                       .cra_driver_name = "cbc-des-talitos",
+                       .cra_blocksize = DES_BLOCK_SIZE,
+                       .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
+                                    CRYPTO_ALG_ASYNC,
+                       .cra_ablkcipher = {
+                               .min_keysize = DES_KEY_SIZE,
+                               .max_keysize = DES_KEY_SIZE,
+                               .ivsize = DES_BLOCK_SIZE,
+                       }
+               },
+               .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
+                                    DESC_HDR_SEL0_DEU |
+                                    DESC_HDR_MODE0_DEU_CBC,
+       },
+       {       .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
+               .alg.crypto = {
+                       .cra_name = "ecb(des3_ede)",
+                       .cra_driver_name = "ecb-3des-talitos",
+                       .cra_blocksize = DES3_EDE_BLOCK_SIZE,
+                       .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
+                                    CRYPTO_ALG_ASYNC,
+                       .cra_ablkcipher = {
+                               .min_keysize = DES3_EDE_KEY_SIZE,
+                               .max_keysize = DES3_EDE_KEY_SIZE,
+                               .ivsize = DES3_EDE_BLOCK_SIZE,
+                       }
+               },
+               .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
+                                    DESC_HDR_SEL0_DEU |
+                                    DESC_HDR_MODE0_DEU_3DES,
+       },
        {       .type = CRYPTO_ALG_TYPE_ABLKCIPHER,
                .alg.crypto = {
                        .cra_name = "cbc(des3_ede)",
index 0090f3211d68bc94af9d4105f51de7c1123ded0b..8dd8f40e2771ac29993cbfea536503288e26c99a 100644 (file)
@@ -345,6 +345,7 @@ static inline bool has_ftr_sec1(struct talitos_private *priv)
 /* primary execution unit mode (MODE0) and derivatives */
 #define        DESC_HDR_MODE0_ENCRYPT          cpu_to_be32(0x00100000)
 #define        DESC_HDR_MODE0_AESU_CBC         cpu_to_be32(0x00200000)
+#define        DESC_HDR_MODE0_AESU_CTR         cpu_to_be32(0x00600000)
 #define        DESC_HDR_MODE0_DEU_CBC          cpu_to_be32(0x00400000)
 #define        DESC_HDR_MODE0_DEU_3DES         cpu_to_be32(0x00200000)
 #define        DESC_HDR_MODE0_MDEU_CONT        cpu_to_be32(0x08000000)