Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3747833ybi; Tue, 2 Jul 2019 12:45:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyY5am1I4UXQbuISwYKo/RGh59aHtIpzFUg/ypfSgxf/VHTL1xThosdnB1j9w0GPzuS+uSU X-Received: by 2002:a17:902:5a4c:: with SMTP id f12mr37382749plm.332.1562096721760; Tue, 02 Jul 2019 12:45:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562096721; cv=none; d=google.com; s=arc-20160816; b=j4lH2S6vwe85GNecQvWQXptxoDI86l7j7kSTRQHDGoZQHiUdsJAsyhq/QRVGaVyQV3 auWHXpSRZ+IFx1Gp6HeM+pnwlOJ3+wl00Cq/cvJK16jsMVueToQiK6BcKSyM8b/l+Uvp CAmgVB4l/OHKPdAKgWB2snFam1TWCUNICmIVGKbttlpMkcnAB0WztRsW+9luuXtmMyX2 ujvHdb2Cxtu7pYRib/qPi8pStbMs+ZXA+WEnLY/fu3AeOolUj8PzKBOP1RfHjmGbYR3J pAtfDpWCowZHbPzP2e1V2Be1FFFZ5VeWM0KgwCXE3j0TI5f4mWPzt2gTq9ebmnhYh5// qcug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=II4IaI2l8ysBnoBGFcY14xsKlW45HqjpdlGpUkQ7rBQ=; b=ajmZnKa8K984guiXyuBQBzdlhe2PPUs/YIcqQlR60Qz8G6T9z1zuTxcz0vHv37Dwqd frcFdOCRSXSpXu6ZMAb1Zeic8gzyspegjPaaTy0rsCd2xCDwUJg2NYUrrNXvK0mZNyKa mtIdi5A1Ic+0EFMHBuLHSwR1081BNvFTGsMiwTdkEnNC99VlQbGOwkn/A4gBd+Ujz36+ c1387CsQz0RnqKsvqbtw3uPFAjPt7B6jE2BL6qpzcRKzR9V8FKPdJKuj0Qb5PpAad+M1 SOdyDvzcIapaVtTCQSbiSVKI/8XAVooDkvz3baia27GOZIlYBBKMkjU8qxPh0e0WAQ2H Gwsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y4AyQA13; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si15595831pfz.120.2019.07.02.12.45.06; Tue, 02 Jul 2019 12:45:21 -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 header.s=google header.b=Y4AyQA13; 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 S1727119AbfGBTmu (ORCPT + 99 others); Tue, 2 Jul 2019 15:42:50 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:37963 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727101AbfGBTmt (ORCPT ); Tue, 2 Jul 2019 15:42:49 -0400 Received: by mail-lj1-f195.google.com with SMTP id r9so18181790ljg.5 for ; Tue, 02 Jul 2019 12:42:48 -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=II4IaI2l8ysBnoBGFcY14xsKlW45HqjpdlGpUkQ7rBQ=; b=Y4AyQA13rcUlRIXMIl6Mk3NNAkJq4EQnuk82FBjoq/Qv+Zwd6RhPeTxLusCR8WustC r1+2xoT5ECWF5WuYISoiLeM5jQWSXe//Swi827ZKtsu0IFTo4xkstqpFoTQEjgoQB+rS t+pYWKzVpFB3TNV6s6VKBeLJZE9cKibesYLscNDUbJ/dsusDr/ZWmIY7n3cUy47hDSr7 0gHhD3GM6YZqhE7e2G0NkSuENaFunDkqJpWKM2ndKGoyfcEv4deJYy04KjAtp6GACG/U H0/KIEKUScE3ovwYMDBIQme49SbhUYvyMKsC4iDjmujVPtagpRgMFM+lfsDxmNu9aHrk QEyQ== 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=II4IaI2l8ysBnoBGFcY14xsKlW45HqjpdlGpUkQ7rBQ=; b=elXG9DY4wVFFmQZHbepx6/e4fwz5BbtOygLi7EiPBVQVI+raEUr0Zuk4Lv2k0xVRMQ /mJXVRqXKR7J99ffRVz748mgOFnEM/htqi4lroKPn16ah+3b4PJ3MuwaDXk7lwPmNsnz xpzQxGcrkOgtCkYR1TKAX+YMpvadW7sp6c+qzSEsQkKvaBQ4/GZKOXhfA3URjfOTdLe0 68wjXi2h65zLijCm4R1oJJNvy+qn7DwS0t6QYCmT+x8kw1l1XGajiIIQrHBXGVNgcISM oeLblpOL0ppQy2wjAhaQvr+toxSrjvNyLuPYiWYVLP3cMlOgEuM7dhuhu9nF4z6uRIVw Hp6g== X-Gm-Message-State: APjAAAUx5H7AsxLyMrzh0H7b2iJWGl3V2+YwPSsJp9vEQaw4QsOkwVBg YggTCKo0ES3TrJZ7QYiGIQ8fFmRYq6qVU86b X-Received: by 2002:a2e:b1c1:: with SMTP id e1mr18245038lja.228.1562096567433; Tue, 02 Jul 2019 12:42:47 -0700 (PDT) Received: from e111045-lin.arm.com (89-212-78-239.static.t-2.net. [89.212.78.239]) by smtp.gmail.com with ESMTPSA id 24sm4475163ljs.63.2019.07.02.12.42.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 12:42:46 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, ebiggers@google.com, Ard Biesheuvel Subject: [PATCH v4 28/32] crypto: lib/aes - export sbox and inverse sbox Date: Tue, 2 Jul 2019 21:41:46 +0200 Message-Id: <20190702194150.10405-29-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190702194150.10405-1-ard.biesheuvel@linaro.org> References: <20190702194150.10405-1-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org There are a few copies of the AES S-boxes floating around, so export the ones from the AES library so that we can reuse them in other modules. Signed-off-by: Ard Biesheuvel --- include/crypto/aes.h | 3 +++ lib/crypto/aes.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/include/crypto/aes.h b/include/crypto/aes.h index df8426fd8051..8e0f4cf948e5 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -67,4 +67,7 @@ void aes_encrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in); */ void aes_decrypt(const struct crypto_aes_ctx *ctx, u8 *out, const u8 *in); +extern const u8 crypto_aes_sbox[]; +extern const u8 crypto_aes_inv_sbox[]; + #endif diff --git a/lib/crypto/aes.c b/lib/crypto/aes.c index 9928b23e0a8a..4e100af38c51 100644 --- a/lib/crypto/aes.c +++ b/lib/crypto/aes.c @@ -82,6 +82,12 @@ static volatile const u8 __cacheline_aligned aes_inv_sbox[] = { 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d, }; +extern const u8 crypto_aes_sbox[256] __alias(aes_sbox); +extern const u8 crypto_aes_inv_sbox[256] __alias(aes_inv_sbox); + +EXPORT_SYMBOL(crypto_aes_sbox); +EXPORT_SYMBOL(crypto_aes_inv_sbox); + static u32 mul_by_x(u32 w) { u32 x = w & 0x7f7f7f7f; -- 2.17.1