From patchwork Tue Jun 20 11:07:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 694464 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp245411wrm; Tue, 20 Jun 2023 04:12:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67JTbQlfel7y+fNigGwSwcEG/+cVi2jkeYyB4pO8NkKzzw/PEia7daSzLznq+5alGaCINr X-Received: by 2002:ac8:7d0e:0:b0:3fb:425f:d4e6 with SMTP id g14-20020ac87d0e000000b003fb425fd4e6mr16010503qtb.6.1687259549632; Tue, 20 Jun 2023 04:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687259549; cv=none; d=google.com; s=arc-20160816; b=PYbBRPq3Y71VPfQAJCB9dldxyaOcaSjCG6lEg97WxEY6s0cZxAtVL22eEX3qJxrTjc dhyWW4HWCuBACbWgNhKi0tQzWvcwZVFk45l8tZ9EWDakYJ3w/DkhqegEjYlrgnFeonPF TYBl5fX28KBpQgOsIu7wSv18MSJqA0gmRR0SqgKGwoKnac1NrVGDCieYDU+y2icVqnbN WABsZF8D5eYRezgKB+gxyTLihQP7c/jdpVWo8UiwG/smOAIARCUiaBRiY9SUB1XjlDaD pE1WYpZDGKp+RdYqWh9r64r7hJh6QWIPRUviahZ8BOqqVmoPjQN2riClglQehu/U6O+/ i3rQ== 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=wGlC/81ss1Jj94uQ0vf5KkBvhLt8Sw0gG5elkpKjdEk=; b=c3qKWSmXAOOaWb5hVZ9oHfBl0CfSSYW4nuEJ9rbQUJ2wFXJM9z0o3Zg9XEI9zxRXnA +SXm5UdSxVbRGvmYlYu6EEF5lhjNYnXKZg52iw2MzoykawGV/Gjpz6i/9+pNHuK8pPdQ Pq1RoRwle0LQCLh7PTlSrBuhv4TNN8CQhMAfvOL/lBqIj0QTtNCcAprTsYsmi7MlXMj2 CzKr+o/fjds6MgwyfJrB5yzjJ/VOOVhKZFeQDiSYCTl0KeeKjgdCvqehxMhTEzCO7fC/ jYch9PsIzA8R6g0WzOeOhWbhL445WmMjnRP6FbkBizAjDcPnaq7AvI58R93nfJ3FAhUK aGQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M+U36JOb; 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 e9-20020a05622a110900b003f4e4c15f87si675046qty.92.2023.06.20.04.12.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Jun 2023 04:12:29 -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=M+U36JOb; 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 1qBZEA-0006lH-7U; Tue, 20 Jun 2023 07:08:51 -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 1qBZE3-0006bz-FB for qemu-devel@nongnu.org; Tue, 20 Jun 2023 07:08:43 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qBZE0-0004V9-EU for qemu-devel@nongnu.org; Tue, 20 Jun 2023 07:08:43 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-982a88ca610so546806866b.2 for ; Tue, 20 Jun 2023 04:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687259319; x=1689851319; 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=wGlC/81ss1Jj94uQ0vf5KkBvhLt8Sw0gG5elkpKjdEk=; b=M+U36JOb+hdpql7wKTS5xxcjO6q0z3C42moEd/BzLzNsbtb4qHxKWGxDyv6EwrIQuj ji5JLF+DAhfp+DDQ87TKXtNICqMAQ5aeVb3p29odObllS3aS8tG1joJ4YYlt/iadjEhk VX80kJjB//wSXh0shC18870/fQL8uQEqYGcIgigKiPCQap7AGDvomy2itvTzYpeJvagy +ryEew+VVBTsrscb45I1AMk5yns40t/nJQQ64RYQfu7KmpR3kc6Vb8QYhiMp7H0VvpQx DZMLro7AsLxXzhl9fajRg+wRI/R7g+w88yyHHtOqnCWoE78LvQ/UgLbvx43uo0QWurXT 37xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687259319; x=1689851319; 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=wGlC/81ss1Jj94uQ0vf5KkBvhLt8Sw0gG5elkpKjdEk=; b=D43bMAtdsK7s1+B9f1pJBRYm41nd2xppybMbK2A+GJT9fisf8/6wSLL3tbiYqb1a0N 9vinc6U6sBohJ3v4yFoQQWaWMbF9JtHuZ13QTa8EeEudMcGCbbde5HHCFIfhbiByGktE mh7BYG+Ec9SqMdXmdA4Lr+6Bwe10fl5alYJ7JTvOAmIT+qfPCiZsw0a35Lzy9pNDzWIi 0oE+loqkHnmshE5wTtaayRjaCtPmNjC/wlPyM5ELsDuY/gcSFt2JLAdbez//krsKtGx6 +zeucJrclaAV42SsgLMu85huZiLolUuufavyoo8mm9GDoL0WlKhSd6D+hvVc2DT1x1nD cQuw== X-Gm-Message-State: AC+VfDwMPf2yaepoCy+DNeh3gqgF+mIobzwYdDWaM/f/WhPR5tlqI6hZ +28zicKZJi4Y2jrGoKRESrgziEepDrdhpjf9iHrBoxTn X-Received: by 2002:a17:907:a412:b0:989:d9d:d90f with SMTP id sg18-20020a170907a41200b009890d9dd90fmr1541158ejc.67.1687259318985; Tue, 20 Jun 2023 04:08:38 -0700 (PDT) Received: from stoup.lan ([176.176.183.29]) by smtp.gmail.com with ESMTPSA id x17-20020a170906711100b009884f015a44sm1170687ejj.49.2023.06.20.04.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 04:08:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: berrange@redhat.com, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 29/37] crypto: Add aesdec_ISB_ISR_AK_IMC Date: Tue, 20 Jun 2023 13:07:50 +0200 Message-Id: <20230620110758.787479-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230620110758.787479-1-richard.henderson@linaro.org> References: <20230620110758.787479-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-ej1-x62f.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=unavailable 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. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Acked-by: Daniel P. Berrangé --- 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 68cec14950..ffd8ec6fa8 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 53696e8953..2676faa962 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1576,6 +1576,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. */