1
0
mirror of http://galexander.org/git/simplesshd.git synced 2024-11-15 19:48:56 +00:00
simplesshd/dropbear/libtommath/bn_mp_shrink.c

23 lines
629 B
C
Raw Normal View History

2020-12-28 21:40:37 +00:00
#include "tommath_private.h"
2014-12-10 21:56:49 +00:00
#ifdef BN_MP_SHRINK_C
2020-12-28 21:40:37 +00:00
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */
2014-12-10 21:56:49 +00:00
/* shrink a bignum */
2020-12-28 21:40:37 +00:00
mp_err mp_shrink(mp_int *a)
2014-12-10 21:56:49 +00:00
{
2020-12-28 21:40:37 +00:00
mp_digit *tmp;
int alloc = MP_MAX(MP_MIN_PREC, a->used);
if (a->alloc != alloc) {
if ((tmp = (mp_digit *) MP_REALLOC(a->dp,
(size_t)a->alloc * sizeof(mp_digit),
(size_t)alloc * sizeof(mp_digit))) == NULL) {
return MP_MEM;
}
a->dp = tmp;
a->alloc = alloc;
}
return MP_OKAY;
2014-12-10 21:56:49 +00:00
}
#endif