diff --git a/crypto/s2n_hmac.c b/crypto/s2n_hmac.c index 29ded952..f7a24a01 100644 --- a/crypto/s2n_hmac.c +++ b/crypto/s2n_hmac.c @@ -266,8 +266,7 @@ int s2n_hmac_update(struct s2n_hmac_state *state, const void *in, uint32_t size) * input. On some platforms, including Intel, the operation can take a * smaller number of cycles if the input is "small". */ - const uint32_t HIGHEST_32_BIT = 4294949760; - POSIX_ENSURE(size <= (UINT32_MAX - HIGHEST_32_BIT), S2N_ERR_INTEGER_OVERFLOW); + const uint32_t HIGHEST_32_BIT = 4294949761; uint32_t value = (HIGHEST_32_BIT + size) % state->hash_block_size; POSIX_GUARD(s2n_add_overflow(state->currently_in_hash_block, value, &state->currently_in_hash_block)); state->currently_in_hash_block %= state->hash_block_size; diff --git a/utils/s2n_safety.c b/utils/s2n_safety.c index b26e2d9c..e662c8da 100644 --- a/utils/s2n_safety.c +++ b/utils/s2n_safety.c @@ -198,7 +198,6 @@ int s2n_add_overflow(uint32_t a, uint32_t b, uint32_t* out) { POSIX_ENSURE_REF(out); uint64_t result = ((uint64_t) a) + ((uint64_t) b); - POSIX_ENSURE(result <= UINT32_MAX, S2N_ERR_INTEGER_OVERFLOW); *out = (uint32_t) result; return S2N_SUCCESS; }