From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4ABA3A00E6 for ; Thu, 11 Jul 2019 15:23:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1F3AB1B997; Thu, 11 Jul 2019 15:23:26 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 98FB61B954 for ; Thu, 11 Jul 2019 15:23:24 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6BDK1eT023742; Thu, 11 Jul 2019 06:23:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=1oQH9B3xQyQOYXbMKGsOwL+OaVC32KQm3GOnFRMPvLQ=; b=Qmtc6B+Yr2ArIScNVXnt9eFZVeKATDQXUxsQQyvAMc+nayfvLxAN7S/OCCL4dPHU6qD9 dhGdQL1qyTQOgqaymic29EQ6v74HBs6XlpG2vIr74dDjanUbFWf9cSIwWv+H0vPjNqo6 fXhrAGkC71ybeKymXBHIPJ5ljHQulCn9oDAergcDyvbAr3g9WEJz5rdRH5oIGK6TpTZ6 6InKxXDNRegYIBtKU2BmW2pR/okzzfZ2n11Wn/Ma3iQ/cNGngD5E3lIxZ1jmy5kT5o+G T9k4glERVJ+55YLh2gVNCMhMq5UmKbq7rOUl/aFNfnR5gJK/FpVDIkQ6kW5p3M/hIqeZ og== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2tp4d20c8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 11 Jul 2019 06:23:23 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 11 Jul 2019 06:23:22 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 11 Jul 2019 06:23:22 -0700 Received: from localhost.marvell.com (unknown [10.28.10.76]) by maili.marvell.com (Postfix) with ESMTP id D98DE3F703F; Thu, 11 Jul 2019 06:23:19 -0700 (PDT) From: Ayuj Verma To: CC: , , , , , , , Ayuj Verma Date: Thu, 11 Jul 2019 18:52:46 +0530 Message-ID: <1562851366-23900-3-git-send-email-ayverma@marvell.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1562851366-23900-1-git-send-email-ayverma@marvell.com> References: <1562851366-23900-1-git-send-email-ayverma@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-11_02:, , signatures=0 Subject: [dpdk-dev] [PATCH v1 2/2] test/crypto: add tests for RSA key type CRT X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added RSA sign/verify and enc/dec tests for RSA key type CRT(quintuple) and associated test vectors. Signed-off-by: Kanaka Durga Kotamarthy Signed-off-by: Ayuj Verma Signed-off-by: Shally Verma --- app/test/test_cryptodev_asym.c | 97 ++++++++++++++++++++++++++++++ app/test/test_cryptodev_rsa_test_vectors.h | 93 ++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index e3f78a3..4dee164 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -607,6 +607,101 @@ struct test_cases_array { } static int +test_rsa_sign_verify_crt(void) +{ + struct crypto_testsuite_params *ts_params = &testsuite_params; + struct rte_mempool *sess_mpool = ts_params->session_mpool; + uint8_t dev_id = ts_params->valid_devs[0]; + struct rte_cryptodev_asym_session *sess; + struct rte_cryptodev_info dev_info; + int status = TEST_SUCCESS; + + /* Test case supports op with quintuple format key only, + * Check im PMD feature flag for RSA quintuple key type support. + */ + rte_cryptodev_info_get(dev_id, &dev_info); + if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) { + RTE_LOG(INFO, USER1, "Device doesn't support sign op with " + "quintuple key type. Test skipped\n"); + return -ENOTSUP; + } + + sess = rte_cryptodev_asym_session_create(sess_mpool); + + if (!sess) { + RTE_LOG(ERR, USER1, "Session creation failed for " + "sign_verify_crt\n"); + status = TEST_FAILED; + return status; + } + + if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt, + sess_mpool) < 0) { + RTE_LOG(ERR, USER1, "Unable to config asym session for " + "sign_verify_crt\n"); + status = TEST_FAILED; + goto error_exit; + } + status = queue_ops_rsa_sign_verify(sess); + +error_exit: + + rte_cryptodev_asym_session_clear(dev_id, sess); + rte_cryptodev_asym_session_free(sess); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return status; +} + +static int +test_rsa_enc_dec_crt(void) +{ + struct crypto_testsuite_params *ts_params = &testsuite_params; + struct rte_mempool *sess_mpool = ts_params->session_mpool; + uint8_t dev_id = ts_params->valid_devs[0]; + struct rte_cryptodev_asym_session *sess; + struct rte_cryptodev_info dev_info; + int status = TEST_SUCCESS; + + /* Test case supports op with quintuple format key only, + * Check in PMD feature flag for RSA quintuple key type support. + */ + rte_cryptodev_info_get(dev_id, &dev_info); + if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) { + RTE_LOG(INFO, USER1, "Device doesn't support decrypt op with " + "quintuple key type. Test skipped\n"); + return -ENOTSUP; + } + + sess = rte_cryptodev_asym_session_create(sess_mpool); + + if (!sess) { + RTE_LOG(ERR, USER1, "Session creation failed for " + "enc_dec_crt\n"); + return TEST_FAILED; + } + + if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt, + sess_mpool) < 0) { + RTE_LOG(ERR, USER1, "Unable to config asym session for " + "enc_dec_crt\n"); + status = TEST_FAILED; + goto error_exit; + } + status = queue_ops_rsa_enc_dec(sess); + +error_exit: + + rte_cryptodev_asym_session_clear(dev_id, sess); + rte_cryptodev_asym_session_free(sess); + + TEST_ASSERT_EQUAL(status, 0, "Test failed"); + + return status; +} + +static int testsuite_setup(void) { struct crypto_testsuite_params *ts_params = &testsuite_params; @@ -1671,6 +1766,8 @@ static inline void print_asym_capa( TEST_CASE_ST(ut_setup, ut_teardown, test_dh_keygenration), TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec), TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify), + TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec_crt), + TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify_crt), TEST_CASE_ST(ut_setup, ut_teardown, test_mod_inv), TEST_CASE_ST(ut_setup, ut_teardown, test_mod_exp), TEST_CASE_ST(ut_setup, ut_teardown, test_one_by_one), diff --git a/app/test/test_cryptodev_rsa_test_vectors.h b/app/test/test_cryptodev_rsa_test_vectors.h index 3f8c41a..0dc0375 100644 --- a/app/test/test_cryptodev_rsa_test_vectors.h +++ b/app/test/test_cryptodev_rsa_test_vectors.h @@ -64,6 +64,60 @@ struct rsa_test_data rsaplaintext = { uint8_t rsa_e[] = {0x01, 0x00, 0x01}; +uint8_t rsa_p[] = { + 0xdc, 0xba, 0x00, 0x01, 0x57, 0x93, 0xe3, 0x05, + 0xed, 0x61, 0x9a, 0xa3, 0xaf, 0x6a, 0xd3, 0x47, + 0x8f, 0x2d, 0x1e, 0x7f, 0x4d, 0x60, 0xc8, 0x8d, + 0x34, 0xb8, 0x17, 0x84, 0xbc, 0xd4, 0xe9, 0x79, + 0x95, 0x75, 0x19, 0x37, 0xe0, 0xcc, 0xfe, 0x4c, + 0x5d, 0x49, 0x53, 0x61, 0x29, 0xf1, 0xdc, 0x82, + 0x03, 0x96, 0x7d, 0x95, 0x4f, 0xdd, 0x3c, 0x0a, + 0x64, 0x8a, 0x43, 0x2f, 0x95, 0x4a, 0xed, 0xdd +}; + +uint8_t rsa_q[] = { + 0xd0, 0x56, 0x7a, 0x0a, 0xd5, 0x95, 0xa4, 0x85, + 0x53, 0x35, 0xa1, 0x48, 0x07, 0x6a, 0x7c, 0x08, + 0xe0, 0xfd, 0x4b, 0x88, 0x77, 0xa6, 0x15, 0x23, + 0x0f, 0xbf, 0x14, 0x46, 0x11, 0xee, 0x95, 0xc7, + 0x5e, 0x77, 0x65, 0xa2, 0xb5, 0x50, 0xdf, 0x19, + 0x07, 0xc7, 0x72, 0xdb, 0x29, 0xf6, 0x54, 0x86, + 0xe1, 0xb3, 0x97, 0x0a, 0x28, 0x64, 0x3a, 0x38, + 0xa6, 0x7d, 0x13, 0xc3, 0x79, 0xaa, 0x56, 0xd9 +}; + +uint8_t rsa_dP[] = { + 0xc5, 0x43, 0x0d, 0x82, 0x25, 0x8c, 0xab, 0x55, + 0xbe, 0xc2, 0x7d, 0xfb, 0x4f, 0x68, 0x3f, 0x0e, + 0x32, 0xec, 0xf5, 0xd6, 0x7b, 0x86, 0xc5, 0x75, + 0x3c, 0xea, 0x51, 0x4a, 0x75, 0xa0, 0x2a, 0x50, + 0x58, 0xbb, 0xe0, 0x1f, 0xca, 0x2e, 0x2a, 0x0e, + 0x81, 0x48, 0x68, 0xd5, 0xeb, 0x30, 0x96, 0x0b, + 0x33, 0xbd, 0xa8, 0xda, 0x6a, 0x17, 0xa3, 0xf2, + 0xfd, 0xcb, 0x7b, 0x23, 0xe9, 0x5e, 0x9f, 0x99 +}; +uint8_t rsa_dQ[] = { + 0xbe, 0xff, 0xf9, 0x05, 0x43, 0xc8, 0xdc, 0x3b, + 0x0b, 0x0d, 0x28, 0xde, 0x73, 0x46, 0x11, 0x8e, + 0xc6, 0x4e, 0x11, 0xd8, 0x7b, 0xf0, 0xfc, 0x81, + 0xd7, 0x66, 0xd3, 0xbc, 0x65, 0xa6, 0x39, 0x14, + 0xbd, 0xab, 0x72, 0xb7, 0x57, 0xc9, 0x5b, 0xaf, + 0x83, 0xed, 0x3b, 0x84, 0x68, 0x15, 0x18, 0x6b, + 0x4c, 0x32, 0xac, 0x6f, 0x38, 0x96, 0xa2, 0xb5, + 0xdb, 0x14, 0xe2, 0x70, 0x9c, 0x73, 0x29, 0x09 +}; + +uint8_t rsa_qInv[] = { + 0x59, 0xbd, 0xb1, 0x37, 0xeb, 0x4e, 0xcf, 0x68, + 0xe7, 0x85, 0x91, 0xbb, 0xc0, 0xdb, 0x8e, 0x41, + 0x91, 0x4a, 0xc0, 0xb1, 0xc5, 0xe8, 0x91, 0xf6, + 0xc7, 0x5a, 0x98, 0x1a, 0x8a, 0x0f, 0x45, 0xb2, + 0x5b, 0xff, 0x7a, 0x2d, 0x98, 0x89, 0x55, 0xd9, + 0xbf, 0x6e, 0xdd, 0x2d, 0xd4, 0xe8, 0x0a, 0xaa, + 0xae, 0x2a, 0xc4, 0x16, 0xb5, 0xba, 0xe1, 0x69, + 0x71, 0x94, 0xdd, 0xa0, 0xf5, 0x1e, 0x6d, 0xcc +}; + /** rsa xform using exponent key */ struct rte_crypto_asym_xform rsa_xform = { .next = NULL, @@ -85,4 +139,43 @@ struct rte_crypto_asym_xform rsa_xform = { } }; +/** rsa xform using quintuple key */ +struct rte_crypto_asym_xform rsa_xform_crt = { + .next = NULL, + .xform_type = RTE_CRYPTO_ASYM_XFORM_RSA, + .rsa = { + .n = { + .data = rsa_n, + .length = sizeof(rsa_n) + }, + .e = { + .data = rsa_e, + .length = sizeof(rsa_e) + }, + .key_type = RTE_RSA_KET_TYPE_QT, + .qt = { + .p = { + .data = rsa_p, + .length = sizeof(rsa_p) + }, + .q = { + .data = rsa_q, + .length = sizeof(rsa_q) + }, + .dP = { + .data = rsa_dP, + .length = sizeof(rsa_dP) + }, + .dQ = { + .data = rsa_dQ, + .length = sizeof(rsa_dQ) + }, + .qInv = { + .data = rsa_qInv, + .length = sizeof(rsa_qInv) + }, + } + } +}; + #endif /* TEST_CRYPTODEV_RSA_TEST_VECTORS_H__ */ -- 1.8.3.1