From patchwork Fri Jun 9 02:23:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 690861 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp598090wru; Thu, 8 Jun 2023 19:27:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7m6CB+majs9Y6y6fq1G46mEYAibJygM7VHwn4HnYFOot4WA5EttG4CWBtLPEpNk1WofvdI X-Received: by 2002:ad4:5d49:0:b0:623:8d60:da6d with SMTP id jk9-20020ad45d49000000b006238d60da6dmr328083qvb.52.1686277629309; Thu, 08 Jun 2023 19:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686277629; cv=none; d=google.com; s=arc-20160816; b=lE3Ooet/BljX5JqlNSq26qtRNIenWWHx8YZ95sbTvj4qFuljMQP95QIIhhP1LazlqX /002uhcUiFBM8V4eMg/rGD26OVna9n2v4NfRfHwM5uLuT5TvdpILYiDZToJc8u3zA67i q2wx1cp37daq2awQkm0sbCaoJ0ZpecoctlwTdfjCNup/T8CVRWF9IyMhrY4d2SekPSCX f+8UerDnDKmDk0ZoXYlQq5NVSJ67Rf5mMEYXHAtmZmJRANU4rCPqaPtXoChS2VceS3kP 4j/d9oy0qoALEz9x7zxRXs0Z/D0wAlPl+YmUg6hnh3xRalKAZb90Of/w1RpSuHVqf/Cl 2DYw== 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=u7OP8fDbC6urrB2bXAJpW7NX+lGAPWizA7RFbg2xWO8=; b=qgTH0pvfheJKNK/oGynKYitBziET4mF+cHY3ceVF/Mgq3C2N03rubmcMpX5M4LJ8LS tyc+gKmUUIq7a3a+avFS7JGYpUrQBisE4d58YIUx6ysH9AcgVZDuc+5MAnq09/lA9sFW QtWe8PUl4XcITGGuE6dfjvwhd30oieIYiOeOF/kT2/HxLnLOpc3W4Wdvndhb1JF/ua9k bB7e0GYL52WxNEqyRRGQU0/tnpf5cO/uf/BrO0L9CliI6ozcEU6v4TwI7Eh4Y3ZhvPIc WSrt7L5hQU1OdIdD1sg/MoQJKRNhAFFwyWJyXhG22Mbm0bYerVLbs6oWAFHq/nB5PLiI 4vtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JbXj5bj+; 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 jl14-20020ad45e8e000000b006258465cd73si1721359qvb.516.2023.06.08.19.27.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Jun 2023 19:27:09 -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=JbXj5bj+; 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 1q7Rp5-0004bp-JJ; Thu, 08 Jun 2023 22:25:55 -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 1q7RoO-0003DS-2Q for qemu-devel@nongnu.org; Thu, 08 Jun 2023 22:25:13 -0400 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q7Rnl-0005mP-Qg for qemu-devel@nongnu.org; Thu, 08 Jun 2023 22:25:11 -0400 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-39c82204e62so248730b6e.1 for ; Thu, 08 Jun 2023 19:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686277470; x=1688869470; 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=u7OP8fDbC6urrB2bXAJpW7NX+lGAPWizA7RFbg2xWO8=; b=JbXj5bj+aahVo0emTwnL0g2E4Tu3XvyxD9sJBVQ3MP/Ojpli5zXah8QNHtnlhVFYtw vzKhHQzZ/zcOVsmqj57yuoRLtfOJTT7daXYkXFZ2AS3cQ3k+tiPeVMtLMN8+DnV1LJf6 9LAm9Al5cDR6qa/9nTy+Wif6gmLbrmdMADywo9c7tRZlCm/1Bm3SED3vYclz+ezfMJrX o/EEQFR2Ib5bpCjXZ+472vkDl/Za0EfefBcLQG004iJR0eVze0DVrE9ig8Z1gT/4Y+Bu Pn5jjAVxfroMGIjApGEO5t+UUfe/QddyJ+Yw7KA8MopQGz2ghcN9bt+nitcmWpSSXwxC +2QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686277470; x=1688869470; 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=u7OP8fDbC6urrB2bXAJpW7NX+lGAPWizA7RFbg2xWO8=; b=MGBW+wcx3XfRAhX5qbs6ZrxKTCdQLsmDtqDW4ghRPMlV67AktwSaJ2PVMJChoumSyH Kcru7h8wvpbD9aF4cvOma7ljIuNgwAW2C8ZlbySoGiU1M3rv3k4ZRTZLM8qSRBIL1i3I ATnUE3xjgP+RJvEu5af4b32rMVT0l6Je+ayOgy7IC64y84eycbsBr060mPL9wS8UJ+2c sCJYNFfPz2dFu/1A28ZJolOBCkLe44fZncyOXmymsUSWeGak6InsSakflS92aE9uPQ7D D1ZGkOGEooJCIud2D21nC2bfJgxD7aQ3nM8dtiuRZo9atM6yFHsYVxsqg8jS58FPhtu6 cisg== X-Gm-Message-State: AC+VfDwM9aF6mswa58utuxZ2NOlqcBvZvbFQI9WGm7ILVCEwcPQkWUtv XTbWoltJZ0yKNxUB2e7lQ9eIM6PsgFt9idcjDjg= X-Received: by 2002:a05:6808:349:b0:39a:b787:1ae2 with SMTP id j9-20020a056808034900b0039ab7871ae2mr231115oie.52.1686277470630; Thu, 08 Jun 2023 19:24:30 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:b071:df63:5761:f449]) by smtp.gmail.com with ESMTPSA id x25-20020a62fb19000000b0063afb08afeesm1686458pfm.67.2023.06.08.19.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 19:24:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: ardb@kernel.org, berrange@redhat.com, qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com Subject: [PATCH v2 30/38] crypto: Add aesdec_ISB_ISR_AK_IMC Date: Thu, 8 Jun 2023 19:23:53 -0700 Message-Id: <20230609022401.684157-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609022401.684157-1-richard.henderson@linaro.org> References: <20230609022401.684157-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::233; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x233.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. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- host/include/generic/host/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/aes-round.h b/host/include/generic/host/aes-round.h index 16b4447831..c52fea936f 100644 --- a/host/include/generic/host/aes-round.h +++ b/host/include/generic/host/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 31c5f10df6..dd8f49becb 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 b671a3a6fb..f0721ad4a2 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -1564,6 +1564,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. */