From patchwork Mon Jan 2 18:21:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 89571 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp7697111qgi; Mon, 2 Jan 2017 10:23:44 -0800 (PST) X-Received: by 10.84.215.2 with SMTP id k2mr126129685pli.58.1483381424187; Mon, 02 Jan 2017 10:23:44 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 91si66393413ply.117.2017.01.02.10.23.44; Mon, 02 Jan 2017 10:23:44 -0800 (PST) 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=neutral (body hash did not verify) 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=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933802AbdABSXV (ORCPT + 1 other); Mon, 2 Jan 2017 13:23:21 -0500 Received: from mail-wj0-f179.google.com ([209.85.210.179]:33122 "EHLO mail-wj0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756545AbdABSWb (ORCPT ); Mon, 2 Jan 2017 13:22:31 -0500 Received: by mail-wj0-f179.google.com with SMTP id tq7so192500129wjb.0 for ; Mon, 02 Jan 2017 10:22:31 -0800 (PST) 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=k2sVdfgxPqc+9tTpO0I7IWswUmwGgsB3aoxd13EU9hM=; b=AnuBRNOad8EkIXXZUWSgE1kEAHT06ETH9tNE0rd/revQ1rFPpzZPgu9NYPt0tG7dS1 X5b/yAuomG+ZsFbYenaxROz0QJGNqUYx2BujDobLIEpBMBQEllLGopYWfHzQJGxUF9nJ HQwDRrlDVz4cC10jITvFtPVPfuIVnOH38GOZA= 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=k2sVdfgxPqc+9tTpO0I7IWswUmwGgsB3aoxd13EU9hM=; b=emvAAwS9An9eUNVEJK1hv6vCVx+PD4dRzeko9UxzioDIx4sUbDr5t9Bn1h1eXgKP+e UbiiwCAMZSwSWEr9I2r8gi4aq0sfCOQelmNtuI6pVfE8VYZFW+CE2CdHY1ODzL0VviFO La6NdiIlhjh3h+DMVlfoNSF5O/mx37jW1XqlQoSfSibctmatDptjty4e88r+BeknTB13 EIw16TEAT4iUpupvcgGRk1BjEjv/Rp56EObtOwI8Vi4ldzlRhrpvSmXe0SrEcttx0e42 +IBfkZBTvywqe9zcISaPYft8k+h6/u3OMsEHPzh61fNHSot1frc9LH8KCOyuQpHw/RMy sKRQ== X-Gm-Message-State: AIkVDXI/GNlqhO5nzuIZFvZMzAD9ydIJZG7KTvgJ0WTGRGayCCuhfhYD9HEeCw1cI8iwvpNr X-Received: by 10.194.123.201 with SMTP id mc9mr62622015wjb.47.1483381350238; Mon, 02 Jan 2017 10:22:30 -0800 (PST) Received: from localhost.localdomain ([105.146.125.96]) by smtp.gmail.com with ESMTPSA id l67sm85077652wmf.0.2017.01.02.10.22.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jan 2017 10:22:29 -0800 (PST) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, herbert@gondor.apana.org.au, Ard Biesheuvel Subject: [PATCH 5/6] crypto: arm64/aes-blk - expose AES-CTR as synchronous cipher as well Date: Mon, 2 Jan 2017 18:21:07 +0000 Message-Id: <1483381268-12987-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483381268-12987-1-git-send-email-ard.biesheuvel@linaro.org> References: <1483381268-12987-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 In addition to wrapping the AES-CTR cipher into the async SIMD wrapper, which exposes it as an async skcipher that defers processing to process context, expose our AES-CTR implementation directly as a synchronous cipher as well, but with a lower priority. This makes the AES-CTR transform usable in places where synchronous transforms are required, such as the MAC802.11 encryption code, which executes in sotfirq context, where SIMD processing is allowed on arm64. Users of the async transform will keep the existing behavior. Signed-off-by: Ard Biesheuvel --- arch/arm64/crypto/aes-glue.c | 25 ++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c index 4e3f8adb1793..5164aaf82c6a 100644 --- a/arch/arm64/crypto/aes-glue.c +++ b/arch/arm64/crypto/aes-glue.c @@ -327,6 +327,23 @@ static struct skcipher_alg aes_algs[] = { { .decrypt = ctr_encrypt, }, { .base = { + .cra_name = "ctr(aes)", + .cra_driver_name = "ctr-aes-" MODE, + .cra_priority = PRIO - 1, + .cra_blocksize = 1, + .cra_ctxsize = sizeof(struct crypto_aes_ctx), + .cra_alignmask = 7, + .cra_module = THIS_MODULE, + }, + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, + .ivsize = AES_BLOCK_SIZE, + .chunksize = AES_BLOCK_SIZE, + .setkey = skcipher_aes_setkey, + .encrypt = ctr_encrypt, + .decrypt = ctr_encrypt, +}, { + .base = { .cra_name = "__xts(aes)", .cra_driver_name = "__xts-aes-" MODE, .cra_priority = PRIO, @@ -350,8 +367,9 @@ static void aes_exit(void) { int i; - for (i = 0; i < ARRAY_SIZE(aes_simd_algs) && aes_simd_algs[i]; i++) - simd_skcipher_free(aes_simd_algs[i]); + for (i = 0; i < ARRAY_SIZE(aes_simd_algs); i++) + if (aes_simd_algs[i]) + simd_skcipher_free(aes_simd_algs[i]); crypto_unregister_skciphers(aes_algs, ARRAY_SIZE(aes_algs)); } @@ -370,6 +388,9 @@ static int __init aes_init(void) return err; for (i = 0; i < ARRAY_SIZE(aes_algs); i++) { + if (!(aes_algs[i].base.cra_flags & CRYPTO_ALG_INTERNAL)) + continue; + algname = aes_algs[i].base.cra_name + 2; drvname = aes_algs[i].base.cra_driver_name + 2; basename = aes_algs[i].base.cra_driver_name;