From patchwork Thu Jun 1 08:22:53 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: 100831 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp697645qge; Thu, 1 Jun 2017 01:34:40 -0700 (PDT) X-Received: by 10.200.56.243 with SMTP id g48mr285176qtc.79.1496306080038; Thu, 01 Jun 2017 01:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496306080; cv=none; d=google.com; s=arc-20160816; b=k07tAMSDnVeFYvBxG94tjxTfDN7wDjWJaabc98SfMU90q7vhANaLObW+2L9NtLGlfl IVGgnsAUS4t4ZLe9XXOR8OsxDWFnobUcFhchH2dBRer9CATicG8L9PCnqJp4SgT7vSxQ lwKiMZO9eyn5swzK8PA42EnnBIVGWwfDNitr7O3DTFS+rTnNTJtp9FJoPx7I6k37tRrW 7eYw1GcB3E3uJqFtrlc1fIddDyagwhFr77S294990Spzyx3dczvV/Kj4t62paNBELHTO QIhAbwMPXOvB9FEjJxADJRyiJO/OFiBCBIpEzgBbgQ+osjPvlBwXjVKyzDYNAWIgGm8P gvKw== 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=buen9whzkhMk1pGT/epDL4pAkV2JKRty0fL77PGqsmY=; b=fTGAqEGKCksOFYoDwxbL2PU/IRO9RxdaTerRSIqwKgYzTisPcuPiqxskMyDLNOIUpn N2o8y0F+Nsaf/I/axeVza0DXd/fIoSSCEyX0mgLCPcKvLOYnWTlZYF3pp7/nB2pkzEME Hvypfkzr0w/yQgMQCi5cW6szC3HMwsjZzKezgrffcLFNNjJf/HEQo9jRHnKT1AgxE7op C5iheUhi8ONEu8tz3oCPqvdoDqCtASm21F/1JSGs53WDsRJAhqukF2baferMK/jPcR2w FvT9Ss3vKDT6BUnLfevQ45+EbwNebRDHrzxid/2HmFmXmWtj1v08ko2v1dfm+VB1B9tm 0OPw== 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 v189si18959781qki.292.2017.06.01.01.34.39; Thu, 01 Jun 2017 01:34:40 -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 9F8766069A; Thu, 1 Jun 2017 08:34:39 +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 91B7260D87; Thu, 1 Jun 2017 08:26:04 +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 B17C460C42; Thu, 1 Jun 2017 08:25:54 +0000 (UTC) Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) by lists.linaro.org (Postfix) with ESMTPS id F17F060C42 for ; Thu, 1 Jun 2017 08:23:37 +0000 (UTC) Received: by mail-lf0-f46.google.com with SMTP id 99so22040866lfu.1 for ; Thu, 01 Jun 2017 01:23:37 -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=buen9whzkhMk1pGT/epDL4pAkV2JKRty0fL77PGqsmY=; b=G8muWEUV29g6glzv+kHXPS/mKoJOFiyjFqvNtopNLaoUNpAUhj/VUJs17bPLIQ4Muu sjgqbEIde+p206sir2Q6K1K/JJC4UqfZYWOPw7bFACIOHloeQZGbHvnmqHtyK8zhS1TJ 041Oi2TuahMxQ93XXnsNaS3R+HmWVYXI4us3Zezm6r3Okk0puZtvT1gz7pmdwXAUJ9TD 4xaEivT5WZusjviUdoWUXgNPlDNXPiUOOrcTROPW/EDfD2SDhdPXhq7N6If6VPnWYs90 47QLdYluqNXVBTyYnnJe21pP3rqg8wkPgCgFnmEl7W4oZBIsDTvS1AB+Zsb2SYFQAoKW vouQ== X-Gm-Message-State: AODbwcDHWEO9gz66RQxgPvJWs6w0yWRNAK9Ij2M4gD7JCoAAHrkOKgbl vcNNj5RNazy+c8vbhvYEJddu X-Received: by 10.46.69.69 with SMTP id s66mr119583lja.110.1496305416680; Thu, 01 Jun 2017 01:23:36 -0700 (PDT) Received: from forlindon.lumag.auriga.ru ([188.162.64.12]) by smtp.gmail.com with ESMTPSA id c78sm4185837lfh.25.2017.06.01.01.23.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:36 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:53 +0300 Message-Id: <20170601082320.4673-14-dmitry.ereminsolenikov@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170601082320.4673-1-dmitry.ereminsolenikov@linaro.org> References: <20170601082320.4673-1-dmitry.ereminsolenikov@linaro.org> Subject: [lng-odp] [PATCH 08/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 352cfa536268..5f4f5250df14 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} } }; @@ -562,8 +568,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; @@ -602,8 +608,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);