From patchwork Wed Jan 11 16:41:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 90943 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1209282qgi; Wed, 11 Jan 2017 08:42:16 -0800 (PST) X-Received: by 10.99.226.83 with SMTP id y19mr11787877pgj.147.1484152936066; Wed, 11 Jan 2017 08:42:16 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21si6264351pgi.268.2017.01.11.08.42.15; Wed, 11 Jan 2017 08:42:16 -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 sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761971AbdAKQmO (ORCPT + 1 other); Wed, 11 Jan 2017 11:42:14 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:38605 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762168AbdAKQmK (ORCPT ); Wed, 11 Jan 2017 11:42:10 -0500 Received: by mail-wm0-f44.google.com with SMTP id r144so34214762wme.1 for ; Wed, 11 Jan 2017 08:42:09 -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=BB5M+r8FDFsyYO2J4D6d17CPo1XnzARZyYpjJv+rfEkvnoz96mdu75XffTf94NqYB7 HdthxPjmUW48DU9mFcpucyonNhb4JwS0padZmVZukJIrqTKdjfDQypnP9CDiRjGAPZKn 3dqJpui6WlhDZe4YOuN48au4RxmyohcAaA3ug= 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=dahkzWiqaLNfcAtfErJXXepcs+l25zv36tTpcNj9pjAHKoQvfh7mZBEvnkKyswhcfN CZUHc8siSvbCESzLxbTEZ0JtyXhFS2MxMSMjSAlX5WU0ZR37Sn93cpVK9K/0Rn3NnWtV W3fNz9aTfEXhNaEzCNgMqHKOXi+TIwoqkpSpuahEQidB2KeNyaJ0eRhyFmGenntB8KnA wimo+OhwOZmNLIiDNRmHhyAvdd6/X/9rsKqGynRCkMu2yQUnphM2BdVSJq9R7FsfJIs3 FPtOS9the2KpSQoZ2VzXs7Bd+Wuvzz2SXjObkE4UbJ1TSaKGuyQcYKcgfX9/jf1Yk+A1 0ypQ== X-Gm-Message-State: AIkVDXJcKmab7QyGNLy5BWoY+7UvQCsxENQJB0fCQVW9354cp5n2neyxeKgLPS+wDWKAt8uS X-Received: by 10.28.14.66 with SMTP id 63mr5588830wmo.127.1484152928827; Wed, 11 Jan 2017 08:42:08 -0800 (PST) Received: from localhost.localdomain ([160.167.203.25]) by smtp.gmail.com with ESMTPSA id kq7sm9328885wjb.30.2017.01.11.08.42.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Jan 2017 08:42:08 -0800 (PST) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel Subject: [PATCH v2 3/7] crypto: arm64/aes-blk - expose AES-CTR as synchronous cipher as well Date: Wed, 11 Jan 2017 16:41:51 +0000 Message-Id: <1484152915-26517-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484152915-26517-1-git-send-email-ard.biesheuvel@linaro.org> References: <1484152915-26517-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;