From d3e5e9fdf64f7a4198a73244ab3900ca8ffbacbe Mon Sep 17 00:00:00 2001 From: Lynn Boger Date: Mon, 25 Mar 2024 11:14:27 -0500 Subject: [PATCH] crypto/aes: fix regression for ppc64x CL 561080 introduced some failures for CBC and GCM crypto tests that are run during a build resulting in dashboard failures. Tests that are failing: - TestCBCEncrypterAES - TestCBCDecrypterAES - TestAESGCM - TestGCMCounterWrap - TestGCMAsm This fixes those failures. Change-Id: I90d6f8d279a3051cf951a1a9628afb8d0b5c2f17 Reviewed-on: https://go-review.googlesource.com/c/go/+/574076 Reviewed-by: Marten Seemann Run-TryBot: Emmanuel Odeke LUCI-TryBot-Result: Go LUCI Run-TryBot: Lynn Boger TryBot-Result: Gopher Robot Reviewed-by: Paul Murphy Reviewed-by: Than McIntosh Reviewed-by: Eli Bendersky Auto-Submit: Than McIntosh Reviewed-by: Michael Knyszek --- src/crypto/aes/cbc_ppc64x.go | 4 ++-- src/crypto/aes/gcm_ppc64x.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/crypto/aes/cbc_ppc64x.go b/src/crypto/aes/cbc_ppc64x.go index 2cb9606e58..d5b491e8e1 100644 --- a/src/crypto/aes/cbc_ppc64x.go +++ b/src/crypto/aes/cbc_ppc64x.go @@ -59,9 +59,9 @@ func (x *cbc) CryptBlocks(dst, src []byte) { } if len(src) > 0 { if x.enc == cbcEncrypt { - cryptBlocksChain(&src[0], &dst[0], len(src), &x.b.enc[0], &x.iv[0], x.enc, len(x.b.enc)/4-1) + cryptBlocksChain(&src[0], &dst[0], len(src), &x.b.enc[0], &x.iv[0], x.enc, int(x.b.l)/4-1) } else { - cryptBlocksChain(&src[0], &dst[0], len(src), &x.b.dec[0], &x.iv[0], x.enc, len(x.b.dec)/4-1) + cryptBlocksChain(&src[0], &dst[0], len(src), &x.b.dec[0], &x.iv[0], x.enc, int(x.b.l)/4-1) } } } diff --git a/src/crypto/aes/gcm_ppc64x.go b/src/crypto/aes/gcm_ppc64x.go index f206b47607..20b0eade0a 100644 --- a/src/crypto/aes/gcm_ppc64x.go +++ b/src/crypto/aes/gcm_ppc64x.go @@ -119,7 +119,8 @@ func (g *gcmAsm) deriveCounter(counter *[gcmBlockSize]byte, nonce []byte) { // counterCryptASM implements counterCrypt which then allows the loop to // be unrolled and optimized. func (g *gcmAsm) counterCrypt(out, in []byte, counter *[gcmBlockSize]byte) { - counterCryptASM(len(g.cipher.enc)/4-1, out, in, counter, &g.cipher.enc[0]) + counterCryptASM(int(g.cipher.l)/4-1, out, in, counter, &g.cipher.enc[0]) + } // increments the rightmost 32-bits of the count value by 1.