From patchwork Sat Jun 3 02:33:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 688760 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d8a:0:0:0:0:0 with SMTP id b10csp1164235wru; Fri, 2 Jun 2023 19:35:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5w8GabdtcYTwA/vevAK8fwtoWSiS0oYpZwTiioW6UzLT0OyUf7954tAZNfRD2dWcaLnLLI X-Received: by 2002:a05:620a:2489:b0:75b:23a1:3687 with SMTP id i9-20020a05620a248900b0075b23a13687mr18540041qkn.72.1685759724007; Fri, 02 Jun 2023 19:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685759723; cv=none; d=google.com; s=arc-20160816; b=Sl7irVjM89rEffsg5zFu2nNxP52zvJ4VxgKCs4lKVTmTrIBIqsdCJYh3kyvgdrWysA Lvs9KIgQouJIDtXmJ1vXTUf7Bd55Qy7r8XPS4e+sElEDc9VfwmAIVHGPQD56rQuXfFwe vhviTg42c/3YUZTiG30iJyn5Z0mpwWCWgFDHnzXmh+Xn7gUvTed2VVTXYUEu7gxD84jH SS6QhOCivQUN1gRcDIuPb3A4/mn3hV0VMVFDRkq7PR26jgirQQ3gi4M6Wi+rNwUcbQKB OXjYEmqYRVUUGA7Sx9E6EJI2DnvlkzSJ1HnyYnV+m2b3cAMjGPLWjGblR6pmzknavGbm KE0A== 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=tqOStWj9wy4vSlw/JP9FJsk77s8bELBPoB35SE08RZM=; b=wvHEsrCPbH/tJkVp9xSmyFzCmVcn4xP2vsh97LIybQh5QvPpDKJ2vM3rLvkl6j4qyd 5U6oWE3NGhs7e0Z4mC6xAOZ/lGcJy96YELtDzfrxxm2z4JhcNWJc4e/CT+YuEfZdKq6K GIHNpE2ERxu+iayPfZnQ97E1wcdsMGZnO6395EY7YpDzXLtv6hner9vKmm+NB0zbJKUg HtTqgFGlBkyR0Zz6O1h5DKDISsw5BKWdIryL/+K2RFL/Byw/nH7U6QEBwL4ZHgWdlUeT 7Z8gvWwfA9aTKq8u6+x6EGJ6k4rdObrN2BY0+l1EDb/9XMTr7p6lVaeaIexDUmhNopHK tKxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WulAntH4; 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 z27-20020a05620a101b00b0074ded57f5e0si1611125qkj.409.2023.06.02.19.35.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Jun 2023 19:35:23 -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=WulAntH4; 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 1q5H6Q-0000T6-FK; Fri, 02 Jun 2023 22:34:50 -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 1q5H6E-0000Jz-Bl for qemu-devel@nongnu.org; Fri, 02 Jun 2023 22:34:39 -0400 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q5H67-0004hU-IL for qemu-devel@nongnu.org; Fri, 02 Jun 2023 22:34:37 -0400 Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-5585f2f070bso1975903eaf.0 for ; Fri, 02 Jun 2023 19:34:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685759670; x=1688351670; 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=tqOStWj9wy4vSlw/JP9FJsk77s8bELBPoB35SE08RZM=; b=WulAntH4HE494wgcKNFlm7uZR/9kx2mCN6tD/4dh5C3ACPdKg7Dw3/yaDQ8fZNWrBC 8iLvOMXWVKEb6g2j8snAnRY9/Hmh5GKCgQrAfglN8ZpAs0jtsX1U1zVQGQTTYPiAtFni vOhaR1OKU3CAd4u+QX5zLDOWHGRJh9FHV0wpWG6YgDBPAr549mCeTvKN5k6al/Al6Ki9 Pt05l+3RTE1AsWecOamac0yfGmjIwohCg6sdsxm6Em/CLO9bd/YWCKSVlZy/SmIN3spN IHg8LIrLnf02h8bQkauGTexDzowD8L9O/i9KXk4uiBWH4dZyfOC+SqUnib2I0iXZDCLI sEvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685759670; x=1688351670; 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=tqOStWj9wy4vSlw/JP9FJsk77s8bELBPoB35SE08RZM=; b=MTYeb+njlBtRLVCUX7NMeLFK0CxKh5IApaogj8ok4vWmHmIdrtPJz3/wajuTgCOE1a qHucmvMT/l9i+usyPU3W1Q9UlnfVaoNXZDkteB6iiI+gD+XqoBt7sG9f+MWoOV4MP6BK PzNXXS87QSTW9EvZDBU3CQo7K+I0gJkgW1zFnUihGizWJLpehZczSLO6hov/iJDrB6z1 QnXEwO2yCD+xLYp04EIgaiLi6Qwoqw4VXr51cSX/Ex5qZkD4xDHgJJ1mHCnw0S2x0JIW hDr+2x/+5ZxA6xoDhW+aFX+qG5wwcHkZPAwPIs+ILvnMXqsTselgEk5UHkuMsickvpQV /C7w== X-Gm-Message-State: AC+VfDxJdNtHksv9rZ0vosFW0et7r+PRtbFnHGQsO9f/GMmwmTNsq79i DjcWnHFdexe6N4nT+IMLrJadGb6/SzfJOKTiWF8= X-Received: by 2002:a05:6358:7208:b0:125:83c8:72f6 with SMTP id h8-20020a056358720800b0012583c872f6mr15392888rwa.0.1685759670394; Fri, 02 Jun 2023 19:34:30 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:66a6:82c2:d794:68f6]) by smtp.gmail.com with ESMTPSA id e91-20020a17090a6fe400b002508d73f4e8sm3914289pjk.57.2023.06.02.19.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 19:34:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: ardb@kernel.org, berrange@redhat.com, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, pbonzini@redhat.com Subject: [PATCH 03/35] crypto/aes: Add constants for ShiftRows, InvShiftRows Date: Fri, 2 Jun 2023 19:33:54 -0700 Message-Id: <20230603023426.1064431-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230603023426.1064431-1-richard.henderson@linaro.org> References: <20230603023426.1064431-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2a; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2a.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 These symbols will avoid the indirection through memory when fully unrolling some new primitives. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- crypto/aes.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/crypto/aes.c b/crypto/aes.c index 72c95c38fb..1309a13e91 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -108,12 +108,58 @@ const uint8_t AES_isbox[256] = { 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D, }; +/* AES ShiftRows, for complete unrolling. */ +enum { + AES_SH_0 = 0x0, + AES_SH_1 = 0x5, + AES_SH_2 = 0xa, + AES_SH_3 = 0xf, + AES_SH_4 = 0x4, + AES_SH_5 = 0x9, + AES_SH_6 = 0xe, + AES_SH_7 = 0x3, + AES_SH_8 = 0x8, + AES_SH_9 = 0xd, + AES_SH_A = 0x2, + AES_SH_B = 0x7, + AES_SH_C = 0xc, + AES_SH_D = 0x1, + AES_SH_E = 0x6, + AES_SH_F = 0xb, +}; + const uint8_t AES_shifts[16] = { - 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11 + AES_SH_0, AES_SH_1, AES_SH_2, AES_SH_3, + AES_SH_4, AES_SH_5, AES_SH_6, AES_SH_7, + AES_SH_8, AES_SH_9, AES_SH_A, AES_SH_B, + AES_SH_C, AES_SH_D, AES_SH_E, AES_SH_F, +}; + +/* AES InvShiftRows, for complete unrolling. */ +enum { + AES_ISH_0 = 0x0, + AES_ISH_1 = 0xd, + AES_ISH_2 = 0xa, + AES_ISH_3 = 0x7, + AES_ISH_4 = 0x4, + AES_ISH_5 = 0x1, + AES_ISH_6 = 0xe, + AES_ISH_7 = 0xb, + AES_ISH_8 = 0x8, + AES_ISH_9 = 0x5, + AES_ISH_A = 0x2, + AES_ISH_B = 0xf, + AES_ISH_C = 0xc, + AES_ISH_D = 0x9, + AES_ISH_E = 0x6, + AES_ISH_F = 0x3, }; const uint8_t AES_ishifts[16] = { - 0, 13, 10, 7, 4, 1, 14, 11, 8, 5, 2, 15, 12, 9, 6, 3 + AES_ISH_0, AES_ISH_1, AES_ISH_2, AES_ISH_3, + AES_ISH_4, AES_ISH_5, AES_ISH_6, AES_ISH_7, + AES_ISH_8, AES_ISH_9, AES_ISH_A, AES_ISH_B, + AES_ISH_C, AES_ISH_D, AES_ISH_E, AES_ISH_F, }; /*