From patchwork Sun Mar 26 18:49:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96020 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp923280qgd; Sun, 26 Mar 2017 11:57:38 -0700 (PDT) X-Received: by 10.84.218.2 with SMTP id q2mr24826936pli.141.1490554658278; Sun, 26 Mar 2017 11:57:38 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si10147965plq.107.2017.03.26.11.57.38; Sun, 26 Mar 2017 11:57:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751595AbdCZS5Q (ORCPT + 1 other); Sun, 26 Mar 2017 14:57:16 -0400 Received: from mail-wr0-f174.google.com ([209.85.128.174]:35797 "EHLO mail-wr0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751638AbdCZS4U (ORCPT ); Sun, 26 Mar 2017 14:56:20 -0400 Received: by mail-wr0-f174.google.com with SMTP id u1so27350097wra.2 for ; Sun, 26 Mar 2017 11:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BJL9WZLf5E//W3ZFKxGrVOYUbQwoZXaO0DyEENd8NvU=; b=k1s/chPlyNA9wNuofuhhmiaxldfEn/cUCxbVwIg6NTEsglNqZY4c3LBaAAF92D0F1c Y9jQfxApBxzb3fcDePJs0W2owLG+8UrOFRgse3cDKrw/RHJW1LHHRiQUp7BvvXPPybb/ cwmyjY7QGWUpaINDBnx0+tnE5vRXY/DZM7fWs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BJL9WZLf5E//W3ZFKxGrVOYUbQwoZXaO0DyEENd8NvU=; b=JRV5IVsurOwrLRgez4KNzYl7yg1YJh6SIBkorlRTN0k7HdsqhxkuLyVXzHSl618OAp aZ2dbmW4sXYLuSZFeog8pZwQxj5+PLXA4jkngTg/ckAuFe5k1X7GMZzb62G7euuSKtRD 1122S6rLXT+BRIENyI3GWpC6BrLhPea4tIrJpnNP1Z7ko2sbf+ne0OIX33RNgqq1WoIH GP1kkffqfUZeXDysYcLFg8ZkI73tyapBflbJ4OiPLy0UpT44X4ZKt7PQsnRc8v2wXxIx i9Uoti2EyiLKU/0XKm6xpTM5aSW57rVeWifaRvBNUvlbyYTeclmEJU5AV3imiU4oiVAj t8kA== X-Gm-Message-State: AFeK/H2qTyqaZCZGPYRYoBAM7dIXZF6w+kgSn9A1BhvQ8anrKk51Jj412C41hyk07GC3YA3i X-Received: by 10.28.15.69 with SMTP id 66mr6450988wmp.105.1490554163015; Sun, 26 Mar 2017 11:49:23 -0700 (PDT) Received: from localhost.localdomain ([196.81.160.3]) by smtp.gmail.com with ESMTPSA id i133sm11362112wmg.26.2017.03.26.11.49.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Mar 2017 11:49:22 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Cc: nico@linaro.org, ebiggers3@gmail.com, Ard Biesheuvel Subject: [PATCH 4/7] crypto: aes/arm64 - eliminate dependency on crypto_aes_set_key() Date: Sun, 26 Mar 2017 19:49:05 +0100 Message-Id: <1490554148-10953-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490554148-10953-1-git-send-email-ard.biesheuvel@linaro.org> References: <1490554148-10953-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Call crypto_aes_expand_key() rather than crypto_aes_set_key() so that we can move to another implementation of it in a subsequent patch. Signed-off-by: Ard Biesheuvel --- arch/arm64/crypto/aes-glue.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c index bcf596b0197e..f4e0e122a86e 100644 --- a/arch/arm64/crypto/aes-glue.c +++ b/arch/arm64/crypto/aes-glue.c @@ -23,7 +23,6 @@ #ifdef USE_V8_CRYPTO_EXTENSIONS #define MODE "ce" #define PRIO 300 -#define aes_setkey ce_aes_setkey #define aes_expandkey ce_aes_expandkey #define aes_ecb_encrypt ce_aes_ecb_encrypt #define aes_ecb_decrypt ce_aes_ecb_decrypt @@ -37,7 +36,6 @@ MODULE_DESCRIPTION("AES-ECB/CBC/CTR/XTS using ARMv8 Crypto Extensions"); #else #define MODE "neon" #define PRIO 200 -#define aes_setkey crypto_aes_set_key #define aes_expandkey crypto_aes_expand_key #define aes_ecb_encrypt neon_aes_ecb_encrypt #define aes_ecb_decrypt neon_aes_ecb_decrypt @@ -103,7 +101,15 @@ struct mac_desc_ctx { static int skcipher_aes_setkey(struct crypto_skcipher *tfm, const u8 *in_key, unsigned int key_len) { - return aes_setkey(crypto_skcipher_tfm(tfm), in_key, key_len); + struct crypto_aes_ctx *ctx = crypto_skcipher_ctx(tfm); + int ret; + + ret = aes_expandkey(ctx, in_key, key_len); + if (!ret) + return 0; + + crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); + return -EINVAL; } static int xts_set_key(struct crypto_skcipher *tfm, const u8 *in_key,