crypto/openssl: support DES-CBC
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 5 Oct 2017 05:27:59 +0000 (06:27 +0100)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 12 Oct 2017 14:14:44 +0000 (15:14 +0100)
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
doc/guides/rel_notes/release_17_11.rst
drivers/crypto/openssl/rte_openssl_pmd.c
drivers/crypto/openssl/rte_openssl_pmd_ops.c
test/test/test_cryptodev.c
test/test/test_cryptodev_des_test_vectors.h

index 7704559..d0b2ff6 100644 (file)
@@ -99,6 +99,12 @@ New Features
   This requires the IPSec Multi-buffer library 0.47. For more details,
   check out the AESNI MB PMD documenation.
 
+* **Updated the OpenSSL PMD.**
+
+  The OpenSSL PMD has been updated with additional support for:
+
+  * DES CBC algorithm.
+
 * **Add new benchmarking mode to dpdk-test-crypto-perf application.**
 
   Added new "PMD cyclecount" benchmark mode to dpdk-test-crypto-perf application
index 280148e..0c822a4 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;
index 8cdd0b2..a197f79 100644 (file)
@@ -427,6 +427,26 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
                        }, }
                }, }
        },
+       {       /* DES CBC */
+               .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
+               {.sym = {
+                       .xform_type = RTE_CRYPTO_SYM_XFORM_CIPHER,
+                       {.cipher = {
+                               .algo = RTE_CRYPTO_CIPHER_DES_CBC,
+                               .block_size = 8,
+                               .key_size = {
+                                       .min = 8,
+                                       .max = 8,
+                                       .increment = 0
+                               },
+                               .iv_size = {
+                                       .min = 8,
+                                       .max = 8,
+                                       .increment = 0
+                               }
+                       }, }
+               }, }
+       },
        {       /* DES DOCSIS BPI */
                .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
                {.sym = {
index aa0ca51..4c750f6 100644 (file)
@@ -4671,6 +4671,25 @@ test_DES_cipheronly_qat_all(void)
        return TEST_SUCCESS;
 }
 
+static int
+test_DES_cipheronly_openssl_all(void)
+{
+       struct crypto_testsuite_params *ts_params = &testsuite_params;
+       int status;
+
+       status = test_blockcipher_all_tests(ts_params->mbuf_pool,
+               ts_params->op_mpool,
+               ts_params->session_mpool,
+               ts_params->valid_devs[0],
+               rte_cryptodev_driver_id_get(
+               RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
+               BLKCIPHER_DES_CIPHERONLY_TYPE);
+
+       TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+       return TEST_SUCCESS;
+}
+
 static int
 test_DES_docsis_openssl_all(void)
 {
@@ -8352,6 +8371,8 @@ static struct unit_test_suite cryptodev_openssl_testsuite  = {
                                test_3DES_chain_openssl_all),
                TEST_CASE_ST(ut_setup, ut_teardown,
                                test_3DES_cipheronly_openssl_all),
+               TEST_CASE_ST(ut_setup, ut_teardown,
+                               test_DES_cipheronly_openssl_all),
                TEST_CASE_ST(ut_setup, ut_teardown,
                                test_DES_docsis_openssl_all),
                TEST_CASE_ST(ut_setup, ut_teardown,
index 9bb3618..bb01246 100644 (file)
@@ -852,14 +852,16 @@ static const struct blockcipher_test_case des_cipheronly_test_cases[] = {
                .test_data = &des_cbc_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
                .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_QAT |
-                       BLOCKCIPHER_TEST_TARGET_PMD_MB
+                       BLOCKCIPHER_TEST_TARGET_PMD_MB |
+                       BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL
        },
        {
                .test_descr = "DES-CBC Decryption",
                .test_data = &des_cbc_test_vector,
                .op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
                .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_QAT |
-                       BLOCKCIPHER_TEST_TARGET_PMD_MB
+                       BLOCKCIPHER_TEST_TARGET_PMD_MB |
+                       BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL
        },
 
 };