2020-12-28 21:40:37 +00:00
|
|
|
#include "tommath_private.h"
|
2014-12-10 21:56:49 +00:00
|
|
|
#ifdef BN_MP_INIT_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
|
|
|
|
|
|
|
/* init a new mp_int */
|
2020-12-28 21:40:37 +00:00
|
|
|
mp_err mp_init(mp_int *a)
|
2014-12-10 21:56:49 +00:00
|
|
|
{
|
2020-12-28 21:40:37 +00:00
|
|
|
/* allocate memory required and clear it */
|
|
|
|
a->dp = (mp_digit *) MP_CALLOC((size_t)MP_PREC, sizeof(mp_digit));
|
|
|
|
if (a->dp == NULL) {
|
|
|
|
return MP_MEM;
|
|
|
|
}
|
2014-12-10 21:56:49 +00:00
|
|
|
|
2020-12-28 21:40:37 +00:00
|
|
|
/* set the used to zero, allocated digits to the default precision
|
|
|
|
* and sign to positive */
|
|
|
|
a->used = 0;
|
|
|
|
a->alloc = MP_PREC;
|
|
|
|
a->sign = MP_ZPOS;
|
2014-12-10 21:56:49 +00:00
|
|
|
|
2020-12-28 21:40:37 +00:00
|
|
|
return MP_OKAY;
|
2014-12-10 21:56:49 +00:00
|
|
|
}
|
|
|
|
#endif
|