2020-12-28 21:40:37 +00:00
|
|
|
#include "tommath_private.h"
|
2014-12-10 21:56:49 +00:00
|
|
|
#ifdef BN_MP_INIT_COPY_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
|
|
|
|
|
|
|
/* creates "a" then copies b into it */
|
2020-12-28 21:40:37 +00:00
|
|
|
mp_err mp_init_copy(mp_int *a, const mp_int *b)
|
2014-12-10 21:56:49 +00:00
|
|
|
{
|
2020-12-28 21:40:37 +00:00
|
|
|
mp_err err;
|
2014-12-10 21:56:49 +00:00
|
|
|
|
2020-12-28 21:40:37 +00:00
|
|
|
if ((err = mp_init_size(a, b->used)) != MP_OKAY) {
|
|
|
|
return err;
|
|
|
|
}
|
2019-06-09 20:44:26 +00:00
|
|
|
|
2020-12-28 21:40:37 +00:00
|
|
|
if ((err = mp_copy(b, a)) != MP_OKAY) {
|
|
|
|
mp_clear(a);
|
|
|
|
}
|
2019-06-09 20:44:26 +00:00
|
|
|
|
2020-12-28 21:40:37 +00:00
|
|
|
return err;
|
2014-12-10 21:56:49 +00:00
|
|
|
}
|
|
|
|
#endif
|