From patchwork Sun Jul 9 18:28:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 700875 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp4827969wrs; Sun, 9 Jul 2023 11:34:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlFGBfu8/67ztkExCliQ8CCUI1PJBibpZzLET2tYeZmMqMXESgcMvuWhV2iYAyE/6HKy5kp1 X-Received: by 2002:a05:622a:152:b0:403:9ace:57a7 with SMTP id v18-20020a05622a015200b004039ace57a7mr8935958qtw.7.1688927644588; Sun, 09 Jul 2023 11:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688927644; cv=none; d=google.com; s=arc-20160816; b=gKy0BpPKlzL9srJbgjwKodv1rBah7sCs6lsn34i1vxzlbkqey0jBkuhThRgAcTNd4f hhMmdMqazHh7EP1XPYtcJel5/qiApc1HJV1BxH2fVsiNmt0R4PepWsUUmuF9aPfZ8fnQ YVy1jnDwAKuFDD3XN9TM1u6iNN2+5EIYwQ7OrCxijqHKYw0mQWvBpu0C0D2yKgDG9w3k cN8Jh+TDan6c0tYJu2cHqzidCwj0iPhlBBUMa0Ucfly+74zhQPUWWI6CYaPOavubsHle 1v5kd3q26UUzs9l5raTuldXf5rLGF63H8Jk9rwB3BoXy+1i7wNVbcfK43K67WSTukT2J 92KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/QBtvBQSI1Tt7HA/Hos/l3dVZOAq+hVRSg1lIqyT39k=; fh=lMWaYJWKNNp5se7C5JIc/IAy1MaLsIKSBhk4MhqnayU=; b=p7lYia6KCmliJ7GKQo+WCNzbH3di6Rd3D38u7X+rqXCFq0+p+G6U8YucC0T4IDQLkY tKo+Kv1r2YsEXk/XAhJJjeHFB6RqC4dkabiDRtGFxzdSv1+VUIwV+Zpd7hMx6eZH7rSR kArfzbiS1XuUCguyKn7Ub6RfI7OQIKlWwsj/iTb6aF7L8lTpvHLEVb8cLPtxlrwl2XHU qHq/guE0EufQ8WjyzXqdbO2sng7I2NdMrUkn3EAiR5jeATKQrGxYAOdAKFurLA3XYHx2 LZyaKBhTV7ynChbchjDfpNxqX6oUHlPVtVXXvIA9dmviFeGOjO1tzseL0hC/IdrOljjm kH5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LPVTtHy8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n16-20020a05622a041000b004039ef1cdd9si2774408qtx.443.2023.07.09.11.34.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2023 11:34:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LPVTtHy8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIZAV-0008JT-7b; Sun, 09 Jul 2023 14:29:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIZAT-0008Iy-HH for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:57 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIZAR-0000Hg-TP for qemu-devel@nongnu.org; Sun, 09 Jul 2023 14:29:57 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbea14706eso37891745e9.2 for ; Sun, 09 Jul 2023 11:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688927394; x=1691519394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/QBtvBQSI1Tt7HA/Hos/l3dVZOAq+hVRSg1lIqyT39k=; b=LPVTtHy8rS0l+ARnT9UwhpqFth+8dMEaFGITPAGTXV4iU/+GU903B+EplpYbjnpfMb pCNOpXlSVX3CKecuXOheldX1fxwIZl+91nR6enZjgkcpkX+OcrTx4oAPBmrcHJncJZdw k5565BT8poZE1j+4mJC8NpndqouedIAZ63Zo0KZtgMTkp6QzAdgwReCEw1Q57Y0GKuKM Y9HROJMr1godTBObRmKd4T4jwGikCm/i9C+6AUzsUHc+zaps11457Vlu2iJdlTvR/Wip Dqd1s4vsfpvNHxy98TiiPlnS2p+/SDc4PvHv5fG6zEnq30T5JZPzqxZYqsuJUJuHPbGf XJTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688927394; x=1691519394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/QBtvBQSI1Tt7HA/Hos/l3dVZOAq+hVRSg1lIqyT39k=; b=LfEkOFwGIP+VwKnc8NrgG6cGfZ8l0a4BXcMYX+3biuZNSZH5gLw2PqS0kto9GYkKUV WIjolqwfbUeoSuW/9wZFBcc6K/r+YnAVYbX2o/OCWuXAM0w30fmNwOf7+zz/gbhTlbm6 P/c7kWa1qQzyJY23mei6w454INgpMEPo3x6e/9tzECYedBd3KNPIoZZtu1KcvpMn0JAl 1dty8ERU+ucJ4t8rZCTTeDNBsoAIhR3ZHdP9DlYVSovwA+Uo/ykZ6w469KP42XpR6mhx qkqzDUnJh3x0ZUMk0KbheRW8WNDlJ3FffbJbpMZKCgCoUShNbovZAsLxbZ3RLbcot3pF jFVQ== X-Gm-Message-State: ABy/qLYMGB+SPPm2gMaHKvt6u/kmrWcC+KIZLrzzmS0ZrnWhce2YSQR3 INaubJwoE597kEjV2GPANmdYu5jM8THRLhf5S/YVzA== X-Received: by 2002:a05:600c:234b:b0:3fc:dd9:91fd with SMTP id 11-20020a05600c234b00b003fc0dd991fdmr1707665wmq.40.1688927394581; Sun, 09 Jul 2023 11:29:54 -0700 (PDT) Received: from stoup.. ([148.252.133.210]) by smtp.gmail.com with ESMTPSA id q15-20020a7bce8f000000b003fbe791a0e8sm8317108wmj.0.2023.07.09.11.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 11:29:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [PULL 11/37] crypto: Add aesdec_ISB_ISR_AK_IMC Date: Sun, 9 Jul 2023 19:28:33 +0100 Message-Id: <20230709182934.309468-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230709182934.309468-1-richard.henderson@linaro.org> References: <20230709182934.309468-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add a primitive for InvSubBytes + InvShiftRows + AddRoundKey + InvMixColumns. Acked-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- host/include/generic/host/crypto/aes-round.h | 3 +++ include/crypto/aes-round.h | 21 ++++++++++++++++++++ crypto/aes.c | 14 +++++++++++++ 3 files changed, 38 insertions(+) diff --git a/host/include/generic/host/crypto/aes-round.h b/host/include/generic/host/crypto/aes-round.h index db8cfe17eb..1b9720f917 100644 --- a/host/include/generic/host/crypto/aes-round.h +++ b/host/include/generic/host/crypto/aes-round.h @@ -23,6 +23,9 @@ void aesdec_IMC_accel(AESState *, const AESState *, bool) void aesdec_ISB_ISR_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); +void aesdec_ISB_ISR_AK_IMC_accel(AESState *, const AESState *, + const AESState *, bool) + QEMU_ERROR("unsupported accel"); void aesdec_ISB_ISR_IMC_AK_accel(AESState *, const AESState *, const AESState *, bool) QEMU_ERROR("unsupported accel"); diff --git a/include/crypto/aes-round.h b/include/crypto/aes-round.h index 9996f1c219..854fb0966a 100644 --- a/include/crypto/aes-round.h +++ b/include/crypto/aes-round.h @@ -119,6 +119,27 @@ static inline void aesdec_ISB_ISR_AK(AESState *r, const AESState *st, } } +/* + * Perform InvSubBytes + InvShiftRows + AddRoundKey + InvMixColumns. + */ + +void aesdec_ISB_ISR_AK_IMC_gen(AESState *ret, const AESState *st, + const AESState *rk); +void aesdec_ISB_ISR_AK_IMC_genrev(AESState *ret, const AESState *st, + const AESState *rk); + +static inline void aesdec_ISB_ISR_AK_IMC(AESState *r, const AESState *st, + const AESState *rk, bool be) +{ + if (HAVE_AES_ACCEL) { + aesdec_ISB_ISR_AK_IMC_accel(r, st, rk, be); + } else if (HOST_BIG_ENDIAN == be) { + aesdec_ISB_ISR_AK_IMC_gen(r, st, rk); + } else { + aesdec_ISB_ISR_AK_IMC_genrev(r, st, rk); + } +} + /* * Perform InvSubBytes + InvShiftRows + InvMixColumns + AddRoundKey. */ diff --git a/crypto/aes.c b/crypto/aes.c index c2546ef12e..c765f11c1e 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1542,6 +1542,20 @@ void aesdec_ISB_ISR_IMC_AK_genrev(AESState *r, const AESState *st, aesdec_ISB_ISR_IMC_AK_swap(r, st, rk, true); } +void aesdec_ISB_ISR_AK_IMC_gen(AESState *ret, const AESState *st, + const AESState *rk) +{ + aesdec_ISB_ISR_AK_gen(ret, st, rk); + aesdec_IMC_gen(ret, ret); +} + +void aesdec_ISB_ISR_AK_IMC_genrev(AESState *ret, const AESState *st, + const AESState *rk) +{ + aesdec_ISB_ISR_AK_genrev(ret, st, rk); + aesdec_IMC_genrev(ret, ret); +} + /** * Expand the cipher key into the encryption key schedule. */