From patchwork Thu Jun 1 09:03:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Eremin-Solenikov X-Patchwork-Id: 100855 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp710226qge; Thu, 1 Jun 2017 02:17:07 -0700 (PDT) X-Received: by 10.200.52.39 with SMTP id u36mr475619qtb.231.1496308626978; Thu, 01 Jun 2017 02:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496308626; cv=none; d=google.com; s=arc-20160816; b=FI+vbmu3GqetiStIZzYhkRYJZUMCkk+KyYYt5fVqg+XblLTOzsxZZY7cGC8bONzOq7 h5IjZmvJl6StA0cair0przcIWaUZhplrBJbMSO2YsVVnoUGsYTgmovTnlkirWccVCQJT eywfvr7adRUpQd5/nlfLawdb1G1gm/Ra1fqktqBN0BHBs9Gret+ZhXj8JLN4EuAWBXSh dSla3H+ExJJyZz4Oiix/7PAq9J7jyVcczozSt5iSfKtVRI/IayWAIlCScRsOyLygeqMA yWFP/W/qiV5oqmkWbifWSlb6HbM6ywKel6X8rRNPqMKWzgu7xpleyr3dtNw/7nvG73Rb lUsA== 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:references:in-reply-to :message-id:date:to:from:delivered-to:arc-authentication-results; bh=NM3QIgt1rNQ2u6hebM0PMBdHqO/ArvUNrEvPKZDgznE=; b=xgeI/h9rsA+MZe62Ss4muqCufecE0ma03C+KB9xDVCDPg33CwB+fndNyfKKIuBHVL8 k+YkDvE8z2mKdEvCSC8YQ7xhIbJ01EQvMpjCnA+07akzZW4yHobIT3SzSE3CvNhyrFAO 359JTkF9QmSZMJaRbd23g+KS5M8QrgnoYCo/1uFbAMkilqdYEKyuESJ9zDExZz9dFtp4 AzF3kWNd2m9+/SkRwdMolQzXoKjcVPDi1oXfQbriqsU+e0qrp4elKhLqoTyScB7BvW2/ mOJT8lmAUMd0PkMGLdyPN0KAbzc+v8NRdb5VBJrGJpjMLMVvHmQh4yn40juHdeltw/H2 tBmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i5si19272877qke.210.2017.06.01.02.17.06; Thu, 01 Jun 2017 02:17:06 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A164F608DD; Thu, 1 Jun 2017 09:17:06 +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=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, 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 70F2260D99; Thu, 1 Jun 2017 09:06: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 A383B60D92; Thu, 1 Jun 2017 09:06:25 +0000 (UTC) Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) by lists.linaro.org (Postfix) with ESMTPS id C2F4F60BF0 for ; Thu, 1 Jun 2017 09:04:03 +0000 (UTC) Received: by mail-lf0-f41.google.com with SMTP id c184so17853002lfe.2 for ; Thu, 01 Jun 2017 02:04:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=NM3QIgt1rNQ2u6hebM0PMBdHqO/ArvUNrEvPKZDgznE=; b=bQky3VCf1fwcTmNfaRngLUmO9To7FRzA/ArIYcFRhiTF92zRc4pqfaoXDdXzR0WSgo 2DooTyq9IQ+SyXRdwlpRMpsCXXxgZBCbryQSLR9yKp1H+pmoEMQZdGhv/9kN2jCPXU66 623f0+JEuiytCsH/+4ZXClkA41FYjlQZ7rAxeO9mK5yaDyRb9DFg4ehdQ8xX8BHufBFV Mg4zw72NxqZm7SHB3ZbdgFudT0jh4QKWRWze3QguDluNoGPAXd+viXRj8ZWdiCSbDjHq SkIywwExCEgJygMgCkzy7SaVIUw5HbuEnTyT+ReseFRTmcae3Md0SboBl3fZAaGBlkZh ivgw== X-Gm-Message-State: AODbwcAaMucttB9ykdL8/qd9l/seLht5FEqSLk7peBd93G5Bp0saL1M7 3iB+1NE0dtKtFc2/OtXXskaL X-Received: by 10.25.17.39 with SMTP id g39mr197269lfi.122.1496307842389; Thu, 01 Jun 2017 02:04:02 -0700 (PDT) Received: from forlindon.lumag.auriga.ru ([188.162.64.12]) by smtp.gmail.com with ESMTPSA id 129sm4232819ljf.36.2017.06.01.02.04.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 02:04:01 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 12:03:34 +0300 Message-Id: <20170601090339.9313-19-dmitry.ereminsolenikov@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170601090339.9313-1-dmitry.ereminsolenikov@linaro.org> References: <20170601090339.9313-1-dmitry.ereminsolenikov@linaro.org> Subject: [lng-odp] [PATCH API-NEXT v5 18/23] crypto: linux-generic: add capabilities for CIPHER_NULL and AUTH_NULL 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" There is no point in having separate cases for NULL algorithms. Add capabilities returning 0 key/digest/iv length. Signed-off-by: Dmitry Eremin-Solenikov --- platform/linux-generic/odp_crypto.c | 14 ++++++++++---- .../validation/api/crypto/odp_crypto_test_inp.c | 18 ++++-------------- 2 files changed, 14 insertions(+), 18 deletions(-) -- 2.11.0 diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 32fece308beb..9e5a11900d66 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -34,6 +34,9 @@ * * Keep sorted: first by key length, then by IV length */ +static const odp_crypto_cipher_capability_t cipher_capa_null[] = { +{.key_len = 0, .iv_len = 0} }; + static const odp_crypto_cipher_capability_t cipher_capa_des[] = { {.key_len = 24, .iv_len = 8} }; @@ -51,6 +54,9 @@ static const odp_crypto_cipher_capability_t cipher_capa_aes_gcm[] = { * * Keep sorted: first by digest length, then by key length */ +static const odp_crypto_auth_capability_t auth_capa_null[] = { +{.digest_len = 0, .key_len = 0, .aad_len = {.min = 0, .max = 0, .inc = 0} } }; + static const odp_crypto_auth_capability_t auth_capa_md5_hmac[] = { {.digest_len = 12, .key_len = 16, .aad_len = {.min = 0, .max = 0, .inc = 0} }, {.digest_len = 16, .key_len = 16, .aad_len = {.min = 0, .max = 0, .inc = 0} } }; @@ -571,8 +577,8 @@ int odp_crypto_cipher_capability(odp_cipher_alg_t cipher, switch (cipher) { case ODP_CIPHER_ALG_NULL: - src = NULL; - num = 0; + src = cipher_capa_null; + num = sizeof(cipher_capa_null) / size; break; case ODP_CIPHER_ALG_DES: src = cipher_capa_des; @@ -611,8 +617,8 @@ int odp_crypto_auth_capability(odp_auth_alg_t auth, switch (auth) { case ODP_AUTH_ALG_NULL: - src = NULL; - num = 0; + src = auth_capa_null; + num = sizeof(auth_capa_null) / size; break; case ODP_AUTH_ALG_MD5_HMAC: src = auth_capa_md5_hmac; diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c index c89d04f9c238..470c5bc5e70d 100644 --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c @@ -141,13 +141,8 @@ static void alg_test(odp_crypto_op_t op, num = odp_crypto_cipher_capability(cipher_alg, cipher_capa, MAX_ALG_CAPA); - if (cipher_alg != ODP_CIPHER_ALG_NULL) { - CU_ASSERT(num > 0); - found = 0; - } else { - CU_ASSERT(num == 0); - found = 1; - } + CU_ASSERT(num > 0); + found = 0; CU_ASSERT(num <= MAX_ALG_CAPA); @@ -167,13 +162,8 @@ static void alg_test(odp_crypto_op_t op, num = odp_crypto_auth_capability(auth_alg, auth_capa, MAX_ALG_CAPA); - if (auth_alg != ODP_AUTH_ALG_NULL) { - CU_ASSERT(num > 0); - found = 0; - } else { - CU_ASSERT(num == 0); - found = 1; - } + CU_ASSERT(num > 0); + found = 0; CU_ASSERT(num <= MAX_ALG_CAPA);