Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3474983imu; Sun, 11 Nov 2018 15:57:53 -0800 (PST) X-Google-Smtp-Source: AJdET5fJeSdQk2+XLmR9dEAJK1l2RY0NaFEBTZ94aHfxSf8A2LdMu7w7MFZrENfPlfFC/R4qJCKz X-Received: by 2002:a62:6881:: with SMTP id d123-v6mr18432234pfc.195.1541980673592; Sun, 11 Nov 2018 15:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980673; cv=none; d=google.com; s=arc-20160816; b=J9kgZN30wcftRL2HfGrkmt4+3rAhPl6cxG/nWuT4YoNkMpC7C1gCVKB0YJAVhhqbCA CuADPGj0+viEJYuk5KYloa+DS4Q2cF/pPFwjGPrV4I2gXfZLyhsoyoZpCdOHmb3ax4qX DXGoM1DNAS33FsThyXQwgFh8JLUfE5fbkhYIqT4fv386nHmSDOUdNMseVI/gIkFqM5J4 K3etKJUuB6RzXZlAb3JvTMfvIRrfan8UivMGhQL0wzxMWHqX97HttJD+gWGZi6SNDZtW eoKSrumfVcstK6dL+opmNlLT1zq+IS/OgZPd/Oc8PH+hLLZrxrtZ+/2ajVMGtj7wtsrJ SMwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HjXp7pV2iB5zLBn4pH4pwCmAb/yQ0wiJtIPaVaf/K5I=; b=tbqaUm0ZMmt4gEXQUxIGUvL1e0XqVIVrhnonxAHXwyIY35T03uQRuy6+yWJRbqm/4A OCTk28NGvTeVMJ3UdK1Ax12YSQdOwuXvb5SeQZ1yFCJgRnJee6E6I4cGVmQEX3nnkMxX bp3kVB2zOh0hdFeLAvu66y1SqXH0xS8MznVL3nDqPbb6JaZBv2FJTV4pEQe3JmfF2Hu9 V24lOfPlcbAVf+K2AMPXWoljYUGbb/A/UcNwsJLm0uj/g+MR8kmqT66/fjqzejBIcfDc 7u5UtTwdz4VXxTX00k8FoQ0ibTrVRp9+HleyNsxEUEUMsD+KXbaT9GL4eZlqoXXXaUWo YBGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qj8s7TwA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11-v6si15828115plt.5.2018.11.11.15.57.38; Sun, 11 Nov 2018 15:57:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=qj8s7TwA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732601AbeKLISP (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:34210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732568AbeKLISO (ORCPT ); Mon, 12 Nov 2018 03:18:14 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4D0B021508; Sun, 11 Nov 2018 22:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975298; bh=zca4I/sBX6U7/TIEu8dVvsjR7mnMVt0VQLM+iImvAVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qj8s7TwA12SWa1EkvsO9bRxkX3YHOBoScw8bHeVfyLVJ+lDWCKNvJCpI/RC5dRs2V T8HgBV9vNKRfRK9Kns5V5zuwtKIeaVKfEwqg2WeAy5xncLb/eD+uRLGiCwV+d9ggO1 0rYlBLrvE3wfplUHmDOPFS/Jd71u/REfrLsIH0V0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Ondrej Mosnacek , Herbert Xu Subject: [PATCH 4.19 246/361] crypto: aegis/generic - fix for big endian systems Date: Sun, 11 Nov 2018 14:19:53 -0800 Message-Id: <20181111221652.769967198@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ard Biesheuvel commit 4a34e3c2f2f48f47213702a84a123af0fe21ad60 upstream. Use the correct __le32 annotation and accessors to perform the single round of AES encryption performed inside the AEGIS transform. Otherwise, tcrypt reports: alg: aead: Test 1 failed on encryption for aegis128-generic 00000000: 6c 25 25 4a 3c 10 1d 27 2b c1 d4 84 9a ef 7f 6e alg: aead: Test 1 failed on encryption for aegis128l-generic 00000000: cd c6 e3 b8 a0 70 9d 8e c2 4f 6f fe 71 42 df 28 alg: aead: Test 1 failed on encryption for aegis256-generic 00000000: aa ed 07 b1 96 1d e9 e6 f2 ed b5 8e 1c 5f dc 1c Fixes: f606a88e5823 ("crypto: aegis - Add generic AEGIS AEAD implementations") Cc: # v4.18+ Signed-off-by: Ard Biesheuvel Reviewed-by: Ondrej Mosnacek Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/aegis.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) --- a/crypto/aegis.h +++ b/crypto/aegis.h @@ -21,7 +21,7 @@ union aegis_block { __le64 words64[AEGIS_BLOCK_SIZE / sizeof(__le64)]; - u32 words32[AEGIS_BLOCK_SIZE / sizeof(u32)]; + __le32 words32[AEGIS_BLOCK_SIZE / sizeof(__le32)]; u8 bytes[AEGIS_BLOCK_SIZE]; }; @@ -57,24 +57,22 @@ static void crypto_aegis_aesenc(union ae const union aegis_block *src, const union aegis_block *key) { - u32 *d = dst->words32; const u8 *s = src->bytes; - const u32 *k = key->words32; const u32 *t0 = crypto_ft_tab[0]; const u32 *t1 = crypto_ft_tab[1]; const u32 *t2 = crypto_ft_tab[2]; const u32 *t3 = crypto_ft_tab[3]; u32 d0, d1, d2, d3; - d0 = t0[s[ 0]] ^ t1[s[ 5]] ^ t2[s[10]] ^ t3[s[15]] ^ k[0]; - d1 = t0[s[ 4]] ^ t1[s[ 9]] ^ t2[s[14]] ^ t3[s[ 3]] ^ k[1]; - d2 = t0[s[ 8]] ^ t1[s[13]] ^ t2[s[ 2]] ^ t3[s[ 7]] ^ k[2]; - d3 = t0[s[12]] ^ t1[s[ 1]] ^ t2[s[ 6]] ^ t3[s[11]] ^ k[3]; - - d[0] = d0; - d[1] = d1; - d[2] = d2; - d[3] = d3; + d0 = t0[s[ 0]] ^ t1[s[ 5]] ^ t2[s[10]] ^ t3[s[15]]; + d1 = t0[s[ 4]] ^ t1[s[ 9]] ^ t2[s[14]] ^ t3[s[ 3]]; + d2 = t0[s[ 8]] ^ t1[s[13]] ^ t2[s[ 2]] ^ t3[s[ 7]]; + d3 = t0[s[12]] ^ t1[s[ 1]] ^ t2[s[ 6]] ^ t3[s[11]]; + + dst->words32[0] = cpu_to_le32(d0) ^ key->words32[0]; + dst->words32[1] = cpu_to_le32(d1) ^ key->words32[1]; + dst->words32[2] = cpu_to_le32(d2) ^ key->words32[2]; + dst->words32[3] = cpu_to_le32(d3) ^ key->words32[3]; } #endif /* _CRYPTO_AEGIS_H */