crypto/dpaa2_sec: support ZUC ciphering/integrity
authorHemant Agrawal <hemant.agrawal@nxp.com>
Mon, 30 Sep 2019 14:41:00 +0000 (20:11 +0530)
committerAkhil Goyal <akhil.goyal@nxp.com>
Wed, 9 Oct 2019 09:50:12 +0000 (11:50 +0200)
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
doc/guides/cryptodevs/features/dpaa2_sec.ini
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
drivers/crypto/dpaa2_sec/dpaa2_sec_priv.h

index fe550d6..3a88828 100644 (file)
@@ -26,6 +26,7 @@ AES CTR (192) = Y
 AES CTR (256) = Y
 3DES CBC      = Y
 SNOW3G UEA2   = Y
+ZUC EEA3      = Y
 
 ;
 ; Supported authentication algorithms of the 'dpaa2_sec' crypto driver.
@@ -38,6 +39,7 @@ SHA256 HMAC  = Y
 SHA384 HMAC  = Y
 SHA512 HMAC  = Y
 SNOW3G UIA2  = Y
+ZUC EIA3     = Y
 
 ;
 ; Supported AEAD algorithms of the 'dpaa2_sec' crypto driver.
index 451fa91..1653245 100644 (file)
@@ -1072,6 +1072,9 @@ build_auth_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
                if (sess->auth_alg == RTE_CRYPTO_AUTH_SNOW3G_UIA2) {
                        iv_ptr = conv_to_snow_f9_iv(iv_ptr);
                        sge->length = 12;
+               } else if (sess->auth_alg == RTE_CRYPTO_AUTH_ZUC_EIA3) {
+                       iv_ptr = conv_to_zuc_eia_iv(iv_ptr);
+                       sge->length = 8;
                } else {
                        sge->length = sess->iv.length;
                }
@@ -1897,8 +1900,14 @@ dpaa2_sec_cipher_init(struct rte_cryptodev *dev,
                                              &cipherdata,
                                              session->dir);
                break;
-       case RTE_CRYPTO_CIPHER_KASUMI_F8:
        case RTE_CRYPTO_CIPHER_ZUC_EEA3:
+               cipherdata.algtype = OP_ALG_ALGSEL_ZUCE;
+               session->cipher_alg = RTE_CRYPTO_CIPHER_ZUC_EEA3;
+               bufsize = cnstr_shdsc_zuce(priv->flc_desc[0].desc, 1, 0,
+                                             &cipherdata,
+                                             session->dir);
+               break;
+       case RTE_CRYPTO_CIPHER_KASUMI_F8:
        case RTE_CRYPTO_CIPHER_AES_F8:
        case RTE_CRYPTO_CIPHER_AES_ECB:
        case RTE_CRYPTO_CIPHER_3DES_ECB:
@@ -2045,8 +2054,18 @@ dpaa2_sec_auth_init(struct rte_cryptodev *dev,
                                              !session->dir,
                                              session->digest_length);
                break;
-       case RTE_CRYPTO_AUTH_KASUMI_F9:
        case RTE_CRYPTO_AUTH_ZUC_EIA3:
+               authdata.algtype = OP_ALG_ALGSEL_ZUCA;
+               authdata.algmode = OP_ALG_AAI_F9;
+               session->auth_alg = RTE_CRYPTO_AUTH_ZUC_EIA3;
+               session->iv.offset = xform->auth.iv.offset;
+               session->iv.length = xform->auth.iv.length;
+               bufsize = cnstr_shdsc_zuca(priv->flc_desc[DESC_INITFINAL].desc,
+                                          1, 0, &authdata,
+                                          !session->dir,
+                                          session->digest_length);
+               break;
+       case RTE_CRYPTO_AUTH_KASUMI_F9:
        case RTE_CRYPTO_AUTH_NULL:
        case RTE_CRYPTO_AUTH_SHA1:
        case RTE_CRYPTO_AUTH_SHA256:
@@ -2357,6 +2376,7 @@ dpaa2_sec_aead_chain_init(struct rte_cryptodev *dev,
                session->cipher_alg = RTE_CRYPTO_CIPHER_AES_CTR;
                break;
        case RTE_CRYPTO_CIPHER_SNOW3G_UEA2:
+       case RTE_CRYPTO_CIPHER_ZUC_EEA3:
        case RTE_CRYPTO_CIPHER_NULL:
        case RTE_CRYPTO_CIPHER_3DES_ECB:
        case RTE_CRYPTO_CIPHER_AES_ECB:
@@ -2651,6 +2671,7 @@ dpaa2_sec_ipsec_proto_init(struct rte_crypto_cipher_xform *cipher_xform,
                cipherdata->algtype = OP_PCL_IPSEC_NULL;
                break;
        case RTE_CRYPTO_CIPHER_SNOW3G_UEA2:
+       case RTE_CRYPTO_CIPHER_ZUC_EEA3:
        case RTE_CRYPTO_CIPHER_3DES_ECB:
        case RTE_CRYPTO_CIPHER_AES_ECB:
        case RTE_CRYPTO_CIPHER_KASUMI_F8:
index 3d79336..ca4fcfe 100644 (file)
@@ -456,6 +456,51 @@ static const struct rte_cryptodev_capabilities dpaa2_sec_capabilities[] = {
                        }, }
                }, }
        },
+       {       /* ZUC (EEA3) */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       {.cipher = {
+                               .algo = RTE_CRYPTO_CIPHER_ZUC_EEA3,
+                               .block_size = 16,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               },
+                               .iv_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               }
+                       }, }
+               }, }
+       },
+       {       /* ZUC (EIA3) */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
+                       {.auth = {
+                               .algo = RTE_CRYPTO_AUTH_ZUC_EIA3,
+                               .block_size = 16,
+                               .key_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               },
+                               .digest_size = {
+                                       .min = 4,
+                                       .max = 4,
+                                       .increment = 0
+                               },
+                               .iv_size = {
+                                       .min = 16,
+                                       .max = 16,
+                                       .increment = 0
+                               }
+                       }, }
+               }, }
+       },
        RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };