bn_mp_init.c 572 B

1234567891011121314151617181920212223
  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. /* init a new mp_int */
  6. mp_err mp_init(mp_int *a)
  7. {
  8. /* allocate memory required and clear it */
  9. a->dp = (mp_digit *) MP_CALLOC((size_t)MP_PREC, sizeof(mp_digit));
  10. if (a->dp == NULL) {
  11. return MP_MEM;
  12. }
  13. /* set the used to zero, allocated digits to the default precision
  14. * and sign to positive */
  15. a->used = 0;
  16. a->alloc = MP_PREC;
  17. a->sign = MP_ZPOS;
  18. return MP_OKAY;
  19. }
  20. #endif