From patchwork Wed Nov 8 18:00:11 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: 118304 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5602677qgn; Wed, 8 Nov 2017 10:06:43 -0800 (PST) X-Google-Smtp-Source: ABhQp+TVCYJtm6hsu86KLc/EYq3KRC2YwdMuxhLNf+TFI88RxoYoAXiYQtOdhW89YjSu1zuOOi7X X-Received: by 10.200.63.100 with SMTP id w33mr2239308qtk.214.1510164402963; Wed, 08 Nov 2017 10:06:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510164402; cv=none; d=google.com; s=arc-20160816; b=jRkRUWdrnNMxLyTlFilMl9woprBKhlPiwSGeXNFtLOrWiFrkJrNGNAIOIjnH5YwdGs rFdC7UrAnQDCoio36RuDc5818UqfTVN+Gl7HGeZ8tPj1Bvt0Q8TWuwTMP8fsO4VpoOST OHvL700sQVVCliAFqTiugywY4i/Rjc98sI912ZNG7ovENsIwXw2iF8gHakGaxd+WgqRS SkBURcSroNjMLSqJkestJ3Yq/JXKDJK37BcaGKNTXo+umDOKb9TcY8MoAoy9k96W9sj7 X/YIWGNDUXQ1PufgKRY8sZPKmGjo5CHEYPu2USSSMTTtf/aimzu0IIalhxU0UhZQVqUZ Ymog== 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=OEovJctv4lsWN+UcPnN/S1ElhKPiyYvczjLt8gqaODM=; b=iaK7CsX8yiqrNtysWcUv7QL70s8uUsI8Y3Bf7hTYxweRu0I7b1iJSgQhcvULOOK7aH m7mAVlDHdlJrop/OSp4WnEtiGnvsJLD7zi8Em8O9tghwojBD6MF7lbRepdlH9V7sHSdD q97Zl0N5Kj0ajRhUvpdJLrbsUUT3HLuZVEqyaeprALsBsauJSzm6JJnEvGcCEO6Vcylk WqEDVc/zB8aEI7cwQz8YV8EvWYcnUB634SJlVHTYN5lUqhuE+FFDI0gC0HaxQI5O0IVF uiw6ezfxI85ZVAmJt5q/AXoG0ru8424mmbYQ7JfVCA6R20bcBpTW1M5m8Kz+0e6D2knT 282A== 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 a136si1510551qkc.304.2017.11.08.10.06.42; Wed, 08 Nov 2017 10:06:42 -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 A8B6660C26; Wed, 8 Nov 2017 18:06:42 +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_H3,RCVD_IN_MSPIKE_WL,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 1784260FFE; Wed, 8 Nov 2017 18:01:12 +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 C901C60692; Wed, 8 Nov 2017 18:00:23 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id BAA6560890 for ; Wed, 8 Nov 2017 18:00:17 +0000 (UTC) Received: from mxback15g.mail.yandex.net (mxback15g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:94]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 6BDC41801554 for ; Wed, 8 Nov 2017 21:00:16 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback15g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id TeP5Ab36Ql-0GKmlvTJ; Wed, 08 Nov 2017 21:00:16 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id unJA9Y8tSc-0F3OIF9d; Wed, 08 Nov 2017 21:00:15 +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:11 +0300 Message-Id: <1510164012-14286-8-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 7/8] validation: ipsec: check authentication key length is supported 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 check through auth capabilities, verifying that key length is supported. 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/ipsec/ipsec.c | 32 ++++++++++++++++++++++++-------- test/validation/api/ipsec/ipsec.h | 11 ++++++----- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index a8fdf2b14..fb5f7863e 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -119,13 +119,14 @@ static void pktio_stop(odp_pktio_t pktio) int ipsec_check(odp_bool_t ah, odp_cipher_alg_t cipher, uint32_t cipher_bits, - odp_auth_alg_t auth) + odp_auth_alg_t auth, + uint32_t auth_bits) { odp_ipsec_capability_t capa; odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA]; odp_crypto_auth_capability_t auth_capa[MAX_ALG_CAPA]; int i, num; - odp_bool_t found = false; + odp_bool_t found; if (odp_ipsec_capability(&capa) < 0) return ODP_TEST_INACTIVE; @@ -212,6 +213,7 @@ int ipsec_check(odp_bool_t ah, } /* Search for the test case */ + found = false; for (i = 0; i < num; i++) { if (cipher_capa[i].key_len == cipher_bits / 8) { found = 1; @@ -230,42 +232,56 @@ int ipsec_check(odp_bool_t ah, return ODP_TEST_INACTIVE; } + /* Search for the test case */ + found = false; + for (i = 0; i < num; i++) { + if (auth_capa[i].key_len == auth_bits / 8) { + found = 1; + break; + } + } + + if (!found) { + fprintf(stderr, "Unsupported auth key length\n"); + return ODP_TEST_INACTIVE; + } + return ODP_TEST_ACTIVE; } int ipsec_check_ah_sha256(void) { - return ipsec_check_ah(ODP_AUTH_ALG_SHA256_HMAC); + return ipsec_check_ah(ODP_AUTH_ALG_SHA256_HMAC, 256); } int ipsec_check_esp_null_sha256(void) { return ipsec_check_esp(ODP_CIPHER_ALG_NULL, 0, - ODP_AUTH_ALG_SHA256_HMAC); + ODP_AUTH_ALG_SHA256_HMAC, 256); } int ipsec_check_esp_aes_cbc_128_null(void) { return ipsec_check_esp(ODP_CIPHER_ALG_AES_CBC, 128, - ODP_AUTH_ALG_NULL); + ODP_AUTH_ALG_NULL, 0); } int ipsec_check_esp_aes_cbc_128_sha256(void) { return ipsec_check_esp(ODP_CIPHER_ALG_AES_CBC, 128, - ODP_AUTH_ALG_SHA256_HMAC); + ODP_AUTH_ALG_SHA256_HMAC, 256); } int ipsec_check_esp_aes_gcm_128(void) { return ipsec_check_esp(ODP_CIPHER_ALG_AES_GCM, 128, - ODP_AUTH_ALG_AES_GCM); + ODP_AUTH_ALG_AES_GCM, 0); } int ipsec_check_esp_aes_gcm_256(void) { return ipsec_check_esp(ODP_CIPHER_ALG_AES_GCM, 256, - ODP_AUTH_ALG_AES_GCM); + ODP_AUTH_ALG_AES_GCM, 0); } void ipsec_sa_param_fill(odp_ipsec_sa_param_t *param, diff --git a/test/validation/api/ipsec/ipsec.h b/test/validation/api/ipsec/ipsec.h index d1c6854b7..9dd0feabf 100644 --- a/test/validation/api/ipsec/ipsec.h +++ b/test/validation/api/ipsec/ipsec.h @@ -74,11 +74,12 @@ void ipsec_check_out_in_one(const ipsec_test_part *part, int ipsec_check(odp_bool_t ah, odp_cipher_alg_t cipher, uint32_t cipher_bits, - odp_auth_alg_t auth); -#define ipsec_check_ah(auth) \ - ipsec_check(true, ODP_CIPHER_ALG_NULL, 0, auth) -#define ipsec_check_esp(cipher, cipher_bits, auth) \ - ipsec_check(false, cipher, cipher_bits, auth) + odp_auth_alg_t auth, + uint32_t auth_bits); +#define ipsec_check_ah(auth, auth_bits) \ + ipsec_check(true, ODP_CIPHER_ALG_NULL, 0, auth, auth_bits) +#define ipsec_check_esp(cipher, cipher_bits, auth, auth_bits) \ + ipsec_check(false, cipher, cipher_bits, auth, auth_bits) int ipsec_check_ah_sha256(void); int ipsec_check_esp_null_sha256(void); int ipsec_check_esp_aes_cbc_128_null(void);