1 #include "tommath_private.h"
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */
4 /* SPDX-License-Identifier: Unlicense */
7 mp_err mp_copy(const mp_int *a, mp_int *b)
10 mp_digit *tmpa, *tmpb;
13 /* if dst == src do nothing */
19 if (b->alloc < a->used) {
20 if ((err = mp_grow(b, a->used)) != MP_OKAY) {
25 /* zero b and copy the parameters over */
34 /* copy all the digits */
35 for (n = 0; n < a->used; n++) {
39 /* clear high digits */
40 MP_ZERO_DIGITS(tmpb, b->used - n);
42 /* copy used count and sign */