From patchwork Wed May 17 10:49:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Garapati X-Patchwork-Id: 99970 Delivered-To: patch@linaro.org Received: by 10.182.142.97 with SMTP id rv1csp149244obb; Wed, 17 May 2017 03:49:47 -0700 (PDT) X-Received: by 10.55.106.7 with SMTP id f7mr2517980qkc.189.1495018187062; Wed, 17 May 2017 03:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495018187; cv=none; d=google.com; s=arc-20160816; b=jonW29DX4QJ6oL+pmQ7Oyt7kTAOttdiw7GZ82ZfhAHItjpo//o7/56LgdjcLqR0f+K pJfS9o7xTAhr9lb4zEIQVcNFgxhxb7sb2xIQBlpFDTsj7aTgGzH/G6MnJTfpdZVE4mOO LqhZcgAXRVHQ44Ob2EzMcR3C0XpQYK4S+Nua5fcPz3yawslGU+9rlw5py7y801xrny4s af85v+GZ+CaTCqUbpTme5oGR6qef72hEYVIovWWkznu3MIVjbGHrImR6jB10cjHJkyWl h1tx9tlZfHzrs85Mmnm3Intuu0LokeI889k3Pejm49nQz/Lke2KsOjtSzFDAvENRsWO6 VtiQ== 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:message-id:date:to:from :delivered-to:arc-authentication-results; bh=6Cte+j+M/LQVKM3JH+N8wFFvw5sIBoOsDdFzmRKpAcw=; b=oqOF6OQX6YljWQpIQHOKIGZW800hSKHccCY5uZmWOKSaV++bWjmQGAkQdgArqEsA5t dvdacxmywb+yFrtzcH5i8eW4VDWy8hTBbnFwZ9j5r05DH3nHpevWH+ii2zbl+F5uUADL /bXrTC34GUQqTwZEFCNc5ju7t0CyZSLUqlDml6ErgS5kYcQezSRcW+CpqZw9TP+05R3E lCLudmoIvnOxVKJ8EYUAqI95iJMmZqYnClr2FnuV/QJYB7fTc35egVzo6ENGTk4N6f2J 523n7MVyRfulDnOzvNI9ZZuFH+LXj3RH/quJlEaH0zz+iH8havFQvcdENp/nqeT/QeBT PrfA== 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 c49si1823073qtb.119.2017.05.17.03.49.46; Wed, 17 May 2017 03:49:47 -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 802CF60C14; Wed, 17 May 2017 10:49:46 +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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 224D860C0D; Wed, 17 May 2017 10:49:41 +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 8A24B60C0C; Wed, 17 May 2017 10:49:39 +0000 (UTC) Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by lists.linaro.org (Postfix) with ESMTPS id 7505D60C0C for ; Wed, 17 May 2017 10:49:38 +0000 (UTC) Received: by mail-wm0-f43.google.com with SMTP id b84so160085752wmh.0 for ; Wed, 17 May 2017 03:49:38 -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; bh=6Cte+j+M/LQVKM3JH+N8wFFvw5sIBoOsDdFzmRKpAcw=; b=YB20hBkNkO+pFNRdVFrkTv4+jlmC6dD64NBG3Dtgh9z323tYzoKKz+g21HBIturKxf A9dgch1U/xF6dgeFBReFwjrKK4xjVgsRo1ovP3k7I2CdjKardPoSKFtMArbRqlelpRbH WwXC/HYnnJl3XLCNKzfvIaXAUjKRL2EmHaE2sDcVqPJU7ArkvmkqPQvWfeGyokHnrKb1 2jlRD7+IfqaTjuCCw94JKG8y2+aH1xvideoJOGlRF9BawhUg6A70smCtad0K/tubruJ1 PZlNTXVoW8W7e61Ld655Fwn7gyrgVfqtu7xqUGsErY/BqxWwjTrDieJ+4pC14q9MhlaM Au0w== X-Gm-Message-State: AODbwcDGDgYDh4U7xdLANAFqd6V4YWYa6ux9PLNygd6IdbbrrNaKyvfK U/967S7LbouzpngULzrHH2Aa X-Received: by 10.25.235.210 with SMTP id f79mr796113lfk.27.1495018177126; Wed, 17 May 2017 03:49:37 -0700 (PDT) Received: from elxahtkds32.localdomain (host-90-236-206-29.mobileonline.telia.com. [90.236.206.29]) by smtp.gmail.com with ESMTPSA id h74sm321802ljh.21.2017.05.17.03.49.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 May 2017 03:49:36 -0700 (PDT) From: Balakrishna Garapati To: lng-odp@lists.linaro.org Date: Wed, 17 May 2017 12:49:34 +0200 Message-Id: <1495018174-23937-1-git-send-email-balakrishna.garapati@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [API-NEXT PATCHv3] api: crypto: change iv_len field to feature min-max len 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" dpdk pmd's require to minatain min, max, inc fields for all crypto capabilitites. By making iv_len to feature like dpdk pmd's it is easier to create cipher entires in odp based on key_len. Signed-off-by: Balakrishna Garapati --- since v1: fixed comments from v1, - updated the description about the patch - Fixed the bug in crypto validation since v2: if statement correction in validation "check_cipher_options" include/odp/api/spec/crypto.h | 12 +++- platform/linux-generic/odp_crypto.c | 8 +-- .../validation/api/crypto/odp_crypto_test_inp.c | 81 ++++++---------------- 3 files changed, 37 insertions(+), 64 deletions(-) -- 1.9.1 diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h index c47d314..a1b540a 100644 --- a/include/odp/api/spec/crypto.h +++ b/include/odp/api/spec/crypto.h @@ -497,7 +497,17 @@ typedef struct odp_crypto_cipher_capability_t { uint32_t key_len; /** IV length in bytes */ - uint32_t iv_len; + struct { + /** Minimum iv length in bytes */ + uint32_t min; + + /** Maximum iv length in bytes */ + uint32_t max; + + /** Increment of supported lengths between min and max + * (in bytes) */ + uint32_t inc; + } iv_len; } odp_crypto_cipher_capability_t; diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index a0f3f7e..3e9b607 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -35,16 +35,16 @@ * Keep sorted: first by key length, then by IV length */ static const odp_crypto_cipher_capability_t cipher_capa_des[] = { -{.key_len = 24, .iv_len = 8} }; +{.key_len = 24, .iv_len = {.min = 8, .max = 8, .inc = 0} } }; static const odp_crypto_cipher_capability_t cipher_capa_trides_cbc[] = { -{.key_len = 24, .iv_len = 8} }; +{.key_len = 24, .iv_len = {.min = 8, .max = 8, .inc = 0} } }; static const odp_crypto_cipher_capability_t cipher_capa_aes_cbc[] = { -{.key_len = 16, .iv_len = 16} }; +{.key_len = 16, .iv_len = {.min = 16, .max = 16, .inc = 0} } }; static const odp_crypto_cipher_capability_t cipher_capa_aes_gcm[] = { -{.key_len = 16, .iv_len = 12} }; +{.key_len = 16, .iv_len = {.min = 12, .max = 12, .inc = 0} } }; /* * Authentication algorithm capabilities 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 24ea493..0f98fe5 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 @@ -93,10 +93,6 @@ static void alg_test(odp_crypto_op_t op, odp_crypto_op_param_t op_params; uint8_t *data_addr; int data_off; - odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA]; - odp_crypto_auth_capability_t auth_capa[MAX_ALG_CAPA]; - int num, i; - int found; rc = odp_crypto_capability(&capa); CU_ASSERT(!rc); @@ -136,59 +132,6 @@ static void alg_test(odp_crypto_op_t op, CU_ASSERT(!rc); CU_ASSERT((~capa.auths.all_bits & capa.hw_auths.all_bits) == 0); - 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 <= MAX_ALG_CAPA); - - if (num > MAX_ALG_CAPA) - num = MAX_ALG_CAPA; - - /* Search for the test case */ - for (i = 0; i < num; i++) { - if (cipher_capa[i].key_len == cipher_key.length && - cipher_capa[i].iv_len == ses_iv.length) { - found = 1; - break; - } - } - - CU_ASSERT(found); - - 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 <= MAX_ALG_CAPA); - - if (num > MAX_ALG_CAPA) - num = MAX_ALG_CAPA; - - /* Search for the test case */ - for (i = 0; i < num; i++) { - if (auth_capa[i].digest_len == digest_len && - auth_capa[i].key_len == auth_key.length) { - found = 1; - break; - } - } - - CU_ASSERT(found); - /* Create a crypto session */ odp_crypto_session_param_init(&ses_params); ses_params.op = op; @@ -379,14 +322,34 @@ static int check_cipher_options(odp_cipher_alg_t cipher, uint32_t key_len, { int i; int num; + int found = 0; + odp_crypto_cipher_capability_t cipher_capa[MAX_ALG_CAPA]; num = odp_crypto_cipher_capability(cipher, cipher_capa, MAX_ALG_CAPA); CU_ASSERT_FATAL(num >= 1); for (i = 0; i < num; i++) { - if (key_len == cipher_capa[i].key_len && - iv_len == cipher_capa[i].iv_len) + uint8_t inc = cipher_capa[i].iv_len.inc; + uint8_t iv_min = cipher_capa[i].iv_len.min; + uint8_t iv_max = cipher_capa[i].iv_len.max; + + if (inc == 0) { + if (iv_len == iv_min && + key_len == cipher_capa[i].key_len) { + found = 1; + } + } else { + for (uint8_t iv = iv_min; iv <= iv_max; iv = iv + inc) { + if (iv_len == iv && + key_len == cipher_capa[i].key_len) { + found = 1; + break; + } + } + } + + if (found == 1) break; }