From 485e95e28f88263129557e462e78bc980255bbe1 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Tue, 22 Apr 2025 14:01:07 +0000 Subject: Use crypto_load_be32toh()/crypto_store_htobe32() instead of GETU32/PUTU32. ok tb@ --- src/lib/libcrypto/modes/ctr128.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/lib/libcrypto/modes/ctr128.c') diff --git a/src/lib/libcrypto/modes/ctr128.c b/src/lib/libcrypto/modes/ctr128.c index 9d1be0757b..c2ce1bda21 100644 --- a/src/lib/libcrypto/modes/ctr128.c +++ b/src/lib/libcrypto/modes/ctr128.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ctr128.c,v 1.14 2025/04/21 16:01:18 jsing Exp $ */ +/* $OpenBSD: ctr128.c,v 1.15 2025/04/22 14:01:07 jsing Exp $ */ /* ==================================================================== * Copyright (c) 2008 The OpenSSL Project. All rights reserved. * @@ -54,6 +54,7 @@ #include +#include "crypto_internal.h" #include "modes_local.h" /* NOTE: the IV/counter CTR mode is big-endian. The code itself @@ -212,7 +213,8 @@ CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out, n = (n + 1) % 16; } - ctr32 = GETU32(ivec + 12); + ctr32 = crypto_load_be32toh(&ivec[12]); + while (len >= 16) { size_t blocks = len/16; /* @@ -236,7 +238,7 @@ CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out, } (*func)(in, out, blocks, key, ivec); /* (*ctr) does not update ivec, caller does: */ - PUTU32(ivec + 12, ctr32); + crypto_store_htobe32(&ivec[12], ctr32); /* ... overflow was detected, propagate carry. */ if (ctr32 == 0) ctr96_inc(ivec); @@ -249,7 +251,7 @@ CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out, memset(ecount_buf, 0, 16); (*func)(ecount_buf, ecount_buf, 1, key, ivec); ++ctr32; - PUTU32(ivec + 12, ctr32); + crypto_store_htobe32(&ivec[12], ctr32); if (ctr32 == 0) ctr96_inc(ivec); while (len--) { -- cgit v1.2.3-55-g6feb