From patchwork Tue Oct 11 18:15:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 77517 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp121500qge; Tue, 11 Oct 2016 11:16:16 -0700 (PDT) X-Received: by 10.107.15.27 with SMTP id x27mr7601767ioi.218.1476209776076; Tue, 11 Oct 2016 11:16:16 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4si5147972pfk.12.2016.10.11.11.16.15; Tue, 11 Oct 2016 11:16:16 -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=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 S1752534AbcJKSQO (ORCPT + 1 other); Tue, 11 Oct 2016 14:16:14 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:37894 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753147AbcJKSQJ (ORCPT ); Tue, 11 Oct 2016 14:16:09 -0400 Received: by mail-wm0-f45.google.com with SMTP id c78so873374wme.1 for ; Tue, 11 Oct 2016 11:15:50 -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=eiYYcX5g75Cbk5tHeKDN5RDivwtN18Uec+jmBn8JBvQ=; b=d3Z37hS9ayqLoPh4ZJprDPBGf72ZoutnvWiY/Cq+z3MUfONyTsSFjoqR/fWPQYF7V8 xi1bhtb+kmQ5QYw+Pa9VI4uJDIL5EG+1n3U6LwffA2pgIWrjkyj3Noh2WXGR37B3/ew+ XGU/RrCaLrKWnFUgTWB57GQU5CbRSgIi3bJFo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eiYYcX5g75Cbk5tHeKDN5RDivwtN18Uec+jmBn8JBvQ=; b=muonfye607cT9WVinEU+nm7/sBtVYOh8OU7VaIWgu29HfUrVeoPfbt68XyTL+BHbpK WvfeTMgE2eE7IjFFdzLk+Vn6SvvEpMNb8DtCpPK2l3iS2H1DhqSE6JJi82nnko7xm5d9 3RndOuNg68af+tCA04KzEKiHkRtudxS7uJuV7nUl3T8nFNOG5hFRg9gf1A8BqvFM0Cxb gTYzFQQigKpAUjYVhAMdG4iy2Kddl428w+yq5J1bJJqUd+MlxEMH32O3oqOSs0vbRkfe PYtBgXozKzbl+2JU5Dm0BlD+4KC9lcZr+79FgJKHSr084D8K0rAgZUiMkRYFYqG8cFEO nfVA== X-Gm-Message-State: AA6/9RkzpWe0vzcg9q87izNIEdVF5bDhDMg8mH7aoPC84nr2Pud1UzBSnBGdqZIEyKPWDvbL X-Received: by 10.194.149.51 with SMTP id tx19mr6705962wjb.221.1476209749219; Tue, 11 Oct 2016 11:15:49 -0700 (PDT) Received: from localhost.localdomain ([105.147.31.57]) by smtp.gmail.com with ESMTPSA id ya1sm8341523wjb.23.2016.10.11.11.15.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Oct 2016 11:15:48 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, herbert@gondor.apana.org.au Cc: will.deacon@arm.com, catalin.marinas@arm.com, linux@arm.linux.org.uk, Ard Biesheuvel Subject: [PATCH v2 8/8] crypto: arm/aes-ce - fix for big endian Date: Tue, 11 Oct 2016 19:15:20 +0100 Message-Id: <1476209720-21114-9-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476209720-21114-1-git-send-email-ard.biesheuvel@linaro.org> References: <1476209720-21114-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 AES key schedule generation is mostly endian agnostic, with the exception of the rotation and the incorporation of the round constant at the start of each round. So implement a big endian specific version of that part to make the whole routine big endian compatible. Fixes: 86464859cc77 ("crypto: arm - AES in ECB/CBC/CTR/XTS modes using ARMv8 Crypto Extensions") Signed-off-by: Ard Biesheuvel --- arch/arm/crypto/aes-ce-glue.c | 5 +++++ 1 file changed, 5 insertions(+) -- 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/arm/crypto/aes-ce-glue.c b/arch/arm/crypto/aes-ce-glue.c index aef022a87c53..04410d9f5e72 100644 --- a/arch/arm/crypto/aes-ce-glue.c +++ b/arch/arm/crypto/aes-ce-glue.c @@ -88,8 +88,13 @@ static int ce_aes_expandkey(struct crypto_aes_ctx *ctx, const u8 *in_key, u32 *rki = ctx->key_enc + (i * kwords); u32 *rko = rki + kwords; +#ifndef CONFIG_CPU_BIG_ENDIAN rko[0] = ror32(ce_aes_sub(rki[kwords - 1]), 8); rko[0] = rko[0] ^ rki[0] ^ rcon[i]; +#else + rko[0] = rol32(ce_aes_sub(rki[kwords - 1]), 8); + rko[0] = rko[0] ^ rki[0] ^ (rcon[i] << 24); +#endif rko[1] = rko[0] ^ rki[1]; rko[2] = rko[1] ^ rki[2]; rko[3] = rko[2] ^ rki[3];