Remove building with NOCRYPTO option
[minix.git] / crypto / external / bsd / heimdal / dist / lib / hcrypto / libtommath / bn_mp_copy.c
blob1ddfa92a9b9b29ee1bffeccc3388db86e341ca0a
1 /* $NetBSD: bn_mp_copy.c,v 1.1.1.2 2014/04/24 12:45:31 pettai Exp $ */
3 #include <tommath.h>
4 #ifdef BN_MP_COPY_C
5 /* LibTomMath, multiple-precision integer library -- Tom St Denis
7 * LibTomMath is a library that provides multiple-precision
8 * integer arithmetic as well as number theoretic functionality.
10 * The library was designed directly after the MPI library by
11 * Michael Fromberger but has been written from scratch with
12 * additional optimizations in place.
14 * The library is free for all purposes without any express
15 * guarantee it works.
17 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
20 /* copy, b = a */
21 int
22 mp_copy (mp_int * a, mp_int * b)
24 int res, n;
26 /* if dst == src do nothing */
27 if (a == b) {
28 return MP_OKAY;
31 /* grow dest */
32 if (b->alloc < a->used) {
33 if ((res = mp_grow (b, a->used)) != MP_OKAY) {
34 return res;
38 /* zero b and copy the parameters over */
40 register mp_digit *tmpa, *tmpb;
42 /* pointer aliases */
44 /* source */
45 tmpa = a->dp;
47 /* destination */
48 tmpb = b->dp;
50 /* copy all the digits */
51 for (n = 0; n < a->used; n++) {
52 *tmpb++ = *tmpa++;
55 /* clear high digits */
56 for (; n < b->used; n++) {
57 *tmpb++ = 0;
61 /* copy used count and sign */
62 b->used = a->used;
63 b->sign = a->sign;
64 return MP_OKAY;
66 #endif
68 /* Source: /cvs/libtom/libtommath/bn_mp_copy.c,v */
69 /* Revision: 1.4 */
70 /* Date: 2006/12/28 01:25:13 */