From patchwork Thu Jun 1 08:22:42 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: 100819 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp694971qge; Thu, 1 Jun 2017 01:25:29 -0700 (PDT) X-Received: by 10.200.48.221 with SMTP id w29mr295627qta.54.1496305529199; Thu, 01 Jun 2017 01:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496305529; cv=none; d=google.com; s=arc-20160816; b=xrPbFxuXCixLnu3S+UUstodaNOxLLf4z9BykTCNk683U6t6BTx6MwZiSp7Ad8vxZw9 yYMEYmYi2E4K3uAZD6/PCj2c4+K9r0dq2TURXSIR/iuB0Dsl52UXiJDPpzPrYwBTisL0 4742PPVvpVsRn2pEbTpYCncxYlEGKf8e1O9e3+i4nWmnzTA6W7LIp89XaarvJcwzrOX8 YKf2OZa0bT8r3quWU0VQO8yJ9LNQ3Skx0SJZ//PTfEp+txkM3KszZnnskcm8eEAnaPB4 /ZX/34Ngpiw1htM3vL3khMvK7lyeevIJWbu3EWLCEwprB+ZuQ7EhQXpDtMhhjPY2deyT 3R/A== 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=kUAr+XVQaKXgipLQmueCBzT5rvPY9nV5MQnBxbXJZIY=; b=YtZWdcEDcmaG6G5EdOTGydMgzzp6mDupWuAx6HIbb7LwwpCsfVsHT83Xe9+/m1m2z1 DPULiT/y3I1F+g+x8VOPaUV9rT+o6a3KrzhBbw2SWs8vIV1AY1UBiUgoGwsqFnP29Juu Iv6Hrz5cLQ/04I0cthHdhSRC8N3jr03LPXTlPNLD9yhVlaPr0OVpApV/FZSHIEqWkj7a lIwZ8/jve+j0fYxgP7e0gd937d9swnR0zSCvv21gwfW5meTVEj4xvXw/miiq9y5ftqg/ DLOsIPgvjM4kWBGMLio1GYXai+ha6cjUqdcorYFkYt4Ymnwwtm6HOVH4q0S7beex437z g07g== 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 r16si18984640qtc.289.2017.06.01.01.25.28; Thu, 01 Jun 2017 01:25:29 -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 D185A60D89; Thu, 1 Jun 2017 08:25: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=-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 C8A0960D34; Thu, 1 Jun 2017 08:23:39 +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 0165260C42; Thu, 1 Jun 2017 08:23:30 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id 8310860972 for ; Thu, 1 Jun 2017 08:23:26 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id a136so7454844lfa.0 for ; Thu, 01 Jun 2017 01:23:26 -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=kUAr+XVQaKXgipLQmueCBzT5rvPY9nV5MQnBxbXJZIY=; b=MsqmWKBEl5b5Cd9jWWUf3W6W8YupaHD+YV2vvuD4sxpNmFzT71xRv5e0do5o2FTCr9 pQpJqBI8xaVeLG4UGas7BsDaPoOP+radGn3ax1NDmCAqln7yFTB4L0rg3HtNIRc/VbzE y3PfEbj0LEgQr/ZaVIFT8XfuXdE9bl7atJpG6oBE6QyFI2IJmE0k6X3d7TrWxg8Cmlxg eohqs73tKcMxkILoqNa0yHNUN4n7efnYlLGR9w62m9KL2apY84vWHRqo7bRPZCBIx1mk aEjYQCyDn8vSMS9BsaJdut+BIq/7BOOnkSTiuCx7o9Bzu5YjWhzZoyvMShZzOBSNntnZ oJSg== X-Gm-Message-State: AODbwcB1PKRw14kXw03QD8uA2/pwfMu/cmp5hfKJfbb6o3qwT7Ogg9oJ dN56eaF8iqptAlj0YC0Kl9MI X-Received: by 10.46.71.14 with SMTP id u14mr114264lja.104.1496305405137; Thu, 01 Jun 2017 01:23:25 -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.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:24 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:42 +0300 Message-Id: <20170601082320.4673-3-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 API-NEXT v4 01/23] validation: crypto: explicitly pass auth_digest_len to crypto subsystem 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" Signed-off-by: Dmitry Eremin-Solenikov --- .../validation/api/crypto/odp_crypto_test_inp.c | 57 +++++++++++++--------- .../validation/api/crypto/test_vectors.h | 10 ++++ .../validation/api/crypto/test_vectors_len.h | 3 -- 3 files changed, 43 insertions(+), 27 deletions(-) -- 2.11.0 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 bfc9da3c681e..3d09e3745b4b 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 @@ -201,6 +201,7 @@ static void alg_test(odp_crypto_op_t op, ses_params.cipher_key = cipher_key; ses_params.iv = ses_iv; ses_params.auth_key = auth_key; + ses_params.auth_digest_len = digest_len; rc = odp_crypto_session_create(&ses_params, &session, &status); CU_ASSERT_FATAL(!rc); @@ -620,7 +621,8 @@ void crypto_test_enc_alg_aes128_gcm(void) cipher_key.length, iv.length)) continue; if (!check_auth_options(ODP_AUTH_ALG_AES_GCM, - auth_key.length, AES128_GCM_CHECK_LEN)) + auth_key.length, + aes128_gcm_reference_tag_length[i])) continue; alg_test(ODP_CRYPTO_OP_ENCODE, @@ -639,7 +641,7 @@ void crypto_test_enc_alg_aes128_gcm(void) aes128_gcm_reference_length[i], aes128_gcm_reference_ciphertext[i] + aes128_gcm_reference_length[i], - AES128_GCM_CHECK_LEN); + aes128_gcm_reference_tag_length[i]); } } @@ -664,7 +666,8 @@ void crypto_test_enc_alg_aes128_gcm_ovr_iv(void) cipher_key.length, iv.length)) continue; if (!check_auth_options(ODP_AUTH_ALG_AES_GCM, - auth_key.length, AES128_GCM_CHECK_LEN)) + auth_key.length, + aes128_gcm_reference_tag_length[i])) continue; alg_test(ODP_CRYPTO_OP_ENCODE, @@ -683,7 +686,7 @@ void crypto_test_enc_alg_aes128_gcm_ovr_iv(void) aes128_gcm_reference_length[i], aes128_gcm_reference_ciphertext[i] + aes128_gcm_reference_length[i], - AES128_GCM_CHECK_LEN); + aes128_gcm_reference_tag_length[i]); } } @@ -714,7 +717,8 @@ void crypto_test_dec_alg_aes128_gcm(void) cipher_key.length, iv.length)) continue; if (!check_auth_options(ODP_AUTH_ALG_AES_GCM, - auth_key.length, AES128_GCM_CHECK_LEN)) + auth_key.length, + aes128_gcm_reference_tag_length[i])) continue; alg_test(ODP_CRYPTO_OP_DECODE, @@ -728,12 +732,13 @@ void crypto_test_dec_alg_aes128_gcm(void) &aes128_gcm_cipher_range[i], &aes128_gcm_auth_range[i], aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i] + AES128_GCM_CHECK_LEN, + aes128_gcm_reference_length[i] + + aes128_gcm_reference_tag_length[i], aes128_gcm_reference_plaintext[i], aes128_gcm_reference_length[i], aes128_gcm_reference_ciphertext[i] + aes128_gcm_reference_length[i], - AES128_GCM_CHECK_LEN); + aes128_gcm_reference_tag_length[i]); alg_test(ODP_CRYPTO_OP_DECODE, 1, @@ -746,11 +751,12 @@ void crypto_test_dec_alg_aes128_gcm(void) &aes128_gcm_cipher_range[i], &aes128_gcm_auth_range[i], aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i] + AES128_GCM_CHECK_LEN, + aes128_gcm_reference_length[i] + + aes128_gcm_reference_tag_length[i], aes128_gcm_reference_plaintext[i], aes128_gcm_reference_length[i], wrong_digest, - AES128_GCM_CHECK_LEN); + aes128_gcm_reference_tag_length[i]); } } @@ -779,7 +785,8 @@ void crypto_test_dec_alg_aes128_gcm_ovr_iv(void) cipher_key.length, iv.length)) continue; if (!check_auth_options(ODP_AUTH_ALG_AES_GCM, - auth_key.length, AES128_GCM_CHECK_LEN)) + auth_key.length, + aes128_gcm_reference_tag_length[i])) continue; alg_test(ODP_CRYPTO_OP_DECODE, @@ -793,12 +800,13 @@ void crypto_test_dec_alg_aes128_gcm_ovr_iv(void) &aes128_gcm_cipher_range[i], &aes128_gcm_auth_range[i], aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i] + AES128_GCM_CHECK_LEN, + aes128_gcm_reference_length[i] + + aes128_gcm_reference_tag_length[i], aes128_gcm_reference_plaintext[i], aes128_gcm_reference_length[i], aes128_gcm_reference_ciphertext[i] + aes128_gcm_reference_length[i], - AES128_GCM_CHECK_LEN); + aes128_gcm_reference_tag_length[i]); alg_test(ODP_CRYPTO_OP_DECODE, 1, @@ -811,11 +819,12 @@ void crypto_test_dec_alg_aes128_gcm_ovr_iv(void) &aes128_gcm_cipher_range[i], &aes128_gcm_auth_range[i], aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i] + AES128_GCM_CHECK_LEN, + aes128_gcm_reference_length[i] + + aes128_gcm_reference_tag_length[i], aes128_gcm_reference_plaintext[i], aes128_gcm_reference_length[i], wrong_digest, - AES128_GCM_CHECK_LEN); + aes128_gcm_reference_tag_length[i]); } } @@ -1004,7 +1013,7 @@ void crypto_test_gen_alg_hmac_md5(void) auth_key.length = sizeof(hmac_md5_reference_key[i]); if (!check_auth_options(ODP_AUTH_ALG_MD5_HMAC, auth_key.length, - HMAC_MD5_96_CHECK_LEN)) + hmac_md5_reference_digest_length[i])) continue; alg_test(ODP_CRYPTO_OP_ENCODE, @@ -1020,7 +1029,7 @@ void crypto_test_gen_alg_hmac_md5(void) hmac_md5_reference_length[i], NULL, 0, hmac_md5_reference_digest[i], - HMAC_MD5_96_CHECK_LEN); + hmac_md5_reference_digest_length[i]); } } @@ -1042,7 +1051,7 @@ void crypto_test_check_alg_hmac_md5(void) auth_key.length = sizeof(hmac_md5_reference_key[i]); if (!check_auth_options(ODP_AUTH_ALG_MD5_HMAC, auth_key.length, - HMAC_MD5_96_CHECK_LEN)) + hmac_md5_reference_digest_length[i])) continue; alg_test(ODP_CRYPTO_OP_DECODE, @@ -1058,7 +1067,7 @@ void crypto_test_check_alg_hmac_md5(void) hmac_md5_reference_length[i], NULL, 0, hmac_md5_reference_digest[i], - HMAC_MD5_96_CHECK_LEN); + hmac_md5_reference_digest_length[i]); alg_test(ODP_CRYPTO_OP_DECODE, 1, @@ -1073,7 +1082,7 @@ void crypto_test_check_alg_hmac_md5(void) hmac_md5_reference_length[i], NULL, 0, wrong_digest, - HMAC_MD5_96_CHECK_LEN); + hmac_md5_reference_digest_length[i]); } } @@ -1106,7 +1115,7 @@ void crypto_test_gen_alg_hmac_sha256(void) if (!check_auth_options(ODP_AUTH_ALG_SHA256_HMAC, auth_key.length, - HMAC_SHA256_128_CHECK_LEN)) + hmac_sha256_reference_digest_length[i])) continue; alg_test(ODP_CRYPTO_OP_ENCODE, @@ -1122,7 +1131,7 @@ void crypto_test_gen_alg_hmac_sha256(void) hmac_sha256_reference_length[i], NULL, 0, hmac_sha256_reference_digest[i], - HMAC_SHA256_128_CHECK_LEN); + hmac_sha256_reference_digest_length[i]); } } @@ -1146,7 +1155,7 @@ void crypto_test_check_alg_hmac_sha256(void) if (!check_auth_options(ODP_AUTH_ALG_SHA256_HMAC, auth_key.length, - HMAC_SHA256_128_CHECK_LEN)) + hmac_sha256_reference_digest_length[i])) continue; alg_test(ODP_CRYPTO_OP_DECODE, @@ -1162,7 +1171,7 @@ void crypto_test_check_alg_hmac_sha256(void) hmac_sha256_reference_length[i], NULL, 0, hmac_sha256_reference_digest[i], - HMAC_SHA256_128_CHECK_LEN); + hmac_sha256_reference_digest_length[i]); alg_test(ODP_CRYPTO_OP_DECODE, 1, @@ -1177,7 +1186,7 @@ void crypto_test_check_alg_hmac_sha256(void) hmac_sha256_reference_length[i], NULL, 0, wrong_digest, - HMAC_SHA256_128_CHECK_LEN); + hmac_sha256_reference_digest_length[i]); } } diff --git a/test/common_plat/validation/api/crypto/test_vectors.h b/test/common_plat/validation/api/crypto/test_vectors.h index a1cf4faf37f7..defbda45ad57 100644 --- a/test/common_plat/validation/api/crypto/test_vectors.h +++ b/test/common_plat/validation/api/crypto/test_vectors.h @@ -139,6 +139,8 @@ static uint8_t aes128_gcm_reference_iv[][AES128_GCM_IV_LEN] = { static uint32_t aes128_gcm_reference_length[] = { 84, 72, 72, 40}; +static uint32_t aes128_gcm_reference_tag_length[] = { 16, 16, 16, 16}; + static odp_packet_data_range_t aes128_gcm_cipher_range[] = { { .offset = 12, .length = 72 }, { .offset = 8, .length = 64 }, @@ -306,6 +308,10 @@ static uint8_t hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] = { 0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 } }; +static uint32_t hmac_md5_reference_digest_length[] = { + 12, 12, 12 +}; + static uint8_t hmac_sha256_reference_key[][HMAC_SHA256_KEY_LEN] = { { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, @@ -350,4 +356,8 @@ static uint8_t hmac_sha256_reference_digest[][HMAC_SHA256_DIGEST_LEN] = { 0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7 } }; +static uint32_t hmac_sha256_reference_digest_length[] = { + 16, 16, 16 +}; + #endif diff --git a/test/common_plat/validation/api/crypto/test_vectors_len.h b/test/common_plat/validation/api/crypto/test_vectors_len.h index 4fbb5cd7070c..80fd927b7f25 100644 --- a/test/common_plat/validation/api/crypto/test_vectors_len.h +++ b/test/common_plat/validation/api/crypto/test_vectors_len.h @@ -21,18 +21,15 @@ #define AES128_GCM_IV_LEN 12 #define AES128_GCM_MAX_DATA_LEN 106 #define AES128_GCM_DIGEST_LEN 16 -#define AES128_GCM_CHECK_LEN 16 /* HMAC-MD5 */ #define HMAC_MD5_KEY_LEN 16 #define HMAC_MD5_MAX_DATA_LEN 128 #define HMAC_MD5_DIGEST_LEN 16 -#define HMAC_MD5_96_CHECK_LEN 12 /* HMAC-SHA256 */ #define HMAC_SHA256_KEY_LEN 32 #define HMAC_SHA256_MAX_DATA_LEN 128 #define HMAC_SHA256_DIGEST_LEN 32 -#define HMAC_SHA256_128_CHECK_LEN 16 #endif From patchwork Thu Jun 1 08:22:44 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: 100821 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp695701qge; Thu, 1 Jun 2017 01:28:18 -0700 (PDT) X-Received: by 10.200.38.199 with SMTP id 7mr288069qtp.242.1496305698916; Thu, 01 Jun 2017 01:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496305698; cv=none; d=google.com; s=arc-20160816; b=iAPmVBqXtul0cgm8HASXzFdvxE6I7GEyWq8JoHYH82LqQqMfCLsQS4FdHcApkUSsHu ok1a2Uj4DlNEgbQPTV9DAq7WWavNt9gdrX9EYflcnycbxUPQpECf+xqTE9bOpU+grKHi GvBCRczcQRaXop5vbkIFNCtOOj5DZW3D7ECgWf+/qUd0A2KokIhv5tEmOexNc5C9B5yW 8APg07sdsQRoXxK8tjfw8sc23mMZVeeNPqnH4gh1WqLhKAmEWy0UjNDLzzFFDggt2JzH H77vgXbbexNbdcLiOAaArq1ETMzBTM+X5WILyzuLkA88go+zN76IXRoGsFtZ3zniHI3L t66A== 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=fqbJ7rwX5hrcDVWFX2UDlILwePKp53W8Yc1cn1uNSGw=; b=rSLxh7fRu7BuxYvZYmx2ND1jT3KTSGO3qPpxUfTH0gUMrU8lJGTwVEX06uUNxN4ynZ nFLuYufAkVCSQpR0qaJm/nxGwIrAIZ/H5BMXd/Fgc2wKm7bVEW3GszGFn5VrkP+85qVP wgJHE5G/yGYn0qn2XT07tK2Jt1p8SCdeGzZt60f0ldKUpb4dDDhPKMVCwfNUI1Mvr0AW kGtRMXT3m/N1ONw5oNsVf7LQ2Yvze3Me4Zhh7ucLahN1WNgz0hCqRtYUtvo7MEUOa8nT urqYsa4giLUPg4QRXCMWkDjYnTvBOe0KouYoONoa7nqineWqdPy6lEbasJC+9bXTI3On pUsg== 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 f129si18930071qkd.136.2017.06.01.01.28.18; Thu, 01 Jun 2017 01:28:18 -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 77C9860D4B; Thu, 1 Jun 2017 08:28:18 +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 DF65D60A0F; Thu, 1 Jun 2017 08:24:34 +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 25F8560D6C; Thu, 1 Jun 2017 08:24:29 +0000 (UTC) Received: from mail-lf0-f45.google.com (mail-lf0-f45.google.com [209.85.215.45]) by lists.linaro.org (Postfix) with ESMTPS id DD78760BE9 for ; Thu, 1 Jun 2017 08:23:28 +0000 (UTC) Received: by mail-lf0-f45.google.com with SMTP id a136so7455363lfa.0 for ; Thu, 01 Jun 2017 01:23:28 -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=fqbJ7rwX5hrcDVWFX2UDlILwePKp53W8Yc1cn1uNSGw=; b=dvqOvHd7RTv9QyYT1A1cBbDGNWKA7wi1YURBWUIDsXq3PFN5lTCmhWsDkv/szvWn0P 04BNOmw9sAurQuDcpINn1L85m2EBslgNIrd5eGDC3sA/CTm48IwwG44e6iuqD9tYuSK7 5DjuKJaJWxDVKhEtDaMs7Ntz7JbVES67aHzgCrvy+YHq85933YBHSClzi7TbdSyWF654 lZjUrKRcmsF0jRjhoQhYSnWE9Ap9FWhp9Q4XH757UrRxj2ORAa1ovERLcJOePuoE9rwL Ani7T8BQSlOkVv7akbJMJSo/85Arf0Gtf13uZ6jiWBGJeFn93e7K2eeC3XHz+rSWJnfl +pQw== X-Gm-Message-State: AODbwcDSG50KKU8AHRZ7AzGJQrsiRMTFpTGWwa8W1HIjj6MHbWDnt+G8 ny+XiOglEXjn/77j7hqmt1LC X-Received: by 10.46.71.203 with SMTP id u194mr103313lja.119.1496305407215; Thu, 01 Jun 2017 01:23:27 -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.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:26 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:44 +0300 Message-Id: <20170601082320.4673-5-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 API-NEXT v4 02/23] validation: crypto: explicitly pass AAD to crypto subsystem 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" Signed-off-by: Dmitry Eremin-Solenikov --- .../validation/api/crypto/odp_crypto_test_inp.c | 55 +++++++++++++----- .../validation/api/crypto/test_vectors.h | 65 ++++++++-------------- 2 files changed, 64 insertions(+), 56 deletions(-) -- 2.11.0 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 3d09e3745b4b..c89d04f9c238 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 @@ -74,6 +74,8 @@ static void alg_test(odp_crypto_op_t op, odp_crypto_key_t auth_key, odp_packet_data_range_t *cipher_range, odp_packet_data_range_t *auth_range, + uint8_t *aad, + uint32_t aad_len, const uint8_t *plaintext, unsigned int plaintext_len, const uint8_t *ciphertext, @@ -240,6 +242,9 @@ static void alg_test(odp_crypto_op_t op, if (op_iv_ptr) op_params.override_iv_ptr = op_iv_ptr; + op_params.aad.ptr = aad; + op_params.aad.length = aad_len; + op_params.hash_result_offset = plaintext_len; if (0 != digest_len) { memcpy(data_addr + op_params.hash_result_offset, @@ -472,6 +477,7 @@ void crypto_test_enc_alg_3des_cbc(void) ODP_AUTH_ALG_NULL, auth_key, NULL, NULL, + NULL, 0, tdes_cbc_reference_plaintext[i], tdes_cbc_reference_length[i], tdes_cbc_reference_ciphertext[i], @@ -508,6 +514,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void) ODP_AUTH_ALG_NULL, auth_key, NULL, NULL, + NULL, 0, tdes_cbc_reference_plaintext[i], tdes_cbc_reference_length[i], tdes_cbc_reference_ciphertext[i], @@ -548,6 +555,7 @@ void crypto_test_dec_alg_3des_cbc(void) ODP_AUTH_ALG_NULL, auth_key, NULL, NULL, + NULL, 0, tdes_cbc_reference_ciphertext[i], tdes_cbc_reference_length[i], tdes_cbc_reference_plaintext[i], @@ -586,6 +594,7 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void) ODP_AUTH_ALG_NULL, auth_key, NULL, NULL, + NULL, 0, tdes_cbc_reference_ciphertext[i], tdes_cbc_reference_length[i], tdes_cbc_reference_plaintext[i], @@ -634,7 +643,9 @@ void crypto_test_enc_alg_aes128_gcm(void) ODP_AUTH_ALG_AES_GCM, auth_key, &aes128_gcm_cipher_range[i], - &aes128_gcm_auth_range[i], + &aes128_gcm_cipher_range[i], + aes128_gcm_reference_aad[i], + aes128_gcm_reference_aad_length[i], aes128_gcm_reference_plaintext[i], aes128_gcm_reference_length[i], aes128_gcm_reference_ciphertext[i], @@ -679,7 +690,9 @@ void crypto_test_enc_alg_aes128_gcm_ovr_iv(void) ODP_AUTH_ALG_AES_GCM, auth_key, &aes128_gcm_cipher_range[i], - &aes128_gcm_auth_range[i], + &aes128_gcm_cipher_range[i], + aes128_gcm_reference_aad[i], + aes128_gcm_reference_aad_length[i], aes128_gcm_reference_plaintext[i], aes128_gcm_reference_length[i], aes128_gcm_reference_ciphertext[i], @@ -730,10 +743,11 @@ void crypto_test_dec_alg_aes128_gcm(void) ODP_AUTH_ALG_AES_GCM, auth_key, &aes128_gcm_cipher_range[i], - &aes128_gcm_auth_range[i], + &aes128_gcm_cipher_range[i], + aes128_gcm_reference_aad[i], + aes128_gcm_reference_aad_length[i], aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i] + - aes128_gcm_reference_tag_length[i], + aes128_gcm_reference_length[i], aes128_gcm_reference_plaintext[i], aes128_gcm_reference_length[i], aes128_gcm_reference_ciphertext[i] + @@ -749,10 +763,11 @@ void crypto_test_dec_alg_aes128_gcm(void) ODP_AUTH_ALG_AES_GCM, auth_key, &aes128_gcm_cipher_range[i], - &aes128_gcm_auth_range[i], + &aes128_gcm_cipher_range[i], + aes128_gcm_reference_aad[i], + aes128_gcm_reference_aad_length[i], aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i] + - aes128_gcm_reference_tag_length[i], + aes128_gcm_reference_length[i], aes128_gcm_reference_plaintext[i], aes128_gcm_reference_length[i], wrong_digest, @@ -798,10 +813,11 @@ void crypto_test_dec_alg_aes128_gcm_ovr_iv(void) ODP_AUTH_ALG_AES_GCM, auth_key, &aes128_gcm_cipher_range[i], - &aes128_gcm_auth_range[i], + &aes128_gcm_cipher_range[i], + aes128_gcm_reference_aad[i], + aes128_gcm_reference_aad_length[i], aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i] + - aes128_gcm_reference_tag_length[i], + aes128_gcm_reference_length[i], aes128_gcm_reference_plaintext[i], aes128_gcm_reference_length[i], aes128_gcm_reference_ciphertext[i] + @@ -817,10 +833,11 @@ void crypto_test_dec_alg_aes128_gcm_ovr_iv(void) ODP_AUTH_ALG_AES_GCM, auth_key, &aes128_gcm_cipher_range[i], - &aes128_gcm_auth_range[i], + &aes128_gcm_cipher_range[i], + aes128_gcm_reference_aad[i], + aes128_gcm_reference_aad_length[i], aes128_gcm_reference_ciphertext[i], - aes128_gcm_reference_length[i] + - aes128_gcm_reference_tag_length[i], + aes128_gcm_reference_length[i], aes128_gcm_reference_plaintext[i], aes128_gcm_reference_length[i], wrong_digest, @@ -865,6 +882,7 @@ void crypto_test_enc_alg_aes128_cbc(void) ODP_AUTH_ALG_NULL, auth_key, NULL, NULL, + NULL, 0, aes128_cbc_reference_plaintext[i], aes128_cbc_reference_length[i], aes128_cbc_reference_ciphertext[i], @@ -901,6 +919,7 @@ void crypto_test_enc_alg_aes128_cbc_ovr_iv(void) ODP_AUTH_ALG_NULL, auth_key, NULL, NULL, + NULL, 0, aes128_cbc_reference_plaintext[i], aes128_cbc_reference_length[i], aes128_cbc_reference_ciphertext[i], @@ -941,6 +960,7 @@ void crypto_test_dec_alg_aes128_cbc(void) ODP_AUTH_ALG_NULL, auth_key, NULL, NULL, + NULL, 0, aes128_cbc_reference_ciphertext[i], aes128_cbc_reference_length[i], aes128_cbc_reference_plaintext[i], @@ -979,6 +999,7 @@ void crypto_test_dec_alg_aes128_cbc_ovr_iv(void) ODP_AUTH_ALG_NULL, auth_key, NULL, NULL, + NULL, 0, aes128_cbc_reference_ciphertext[i], aes128_cbc_reference_length[i], aes128_cbc_reference_plaintext[i], @@ -1025,6 +1046,7 @@ void crypto_test_gen_alg_hmac_md5(void) ODP_AUTH_ALG_MD5_HMAC, auth_key, NULL, NULL, + NULL, 0, hmac_md5_reference_plaintext[i], hmac_md5_reference_length[i], NULL, 0, @@ -1063,6 +1085,7 @@ void crypto_test_check_alg_hmac_md5(void) ODP_AUTH_ALG_MD5_HMAC, auth_key, NULL, NULL, + NULL, 0, hmac_md5_reference_plaintext[i], hmac_md5_reference_length[i], NULL, 0, @@ -1078,6 +1101,7 @@ void crypto_test_check_alg_hmac_md5(void) ODP_AUTH_ALG_MD5_HMAC, auth_key, NULL, NULL, + NULL, 0, hmac_md5_reference_plaintext[i], hmac_md5_reference_length[i], NULL, 0, @@ -1127,6 +1151,7 @@ void crypto_test_gen_alg_hmac_sha256(void) ODP_AUTH_ALG_SHA256_HMAC, auth_key, NULL, NULL, + NULL, 0, hmac_sha256_reference_plaintext[i], hmac_sha256_reference_length[i], NULL, 0, @@ -1167,6 +1192,7 @@ void crypto_test_check_alg_hmac_sha256(void) ODP_AUTH_ALG_SHA256_HMAC, auth_key, NULL, NULL, + NULL, 0, hmac_sha256_reference_plaintext[i], hmac_sha256_reference_length[i], NULL, 0, @@ -1182,6 +1208,7 @@ void crypto_test_check_alg_hmac_sha256(void) ODP_AUTH_ALG_SHA256_HMAC, auth_key, NULL, NULL, + NULL, 0, hmac_sha256_reference_plaintext[i], hmac_sha256_reference_length[i], NULL, 0, diff --git a/test/common_plat/validation/api/crypto/test_vectors.h b/test/common_plat/validation/api/crypto/test_vectors.h index defbda45ad57..0d36c249870f 100644 --- a/test/common_plat/validation/api/crypto/test_vectors.h +++ b/test/common_plat/validation/api/crypto/test_vectors.h @@ -137,31 +137,31 @@ static uint8_t aes128_gcm_reference_iv[][AES128_GCM_IV_LEN] = { 0xa2, 0xfc, 0xa1, 0xa3 } }; -static uint32_t aes128_gcm_reference_length[] = { 84, 72, 72, 40}; +static uint32_t aes128_gcm_reference_length[] = { 72, 64, 64, 28}; static uint32_t aes128_gcm_reference_tag_length[] = { 16, 16, 16, 16}; +static uint32_t aes128_gcm_reference_aad_length[] = { 12, 8, 8, 12}; + static odp_packet_data_range_t aes128_gcm_cipher_range[] = { - { .offset = 12, .length = 72 }, - { .offset = 8, .length = 64 }, - { .offset = 8, .length = 64 }, - { .offset = 12, .length = 28 }, + { .offset = 0, .length = 72 }, + { .offset = 0, .length = 64 }, + { .offset = 0, .length = 64 }, + { .offset = 0, .length = 28 }, }; -static odp_packet_data_range_t aes128_gcm_auth_range[] = { - { .offset = 0, .length = 84 }, - { .offset = 0, .length = 72 }, - { .offset = 0, .length = 72 }, - { .offset = 0, .length = 40 }, +static uint8_t aes128_gcm_reference_aad[][AES128_GCM_MAX_DATA_LEN] = { + { 0x00, 0x00, 0x43, 0x21, 0x87, 0x65, 0x43, 0x21, + 0x00, 0x00, 0x00, 0x00, }, + { 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a, }, + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, }, + { 0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, }, }; static uint8_t aes128_gcm_reference_plaintext[][AES128_GCM_MAX_DATA_LEN] = { - { /* Aad */ - 0x00, 0x00, 0x43, 0x21, 0x87, 0x65, 0x43, 0x21, - 0x00, 0x00, 0x00, 0x00, - /* Plain */ - 0x45, 0x00, 0x00, 0x48, 0x69, 0x9a, 0x00, 0x00, + { 0x45, 0x00, 0x00, 0x48, 0x69, 0x9a, 0x00, 0x00, 0x80, 0x11, 0x4d, 0xb7, 0xc0, 0xa8, 0x01, 0x02, 0xc0, 0xa8, 0x01, 0x01, 0x0a, 0x9b, 0xf1, 0x56, 0x38, 0xd3, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, @@ -171,10 +171,7 @@ aes128_gcm_reference_plaintext[][AES128_GCM_MAX_DATA_LEN] = { 0x63, 0x69, 0x74, 0x79, 0x02, 0x64, 0x6b, 0x00, 0x00, 0x21, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01 }, - { /* Aad */ - 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a, - /* Plain */ - 0x45, 0x00, 0x00, 0x3e, 0x69, 0x8f, 0x00, 0x00, + { 0x45, 0x00, 0x00, 0x3e, 0x69, 0x8f, 0x00, 0x00, 0x80, 0x11, 0x4d, 0xcc, 0xc0, 0xa8, 0x01, 0x02, 0xc0, 0xa8, 0x01, 0x01, 0x0a, 0x98, 0x00, 0x35, 0x00, 0x2a, 0x23, 0x43, 0xb2, 0xd0, 0x01, 0x00, @@ -183,10 +180,7 @@ aes128_gcm_reference_plaintext[][AES128_GCM_MAX_DATA_LEN] = { 0x65, 0x72, 0x63, 0x69, 0x74, 0x79, 0x02, 0x64, 0x6b, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 }, - { /* Aad */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - /* Plain */ - 0x45, 0x00, 0x00, 0x3c, 0x99, 0xc5, 0x00, 0x00, + { 0x45, 0x00, 0x00, 0x3c, 0x99, 0xc5, 0x00, 0x00, 0x80, 0x01, 0xcb, 0x7a, 0x40, 0x67, 0x93, 0x18, 0x01, 0x01, 0x01, 0x01, 0x08, 0x00, 0x07, 0x5c, 0x02, 0x00, 0x44, 0x00, 0x61, 0x62, 0x63, 0x64, @@ -195,11 +189,7 @@ aes128_gcm_reference_plaintext[][AES128_GCM_MAX_DATA_LEN] = { 0x75, 0x76, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x01, 0x02, 0x02, 0x01 }, - { /* Aad */ - 0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, - /* Plain */ - 0x45, 0x00, 0x00, 0x1c, 0x42, 0xa2, 0x00, 0x00, + { 0x45, 0x00, 0x00, 0x1c, 0x42, 0xa2, 0x00, 0x00, 0x80, 0x01, 0x44, 0x1f, 0x40, 0x67, 0x93, 0xb6, 0xe0, 0x00, 0x00, 0x02, 0x0a, 0x00, 0xf5, 0xff, 0x01, 0x02, 0x02, 0x01 } @@ -207,10 +197,7 @@ aes128_gcm_reference_plaintext[][AES128_GCM_MAX_DATA_LEN] = { static uint8_t aes128_gcm_reference_ciphertext[][AES128_GCM_MAX_DATA_LEN] = { - { /* Aad */ - 0x00, 0x00, 0x43, 0x21, 0x87, 0x65, 0x43, 0x21, - 0x00, 0x00, 0x00, 0x00, - /* Plain */ + { /* Plain */ 0xfe, 0xcf, 0x53, 0x7e, 0x72, 0x9d, 0x5b, 0x07, 0xdc, 0x30, 0xdf, 0x52, 0x8d, 0xd2, 0x2b, 0x76, 0x8d, 0x1b, 0x98, 0x73, 0x66, 0x96, 0xa6, 0xfd, @@ -224,9 +211,7 @@ aes128_gcm_reference_ciphertext[][AES128_GCM_MAX_DATA_LEN] = { 0x45, 0x90, 0x18, 0x14, 0x8f, 0x6c, 0xbe, 0x72, 0x2f, 0xd0, 0x47, 0x96, 0x56, 0x2d, 0xfd, 0xb4 }, - { /* Aad */ - 0x00, 0x00, 0xa5, 0xf8, 0x00, 0x00, 0x00, 0x0a, - /* Plain */ + { /* Plain */ 0xde, 0xb2, 0x2c, 0xd9, 0xb0, 0x7c, 0x72, 0xc1, 0x6e, 0x3a, 0x65, 0xbe, 0xeb, 0x8d, 0xf3, 0x04, 0xa5, 0xa5, 0x89, 0x7d, 0x33, 0xae, 0x53, 0x0f, @@ -238,9 +223,8 @@ aes128_gcm_reference_ciphertext[][AES128_GCM_MAX_DATA_LEN] = { /* Digest */ 0x83, 0xb7, 0x0d, 0x3a, 0xa8, 0xbc, 0x6e, 0xe4, 0xc3, 0x09, 0xe9, 0xd8, 0x5a, 0x41, 0xad, 0x4a }, - { /* Aad */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - /* Plain */ + + { /* Plain */ 0x46, 0x88, 0xda, 0xf2, 0xf9, 0x73, 0xa3, 0x92, 0x73, 0x29, 0x09, 0xc3, 0x31, 0xd5, 0x6d, 0x60, 0xf6, 0x94, 0xab, 0xaa, 0x41, 0x4b, 0x5e, 0x7f, @@ -253,10 +237,7 @@ aes128_gcm_reference_ciphertext[][AES128_GCM_MAX_DATA_LEN] = { 0xf8, 0x21, 0xd4, 0x96, 0xee, 0xb0, 0x96, 0xe9, 0x8a, 0xd2, 0xb6, 0x9e, 0x47, 0x99, 0xc7, 0x1d }, - { /* Aad */ - 0x42, 0xf6, 0x7e, 0x3f, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, - /* Plain */ + { /* Plain */ 0xfb, 0xa2, 0xca, 0x84, 0x5e, 0x5d, 0xf9, 0xf0, 0xf2, 0x2c, 0x3e, 0x6e, 0x86, 0xdd, 0x83, 0x1e, 0x1f, 0xc6, 0x57, 0x92, 0xcd, 0x1a, 0xf9, 0x13, From patchwork Thu Jun 1 08:22:45 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: 100823 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp696228qge; Thu, 1 Jun 2017 01:30:06 -0700 (PDT) X-Received: by 10.55.23.1 with SMTP id i1mr277826qkh.67.1496305790188; Thu, 01 Jun 2017 01:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496305790; cv=none; d=google.com; s=arc-20160816; b=C2d2ThdX4lZ9vmanD1VW2NiCroxbaEHG3MEMg9jb3cLsTGbYlie7U821DdPk9sKTc8 Jkptm6kchhd4yDXmrlXYb1jQvmmPUWM9DCCAkjncSoo4Biu4WAGApqMbpvrB/mfffzqW cSrCW6+LIaF0gKkUA+cGUsWXiWjwdMs3fVctaTxXMFGCJgcPI6bVdRY3Uzz8ui/AX0Jv s1D5DkPAUSgrIlszG0BgJHjJwKHHaMru5817XUyx8N5dKxhg5/DOOhd2atnpxK6CUmxI ea8wnXai/iZ4OwIKTCQWNT2vpGu5Ltp8MAGD9XFGJ96iKVDXK0Mgc5eZ6d/z4jeYW17i wJjQ== 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=iFqBWbF7POfbw/sKeAW2FM6TTPlMhW9ASbp+PHNxqlQ=; b=UvGzYwPJXAQGVQketW8hONAuARbb6ZYdjrmyLXd8TOmOvy5gd73ibmN4hanKMpJKDu Fwhldd9l3sHblzdPFLdoGrc4wqNkgk8c5fjC2plMjLmeI/7P+HVVb1KKF4EAvBXsKhMF XTsTBVyU1cGKUZUDBOM2Mt3Xwugd9PAuLUqrBmSIO6BiaDdGBLZTj9ubDc1XFybY7Js+ D/gfMnKG1bd8o8maIU8jsGz5kHEDkie3oK65oH7L7blm1mpDgH2ZDIo5wUG6dvklL0Mk H3DeQvR8bKU4STtKrtNHfZIBCdqyfBUqHs+TdmNt4tMbwXHCF0jm5AiFh8Aa+WXn4H8x +bag== 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 t66si18782379qkf.279.2017.06.01.01.29.49; Thu, 01 Jun 2017 01:29:50 -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 C36F460A1A; Thu, 1 Jun 2017 08:29:49 +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 850E160C10; Thu, 1 Jun 2017 08:24:39 +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 6D7BE60BE9; Thu, 1 Jun 2017 08:24:29 +0000 (UTC) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id 7115860BF0 for ; Thu, 1 Jun 2017 08:23:29 +0000 (UTC) Received: by mail-lf0-f52.google.com with SMTP id c184so17268088lfe.2 for ; Thu, 01 Jun 2017 01:23:29 -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=iFqBWbF7POfbw/sKeAW2FM6TTPlMhW9ASbp+PHNxqlQ=; b=LUqptJshfFt4OrPlJ3Sp81Fnpyo+StylJ6WVCjWUkQTaDFqiOuZ9XGBD8hwiQiAD8T y0dFpDAHCPEpd8jjB/xfJ9T3fRLkgIwweV3rFldgthxkui7Nv2WsVnp4TnGgA1oya6Yc +Mj2V/FhvsUYntb/xHG8oZgZAqwiV33srq59qCRbgdpNUfVKyAaoEqPfvMHMHsweBi92 5snq0cCEnGNfFuIx2eVmdlVo+45Y+zKt2KEEZJa5UXk+6bAz9tQaoSztFULYccmt+2HV JchejHFPHGk5P8xafPylh8FUveoqfp1r7aHTPzSrajit/z/AFoS6h4npBoeUVFivW21O mEzw== X-Gm-Message-State: AODbwcD6SUBudmsBFh3lDxAIeTEig31b+mSGglIpPodLpOPQQUMwl4QE +xGA9k/e6DKP60Rz53TSnFZK X-Received: by 10.25.221.155 with SMTP id w27mr136906lfi.72.1496305408147; Thu, 01 Jun 2017 01:23:28 -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.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:27 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:45 +0300 Message-Id: <20170601082320.4673-6-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 API-NEXT v4 03/23] test: odp_crypto: update performance test to set auth_digest_length 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" Signed-off-by: Dmitry Eremin-Solenikov --- test/common_plat/performance/odp_crypto.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) -- 2.11.0 diff --git a/test/common_plat/performance/odp_crypto.c b/test/common_plat/performance/odp_crypto.c index b3857973eee7..b1ed6743e6e5 100644 --- a/test/common_plat/performance/odp_crypto.c +++ b/test/common_plat/performance/odp_crypto.c @@ -50,7 +50,6 @@ static uint8_t test_key24[24] = { 0x01, 0x02, 0x03, 0x04, 0x05, typedef struct { const char *name; /**< Algorithm name */ odp_crypto_session_param_t session; /**< Prefilled crypto session params */ - unsigned int hash_adjust; /**< Size of hash */ } crypto_alg_config_t; /** @@ -209,9 +208,9 @@ static crypto_alg_config_t algs_config[] = { .auth_key = { .data = test_key16, .length = sizeof(test_key16) - } + }, + .auth_digest_len = 12, }, - .hash_adjust = 12 }, { .name = "null-hmac-md5-96", @@ -221,9 +220,9 @@ static crypto_alg_config_t algs_config[] = { .auth_key = { .data = test_key16, .length = sizeof(test_key16) - } + }, + .auth_digest_len = 12, }, - .hash_adjust = 12 }, }; @@ -578,7 +577,7 @@ run_measure_one(crypto_args_t *cargs, mem = odp_packet_data(params.out_pkt); print_mem("Immediately encrypted packet", mem, payload_length + - config->hash_adjust); + config->session.auth_digest_len); } if (!cargs->in_place) { if (cargs->reuse_packet) { @@ -611,7 +610,7 @@ run_measure_one(crypto_args_t *cargs, print_mem("Receieved encrypted packet", mem, payload_length + - config->hash_adjust); + config->session.auth_digest_len); } if (cargs->reuse_packet) { params.pkt = out_pkt; From patchwork Thu Jun 1 08:22:46 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: 100822 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp696021qge; Thu, 1 Jun 2017 01:29:24 -0700 (PDT) X-Received: by 10.55.111.198 with SMTP id k189mr294711qkc.160.1496305764931; Thu, 01 Jun 2017 01:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496305764; cv=none; d=google.com; s=arc-20160816; b=NrzZj4b3+gh/WsrxO6NBNrmymauoZfFwNR21knQ7hcXiH8gaJOCDmKuBxMTAjbOKWB YUG7pKVgYajDI+9XlQtk/wShXzY4h1iEZTldlSaH7MsHXXLEc4oBz1mlBig8jz6/0r5d sHpUooX211WXW5NMVuXpTzS1l8MNROUfUE9FZ42CG8yu2n+PfE/AOqpyZl9TH2aTi70S EzmoFx2v9JbteQXvlzQ0c2RMHZtWsL87ESkPYyvMwllP47ZUhg6K79PnamwL1B/Tpivh wehLNmujHSv041kSJZzGZb0deX0/MWm2ZlG3DM72Pmiia0IC+A3zeBgirO5/gbMhHJjr hP4w== 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=x6njpu0m23EKhgdO1OU81zglp/NKztNL1/DKu/8Bl5w=; b=JkpSkD+eZ23GXYd2pkLQnpSYT1lOUi4eRXtt1k+3rRHx4dfo8uhPFZFXtOH/aYte1n IkyMIyeL9ZYJNjd33ALDHfEiqKT5l141nKHaX1lfJt3qDre49ycEowe2lCt1IOwgrQVp T61VGMAITdcW5Vm6zoc3bYiHnIQKTnmop/Z0s+LQ2hj4AUPnFQHsJtTTKiTTTQ3S5J0k 9JM8JrAoWUlaUo42oO6WZWmAZr08VDoRZYVyJud7lEz4UmfIKx/ixInalPKU8Zvy0Sl9 jDUTckrHj7Hy3eGy3UIySiHYkRD1MJeb+e/DlskQAFQqGKukKA4y9IDd4eh8qjeXKvVm 16Tw== 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 t25si1830447qth.4.2017.06.01.01.29.24; Thu, 01 Jun 2017 01:29:24 -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 8049E60A2E; Thu, 1 Jun 2017 08:29:24 +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 3A37160BF0; Thu, 1 Jun 2017 08:24: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 71B9260BE4; Thu, 1 Jun 2017 08:24:29 +0000 (UTC) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id 4EAF060BF5 for ; Thu, 1 Jun 2017 08:23:30 +0000 (UTC) Received: by mail-lf0-f52.google.com with SMTP id a136so7455680lfa.0 for ; Thu, 01 Jun 2017 01:23:30 -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=x6njpu0m23EKhgdO1OU81zglp/NKztNL1/DKu/8Bl5w=; b=IGJ7kTRE5G+2/esg/J3torFzGpkSut2klsOPSVqlC0GyseW/ix5kU4eIIxfI6XLafg cElB8i2jBbIaZ8GA7b+VMDm7PBAaDN/m/hHJM+1x7NJdaV9nSFvy/7Mqv6zJTCCeflX2 ys81l0fd0qPdurjZELm0aYe3oCSgJAxDURjJzAeCaaUGXzY68btNZgST9KeOcVSyJsS+ kAWprf70vjNOmwChYNiPBJXm96ga0cQhYulejlHJMA48v0fzrYcICPqHYrOPJprXjWZ1 KMW7uVJobCcLEnAkYJbcb/ar0xMwzw2/UVZYF0JSuU47S3H8bFn8TtOxlLYM2e1XqCKg v7EA== X-Gm-Message-State: AODbwcDGcBQnVZJMBGHE/mYd1mKwHReadmARt8aQFRRgg7eFjanU4ztP bX90ZykIg4wN92jJNYl7Ijo1 X-Received: by 10.25.56.6 with SMTP id f6mr139966lfa.92.1496305409095; Thu, 01 Jun 2017 01:23:29 -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.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:28 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:46 +0300 Message-Id: <20170601082320.4673-7-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 API-NEXT v4 04/23] example: ipsec: set auth_digest_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" Signed-off-by: Dmitry Eremin-Solenikov --- example/ipsec/odp_ipsec_cache.c | 1 + 1 file changed, 1 insertion(+) -- 2.11.0 diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c index b2a91c242fe0..dba0ea0ab0c6 100644 --- a/example/ipsec/odp_ipsec_cache.c +++ b/example/ipsec/odp_ipsec_cache.c @@ -100,6 +100,7 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa, params.auth_alg = auth_sa->alg.u.auth; params.auth_key.data = auth_sa->key.data; params.auth_key.length = auth_sa->key.length; + params.auth_digest_len = auth_sa->icv_len; mode = auth_sa->mode; } else { params.auth_alg = ODP_AUTH_ALG_NULL; From patchwork Thu Jun 1 08:22:48 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: 100825 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp696596qge; Thu, 1 Jun 2017 01:31:05 -0700 (PDT) X-Received: by 10.55.136.1 with SMTP id k1mr336103qkd.104.1496305864987; Thu, 01 Jun 2017 01:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496305864; cv=none; d=google.com; s=arc-20160816; b=h9ua55WJtMzR0Y79wqhAGZPrvdLW2s9rdaaxyRKGKjQp2EWpJ+KQvpAvGkrxEBE+43 RExWxaSB2hnnykvEVjhKD5v7WhEMvvMJZGb+9P92zgTN2jCiH9luuMeHDgQ6UGmWxYH3 4CCIZ5XRGYvtD1aUTvAAKil0bKcsq5bVbttLi76g+wW3i6UZ+WC5Y+Ikp2vNAJmE5kZ0 H3PYHy8hXh7ntDYc7Mn0FdGfwZqbyjya/BOk6VCekYj95lmhllBojx2E2KLJfLNpUjyw 5ZzRTbZHECy0LMgKlA9QjGdv9Aon0XqExQKd+V9hUr+KtNmBCsgBmuUmWgd54NxTJ9Kn dp9A== 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=BWxiANhz+T8lxYlL128mWhJ+G9r2LxFQFZI+//rq7pI=; b=UsrAIbLIfpteparCrgEH6tVLnLTXyQjQF0fT7eJT9ewlG5ViGH16kG2MZqEcBPFs77 LmShB0vIx8Fp/NmDAFSwNGkSbwzEUjSQaT7onuiDVmlDTVE0R/AwOgXUnLouNPgjO+m0 WM6qYvrLifMSSpMpmGhS2mSkXMVSdvCNKmk7tz0vnFjZeQkhFvGpPSOHPCqFc5T0763m +tzHflYcwIhsG8mTzd/M8zOemuJ+Mjq+DNWoH2Z5W65szcUU2fi0PKQEIro8/iV+DVLX NgFAJmZ4ySQxK2zf3Pu0rXi0aNEbCjzyCe9j+dOsuYLW8IILawkiZT4W6rDKHWAa57du d0wQ== 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 99si713983qta.163.2017.06.01.01.31.04; Thu, 01 Jun 2017 01:31:04 -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 90B0160972; Thu, 1 Jun 2017 08:31: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 2104E60D73; Thu, 1 Jun 2017 08:24:43 +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 7DF2160A0F; Thu, 1 Jun 2017 08:24:31 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id A6CEE60A0F for ; Thu, 1 Jun 2017 08:23:32 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id 99so22039663lfu.1 for ; Thu, 01 Jun 2017 01:23:32 -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=BWxiANhz+T8lxYlL128mWhJ+G9r2LxFQFZI+//rq7pI=; b=gBFOiHpMQMTrazQ0IvfumMwxDWmtpDphFF/jtQ62EqASbFG8icAD2seJAj+xn0jiTb FKUcyZg0k3G41SHwO+sC0UP8HSDVUjMAavbA8wLyZsF6xv58/VI9Sqwf/qxwUKe2uptm XbRJbHr5CaVHjmeWEqU8Ry2mMfA8FTgMzpzOSVuycBtqhyyP7SKcmH86MbprZJS/r/p9 aRipw410M3pMOqpJ1KqU9SMY3gCyjqeEIM0BZNAm7qrKQrFhxvkVY8+e74/qGLeAGK03 e6DMdHQWO23OjQlZMm9gM4sbMdtxUHChXB5LAiyY06bSdYs40zsu8L3pxqnD7MkE83w7 QdWw== X-Gm-Message-State: AODbwcCNl6L/FsSnGSLx+QmdxePSCQNC+wz5YTQrDvwkv8Bf9YZZ7yaV Coxf8kb/W8qNGIaJR2X+BYHq X-Received: by 10.25.35.87 with SMTP id j84mr140450lfj.118.1496305411251; Thu, 01 Jun 2017 01:23:31 -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.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:30 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:48 +0300 Message-Id: <20170601082320.4673-9-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 API-NEXT v4 05/23] linux-generic: crypto: use auth_digest_len when calculating HMACs 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" Signed-off-by: Dmitry Eremin-Solenikov --- platform/linux-generic/odp_crypto.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -- 2.11.0 diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index a993542f50b5..472ee3107de3 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -522,7 +522,6 @@ static int process_des_param(odp_crypto_generic_session_t *session) } static int process_auth_param(odp_crypto_generic_session_t *session, - uint32_t bits, uint32_t key_length, const EVP_MD *evp_md) { @@ -535,7 +534,9 @@ static int process_auth_param(odp_crypto_generic_session_t *session, session->auth.evp_md = evp_md; /* Number of valid bytes */ - session->auth.bytes = bits / 8; + session->auth.bytes = session->p.auth_digest_len; + if (session->auth.bytes < (unsigned)EVP_MD_size(evp_md) / 2) + return -1; /* Convert keys */ session->auth.key_length = key_length; @@ -745,17 +746,23 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, session->auth.func = null_crypto_routine; rc = 0; break; - case ODP_AUTH_ALG_MD5_HMAC: #if ODP_DEPRECATED_API case ODP_AUTH_ALG_MD5_96: + /* Fixed digest tag length with deprecated algo */ + session->p.auth_digest_len = 96 / 8; + /* Fallthrough */ #endif - rc = process_auth_param(session, 96, 16, EVP_md5()); + case ODP_AUTH_ALG_MD5_HMAC: + rc = process_auth_param(session, 16, EVP_md5()); break; - case ODP_AUTH_ALG_SHA256_HMAC: #if ODP_DEPRECATED_API case ODP_AUTH_ALG_SHA256_128: + /* Fixed digest tag length with deprecated algo */ + session->p.auth_digest_len = 128 / 8; + /* Fallthrough */ #endif - rc = process_auth_param(session, 128, 32, EVP_sha256()); + case ODP_AUTH_ALG_SHA256_HMAC: + rc = process_auth_param(session, 32, EVP_sha256()); break; #if ODP_DEPRECATED_API case ODP_AUTH_ALG_AES128_GCM: From patchwork Thu Jun 1 08:22:50 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: 100827 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp697043qge; Thu, 1 Jun 2017 01:32:29 -0700 (PDT) X-Received: by 10.55.31.12 with SMTP id f12mr266240qkf.101.1496305949193; Thu, 01 Jun 2017 01:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496305949; cv=none; d=google.com; s=arc-20160816; b=opDs8eOpp/CwQPr6PMz5k5QmnKAp0nbd0IPZ8YGDvNz7RXlWEoc3pvC563H5HlawK3 5J0V4qkYzbntapNNPeEdvJmvRnb6XepY+R7XOQT2BGjDEWKhrEuG+Eh3px8eh8a+w5qA U5IfAY3YgTIFh+wjCRbkVa3Rx43Zus9+dTQ/Rj8D9ETA0WEh9CjyiXWmdnJZWA150ONx 4hO78fwLX0FPa+kzAW3bHscJ3whC4sY+L04Xzk9z26caLT+si9YcKBdyQOTsa8rCS9X/ rY+k0cwSBLFpx7k59PPOT9K2NvaRlNw0F6BAzVe6AbvZmA5X5DaccOVr+lKXnJEv9TdT mWAw== 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=AapxmBQ5upJG0SR8lPNSwMa3XcWHhe0tb9rDvQYRQrI=; b=TDP9Tuf1vzwquXQRhF98vkQX1+IG7VnJIEwpLJ0U9HhTmITIlB7FRFOifsZvDhW5OZ CFv34hj2b8t9Fuu6PpsGNQM5Fb4TTTo16Q6rJPh8jGNpqg0q+E5NC3wVl/0/3R3gDTHq C9W1MAAzW6w/ADA1b1DyoE4h3t4lRvmGO0bFhv88lBDpErfM6sZca8QRXlhx8macFDot R2+GTFXMe2F4nGfSlwIFSJLjsc8JYkJ0jLPCDmxyLB9sexgfrmteNWtu15cEim1dpoJv ZjScyGQbenTsMmTgsJDgk5NmP8/n2EoJwmFEVONImLf9/scyA35c9vsIQyXtlre+Diiz oV7A== 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 d70si17454846qkh.318.2017.06.01.01.32.28; Thu, 01 Jun 2017 01:32:29 -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 C93A560A1A; Thu, 1 Jun 2017 08:32: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=-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 4F75660C0C; Thu, 1 Jun 2017 08:25:25 +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 5F3AE60C0C; Thu, 1 Jun 2017 08:25:22 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id 8FA5660C0C for ; Thu, 1 Jun 2017 08:23:34 +0000 (UTC) Received: by mail-lf0-f43.google.com with SMTP id h4so22075528lfj.3 for ; Thu, 01 Jun 2017 01:23:34 -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=AapxmBQ5upJG0SR8lPNSwMa3XcWHhe0tb9rDvQYRQrI=; b=Z+/FyVtm+/jeC1sFFCayR+d00dkfqn0Rke6wi6rxy8Ux40RuK12cqYehYzxUbiD5DT nLU1eZ6r0q1HKAhuL94XcN7fBeiNvBqWHk6sWVMVY9tmYGe4BE9jGKYyKdkrWMFRtV5z UMbpFTEHGLLjRwj2c8rSisx5aoWP2QnfMDtor62QZ1BvHUfdgfhznVUNsaQAdzZ4E9U+ Nm1fK4J1hCtUECLs/+2fPGXgTIYxpVm9tYyj33lhsOMmCXhkpxpkTHWy7/AiQ0ij1OOT GBBLZmsVoTSOecuUd0TYJC74q3evXc/SeKlgeJbTwzGyeQHqgI3fuQ/F9/s78p2FQ3f5 KY+g== X-Gm-Message-State: AODbwcCBtMAewLWreIX2yPAQJRZNdPCWFIlOIi/1uZaEs5F4yIQlAErl PMdAM1X/gigjNwLtPk1o7zZ7 X-Received: by 10.25.115.134 with SMTP id h6mr117810lfk.163.1496305413301; Thu, 01 Jun 2017 01:23:33 -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.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:32 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:50 +0300 Message-Id: <20170601082320.4673-11-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 API-NEXT v4 06/23] linux-generic: crypto: add SHA* capabilities for full length digests 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" In addition to truncated digests (used by IPsec) add full-length capabilities to SHA* algos. Signed-off-by: Dmitry Eremin-Solenikov --- platform/linux-generic/odp_crypto.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 472ee3107de3..91ef05aebadf 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -52,10 +52,12 @@ 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_md5_hmac[] = { -{.digest_len = 12, .key_len = 16, .aad_len = {.min = 0, .max = 0, .inc = 0} } }; +{.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} } }; static const odp_crypto_auth_capability_t auth_capa_sha256_hmac[] = { -{.digest_len = 16, .key_len = 32, .aad_len = {.min = 0, .max = 0, .inc = 0} } }; +{.digest_len = 16, .key_len = 32, .aad_len = {.min = 0, .max = 0, .inc = 0} }, +{.digest_len = 32, .key_len = 32, .aad_len = {.min = 0, .max = 0, .inc = 0} } }; static const odp_crypto_auth_capability_t auth_capa_aes_gcm[] = { {.digest_len = 16, .key_len = 0, .aad_len = {.min = 8, .max = 12, .inc = 4} } }; From patchwork Thu Jun 1 08:22:52 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: 100829 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp697342qge; Thu, 1 Jun 2017 01:33:31 -0700 (PDT) X-Received: by 10.55.143.198 with SMTP id r189mr293990qkd.150.1496306011732; Thu, 01 Jun 2017 01:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496306011; cv=none; d=google.com; s=arc-20160816; b=fuDquH+UMaP8SQk5napsTP4H2hqL8Glu9M5PsqRQQ8mqPktR753UUcmeVJsm5pULTk oBgP0yHXDqEtEOx9edpOR48yUljvPchC08oqxKAcQv3/c0cpwf7jncCLtUdTNwTuoRJZ MCUH0KFdVe7lLM5Py1gdugejESTQVeBpIgz8nRu0W6IjJjhEfey+7hNpzTeOJJuTEweU UuGlf8uBcABLVFdfQPV7BCoD2UK2KvWho3dCbFoxM4oY24WubOQ+7QeEe9IXGd4KywFw 1Eg+7+Y7NKNLuAxV7COxrTPxAoQzlI6GcDxug5ZgokZ56f8T0DoCt9iQuyrDlUiRvciQ IZHw== 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=RpqaW/Z3jJoNerz+esYO/HNQh1sky5GPpoYQrFQ9YoQ=; b=wydbkAhV0izSU/2+QdfeDfDou6W0q3gE+6Acx2PK+DYEknMQ5J/NzKcryy/16PfLIk f62MLvg7PjL9qifMmbRlhfNiuSIkgJma5CBBnVqDA491XvcjHKg6l+u11VikqsZOeoyt Y+EDDqxQrd9xX5cWmbnoKtTjX/FrIoQOoH5biI4g7EPE4WPsCyr/7rjFBmp5kmzeIOE7 10a3Wp27NuflO5Mh+2Z3OHlpTaY6rway2d8gxxYkDPhOiSl6ZEuh/X6kLSmgWPVq70Xo CBePwxoac29TR0sSNhtfqkBZei9s5MFeOvRO0Ld9oiwP3eXTvUK5dfhIuu/yaI9PtmFC uTqA== 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 l39si18362285qkh.74.2017.06.01.01.33.31; Thu, 01 Jun 2017 01:33:31 -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 601C96064C; Thu, 1 Jun 2017 08:33:31 +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 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 0ECF860C42; Thu, 1 Jun 2017 08:25:57 +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 1772B60D87; Thu, 1 Jun 2017 08:25:52 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id DE68460D3D for ; Thu, 1 Jun 2017 08:23:36 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id h4so22076024lfj.3 for ; Thu, 01 Jun 2017 01:23:36 -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=RpqaW/Z3jJoNerz+esYO/HNQh1sky5GPpoYQrFQ9YoQ=; b=ntSgJd1hflBOS0Z864spB+kLG/Vfn3E7HHeoqTyOB5yzsmILgVBF/6GgW/0cxsx8Jy 6rvlIkMhoEiM0qbzbQgNjHrzsCEgigfDvHMJBAfy/rVl2Wqu8fN5gX9SEg/opAlhV1Pj 5B0ijVIL2c+EaehIp0iee1NuG6222cEEvXc91iUBYxsWytIsOMOIutx36NCtAlGm9yar Qz56zbY6KkJ0HVzkSLBid4MGpM0nVjSTjXEwRBvJ+gGKQi09g6X8yZXHhdT6HmUZyJnQ ju4czSDED/cuqO2Ejjxz7yD17aSnssiDrmAnWscj2LnsfP+vHLC92ezD60viiguoI4Dl PJzg== X-Gm-Message-State: AODbwcDdjgL5E6jrHGnMBAGGwuRfS8o58cf2dVupSsGWXu+v0fFTfKW/ pAs3Oy4HbtfsWLcIjdDw34y2 X-Received: by 10.25.16.154 with SMTP id 26mr122428lfq.148.1496305415580; Thu, 01 Jun 2017 01:23:35 -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.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:35 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:52 +0300 Message-Id: <20170601082320.4673-13-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 API-NEXT v4 07/23] linux-generic: crypto: update AES-GCM support to reflect aad and auth_digest_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" Make AES-GCM use recently introduced aad and auth_digest_len fields. Signed-off-by: Dmitry Eremin-Solenikov --- platform/linux-generic/odp_crypto.c | 58 ++++++++++--------------------------- 1 file changed, 15 insertions(+), 43 deletions(-) -- 2.11.0 diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 91ef05aebadf..352cfa536268 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -267,10 +267,8 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, { uint8_t *data = odp_packet_data(param->out_pkt); uint32_t plain_len = param->cipher_range.length; - uint8_t *aad_head = data + param->auth_range.offset; - uint8_t *aad_tail = data + param->cipher_range.offset + - param->cipher_range.length; - uint32_t auth_len = param->auth_range.length; + const uint8_t *aad_head = param->aad.ptr; + uint32_t aad_len = param->aad.length; unsigned char iv_enc[AES_BLOCK_SIZE]; void *iv_ptr; uint8_t *tag = data + param->hash_result_offset; @@ -282,12 +280,6 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, else return ODP_CRYPTO_ALG_ERR_IV_INVALID; - /* All cipher data must be part of the authentication */ - if (param->auth_range.offset > param->cipher_range.offset || - param->auth_range.offset + auth_len < - param->cipher_range.offset + plain_len) - return ODP_CRYPTO_ALG_ERR_DATA_SIZE; - /* * Create a copy of the IV. The DES library modifies IV * and if we are processing packets on parallel threads @@ -305,23 +297,16 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_enc); /* Authenticate header data (if any) without encrypting them */ - if (aad_head < plaindata) { + if (aad_len > 0) EVP_EncryptUpdate(ctx, NULL, &cipher_len, - aad_head, plaindata - aad_head); - } + aad_head, aad_len); EVP_EncryptUpdate(ctx, plaindata, &cipher_len, plaindata, plain_len); - cipher_len = plain_len; - - /* Authenticate footer data (if any) without encrypting them */ - if (aad_head + auth_len > plaindata + plain_len) { - EVP_EncryptUpdate(ctx, NULL, NULL, aad_tail, - auth_len - (aad_tail - aad_head)); - } EVP_EncryptFinal_ex(ctx, plaindata + cipher_len, &cipher_len); - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, 16, tag); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, + session->p.auth_digest_len, tag); return ODP_CRYPTO_ALG_ERR_NONE; } @@ -332,10 +317,8 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, { uint8_t *data = odp_packet_data(param->out_pkt); uint32_t cipher_len = param->cipher_range.length; - uint8_t *aad_head = data + param->auth_range.offset; - uint8_t *aad_tail = data + param->cipher_range.offset + - param->cipher_range.length; - uint32_t auth_len = param->auth_range.length; + const uint8_t *aad_head = param->aad.ptr; + uint32_t aad_len = param->aad.length; unsigned char iv_enc[AES_BLOCK_SIZE]; void *iv_ptr; uint8_t *tag = data + param->hash_result_offset; @@ -347,12 +330,6 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, else return ODP_CRYPTO_ALG_ERR_IV_INVALID; - /* All cipher data must be part of the authentication */ - if (param->auth_range.offset > param->cipher_range.offset || - param->auth_range.offset + auth_len < - param->cipher_range.offset + cipher_len) - return ODP_CRYPTO_ALG_ERR_DATA_SIZE; - /* * Create a copy of the IV. The DES library modifies IV * and if we are processing packets on parallel threads @@ -368,25 +345,18 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_enc); - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, tag); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, + session->p.auth_digest_len, tag); /* Authenticate header data (if any) without encrypting them */ - if (aad_head < cipherdata) { + if (aad_len > 0) EVP_DecryptUpdate(ctx, NULL, &plain_len, - aad_head, cipherdata - aad_head); - } + aad_head, aad_len); EVP_DecryptUpdate(ctx, cipherdata, &plain_len, cipherdata, cipher_len); - plain_len = cipher_len; - - /* Authenticate footer data (if any) without encrypting them */ - if (aad_head + auth_len > cipherdata + cipher_len) { - EVP_DecryptUpdate(ctx, NULL, NULL, aad_tail, - auth_len - (aad_tail - aad_head)); - } - if (EVP_DecryptFinal_ex(ctx, cipherdata + cipher_len, &plain_len) <= 0) + if (EVP_DecryptFinal_ex(ctx, cipherdata + plain_len, &plain_len) <= 0) return ODP_CRYPTO_ALG_ERR_ICV_CHECK; return ODP_CRYPTO_ALG_ERR_NONE; @@ -770,6 +740,8 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, case ODP_AUTH_ALG_AES128_GCM: if (param->cipher_alg == ODP_CIPHER_ALG_AES128_GCM) aes_gcm = 1; + /* Fixed digest tag length with deprecated algo */ + session->p.auth_digest_len = 16; /* Fallthrough */ #endif case ODP_AUTH_ALG_AES_GCM: From patchwork Thu Jun 1 08:22:54 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: 100830 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp697522qge; Thu, 1 Jun 2017 01:34:12 -0700 (PDT) X-Received: by 10.200.36.15 with SMTP id c15mr367737qtc.124.1496306052356; Thu, 01 Jun 2017 01:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496306052; cv=none; d=google.com; s=arc-20160816; b=AV4B5Rod22vxdZrER38n1tNZtK+WhWn9p8TBLZZphC6EE1oT+ei3hTRnx1dGQcblo/ qkewzWA5Ziwf47ZsEWM/7PS82FNahnTB02A35hwivWiWjRovYsuisjT+r3N/16sR1P1M co/1lzGYn7/fWkfdRhe8dyy49atdr+MXf2GUBsx3YFTdjOO8hqG8ldegPTxSYRQBXrgu 3W7HPTiGK3k9V6OGALgU6enHfasUgCijJMFytXiAzlWjkSpxOEBnwP8b++yN7Wmu6FB/ I2K1692gH8hPQB8w/XZQVV8i5PrVhn8rPAPGMPj5n89u8OOjCa3h/YWRz7jTHB0HNXlU dYqA== 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=lXRuTsmTIk1n3DInJwZPw1OX1Gl409JG1HSJbtCjgr8=; b=bAy1TbUzu767r5LjyXcIyP+Ho3f+s7Ppv/JpJ4UfswsRZ6x/h97a6UAtqKWGEb/iqD j+BJLVdGc8Mm0M3uh6IfpBMIKO7HTkgW9g9OCkHHHoXXEEg9EoRtfp9XNCFxqfwTiqXb jj6e+9sWJHnlMQ2mw8S6zlSDp59AGiFqaVqBqLehi/xMtoKv0wav6gRxJiUKqLD+iibF eiL7miV7WmWJCTnChpkBXJlrA0rt25qKRk2BaY5Zz0rrees3nHm9SVvCz4S3/Fc/WA3H dHw0508wawFCoNAS4BXLSo1xQ3D6/yH+YSOaCaBMF78Wj7cjWQQOqqjqD8rsFeWDoE// a6mw== 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 e67si19097480qkd.81.2017.06.01.01.34.11; Thu, 01 Jun 2017 01:34:12 -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 813C0609F0; Thu, 1 Jun 2017 08:34:11 +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 4F77960D43; Thu, 1 Jun 2017 08:26:00 +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 5CDF760D7D; Thu, 1 Jun 2017 08:25:54 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id E73D060CCF for ; Thu, 1 Jun 2017 08:23:38 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id c184so17269976lfe.2 for ; Thu, 01 Jun 2017 01:23: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:in-reply-to :references; bh=lXRuTsmTIk1n3DInJwZPw1OX1Gl409JG1HSJbtCjgr8=; b=cD+evJFVeBeBXLK9l2jmejRd/GqRFDGWRaGfFHoxSdQgxXccz+bSBKrI7T1ig4pTL6 ZDA3O5F5KGAaZtKGEPOM0SOn3K2UpYb19Af2YWrRTbIs1tB4e/g8fHHP2lhqXvjIae2R WG98wSzm5kEc/GgaKLylxep2XqHQgRQjjsq+Cmn7Ll9a+Bc1KS0Qf5nhGlY2pZeU8R0J j/9XmiboMesRzkmkSBvtslMPznBAkvedhi82znOFh36cqd9rT2M+FmsQK8KgLoIoHasi GMe5srgb5LvEs6crjHybNry/02VJ2cdSK/NV+TyvZc8Wo/amwRbJP5mwYoD53WaCjD6i 5a8g== X-Gm-Message-State: AODbwcDK+kzeBOIlE/ZHL4uv0zdge7rZX9cm5SrAqE8IenfmRUh02N/a nqiZNawVOmmUGthRqq/XaSQ5 X-Received: by 10.46.84.21 with SMTP id i21mr94675ljb.125.1496305417569; Thu, 01 Jun 2017 01:23:37 -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.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:37 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:54 +0300 Message-Id: <20170601082320.4673-15-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 API-NEXT v4 08/23] linux-generic: crypto: remote extra memcpy in AES-GCM 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 need to memcpy IV if it gets passed to EVP functions. Signed-off-by: Dmitry Eremin-Solenikov --- platform/linux-generic/odp_crypto.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) -- 2.11.0 diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 352cfa536268..3f298485caef 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -269,7 +269,6 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, uint32_t plain_len = param->cipher_range.length; const uint8_t *aad_head = param->aad.ptr; uint32_t aad_len = param->aad.length; - unsigned char iv_enc[AES_BLOCK_SIZE]; void *iv_ptr; uint8_t *tag = data + param->hash_result_offset; @@ -280,13 +279,6 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, else return ODP_CRYPTO_ALG_ERR_IV_INVALID; - /* - * Create a copy of the IV. The DES library modifies IV - * and if we are processing packets on parallel threads - * we could get corruption. - */ - memcpy(iv_enc, iv_ptr, AES_BLOCK_SIZE); - /* Adjust pointer for beginning of area to cipher/auth */ uint8_t *plaindata = data + param->cipher_range.offset; @@ -294,7 +286,7 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, EVP_CIPHER_CTX *ctx = session->cipher.data.aes_gcm.ctx; int cipher_len = 0; - EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_enc); + EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); /* Authenticate header data (if any) without encrypting them */ if (aad_len > 0) @@ -319,7 +311,6 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, uint32_t cipher_len = param->cipher_range.length; const uint8_t *aad_head = param->aad.ptr; uint32_t aad_len = param->aad.length; - unsigned char iv_enc[AES_BLOCK_SIZE]; void *iv_ptr; uint8_t *tag = data + param->hash_result_offset; @@ -330,20 +321,13 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, else return ODP_CRYPTO_ALG_ERR_IV_INVALID; - /* - * Create a copy of the IV. The DES library modifies IV - * and if we are processing packets on parallel threads - * we could get corruption. - */ - memcpy(iv_enc, iv_ptr, AES_BLOCK_SIZE); - /* Adjust pointer for beginning of area to cipher/auth */ uint8_t *cipherdata = data + param->cipher_range.offset; /* Encrypt it */ EVP_CIPHER_CTX *ctx = session->cipher.data.aes_gcm.ctx; int plain_len = 0; - EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_enc); + EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, session->p.auth_digest_len, tag); From patchwork Thu Jun 1 08:22:55 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: 100832 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp697763qge; Thu, 1 Jun 2017 01:35:05 -0700 (PDT) X-Received: by 10.237.32.176 with SMTP id 45mr371190qtb.30.1496306104941; Thu, 01 Jun 2017 01:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496306104; cv=none; d=google.com; s=arc-20160816; b=PyjkcK5YGbk+34kCqHxYEEdz0BnRLC5ZwrPXoT9PwaNh1JxegpWwx6nJqB/e8XvXOg 3P99um+zXFzbBBc+RFTcKF27DJQBWJmQxvv1AraqHlz7nq49tUcfoCo0mUs6GFnlWiHA 9iv8scc5af3stR6MSO4wkUI+In45BKoArvk6m4/DImJsx92P/1kc4xgFggGv3+fzAHCd lXc8wgmIYvR6Rq4Iia0eRcXoVhBI9wKSKjjXi2omw1CK6uF7TC+sHvgD4jBcATEnCjdE KYC2JnnhOCdHn5+Ea6o135jl+iaitFk2rLYfF4ByNV55aJToP59GPuYXCbTbmCHELOVt hhyA== 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=aaDht63rWicF6bPCJrNUMUIiYDsQRq2LZ96lyVms7bs=; b=0R2FZ43zNKxMFOzKqZiHsfEeAOF/SOQp+qLEMGSCeSsTZf4NOA6KQG7ZtcWjJhpQuf 4zeisuZe3ztyQa74iw6eduSWYR5gXKZjOUoPbvrPR3SIGs/YV0JhUG3bnroAgaFntVGc dB73U69LefcUVbsmflZpeJA0adokOW8Lav6lfvolbhF2Z3o6+/iAyBzVhnYw32I3BTPw B3lWe0ERiVNrMKUFheXNfdLyTZ6KMotf0TxI9GjUV3Ae3dI+uXSY0AIeSGbhF2pNdefe tvu3dQbd9UPA7uyeicEJ6s+gJdPgWVMfXL+JWq3VLTwnnZSEi6Dv+j9CQ2cj+l+7QRnC Z3lA== 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 o9si19109488qtb.78.2017.06.01.01.35.04; Thu, 01 Jun 2017 01:35:04 -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 910806069A; Thu, 1 Jun 2017 08:35: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 DD3EE60674; Thu, 1 Jun 2017 08:26:07 +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 494D860C42; Thu, 1 Jun 2017 08:25:56 +0000 (UTC) Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) by lists.linaro.org (Postfix) with ESMTPS id 2539760D48 for ; Thu, 1 Jun 2017 08:23:40 +0000 (UTC) Received: by mail-lf0-f44.google.com with SMTP id a136so7457764lfa.0 for ; Thu, 01 Jun 2017 01:23:40 -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=aaDht63rWicF6bPCJrNUMUIiYDsQRq2LZ96lyVms7bs=; b=JuUQijx6EQNf8DdV+jAkOlMiWtl0Ee6uY2DeUIoHOTqOLwtFRw8e3JN1PmSzTvJCXI pdCznCP1tf06X268lPuFjmG7BrK175N+5bNjRNzmnAfrkYvdvB604qP6v3R7QRVSjvsB GlRT31W5M5HSaOK6ctkHXdfKM4s935eWReN5gr+HtrgL998Xyj3orJ9jrYX9fNge8GNB etQRxJ6XJD9gV5vf6VtZU/ksb/35x95BJSQBv4KYpEM0FDup3iphSMxXYHi1MIWKTgt7 dhEqbhGXTJIkxyLdEocC3TIMvA8EkpcCFkaPXQ/2ufGNZ/pXAb/6ut0XowSl/sETztx6 zW3w== X-Gm-Message-State: AODbwcBt/LYpxtydgjPV+IaRkluahy4S63+wWmEGIE+cPQUTr/EJCMAh d7xmMoWmgEnZ5pXLHuzgTnnT X-Received: by 10.46.7.25 with SMTP id 25mr101686ljh.5.1496305418596; Thu, 01 Jun 2017 01:23:38 -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.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:37 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:55 +0300 Message-Id: <20170601082320.4673-16-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 API-NEXT v4 09/23] linux-generic: crypto: make AES-GCM thread safe 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" Using single context for all operations is not thread safe: multiple threads can access the same context in parallel, affecting its internal state. Make AES-GCM functions use local context for en/decryption operations. Signed-off-by: Dmitry Eremin-Solenikov --- .../linux-generic/include/odp_crypto_internal.h | 2 +- platform/linux-generic/odp_crypto.c | 84 ++++++++++------------ 2 files changed, 38 insertions(+), 48 deletions(-) -- 2.11.0 diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h index 515cefaa06cc..d1020dba3edd 100644 --- a/platform/linux-generic/include/odp_crypto_internal.h +++ b/platform/linux-generic/include/odp_crypto_internal.h @@ -53,7 +53,7 @@ struct odp_crypto_generic_session { AES_KEY key; } aes; struct { - EVP_CIPHER_CTX *ctx; + uint8_t key[EVP_MAX_KEY_LENGTH]; } aes_gcm; } data; crypto_func_t func; diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 3f298485caef..3deec7de3f7c 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -265,11 +265,13 @@ static odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, odp_crypto_generic_session_t *session) { + EVP_CIPHER_CTX *ctx; uint8_t *data = odp_packet_data(param->out_pkt); uint32_t plain_len = param->cipher_range.length; const uint8_t *aad_head = param->aad.ptr; uint32_t aad_len = param->aad.length; void *iv_ptr; + int cipher_len = 0; uint8_t *tag = data + param->hash_result_offset; if (param->override_iv_ptr) @@ -280,12 +282,14 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, return ODP_CRYPTO_ALG_ERR_IV_INVALID; /* Adjust pointer for beginning of area to cipher/auth */ - uint8_t *plaindata = data + param->cipher_range.offset; + data += param->cipher_range.offset; /* Encrypt it */ - EVP_CIPHER_CTX *ctx = session->cipher.data.aes_gcm.ctx; - int cipher_len = 0; - + ctx = EVP_CIPHER_CTX_new(); + EVP_EncryptInit_ex(ctx, EVP_aes_128_gcm(), NULL, + session->cipher.data.aes_gcm.key, NULL); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, + session->p.iv.length, NULL); EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); /* Authenticate header data (if any) without encrypting them */ @@ -293,13 +297,14 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, EVP_EncryptUpdate(ctx, NULL, &cipher_len, aad_head, aad_len); - EVP_EncryptUpdate(ctx, plaindata, &cipher_len, - plaindata, plain_len); + EVP_EncryptUpdate(ctx, data, &cipher_len, data, plain_len); - EVP_EncryptFinal_ex(ctx, plaindata + cipher_len, &cipher_len); + EVP_EncryptFinal_ex(ctx, data + cipher_len, &cipher_len); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, session->p.auth_digest_len, tag); + EVP_CIPHER_CTX_free(ctx); + return ODP_CRYPTO_ALG_ERR_NONE; } @@ -307,10 +312,12 @@ static odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, odp_crypto_generic_session_t *session) { + EVP_CIPHER_CTX *ctx; uint8_t *data = odp_packet_data(param->out_pkt); uint32_t cipher_len = param->cipher_range.length; const uint8_t *aad_head = param->aad.ptr; uint32_t aad_len = param->aad.length; + int plain_len = 0; void *iv_ptr; uint8_t *tag = data + param->hash_result_offset; @@ -322,11 +329,14 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, return ODP_CRYPTO_ALG_ERR_IV_INVALID; /* Adjust pointer for beginning of area to cipher/auth */ - uint8_t *cipherdata = data + param->cipher_range.offset; - /* Encrypt it */ - EVP_CIPHER_CTX *ctx = session->cipher.data.aes_gcm.ctx; - int plain_len = 0; + data += param->cipher_range.offset; + /* Decrypt it */ + ctx = EVP_CIPHER_CTX_new(); + EVP_DecryptInit_ex(ctx, EVP_aes_128_gcm(), NULL, + session->cipher.data.aes_gcm.key, NULL); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, + session->p.iv.length, NULL); EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, @@ -337,12 +347,13 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, EVP_DecryptUpdate(ctx, NULL, &plain_len, aad_head, aad_len); - EVP_DecryptUpdate(ctx, cipherdata, &plain_len, - cipherdata, cipher_len); + EVP_DecryptUpdate(ctx, data, &plain_len, data, cipher_len); - if (EVP_DecryptFinal_ex(ctx, cipherdata + plain_len, &plain_len) <= 0) + if (EVP_DecryptFinal_ex(ctx, data + plain_len, &plain_len) <= 0) return ODP_CRYPTO_ALG_ERR_ICV_CHECK; + EVP_CIPHER_CTX_free(ctx); + return ODP_CRYPTO_ALG_ERR_NONE; } @@ -352,27 +363,14 @@ static int process_aes_gcm_param(odp_crypto_generic_session_t *session) if (session->p.cipher_key.length != 16) return -1; - /* Set function */ - EVP_CIPHER_CTX *ctx = - session->cipher.data.aes_gcm.ctx = EVP_CIPHER_CTX_new(); + memcpy(session->cipher.data.aes_gcm.key, session->p.cipher_key.data, + session->p.cipher_key.length); - if (ODP_CRYPTO_OP_ENCODE == session->p.op) { + /* Set function */ + if (ODP_CRYPTO_OP_ENCODE == session->p.op) session->cipher.func = aes_gcm_encrypt; - EVP_EncryptInit_ex(ctx, EVP_aes_128_gcm(), NULL, NULL, NULL); - } else { + else session->cipher.func = aes_gcm_decrypt; - EVP_DecryptInit_ex(ctx, EVP_aes_128_gcm(), NULL, NULL, NULL); - } - - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, - session->p.iv.length, NULL); - if (ODP_CRYPTO_OP_ENCODE == session->p.op) { - EVP_EncryptInit_ex(ctx, NULL, NULL, - session->p.cipher_key.data, NULL); - } else { - EVP_DecryptInit_ex(ctx, NULL, NULL, - session->p.cipher_key.data, NULL); - } return 0; } @@ -635,17 +633,16 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, /* Copy parameters */ session->p = *param; - /* Copy IV data */ - if (session->p.iv.data) { - if (session->p.iv.length > MAX_IV_LEN) { - ODP_DBG("Maximum IV length exceeded\n"); - free_session(session); - return -1; - } + if (session->p.iv.length > MAX_IV_LEN) { + ODP_DBG("Maximum IV length exceeded\n"); + free_session(session); + return -1; + } + /* Copy IV data */ + if (session->p.iv.data) memcpy(session->cipher.iv_data, session->p.iv.data, session->p.iv.length); - } /* Derive order */ if (ODP_CRYPTO_OP_ENCODE == param->op) @@ -757,15 +754,8 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, int odp_crypto_session_destroy(odp_crypto_session_t session) { odp_crypto_generic_session_t *generic; - int aes_gcm = 0; generic = (odp_crypto_generic_session_t *)(intptr_t)session; -#if ODP_DEPRECATED_API - if (generic->p.cipher_alg == ODP_CIPHER_ALG_AES128_GCM) - aes_gcm = 1; -#endif - if (generic->p.cipher_alg == ODP_CIPHER_ALG_AES_GCM || aes_gcm) - EVP_CIPHER_CTX_free(generic->cipher.data.aes_gcm.ctx); memset(generic, 0, sizeof(*generic)); free_session(generic); return 0; From patchwork Thu Jun 1 08:22:57 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: 100833 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp697954qge; Thu, 1 Jun 2017 01:35:43 -0700 (PDT) X-Received: by 10.55.215.153 with SMTP id t25mr336433qkt.6.1496306143840; Thu, 01 Jun 2017 01:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496306143; cv=none; d=google.com; s=arc-20160816; b=T9VTHNcsXo961eVVJHTHAntIFY2DGafrPr01cu2k09ZXLUshxA1vXT8w82lERGZTXX lLR4JJmnuGL6RwPt67QVKJFEnlT//WJ8uX4qmZh9ecwEJWm3E54ifznYg9F+UQN+aa2Z 5mVXUhq9oaL62CtSXZ2JFjFXRWUPvyhoMRh/lcA2mraN1XfUNsxLwSnA4BZ1/ZbR7aq3 2fbpTjmUILDVk6T6DDs7V00CgipqtLFm7ku6rt/qQTQRix65KefmH/J05ShytbsHuxm7 MVx03jP9jUUCgc3n5A6aQn6AxVWUv88aWxGLUcm6NgBJvuktG5YpiyXDZcRtpQ2md9Wt 21qQ== 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=N/+QgRU4B5MYbcc5NceTLzQ5Ofi/ZeqiQfjc4k3h+Ko=; b=daB84qPyM8b6YCxWynmX8kwsC47M7el/Y2BwPG6b415hqxMnboI0DnUcFsT8DGDWcd FyGuucaPAfXcN8BroOkQ/AIGBDSOz/C/WxewFJANFUKNbS8NOzuxVl4cPgX28K0q4hbk KAYKVZWbyoWIX5f7f/qUO7Don4WIlZC2OG9ZdxTRXzvVc/8W98zbTsHiesc6tQwbPtqK 83cvrS1RqzkZiOIPi2BpBSLFkm3AyffMaHoKbLsVWhFI3CwrSWVvymfSSoNBWGh36rH7 QEuiLN/mcEsSv3msZBNPr+72U75I4RokFZoP5cCkFrzPZdZWJk0yE5xeXckH7y7xOeAK D75Q== 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 c133si19034366qkg.218.2017.06.01.01.35.43; Thu, 01 Jun 2017 01:35:43 -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 7072F6068E; Thu, 1 Jun 2017 08:35:43 +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 3A7A3606A0; Thu, 1 Jun 2017 08:26:10 +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 A283E60C42; Thu, 1 Jun 2017 08:25:56 +0000 (UTC) Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com [209.85.215.48]) by lists.linaro.org (Postfix) with ESMTPS id 12E9060D42 for ; Thu, 1 Jun 2017 08:23:42 +0000 (UTC) Received: by mail-lf0-f48.google.com with SMTP id a136so7458218lfa.0 for ; Thu, 01 Jun 2017 01:23:42 -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=N/+QgRU4B5MYbcc5NceTLzQ5Ofi/ZeqiQfjc4k3h+Ko=; b=Tj/cmEAAKuSpjgRiW0JnMkRx/s6pfJzBGUSgCA+kyxl7G5h7XXaghUeNrUOJJvg9Gg mI7kiCo6HAF9S2c5W0F9RVwxZHCcIozsR+/20csjgjW9AwJaiwG6dpcH8vLpgpprf599 aEic09pF7D9o0nKzbl2n9BlQunUOuiM99j5POEj6oKdJa43uYOFab3ZDiFnEe+hb5QN5 A1aW1+Q4Wmi+hOfKQ3gmKNMvsHpnvFyo1nKT7VynUWQ0qPvIuy+2+qi7udqGWeJtuUyH k/7KrEOKZP8+fTpFnovtA4Euymg0maRTYhd7bxNhqfIOhZ/hhIs+pb6vMYrrW+teG/Rw fPFw== X-Gm-Message-State: AODbwcA/f/Y4j8exSJpdYSQ9ILE2LBWNM6yjxDSic11wXfzV5Rrt38Ba o8hWIZJwmSpPORfL8DZjAqKB X-Received: by 10.25.20.198 with SMTP id 67mr122634lfu.78.1496305420791; Thu, 01 Jun 2017 01:23:40 -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.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:40 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:57 +0300 Message-Id: <20170601082320.4673-18-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 API-NEXT v4 10/23] linux-generic: crypto: explicitly disable padding for AES-GCM 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" Signed-off-by: Dmitry Eremin-Solenikov --- platform/linux-generic/odp_crypto.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.11.0 diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 3deec7de3f7c..ff3f1ac76780 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -291,6 +291,7 @@ odp_crypto_alg_err_t aes_gcm_encrypt(odp_crypto_op_param_t *param, EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, session->p.iv.length, NULL); EVP_EncryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); + EVP_CIPHER_CTX_set_padding(ctx, 0); /* Authenticate header data (if any) without encrypting them */ if (aad_len > 0) @@ -338,6 +339,7 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_param_t *param, EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, session->p.iv.length, NULL); EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_ptr); + EVP_CIPHER_CTX_set_padding(ctx, 0); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, session->p.auth_digest_len, tag);