From patchwork Wed Nov 8 18:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 118300 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5598011qgn; Wed, 8 Nov 2017 10:02:59 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q7fxe15YVreTQzK9C8PXQbMghenQ3Vi4gxGtRZK+WyTOGefWuFlWG3QcIyG7zZpQ07tRqi X-Received: by 10.55.39.211 with SMTP id n202mr2188840qkn.70.1510164179037; Wed, 08 Nov 2017 10:02:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510164179; cv=none; d=google.com; s=arc-20160816; b=rpHR1zpkyPfoIuRoqrTrxaw/3VVFSQEuRW75mSewfrRkg7qFGWuZW4Hws2yAAqBs7S tr+XEvElN9DnzLFhrD57ImA+av8OriFK7Q1sOwJu9ikw2oQAiOnSxPVKfqKWUl7+6yAx JPpCDVJff1oRysq35PjRu+ua3CkGjibeCSO1AAxRZsv4d1bGIQJKidWNYISp8zDH9Ju8 213drG7M+VbLwylrkJQJ1aUBoXXaIQQi38y7C4jzUn6+hRjA9mPNduXyjp4mQh/TbTtx 7jhwqUKzwOGJcZAKe40oISXaq89QCAKWpZcIySnIdowHmioXf1MhL2T2p1NGQCWpWlRQ t6dw== 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=AQ48ONb9fr9u4SM+oOlCY+SFRDgGU0rygJFzF3u381o=; b=BjhiTzxD4oOf7oD4NP7uBh422YOnQADYTsp5/zRdTFseXjgG6/ORog8wPiqJQQdAxe TuVQ3eOMk0a1W0iHLqshCnCW6doXhF6b3mvd3BwojeF+gnuuQgZPLb2gXSKii8aQ/M6U 3oDPJ7jVIA7JZd1VzSBpmGN8xnbl+qWyGQz2HhhAag0xPXDpsTewU9eMAXkzDNjEgERK GHu3u88nzVaQm82MMIYSjUjyzkN9/4QJ3N9eivF4irV9MHFye5r0nbyZMmjrLSGucfC7 D/hCHUzzVTQ5HJ7rKpmvOVIiH4/08NJC9Lab5cKBxkmp2J7qAlfa7Heqf96IFdpeIpkC B0NA== 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 31si4113461qty.256.2017.11.08.10.02.58; Wed, 08 Nov 2017 10:02:59 -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 91E7C61033; Wed, 8 Nov 2017 18:02:58 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED 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 9336860B3F; Wed, 8 Nov 2017 18:00:35 +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 3780560A0A; Wed, 8 Nov 2017 18:00:19 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id 3804A6069A for ; Wed, 8 Nov 2017 18:00:16 +0000 (UTC) Received: from mxback12j.mail.yandex.net (mxback12j.mail.yandex.net [IPv6:2a02:6b8:0:1619::87]) by forward103o.mail.yandex.net (Yandex) with ESMTP id 1C4625884502 for ; Wed, 8 Nov 2017 21:00:15 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback12j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id gfRSu9sbtA-0ECenWgZ; Wed, 08 Nov 2017 21:00:15 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id unJA9Y8tSc-0E30Rapg; Wed, 08 Nov 2017 21:00:14 +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: Wed, 8 Nov 2017 21:00:08 +0300 Message-Id: <1510164012-14286-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510164012-14286-1-git-send-email-odpbot@yandex.ru> References: <1510164012-14286-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v1 4/8] validation: crypto: add AES-GMAC testcase 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 Add AES-GMAC test vector based on draft-mcgrew-gcm-test-01. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 288 (lumag:gmac) ** https://github.com/Linaro/odp/pull/288 ** Patch: https://github.com/Linaro/odp/pull/288.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 569b57eebedebdf2d3148ca06f481cb94bea52e4 **/ test/validation/api/crypto/crypto.h | 2 ++ test/validation/api/crypto/odp_crypto_test_inp.c | 46 ++++++++++++++++++++++++ test/validation/api/crypto/test_vectors.h | 33 +++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/test/validation/api/crypto/crypto.h b/test/validation/api/crypto/crypto.h index 71f862ec3..550d2bbff 100644 --- a/test/validation/api/crypto/crypto.h +++ b/test/validation/api/crypto/crypto.h @@ -32,6 +32,8 @@ void crypto_test_gen_alg_hmac_sha256(void); void crypto_test_check_alg_hmac_sha256(void); void crypto_test_gen_alg_hmac_sha512(void); void crypto_test_check_alg_hmac_sha512(void); +void crypto_test_gen_alg_aes_gmac(void); +void crypto_test_check_alg_aes_gmac(void); /* test arrays: */ extern odp_testinfo_t crypto_suite[]; diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index f05780377..596c8370b 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -50,6 +50,8 @@ static const char *auth_alg_name(odp_auth_alg_t auth) return "ODP_AUTH_ALG_SHA512_HMAC"; case ODP_AUTH_ALG_AES_GCM: return "ODP_AUTH_ALG_AES_GCM"; + case ODP_AUTH_ALG_AES_GMAC: + return "ODP_AUTH_ALG_AES_GMAC"; default: return "Unknown"; } @@ -341,6 +343,9 @@ static void alg_test(odp_crypto_op_t op, if (auth_alg == ODP_AUTH_ALG_AES_GCM && !(capa.auths.bit.aes_gcm)) rc = -1; + if (auth_alg == ODP_AUTH_ALG_AES_GMAC && + !(capa.auths.bit.aes_gmac)) + rc = -1; if (auth_alg == ODP_AUTH_ALG_MD5_HMAC && !(capa.auths.bit.md5_hmac)) rc = -1; @@ -581,6 +586,10 @@ static int check_alg_support(odp_cipher_alg_t cipher, odp_auth_alg_t auth) if (!capability.auths.bit.aes_gcm) return ODP_TEST_INACTIVE; break; + case ODP_AUTH_ALG_AES_GMAC: + if (!capability.auths.bit.aes_gmac) + return ODP_TEST_INACTIVE; + break; default: fprintf(stderr, "Unsupported authentication algorithm\n"); return ODP_TEST_INACTIVE; @@ -1025,6 +1034,39 @@ void crypto_test_check_alg_hmac_sha512(void) false); } +static int check_alg_aes_gmac(void) +{ + return check_alg_support(ODP_CIPHER_ALG_NULL, ODP_AUTH_ALG_AES_GMAC); +} + +void crypto_test_gen_alg_aes_gmac(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], + false); +} + +void crypto_test_check_alg_aes_gmac(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], + false); +} + int crypto_suite_sync_init(void) { suite_context.pool = odp_pool_lookup("packet_pool"); @@ -1122,6 +1164,10 @@ odp_testinfo_t crypto_suite[] = { check_alg_hmac_sha512), ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_hmac_sha512, check_alg_hmac_sha512), + ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_gmac, + check_alg_aes_gmac), + ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_gmac, + 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 652968be7..125a6d465 100644 --- a/test/validation/api/crypto/test_vectors.h +++ b/test/validation/api/crypto/test_vectors.h @@ -361,6 +361,39 @@ static crypto_test_reference_t aes_gcm_reference[] = { } }; +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}, + .iv_length = AES_GCM_IV_LEN, + .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, + 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00, + 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05, + 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd, + 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x01, 0x02, 0x02, 0x01 }, + .ciphertext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x30, 0xda, 0x3a, 0x00, 0x00, + 0x80, 0x01, 0xdf, 0x3b, 0xc0, 0xa8, 0x00, 0x05, + 0xc0, 0xa8, 0x00, 0x01, 0x08, 0x00, 0xc6, 0xcd, + 0x02, 0x00, 0x07, 0x00, 0x61, 0x62, 0x63, 0x64, + 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, + 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, + 0x01, 0x02, 0x02, 0x01 }, + .digest_length = AES_GCM_DIGEST_LEN, + .digest = { 0xf2, 0xa9, 0xa8, 0x36, 0xe1, 0x55, 0x10, + 0x6a, 0xa8, 0xdc, 0xd6, 0x18, 0xe4, 0x09, 0x9a, 0xaa } + }, +}; + static crypto_test_reference_t hmac_md5_reference[] = { { .auth_key_length = HMAC_MD5_KEY_LEN,