Coverage Report

Created: 2023-03-20 06:28

/src/dropbear/libtommath/bn_mp_init.c
Line
Count
Source (jump to first uncovered line)
1
#include "tommath_private.h"
2
#ifdef BN_MP_INIT_C
3
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
4
/* SPDX-License-Identifier: Unlicense */
5
6
/* init a new mp_int */
7
mp_err mp_init(mp_int *a)
8
12.2k
{
9
   /* allocate memory required and clear it */
10
12.2k
   a->dp = (mp_digit *) MP_CALLOC((size_t)MP_PREC, sizeof(mp_digit));
11
12.2k
   if (a->dp == NULL) {
12
0
      return MP_MEM;
13
0
   }
14
15
   /* set the used to zero, allocated digits to the default precision
16
    * and sign to positive */
17
12.2k
   a->used  = 0;
18
12.2k
   a->alloc = MP_PREC;
19
12.2k
   a->sign  = MP_ZPOS;
20
21
12.2k
   return MP_OKAY;
22
12.2k
}
23
#endif