]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix integer truncation in ppc_aes_gcm_crypt
authorScott <scott@elyanlabs.ai>
Mon, 16 Mar 2026 03:53:04 +0000 (22:53 -0500)
committerTomas Mraz <tomas@openssl.foundation>
Tue, 17 Mar 2026 09:44:56 +0000 (10:44 +0100)
The assembly functions ppc_aes_gcm_encrypt and ppc_aes_gcm_decrypt
return size_t, but their return values were stored in int variables,
causing truncation on PPC64 where size_t is 64-bit. This could lead
to incorrect results when processing inputs larger than 2GB via
EVP_Cipher() which accepts unsigned int lengths.

Change the types of s and ndone from int to size_t to match the
function return type and the return type of ppc_aes_gcm_crypt itself.

Tested on POWER8 S824 (ppc64le) — all EVP and cipher tests pass,
AES-128-GCM benchmarks at 2.94 GB/s with hardware acceleration.

CLA: trivial

Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
MergeDate: Tue Mar 17 09:44:33 2026
(Merged from https://github.com/openssl/openssl/pull/30437)

(cherry picked from commit e443447588640d099a3e2f1001cf67dab921f935)

providers/implementations/ciphers/cipher_aes_gcm_hw_ppc.inc

index 153eb798917164e1fbd2366551248dd3986b17b1..9383ec0812f896f631c62a6c7561d76e4a320d3b 100644 (file)
@@ -44,8 +44,8 @@ static inline u32 add32TOU(unsigned char buf[4], u32 n)
 static size_t ppc_aes_gcm_crypt(const unsigned char *in, unsigned char *out, size_t len,
                                 const void *key, unsigned char ivec[16], u64 *Xi, int encrypt)
 {
-    int s = 0;
-    int ndone = 0;
+    size_t s = 0;
+    size_t ndone = 0;
     int ctr_reset = 0;
     u64 blocks_unused;
     u64 nb = len / 16;