1
0
mirror of http://galexander.org/git/simplesshd.git synced 2024-11-15 19:48:56 +00:00
simplesshd/dropbear/libtommath/bn_mp_init_copy.c

22 lines
445 B
C
Raw Normal View History

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