From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4FD3043026; Thu, 10 Aug 2023 15:14:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D08D40DFB; Thu, 10 Aug 2023 15:14:31 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 7434340691 for ; Thu, 10 Aug 2023 15:14:30 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37A8YKbu021020; Thu, 10 Aug 2023 06:14:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=+qnYS67ustGZaJbGHVXQ1yddF2UJ355YqeihrkgdNcU=; b=d89WN9IOZSftrjbXhqEWcpEYHBzkKpcl3Slb2VX/lIgxtzgZSdeL65D2+qc4fq2GnnJF 2Mrpur8sj4wrsgrysD8y7IgM2qwVVEZ3fSVAo8SrOKFzy/sOHM+g6kZlgnTMq6SDhmdN ZYoYCs8J1OC0FGVz6d1hTKi7xvSop2U//zvRJQ7Vlj2WnbCPkjE5aGN8EcymxgLlw2tY w1cN95AWUKRf73XBNfIDymFCXs4FfBvfCywrE7HrZdhyw5HPWSs2ZaqkepGrm1ohKz50 o6CR5MzEKCcDC/iTuyf15apJGxtFWmFZLY//4+mVSHPxAT9CRQdUjVGMyyeDa3YNoBqH RQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3scj5mat5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 10 Aug 2023 06:14:29 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 10 Aug 2023 06:14:27 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 10 Aug 2023 06:14:27 -0700 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 7F56B3F70AB; Thu, 10 Aug 2023 06:14:25 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: , Akhil Goyal , Fan Zhang , Kai Ji , "Gowrishankar Muthukrishnan" Subject: [PATCH] app/test: validate shorter private key in ECDSA P521 test Date: Thu, 10 Aug 2023 18:44:21 +0530 Message-ID: <20230810131421.2596-1-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: Z88XCxciR-i8_X_19Ro1di3n1FHLQIDy X-Proofpoint-GUID: Z88XCxciR-i8_X_19Ro1di3n1FHLQIDy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-10_10,2023-08-10_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Update test vector of ECDSA P521 curve for validating private key of length shorter than prime length. As prime length of this test is not aligned by 8 bytes, this new test vector could test any alignment issue along with the sign validation. Signed-off-by: Gowrishankar Muthukrishnan --- app/test/test_cryptodev_asym.c | 6 + app/test/test_cryptodev_ecdsa_test_vectors.h | 120 ++++++++++++++++++- 2 files changed, 125 insertions(+), 1 deletion(-) diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c index 0ef2642fdd..ef050f8b72 100644 --- a/app/test/test_cryptodev_asym.c +++ b/app/test/test_cryptodev_asym.c @@ -1477,6 +1477,9 @@ test_ecdsa_sign_verify(enum curve curve_id) case SECP521R1: input_params = ecdsa_param_secp521r1; break; + case SECP521R1_UA: + input_params = ecdsa_param_secp521r1_ua; + break; default: RTE_LOG(ERR, USER1, "line %u FAILED: %s", __LINE__, @@ -1792,6 +1795,9 @@ test_ecpm_all_curve(void) const char *msg; for (curve_id = SECP192R1; curve_id < END_OF_CURVE_LIST; curve_id++) { + if (curve_id == SECP521R1_UA) + continue; + status = test_ecpm(curve_id); if (status == TEST_SUCCESS) { msg = "succeeded"; diff --git a/app/test/test_cryptodev_ecdsa_test_vectors.h b/app/test/test_cryptodev_ecdsa_test_vectors.h index 55fbda5979..f1477639ba 100644 --- a/app/test/test_cryptodev_ecdsa_test_vectors.h +++ b/app/test/test_cryptodev_ecdsa_test_vectors.h @@ -14,6 +14,7 @@ enum curve { SECP256R1, SECP384R1, SECP521R1, + SECP521R1_UA, END_OF_CURVE_LIST }; @@ -21,7 +22,9 @@ const char *curve[] = {"SECP192R1", "SECP224R1", "SECP256R1", "SECP384R1", - "SECP521R1"}; + "SECP521R1", + "SECP521R1(unaligned)", +}; struct crypto_testsuite_ecdsa_params { rte_crypto_param pubkey_qx; @@ -502,4 +505,119 @@ struct crypto_testsuite_ecdsa_params ecdsa_param_secp521r1 = { .curve = RTE_CRYPTO_EC_GROUP_SECP521R1 }; +/* SECP521R1 (P-521 NIST) test vectors (unaligned) */ + +static uint8_t ua_digest_secp521r1[] = { + 0x7b, 0xec, 0xf5, 0x96, 0xa8, 0x12, 0x04, 0x4c, + 0x07, 0x96, 0x98, 0x4b, 0xe2, 0x3e, 0x9c, 0x02, + 0xbf, 0xc5, 0x90, 0x96, 0xf4, 0x2f, 0xfc, 0x8a, + 0x3f, 0x9a, 0x65, 0x0e +}; + +static uint8_t ua_pkey_secp521r1[] = { + 0x00, 0x70, 0xa8, 0x4d, 0x30, 0xfd, 0xc9, 0x01, + 0x1c, 0xc6, 0xc3, 0x38, 0xd4, 0x75, 0x6f, 0x3e, + 0x59, 0xd8, 0x91, 0xaa, 0xb4, 0x18, 0x3e, 0x3c, + 0xa5, 0x3d, 0x3f, 0x23, 0xd8, 0xe6, 0xfb, 0x3c, + 0x54, 0x5a, 0xa1, 0xdd, 0x40, 0xec, 0xc5, 0xa0, + 0x40, 0xa7, 0xb1, 0xb1, 0xbc, 0xfe, 0x34, 0xe4, + 0xbf, 0xdb, 0x40, 0x89, 0x45, 0xb5, 0xf7, 0x45, + 0x69, 0xca, 0xa7, 0xc1, 0x9e, 0x4a, 0x76, 0xa8, + 0x05, 0x58 +}; + +static uint8_t ua_scalar_secp521r1[] = { + 0x00, 0x70, 0xa8, 0x4d, 0x30, 0xfd, 0xc9, 0x01, + 0x1c, 0xc6, 0xc3, 0x38, 0xd4, 0x75, 0x6f, 0x3e, + 0x59, 0xd8, 0x91, 0xaa, 0xb4, 0x18, 0x3e, 0x3c, + 0xa5, 0x3d, 0x3f, 0x23, 0xd8, 0xe6, 0xfb, 0x3c, + 0x54, 0x5a, 0xa1, 0xdd, 0x40, 0xec, 0xc5, 0xa0, + 0x40, 0xa7, 0xb1, 0xb1, 0xbc, 0xfe, 0x34, 0xe4, + 0xbf, 0xdb, 0x40, 0x89, 0x45, 0xb5, 0xf7, 0x45, + 0x69, 0xca, 0xa7, 0xc1, 0x9e, 0x4a, 0x76, 0xa8, + 0x05, 0x57 +}; + +static uint8_t ua_pubkey_qx_secp521r1[] = { + 0x01, 0x29, 0x15, 0x13, 0xa6, 0x45, 0x98, 0x5c, + 0x5e, 0x2b, 0xc3, 0x99, 0xc5, 0x25, 0x64, 0x29, + 0x14, 0x91, 0x12, 0xcc, 0x58, 0x3a, 0x9d, 0x91, + 0x95, 0x64, 0x10, 0x9e, 0xc3, 0x2d, 0xde, 0xe2, + 0xb1, 0xac, 0x44, 0xb7, 0x90, 0x70, 0xbf, 0xb5, + 0x50, 0x3b, 0x06, 0x78, 0x36, 0x05, 0x7e, 0x48, + 0xe7, 0x31, 0x6e, 0x3f, 0x78, 0x3b, 0x37, 0xbc, + 0xa8, 0xcd, 0xc0, 0x34, 0xb6, 0x4f, 0xf8, 0x73, + 0xd0, 0xb3 +}; + +static uint8_t ua_pubkey_qy_secp521r1[] = { + 0x00, 0xc1, 0x46, 0x92, 0x6e, 0x1a, 0xb5, 0xe6, + 0xee, 0x25, 0xe3, 0x62, 0x68, 0x30, 0x38, 0xef, + 0x44, 0x2a, 0xb0, 0xb8, 0xa9, 0xbc, 0x4b, 0x4b, + 0x55, 0x4c, 0x35, 0xde, 0x50, 0xcc, 0xc6, 0x9e, + 0xf9, 0x9d, 0x8d, 0xe9, 0x0f, 0x84, 0x95, 0xcb, + 0x41, 0xa2, 0xc7, 0xf3, 0x7d, 0xea, 0xb1, 0x8b, + 0x52, 0x5d, 0x58, 0x45, 0xac, 0xa0, 0xb4, 0x64, + 0x60, 0x74, 0x1f, 0x59, 0x71, 0x97, 0xe8, 0x6b, + 0x9f, 0x5d +}; + +static uint8_t ua_sign_secp521r1_r[] = { + 0x00, 0xf1, 0xea, 0x3b, 0x7b, 0xfb, 0x49, 0x60, + 0xf3, 0x93, 0x66, 0x8d, 0x81, 0x28, 0x7f, 0x40, + 0xe9, 0x35, 0xd6, 0x13, 0xe1, 0x51, 0x1a, 0xee, + 0xc8, 0x98, 0xa1, 0xf9, 0x62, 0xb6, 0x9f, 0xf3, + 0x18, 0xdd, 0x45, 0x3c, 0xbb, 0x9d, 0xee, 0x89, + 0xf1, 0x91, 0xf3, 0xd9, 0xe7, 0x08, 0xc8, 0xe6, + 0xd3, 0x61, 0x19, 0x28, 0x19, 0x17, 0x23, 0x2b, + 0x69, 0x49, 0x32, 0x9c, 0x98, 0x19, 0x52, 0x5c, + 0x73, 0xbf +}; + +static uint8_t ua_sign_secp521r1_s[] = { + 0x00, 0xa5, 0xab, 0x72, 0xc5, 0x71, 0x2a, 0x21, + 0x47, 0x6a, 0x45, 0xc8, 0xc2, 0xe3, 0x45, 0x40, + 0x8e, 0x79, 0xf8, 0x19, 0x65, 0xd4, 0xfd, 0xf2, + 0xd7, 0x28, 0xae, 0x70, 0xb8, 0xc1, 0x6d, 0x09, + 0x16, 0x31, 0x6e, 0xa0, 0x9c, 0xbf, 0x86, 0x19, + 0x9c, 0x04, 0x46, 0x48, 0xc1, 0x3f, 0x89, 0xb1, + 0xdd, 0xa2, 0x71, 0xb7, 0xf7, 0x0e, 0xa6, 0x66, + 0x15, 0x26, 0x66, 0x9b, 0xed, 0xda, 0x00, 0x1b, + 0x2b, 0xc5 +}; + +/** ECDSA SECP521R1 elliptic curve param (unaligned) */ + +struct crypto_testsuite_ecdsa_params ecdsa_param_secp521r1_ua = { + .pubkey_qx = { + .data = ua_pubkey_qx_secp521r1, + .length = sizeof(ua_pubkey_qx_secp521r1), + }, + .pubkey_qy = { + .data = ua_pubkey_qy_secp521r1, + .length = sizeof(ua_pubkey_qy_secp521r1), + }, + .scalar = { + .data = ua_scalar_secp521r1, + .length = sizeof(ua_scalar_secp521r1), + }, + .digest = { + .data = ua_digest_secp521r1, + .length = sizeof(ua_digest_secp521r1), + }, + .sign_r = { + .data = ua_sign_secp521r1_r, + .length = sizeof(ua_sign_secp521r1_r), + }, + .sign_s = { + .data = ua_sign_secp521r1_s, + .length = sizeof(ua_sign_secp521r1_s), + }, + .pkey = { + .data = ua_pkey_secp521r1, + .length = sizeof(ua_pkey_secp521r1), + }, + .curve = RTE_CRYPTO_EC_GROUP_SECP521R1 +}; + #endif /* __TEST_CRYPTODEV_ECDSA_TEST_VECTORS_H__ */ -- 2.25.1