crypto/openssl: fix AEAD parameters
[dpdk.git] / drivers / crypto / openssl / rte_openssl_pmd.c
index 280148e..cc1ec39 100644 (file)
@@ -355,6 +355,33 @@ openssl_set_session_cipher_parameters(struct openssl_session *sess,
                                sess->cipher.key.data) != 0)
                        return -EINVAL;
                break;
+
+       case RTE_CRYPTO_CIPHER_DES_CBC:
+               sess->cipher.algo = xform->cipher.algo;
+               sess->cipher.ctx = EVP_CIPHER_CTX_new();
+               sess->cipher.evp_algo = EVP_des_cbc();
+
+               get_cipher_key(xform->cipher.key.data, sess->cipher.key.length,
+                       sess->cipher.key.data);
+               if (sess->cipher.direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
+                       if (EVP_EncryptInit_ex(sess->cipher.ctx,
+                                       sess->cipher.evp_algo,
+                                       NULL, xform->cipher.key.data,
+                                       NULL) != 1) {
+                               return -EINVAL;
+                       }
+               } else if (sess->cipher.direction ==
+                               RTE_CRYPTO_CIPHER_OP_DECRYPT) {
+                       if (EVP_DecryptInit_ex(sess->cipher.ctx,
+                                       sess->cipher.evp_algo,
+                                       NULL, xform->cipher.key.data,
+                                       NULL) != 1) {
+                               return -EINVAL;
+                       }
+               }
+
+               break;
+
        case RTE_CRYPTO_CIPHER_DES_DOCSISBPI:
                sess->cipher.algo = xform->cipher.algo;
                sess->chain_order = OPENSSL_CHAIN_CIPHER_BPI;
@@ -482,8 +509,15 @@ static int
 openssl_set_session_aead_parameters(struct openssl_session *sess,
                const struct rte_crypto_sym_xform *xform)
 {
-       /* Select cipher direction */
-       sess->cipher.direction = xform->cipher.op;
+       /* Select cipher direction and auth operation */
+       if (xform->aead.op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
+               sess->cipher.direction = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
+               sess->auth.operation = RTE_CRYPTO_AUTH_OP_GENERATE;
+       } else {
+               sess->cipher.direction = RTE_CRYPTO_CIPHER_OP_DECRYPT;
+               sess->auth.operation = RTE_CRYPTO_AUTH_OP_VERIFY;
+       }
+
        /* Select cipher key */
        sess->cipher.key.length = xform->aead.key.length;
 
@@ -491,10 +525,6 @@ openssl_set_session_aead_parameters(struct openssl_session *sess,
        sess->iv.offset = xform->aead.iv.offset;
        sess->iv.length = xform->aead.iv.length;
 
-       /* Select auth generate/verify */
-       sess->auth.operation = xform->auth.op;
-       sess->auth.algo = xform->auth.algo;
-
        /* Select auth algo */
        switch (xform->aead.algo) {
        case RTE_CRYPTO_AEAD_AES_GCM: