bn_mp_init_copy.c 445 B

123456789101112131415161718192021
  1. #include "tommath_private.h"
  2. #ifdef BN_MP_INIT_COPY_C
  3. /* LibTomMath, multiple-precision integer library -- Tom St Denis */
  4. /* SPDX-License-Identifier: Unlicense */
  5. /* creates "a" then copies b into it */
  6. mp_err mp_init_copy(mp_int *a, const mp_int *b)
  7. {
  8. mp_err err;
  9. if ((err = mp_init_size(a, b->used)) != MP_OKAY) {
  10. return err;
  11. }
  12. if ((err = mp_copy(b, a)) != MP_OKAY) {
  13. mp_clear(a);
  14. }
  15. return err;
  16. }
  17. #endif