From patchwork Mon Oct 31 14:51:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 80204 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp156684qge; Mon, 31 Oct 2016 07:52:44 -0700 (PDT) X-Received: by 10.55.164.206 with SMTP id n197mr26852818qke.197.1477925564183; Mon, 31 Oct 2016 07:52:44 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j93si14998481qtd.138.2016.10.31.07.52.43; Mon, 31 Oct 2016 07:52:44 -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 dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C30166173E; Mon, 31 Oct 2016 14:52: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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 9C08B60F0D; Mon, 31 Oct 2016 14:52: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 01D4E61723; Mon, 31 Oct 2016 14:52:37 +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 AD9A7609AF for ; Mon, 31 Oct 2016 14:52:36 +0000 (UTC) Received: by mail-lf0-f48.google.com with SMTP id b81so104851975lfe.1 for ; Mon, 31 Oct 2016 07:52:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=B2QxToVecZa1gUmlsu2YUEFXKeFPGuYIUBwtFoQLocY=; b=ZdwcgdU6QyUetampLBI72SCzI6JKhCOoEtV+20kd2tO7ypWIVNR23bT9ehB8F9n4PW sv823O90qYbjv7CI9wP+/ZF+pzkEfDDAqoJ1ulZ3XuAYQagCZTKjIf/vnOK911KU58D7 hp9/HZBy6NAxDgnSMpwXP1N0XT7J3PopyYiCdp7YQH4KMqoZbiHmM/KmYGv5+VzHlrVe QUPE7ESabkRp5OCJSMsOU0r8yrhSk0NqwI3V9JpQcEjZgaaOKx0Jh+m58leJmIBTz5CZ iaKBD6cTbD52e0AyCco08R4QJjuNMDLF4TOyyvP2H1QGwSMptFq4ifEDxAZcJnpkLFYJ oBJA== X-Gm-Message-State: ABUngvcpQ/naG0uCnNUCPddLVAk08Uu/PLSWa0YETO7JDepWIprQhcW3C/Gykmf4nIztIecU6h8= X-Received: by 10.25.195.18 with SMTP id t18mr14563190lff.96.1477925555213; Mon, 31 Oct 2016 07:52:35 -0700 (PDT) Received: from localhost.localdomain (ppp46-138-205-38.pppoe.spdop.ru. [46.138.205.38]) by smtp.gmail.com with ESMTPSA id u74sm2133382lfi.9.2016.10.31.07.52.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Oct 2016 07:52:34 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 31 Oct 2016 17:51:50 +0300 Message-Id: <1477925510-6974-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: crypto patch Subject: [lng-odp] [PATCHv2] linux-gen: crypto: fix aes gcm decryption 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" We should first initialize, then set up decryption and only then push blocks for decryption. https://bugs.linaro.org/show_bug.cgi?id=2571 Signed-off-by: Maxim Uvarov --- v2: clear reworking btw, it was tested here: https://s3.amazonaws.com/archive.travis-ci.org/jobs/171998583/log.txt platform/linux-generic/odp_crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.1.250.gff4ea60 Reviewed-by: Balakrishna Garapati diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index c7431e6..9e09d42 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -398,6 +398,8 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_params_t *params, EVP_DecryptInit_ex(ctx, NULL, NULL, NULL, iv_enc); + EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, tag); + /* Authenticate header data (if any) without encrypting them */ if (aad_head < cipherdata) { EVP_DecryptUpdate(ctx, NULL, &plain_len, @@ -414,8 +416,6 @@ odp_crypto_alg_err_t aes_gcm_decrypt(odp_crypto_op_params_t *params, auth_len - (aad_tail - aad_head)); } - EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, tag); - if (EVP_DecryptFinal_ex(ctx, cipherdata + cipher_len, &plain_len) < 0) return ODP_CRYPTO_ALG_ERR_ICV_CHECK;