From patchwork Mon Jan 2 18:21:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 89568 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp7697029qgi; Mon, 2 Jan 2017 10:23:26 -0800 (PST) X-Received: by 10.84.128.67 with SMTP id 61mr55304929pla.153.1483381406086; Mon, 02 Jan 2017 10:23:26 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 12si66368401pfi.251.2017.01.02.10.23.25; Mon, 02 Jan 2017 10:23:26 -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 S1752971AbdABSXX (ORCPT + 1 other); Mon, 2 Jan 2017 13:23:23 -0500 Received: from mail-wj0-f176.google.com ([209.85.210.176]:34193 "EHLO mail-wj0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756391AbdABSWV (ORCPT ); Mon, 2 Jan 2017 13:22:21 -0500 Received: by mail-wj0-f176.google.com with SMTP id sd9so244612525wjb.1 for ; Mon, 02 Jan 2017 10:22:20 -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=NJiqhZ8Rhi8ObTD8ZBOERJwCRlhTw4dC8dzCUJLGavQ=; b=Me8J6XJGsJGddDA+dxW9VF3V4STOoTGWQjmyytqB8SC4r6XF+3BVJIpQaeA8owm6+e nA8evqGaSG2zCg3rt435M/auYJQxnjIF0b1tn26drL+bjAjUVxb3MgPwYCTl4TP4b4aY 1HNNPDFXtQxVuyV2/M2W5NVV+Ecq28gg8IXiI= 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=NJiqhZ8Rhi8ObTD8ZBOERJwCRlhTw4dC8dzCUJLGavQ=; b=iZlHx4rjmvhvgm1qOSm31+z2lGf8t/GJwvkN2G0drw7LDyO4p5yUr8galHBUXQ/6U4 Ywv2VQF6VhlpwoZqHugMK1+r+aCOFOE7VEwSxX939CcWkRBNNeny1z/Oe+nW79c4hnj6 41UqmVtKKGQ3GJvAIDLhHD8hC5yXoVaGnVKoGNghkSKZ41XyzZsfcv1TkxLtGyX5oAYT cfFCSr+9pqdAtcIyRNM+f5vtuqMxDM7yf9FDM5pOl1kP/j0G6+w7pQg6DBFYOG25/FwI OciiaEAlQw9jkkBGwNVyXa5eh5yT2FreI08CKiENJ8bpmL4KXcJtRSzXRqeDzETZM3tf rvmw== X-Gm-Message-State: AIkVDXK6LIeeHSBzwt0YeY2FNtlgo5723WU6E1uP8/mLRHBv+CNdNJcJrmaJcXpNoWXBZ4Fx X-Received: by 10.194.56.99 with SMTP id z3mr57827427wjp.55.1483381339561; Mon, 02 Jan 2017 10:22:19 -0800 (PST) Received: from localhost.localdomain ([105.146.125.96]) by smtp.gmail.com with ESMTPSA id l67sm85077652wmf.0.2017.01.02.10.22.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jan 2017 10:22:18 -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 1/6] crypto: generic/aes - export encrypt and decrypt entry points Date: Mon, 2 Jan 2017 18:21:03 +0000 Message-Id: <1483381268-12987-2-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 The generic AES code already shares its key schedule generation routines (and its S-boxes) with other implementations via external linkage. In the same way, export the core encrypt/decrypt routines so they may be reused by other drivers as well. This facility will be used by the bit slicing implementation of AES in XTS mode for arm64, where using the 8-way cipher (and its ~2 KB expanded key schedule) to generate the initial tweak is suboptimal. Signed-off-by: Ard Biesheuvel --- crypto/aes_generic.c | 10 ++++++---- include/crypto/aes.h | 3 +++ 2 files changed, 9 insertions(+), 4 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/crypto/aes_generic.c b/crypto/aes_generic.c index 3dd101144a58..26fd7b8c2e5f 100644 --- a/crypto/aes_generic.c +++ b/crypto/aes_generic.c @@ -1326,7 +1326,7 @@ EXPORT_SYMBOL_GPL(crypto_aes_set_key); f_rl(bo, bi, 3, k); \ } while (0) -static void aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) +void crypto_aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) { const struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm); const __le32 *src = (const __le32 *)in; @@ -1366,6 +1366,7 @@ static void aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) dst[2] = cpu_to_le32(b0[2]); dst[3] = cpu_to_le32(b0[3]); } +EXPORT_SYMBOL_GPL(crypto_aes_encrypt); /* decrypt a block of text */ @@ -1398,7 +1399,7 @@ static void aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) i_rl(bo, bi, 3, k); \ } while (0) -static void aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) +void crypto_aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) { const struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm); const __le32 *src = (const __le32 *)in; @@ -1438,6 +1439,7 @@ static void aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in) dst[2] = cpu_to_le32(b0[2]); dst[3] = cpu_to_le32(b0[3]); } +EXPORT_SYMBOL_GPL(crypto_aes_decrypt); static struct crypto_alg aes_alg = { .cra_name = "aes", @@ -1453,8 +1455,8 @@ static struct crypto_alg aes_alg = { .cia_min_keysize = AES_MIN_KEY_SIZE, .cia_max_keysize = AES_MAX_KEY_SIZE, .cia_setkey = crypto_aes_set_key, - .cia_encrypt = aes_encrypt, - .cia_decrypt = aes_decrypt + .cia_encrypt = crypto_aes_encrypt, + .cia_decrypt = crypto_aes_decrypt } } }; diff --git a/include/crypto/aes.h b/include/crypto/aes.h index 7524ba3b6f3c..297fbba5d27b 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -32,6 +32,9 @@ extern const u32 crypto_fl_tab[4][256]; extern const u32 crypto_it_tab[4][256]; extern const u32 crypto_il_tab[4][256]; +void crypto_aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in); +void crypto_aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in); + int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, unsigned int key_len); int crypto_aes_expand_key(struct crypto_aes_ctx *ctx, const u8 *in_key,