From patchwork Mon Jan 22 08:00:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 125341 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1024941ljf; Mon, 22 Jan 2018 00:08:13 -0800 (PST) X-Google-Smtp-Source: AH8x226W7XTysuyJfmT2S6OzkSZ4XEd92WNUq6c4t+eDbWFqsDEBWamUNhXZj2ufVFQRSAup94po X-Received: by 10.200.56.170 with SMTP id f39mr8889133qtc.243.1516608493128; Mon, 22 Jan 2018 00:08:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516608493; cv=none; d=google.com; s=arc-20160816; b=mt1zCNOMPWzz0RYLOmAC+Apb5JvO1uAVtTB24GU69pEqssMZOjvZwb4qZcPyWGbmHE ftKF5eRV23X8nNjJGx1A+Kch/CEYCs9Xm9/Q3EMD1BrFxiTIPcoHGK/1CGAln4dS/otc GIndfQUOriFytpgd5gXuIXK3G4yuvz+usyiLHflFRKpqGqGT5k9iJN9e7A9B8Bx9TTvh xbMMPmegZXPNSXpXOnIODdHKukGYMtvEKTQHydGmT2Tz8txWbznNES0LsEjPWaRL12nS J1SkwDL76+/BunHOa1W+BfOEIDyH/paPJRjwr8oiNxvPPD1FdfCeIl35H/DQg+p042Iz cTgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=+cWax7JYSoxzy6C4aegdp4huSD6zs8tR6OE29Pre1js=; b=OremfQ8t4W4ZIfDaEL9zsg9NZmo0QgNDewnl13/2Zu9lfBY0jeT9vju4HjxFZVWWhI m5l0h95heIwdFDR8WzcTBVT09smyV1/UFGtf4XNXuFz7ZvHBXw7bqFpZuRNX7UvdZXRZ ZU7sWADa6N352W3qeO70uJv2mcqzUv9chLrwOT6BO8mON2RC6a9l5zz/X/rijZ2oeFN6 Grx07veAL+shRN1ewHAYEipshGeBUdFu/eueVpU5KjJYN04Aj9ztfWmA1NjaFo01vN/i HrZDC6tT8Qx8zu1lKgwFfiGSbUgMsGEPU50dASdfDHPt0Xt5SA4Scmrl5hmCvz8yak8g sIdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id u7si5251095qkd.181.2018.01.22.00.08.12; Mon, 22 Jan 2018 00:08:13 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id C79C0617D9; Mon, 22 Jan 2018 08:08:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 3B2E361787; Mon, 22 Jan 2018 08:01:34 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E4F66607B4; Mon, 22 Jan 2018 08:00:40 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id C9D7B6087E for ; Mon, 22 Jan 2018 08:00:18 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward100j.mail.yandex.net (Yandex) with ESMTP id 7F1765D812EC for ; Mon, 22 Jan 2018 11:00:17 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id abAFRdlz7A-0HmuvIiR; Mon, 22 Jan 2018 11:00:17 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id yORTcTkY7i-0GH8LlR9; Mon, 22 Jan 2018 11:00:16 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 22 Jan 2018 11:00:04 +0300 Message-Id: <1516608010-2535-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516608010-2535-1-git-send-email-odpbot@yandex.ru> References: <1516608010-2535-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 413 Subject: [lng-odp] [PATCH v1 6/12] validation: crypto: use auth IV for GMAC test case X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Change GMAC testing code to use new auth IV fields. Signed-off-by: Dmitry Eremin-Solenikov Reviewed-by: Bill Fischofer Reviewed-by: Petri Savolainen Signed-off-by: Maxim Uvarov --- /** Email created from pull request 413 (SonicwallYhe:api-next) ** https://github.com/Linaro/odp/pull/413 ** Patch: https://github.com/Linaro/odp/pull/413.patch ** Base sha: 5a4502fc6bc53e6503169da3028f456b64811a0b ** Merge commit sha: 6669be7b55ab094f9e27d2101a6bb005ca87e405 **/ test/validation/api/crypto/odp_crypto_test_inp.c | 55 +++++++++++++++++++++++- test/validation/api/crypto/test_vectors.h | 8 ++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index 7309b5d52..976c88821 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -79,6 +79,7 @@ static int alg_op(odp_packet_t pkt, odp_bool_t *ok, odp_crypto_session_t session, uint8_t *cipher_iv_ptr, + uint8_t *auth_iv_ptr, odp_packet_data_range_t *cipher_range, odp_packet_data_range_t *auth_range, uint8_t *aad, @@ -101,6 +102,8 @@ static int alg_op(odp_packet_t pkt, op_params.auth_range = *auth_range; if (cipher_iv_ptr) op_params.cipher_iv_ptr = cipher_iv_ptr; + if (auth_iv_ptr) + op_params.auth_iv_ptr = auth_iv_ptr; op_params.aad_ptr = aad; @@ -154,6 +157,7 @@ static int alg_packet_op(odp_packet_t pkt, odp_bool_t *ok, odp_crypto_session_t session, uint8_t *cipher_iv_ptr, + uint8_t *auth_iv_ptr, odp_packet_data_range_t *cipher_range, odp_packet_data_range_t *auth_range, uint8_t *aad, @@ -173,6 +177,8 @@ static int alg_packet_op(odp_packet_t pkt, op_params.auth_range = *auth_range; if (cipher_iv_ptr) op_params.cipher_iv_ptr = cipher_iv_ptr; + if (auth_iv_ptr) + op_params.auth_iv_ptr = auth_iv_ptr; op_params.aad_ptr = aad; @@ -211,6 +217,7 @@ static int alg_packet_op_enq(odp_packet_t pkt, odp_bool_t *ok, odp_crypto_session_t session, uint8_t *cipher_iv_ptr, + uint8_t *auth_iv_ptr, odp_packet_data_range_t *cipher_range, odp_packet_data_range_t *auth_range, uint8_t *aad, @@ -231,6 +238,8 @@ static int alg_packet_op_enq(odp_packet_t pkt, op_params.auth_range = *auth_range; if (cipher_iv_ptr) op_params.cipher_iv_ptr = cipher_iv_ptr; + if (auth_iv_ptr) + op_params.auth_iv_ptr = auth_iv_ptr; op_params.aad_ptr = aad; @@ -321,6 +330,10 @@ static void alg_test(odp_crypto_op_t op, .data = ovr_iv ? NULL : ref->cipher_iv, .length = ref->cipher_iv_length }; + odp_crypto_iv_t auth_iv = { + .data = ovr_iv ? NULL : ref->auth_iv, + .length = ref->auth_iv_length + }; int num, i; int found; @@ -414,6 +427,7 @@ static void alg_test(odp_crypto_op_t op, /* Search for the test case */ for (i = 0; i < num; i++) { if (auth_capa[i].digest_len == ref->digest_length && + auth_capa[i].iv_len == auth_iv.length && auth_capa[i].key_len == auth_key.length) { found = 1; break; @@ -422,8 +436,9 @@ static void alg_test(odp_crypto_op_t op, if (!found) { printf("\n Unsupported: alg=%s, key_len=%" PRIu32 ", " - "digest_len=%" PRIu32 "\n", auth_alg_name(auth_alg), - auth_key.length, ref->digest_length); + "digest_len=%" PRIu32 ", iv_len=%" PRIu32 "\n", + auth_alg_name(auth_alg), auth_key.length, + ref->digest_length, auth_iv.length); return; } @@ -439,6 +454,7 @@ static void alg_test(odp_crypto_op_t op, ses_params.output_pool = suite_context.pool; ses_params.cipher_key = cipher_key; ses_params.cipher_iv = cipher_iv; + ses_params.auth_iv = auth_iv; ses_params.auth_key = auth_key; ses_params.auth_digest_len = ref->digest_length; ses_params.auth_aad_len = ref->aad_length; @@ -489,16 +505,19 @@ static void alg_test(odp_crypto_op_t op, if (!suite_context.packet) rc = alg_op(pkt, &ok, session, ovr_iv ? ref->cipher_iv : NULL, + ovr_iv ? ref->auth_iv : NULL, &cipher_range, &auth_range, ref->aad, ref->length); else if (ODP_CRYPTO_ASYNC == suite_context.op_mode) rc = alg_packet_op_enq(pkt, &ok, session, ovr_iv ? ref->cipher_iv : NULL, + ovr_iv ? ref->auth_iv : NULL, &cipher_range, &auth_range, ref->aad, ref->length); else rc = alg_packet_op(pkt, &ok, session, ovr_iv ? ref->cipher_iv : NULL, + ovr_iv ? ref->auth_iv : NULL, &cipher_range, &auth_range, ref->aad, ref->length); if (rc < 0) @@ -1163,6 +1182,20 @@ static void crypto_test_gen_alg_aes_gmac(void) false); } +static void crypto_test_gen_alg_aes_gmac_ovr_iv(void) +{ + unsigned int test_vec_num = (sizeof(aes_gmac_reference) / + sizeof(aes_gmac_reference[0])); + unsigned int i; + + for (i = 0; i < test_vec_num; i++) + alg_test(ODP_CRYPTO_OP_ENCODE, + ODP_CIPHER_ALG_NULL, + ODP_AUTH_ALG_AES_GMAC, + &aes_gmac_reference[i], + true); +} + static void crypto_test_check_alg_aes_gmac(void) { unsigned int test_vec_num = (sizeof(aes_gmac_reference) / @@ -1177,6 +1210,20 @@ static void crypto_test_check_alg_aes_gmac(void) false); } +static void crypto_test_check_alg_aes_gmac_ovr_iv(void) +{ + unsigned int test_vec_num = (sizeof(aes_gmac_reference) / + sizeof(aes_gmac_reference[0])); + unsigned int i; + + for (i = 0; i < test_vec_num; i++) + alg_test(ODP_CRYPTO_OP_DECODE, + ODP_CIPHER_ALG_NULL, + ODP_AUTH_ALG_AES_GMAC, + &aes_gmac_reference[i], + true); +} + int crypto_suite_sync_init(void) { suite_context.pool = odp_pool_lookup("packet_pool"); @@ -1284,8 +1331,12 @@ odp_testinfo_t crypto_suite[] = { check_alg_hmac_sha512), ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_gmac, check_alg_aes_gmac), + ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_gmac_ovr_iv, + check_alg_aes_gmac), ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_gmac, check_alg_aes_gmac), + ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_gmac_ovr_iv, + check_alg_aes_gmac), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/api/crypto/test_vectors.h b/test/validation/api/crypto/test_vectors.h index 6673ba4b6..d08bf1500 100644 --- a/test/validation/api/crypto/test_vectors.h +++ b/test/validation/api/crypto/test_vectors.h @@ -16,6 +16,8 @@ typedef struct crypto_test_reference_s { uint8_t auth_key[MAX_KEY_LEN]; uint32_t cipher_iv_length; uint8_t cipher_iv[MAX_IV_LEN]; + uint32_t auth_iv_length; + uint8_t auth_iv[MAX_IV_LEN]; uint32_t length; uint8_t plaintext[MAX_DATA_LEN]; uint8_t ciphertext[MAX_DATA_LEN]; @@ -447,9 +449,9 @@ static crypto_test_reference_t aes_gmac_reference[] = { .auth_key_length = AES128_GCM_KEY_LEN, .auth_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda, 0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34}, - .cipher_iv_length = AES_GCM_IV_LEN, - .cipher_iv = { 0x22, 0x43, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }, + .auth_iv_length = AES_GCM_IV_LEN, + .auth_iv = { 0x22, 0x43, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 }, .length = 68, .plaintext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,