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 <gmuthukri...@marvell.com>
---
 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

Reply via email to