libtommath: Fix possible integer overflow CVE-2023-36328
[heimdal.git] / lib / hcrypto / libtommath / bn_mp_set.c
blob44ac6df571c09a506d457eb28cf6ab0baffac483
1 #include "tommath_private.h"
2 #ifdef BN_MP_SET_C
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
6 /* set to a digit */
7 void mp_set(mp_int *a, mp_digit b)
9 a->dp[0] = b & MP_MASK;
10 a->sign = MP_ZPOS;
11 a->used = (a->dp[0] != 0u) ? 1 : 0;
12 MP_ZERO_DIGITS(a->dp + a->used, a->alloc - a->used);
14 #endif