From patchwork Thu Jun 1 08:22:58 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: 100834 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp698067qge; Thu, 1 Jun 2017 01:36:07 -0700 (PDT) X-Received: by 10.55.149.130 with SMTP id x124mr292276qkd.156.1496306167823; Thu, 01 Jun 2017 01:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496306167; cv=none; d=google.com; s=arc-20160816; b=ivkUxImQCR6uF2eiRHEAHtJahdjNVO6oFZgnbPJmC4mhJbt76gxj/HV0eBf9RCaYOc vhGNl+cVFtmguiq5FrPYO9MAc6lNBZh03FBgapZc5ghmdP9RxZrHJgJ6gNnZoAWJRs4u OWJzIeP3103JoJ4VJn0jBi2phEdU62vhxklUj8l+d1BtpSOEt6UwtHQIsY8NSdWDC8CP XsykNZd481QqOJHQfCkSceXDxM6FFI9RVxoYlxFK8gTFYdNYo0abj/dogg+EF8wnWi0C wNS4yHqCX3YwE9+h6w3MUvnOL3RbftHLX/cVkfdI+7YpaIex+osqaspk0hmN+gOQBYgW AR/w== 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=daEBZovmrNXDG8iWdPtlMK6ddyMYsOQrcNyYSqzXJ94=; b=cxSUta8xrBU0MriHQJwqPaUBnWsRa380A+Y0dTToz/nX69Ga7qhSmpdZTw/FzwwlEr rYRR/kWnxVfqetORY4GjXAo87JEfJrvVNhZWmdAo2s+7MdX3ve7hZsp0PHhT3w/XhZ9F HKD4du0lvHJxJbkLYxTmnvt6EoCfphKe9UxMk4DTh1zcE5z4Wpykk112ekxn4icCrSI5 o81Al3toMsFNibvbvEm+M/9hmkdgVXKNaVtEIpHyqpji0f0hCgue+lga5HIGwQTNsrFN SdhXcuzF+X6Z+kH824HjqOb9yqCbp/2k1pB9HucnQaMdluc0+flTXF2rnvS0SDw42rbu elyw== 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 v3si19142210qki.103.2017.06.01.01.36.07; Thu, 01 Jun 2017 01:36:07 -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 7128B60655; Thu, 1 Jun 2017 08:36:07 +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 82049607C8; Thu, 1 Jun 2017 08:26:13 +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 CAA7260CCF; 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 3D08360D44 for ; Thu, 1 Jun 2017 08:23:43 +0000 (UTC) Received: by mail-lf0-f48.google.com with SMTP id 99so22041995lfu.1 for ; Thu, 01 Jun 2017 01:23:43 -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=daEBZovmrNXDG8iWdPtlMK6ddyMYsOQrcNyYSqzXJ94=; b=ivaOuWAxXN6AEFQrYUche4Bbbys7Sq+5SeogcBZMOwk1pzR0dQRJsqHaVivZCbF+Td BgQ4Ntt/6ORPH3hzH8GbYSOl7ePLYy9v0qBmcZt0TjAVRte5YxTOXxpEv0G7NLEWqm/a YkvObhMnjynr+6uBH1yLx7ovRBs9mDobeseM1V32twqruyyKqtH4QwxBn1Ar94nSvWwl Dyk8sAZPQblZ2A0lrwSX3z5+ErtCK5GSZpkP1vTODVu9VJFsojxdgJW6uzAii9aR1ZBf A2vrvAdkwDevbFgZKkS+R8Uy8ieTuWw8tMmylgW/VkCDk0/0jrfbGh/A8XmEx8lKD4BL cgWA== X-Gm-Message-State: AODbwcBhoVwReEJ4B4/Jf29m7e7oBH0DshnbVpjQd7cMg9OJG0lIbMa6 XL2zrEOwQlRM5/+GBNRxvgJ9 X-Received: by 10.46.92.8 with SMTP id q8mr106169ljb.79.1496305421881; Thu, 01 Jun 2017 01:23:41 -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.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:41 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:58 +0300 Message-Id: <20170601082320.4673-19-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 10/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 5f4f5250df14..efbc958de0c8 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -275,7 +275,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; @@ -286,13 +285,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; @@ -300,7 +292,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) @@ -325,7 +317,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; @@ -336,20 +327,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);