From patchwork Tue Nov 14 20:00:06 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: 118884 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3462834qgn; Tue, 14 Nov 2017 12:03:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMbRDI/izQGBVrRyMmmtIhMnVRkrH7t7tsmN4EO5keqJOxRZJsddVQ0+hMZ2XlOH07qnVlri X-Received: by 10.55.133.71 with SMTP id h68mr4886773qkd.17.1510689809083; Tue, 14 Nov 2017 12:03:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510689809; cv=none; d=google.com; s=arc-20160816; b=tEVpGknYPdc6Pui0BuZ5ERNfCCoQAEQlXJ75eRd/3EiHzslo11dG52357hjPVyajUz 4Cn0rsnObnbAoAkZeZrgj+Ijm3y19UHosAA/i5hX1hpe/9FKKYEfVvMkBMGg/OWiPw/l 8be6u4p5fQUEaju4Ky2r4FCYE1Ya0I87e8GPcclX34YD9FHTCppWUO/4rnEHI5mQdFxs j86trzLjuzclO1CqqEbdAF08W5seXRsviBUhHVPAXuN/yLHj6vKLiwQrfpR039NZDMH+ Du9y3sZ/HPPNszlLLuN8XUJP76Mzg3XlvDkFiNsaDgyaUFbxNe5ckNNts7WNGEpNgFTZ X4Tg== 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=XJiqesX+r6Jxw6PfY1FhaqQYHD//imKgn1hMc6BJxAw=; b=kc+go6aI3EjfE5peP1tD4VzrC39db9J5N0ZoH47sagh5i8PMTzQC4bihdOQKrs3iEs dcYpzbtJAP1h0hVpo/GJuH4kAM6/u9lmvLr6TXBOHOmt7bjBG3mxoHIZ60Uaa+THMtgr bkpy24OpXijaHHmQ9pCwdbBt+wNVGLicMSASuS1tut2/FxXtz36GvOInI0qaR3HusjbE xpqkWERzHsVOkFV/U0ifmCH7kzRslGN63+7+sc8bp9mBdTCDV42fCptuV3QHCD7mafM0 v4jo0kS42lWc784dcK1OrS3O98U+u8x5UyilDIz8/eumQw0szlJhckK1seMvrLCisr6T 4E8w== 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 d12si7403281qtc.302.2017.11.14.12.03.28; Tue, 14 Nov 2017 12:03:29 -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 C51D46068A; Tue, 14 Nov 2017 20:03:28 +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 8CDF5606A1; Tue, 14 Nov 2017 20:00:36 +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 3392A6068B; Tue, 14 Nov 2017 20:00:23 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 418E26063A for ; Tue, 14 Nov 2017 20:00:16 +0000 (UTC) Received: from mxback16j.mail.yandex.net (mxback16j.mail.yandex.net [IPv6:2a02:6b8:0:1619::92]) by forward100p.mail.yandex.net (Yandex) with ESMTP id A8A055103F73 for ; Tue, 14 Nov 2017 23:00:14 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback16j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id axgQ9LK9ZX-0EbmHaZa; Tue, 14 Nov 2017 23:00:14 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZsDLds7hfB-0EpeBYTo; Tue, 14 Nov 2017 23: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: Tue, 14 Nov 2017 23:00:06 +0300 Message-Id: <1510689611-17861-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> References: <1510689611-17861-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v8 5/10] 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: ba93e355ddf151215aa18b59cbfca08fe175fe65 ** Merge commit sha: 8363c3a4073075d0f3dd68864b9a33819005aab4 **/ test/validation/api/ipsec/ipsec.c | 34 +++++++++++++++++++++++++--------- test/validation/api/ipsec/ipsec.h | 11 ++++++----- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index 277d393ab..e6a22a1a4 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -122,13 +122,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; @@ -219,6 +220,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; @@ -237,48 +239,62 @@ 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_ctr_128_null(void) { return ipsec_check_esp(ODP_CIPHER_ALG_AES_CTR, 128, - ODP_AUTH_ALG_NULL); + ODP_AUTH_ALG_NULL, 0); } 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 d45063672..3d4e5bcd6 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);