From patchwork Mon Oct 31 14:50:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 80203 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp155926qge; Mon, 31 Oct 2016 07:50:59 -0700 (PDT) X-Received: by 10.55.132.68 with SMTP id g65mr26988304qkd.8.1477925459346; Mon, 31 Oct 2016 07:50:59 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g192si17804468qke.167.2016.10.31.07.50.59; Mon, 31 Oct 2016 07:50:59 -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 0B2546173A; Mon, 31 Oct 2016 14:50:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 EFE50609AF; Mon, 31 Oct 2016 14:50:52 +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 C1B8360F0D; Mon, 31 Oct 2016 14:50:50 +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 85C5F6094C for ; Mon, 31 Oct 2016 14:50:49 +0000 (UTC) Received: by mail-lf0-f52.google.com with SMTP id b81so104802947lfe.1 for ; Mon, 31 Oct 2016 07:50:49 -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=nf3AXulXiJgXt4t7sQYolWqMG72fpOJPo4bR9xeihew=; b=YnLp0n3Eua2SQJHC5eYs3tF2oMrYaV+o1GFEIwp/fW0VPsj7qUe0ZJdKUJ5WEKLFJn 9mN9IW+mwWfaReBRFVC4Um22lnz67asJFe5IR5wvwdX0OUh1UBkbtgV8XD3xkKOiPPUs td+Z1BvZNWmjgzIzabTCWCtzKg62duwKsndCA/0StBgRkS6Ca2DesmpMpRQH6Zgqrwap PVvfE4GsMDhh/gm/QaN0L+ECY6t99Yu7w2z4RjZPWd0e1WgyqZSKIYl0OnKzX8xMzb69 lWdlHMd0SQx+8ccDUWLSfYcwO8uj2xUQyRBC/gejhceI68SBmhYV4fRND4Ju7WAk3GG6 gfNQ== X-Gm-Message-State: ABUngvdqn+go/ia0vsQfJ1MfjN5HomMKgMqgLX3/IZXL5KXXc4zXvsGXQbOkvLbF3pTAQ2+To+k= X-Received: by 10.25.75.66 with SMTP id y63mr15068152lfa.59.1477925448262; Mon, 31 Oct 2016 07:50:48 -0700 (PDT) Received: from localhost.localdomain (ppp46-138-205-38.pppoe.spdop.ru. [46.138.205.38]) by smtp.gmail.com with ESMTPSA id u126sm2748247lja.12.2016.10.31.07.50.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Oct 2016 07:50:47 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 31 Oct 2016 17:50:01 +0300 Message-Id: <1477925401-6860-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: crypto patch Cc: Max Uvarov Subject: [lng-odp] [PATCH] 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 also and only then push blocks for decryption. https://bugs.linaro.org/show_bug.cgi?id=2571 Signed-off-by: Max Uvarov Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.1.250.gff4ea60 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;