From patchwork Mon May 15 12:42:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Garapati X-Patchwork-Id: 99811 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp1527048qge; Mon, 15 May 2017 05:43:05 -0700 (PDT) X-Received: by 10.36.249.73 with SMTP id l70mr4976363ith.1.1494852185471; Mon, 15 May 2017 05:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494852185; cv=none; d=google.com; s=arc-20160816; b=r/awucCKZ9ABE4NMKy7ep7GWyEQhQleqhmDvnbgAP2rXHpDjVdRMGNqfPt00q+Q4Nc hxUSgA/7qgKzwLty10KXxD/HPixFk32QQ6PTA4MAC6+Sk4Zr6ATlfWjNz11FXf72Old+ rM28Vlq/h6bpbDmlF6o7Jz6nOB2G14Y3jZnr/3Vl3hF1D5KQ6O9ugWnSHalikeBs15Sx ZXO14/x/xQaKWFjCcL5Hi9C7Q/i3QkJq//wIbN7rRmv4z89JhA1nQlQ5ARwjg1WqD3my Ctgk+evPIirBw1wnBg9gMM/0O2Bg889YhpC4Otwe4kYJIV3wg8Ur9TQt2xS79TGFClTx m3Eg== 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=mFgkj41eoFVCG5a+AZbyotTQx+wKMaC/yAEAd/AYgOE=; b=KEfVxugJdZs/NdgC38rkVAFnaPmNgWWc8egeVYfn6DUukV7ZbN1B9zNmNCu0LOtr1J xRgvf+0o35T0hGM+JFMXTauY/nPbBsB2+YvP8RT4iX8QULXZ6dNvTg1zj6N71eBthLK6 WJ6pypofoCf3p01+2U4vOANXEQPBoJBBudvnG8uhDiq+0C5VvJbXckoJCRji+y4j5eNH MUM/6nmPxMkI+Xviwg93uN+jjwL0EumkJIgl4OApMOH3PM62xrT1KGJG62/bNU1gGaQT 7E6IOsF6hbupnHz3tQPlF6mOlissdybbQhoiPQEF2p55oDlHS65vOUUKepmj1oIM0/5C QgRQ== 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 o3si11217886ite.25.2017.05.15.05.43.05; Mon, 15 May 2017 05:43:05 -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 BF24C60933; Mon, 15 May 2017 12:43:04 +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 C9BCD607C2; Mon, 15 May 2017 12:42:59 +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 3AADB60809; Mon, 15 May 2017 12:42:58 +0000 (UTC) Received: from mail-qt0-f177.google.com (mail-qt0-f177.google.com [209.85.216.177]) by lists.linaro.org (Postfix) with ESMTPS id 61536607C0 for ; Mon, 15 May 2017 12:42:57 +0000 (UTC) Received: by mail-qt0-f177.google.com with SMTP id c13so30943357qtc.1 for ; Mon, 15 May 2017 05:42:57 -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=mFgkj41eoFVCG5a+AZbyotTQx+wKMaC/yAEAd/AYgOE=; b=b89VPlvvNzVHBMHXN4u5N45UviF1w2BQR/79qXJngfYL4NWLBnE3pXK+SH1OnjhxLr JXTEnVdisxM7q7XKZ3PpJnaj3u42f1UHi2wRR62jOZ1oN3cnzMS4E5gs1HEg5aOZn+61 NQg1ypphAs6tmZWr3P5OjdpwaKbwA7gEFHtQD2/xAn9hEjjfEsuFbFwJB5KlwkqFhp+K QIf9CkID5Y9yiVkFgfk1yVC6jcwOeBZu1eDk1MqM4GK2+BCAQvnDuixjmYU6g158g3QX sLl9TVbY3Ku32AYiLNS/nN845N5OSkB1D0WxulHWMrTqdOyAumyJxwbMfPhTKv6D+3pi mlnA== X-Gm-Message-State: AODbwcBYrjHz2mkpp3Dvv8mkMfzPQpz8Chh91vrSvLyPfnqNSmsG/V1a aBX31jK0z6sGDWGqJh3bfGwM X-Received: by 10.25.206.67 with SMTP id e64mr1807005lfg.180.1494852176307; Mon, 15 May 2017 05:42:56 -0700 (PDT) Received: from elxahtkds32.localdomain (host-90-236-47-36.mobileonline.telia.com. [90.236.47.36]) by smtp.gmail.com with ESMTPSA id e10sm2133129ljb.68.2017.05.15.05.42.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 May 2017 05:42:55 -0700 (PDT) From: Balakrishna Garapati To: lng-odp@lists.linaro.org Date: Mon, 15 May 2017 14:42:54 +0200 Message-Id: <1494852174-9403-1-git-send-email-balakrishna.garapati@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [API-NEXT PATCH] 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" This change is needed to support dpdk crypto pmd's Signed-off-by: Balakrishna Garapati --- include/odp/api/spec/crypto.h | 12 +++- platform/linux-generic/odp_crypto.c | 8 +-- .../validation/api/crypto/odp_crypto_test_inp.c | 76 +++++----------------- 3 files changed, 31 insertions(+), 65 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..628f150 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; @@ -385,9 +328,21 @@ static int check_cipher_options(odp_cipher_alg_t cipher, uint32_t key_len, 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) - break; + 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) + break; + } else { + for (uint8_t iv = iv_min; iv <= iv_max; iv = iv + inc) { + if (iv_len == iv && + key_len == cipher_capa[i].key_len) + break; + } + } } if (i == num) { @@ -396,6 +351,7 @@ static int check_cipher_options(odp_cipher_alg_t cipher, uint32_t key_len, iv_len); return 0; } + return 1; }