From a33b5fdaa6df6faaf1a3fabbd6a4937e8249ee69 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Tue, 12 Aug 2025 10:00:40 +0000 Subject: Add const to bignum_*() function calls. Now that s2n-bignum has marked various inputs as const, we can do the same. In most cases we were casting away const, which we no longer need to do. --- src/lib/libcrypto/bn/arch/amd64/bn_arch.c | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c index 8eb3670def..38a4350d17 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c +++ b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_arch.c,v 1.8 2025/08/05 15:01:13 jsing Exp $ */ +/* $OpenBSD: bn_arch.c,v 1.9 2025/08/12 10:00:40 jsing Exp $ */ /* * Copyright (c) 2023 Joel Sing * @@ -26,8 +26,8 @@ BN_ULONG bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, int b_len) { - return bignum_add(r_len, (uint64_t *)r, a_len, (uint64_t *)a, - b_len, (uint64_t *)b); + return bignum_add(r_len, (uint64_t *)r, a_len, (const uint64_t *)a, + b_len, (const uint64_t *)b); } #endif @@ -36,8 +36,8 @@ bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, BN_ULONG bn_add_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) { - return bignum_add(n, (uint64_t *)rd, n, (uint64_t *)ad, n, - (uint64_t *)bd); + return bignum_add(n, (uint64_t *)rd, n, (const uint64_t *)ad, n, + (const uint64_t *)bd); } #endif @@ -46,8 +46,8 @@ BN_ULONG bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, int b_len) { - return bignum_sub(r_len, (uint64_t *)r, a_len, (uint64_t *)a, - b_len, (uint64_t *)b); + return bignum_sub(r_len, (uint64_t *)r, a_len, (const uint64_t *)a, + b_len, (const uint64_t *)b); } #endif @@ -55,8 +55,8 @@ bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, BN_ULONG bn_sub_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) { - return bignum_sub(n, (uint64_t *)rd, n, (uint64_t *)ad, n, - (uint64_t *)bd); + return bignum_sub(n, (uint64_t *)rd, n, (const uint64_t *)ad, n, + (const uint64_t *)bd); } #endif @@ -64,7 +64,7 @@ bn_sub_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) BN_ULONG bn_mul_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) { - return bignum_cmadd(num, (uint64_t *)rd, w, num, (uint64_t *)ad); + return bignum_cmadd(num, (uint64_t *)rd, w, num, (const uint64_t *)ad); } #endif @@ -72,7 +72,7 @@ bn_mul_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) BN_ULONG bn_mul_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) { - return bignum_cmul(num, (uint64_t *)rd, w, num, (uint64_t *)ad); + return bignum_cmul(num, (uint64_t *)rd, w, num, (const uint64_t *)ad); } #endif @@ -81,7 +81,7 @@ void bn_mul_comba4(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd) { /* XXX - consider using non-alt on CPUs that have the ADX extension. */ - bignum_mul_4_8_alt((uint64_t *)rd, (uint64_t *)ad, (uint64_t *)bd); + bignum_mul_4_8_alt((uint64_t *)rd, (const uint64_t *)ad, (const uint64_t *)bd); } #endif @@ -90,7 +90,7 @@ void bn_mul_comba8(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd) { /* XXX - consider using non-alt on CPUs that have the ADX extension. */ - bignum_mul_8_16_alt((uint64_t *)rd, (uint64_t *)ad, (uint64_t *)bd); + bignum_mul_8_16_alt((uint64_t *)rd, (const uint64_t *)ad, (const uint64_t *)bd); } #endif @@ -98,7 +98,7 @@ bn_mul_comba8(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd) int bn_sqr(BIGNUM *r, const BIGNUM *a, int r_len, BN_CTX *ctx) { - bignum_sqr(r_len, (uint64_t *)r->d, a->top, (uint64_t *)a->d); + bignum_sqr(r_len, (uint64_t *)r->d, a->top, (const uint64_t *)a->d); return 1; } @@ -109,7 +109,7 @@ void bn_sqr_comba4(BN_ULONG *rd, const BN_ULONG *ad) { /* XXX - consider using non-alt on CPUs that have the ADX extension. */ - bignum_sqr_4_8_alt((uint64_t *)rd, (uint64_t *)ad); + bignum_sqr_4_8_alt((uint64_t *)rd, (const uint64_t *)ad); } #endif @@ -118,7 +118,7 @@ void bn_sqr_comba8(BN_ULONG *rd, const BN_ULONG *ad) { /* XXX - consider using non-alt on CPUs that have the ADX extension. */ - bignum_sqr_8_16_alt((uint64_t *)rd, (uint64_t *)ad); + bignum_sqr_8_16_alt((uint64_t *)rd, (const uint64_t *)ad); } #endif -- cgit v1.2.3-55-g6feb