Mercurial > dropbear
comparison libtommath/bn_mp_reduce_2k_setup_l.c @ 1739:13d834efc376 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 15 Oct 2020 19:55:15 +0800 |
parents | 1051e4eea25a |
children |
comparison
equal
deleted
inserted
replaced
1562:768ebf737aa0 | 1739:13d834efc376 |
---|---|
1 #include <tommath_private.h> | 1 #include "tommath_private.h" |
2 #ifdef BN_MP_REDUCE_2K_SETUP_L_C | 2 #ifdef BN_MP_REDUCE_2K_SETUP_L_C |
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis | 3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */ |
4 * | 4 /* SPDX-License-Identifier: Unlicense */ |
5 * LibTomMath is a library that provides multiple-precision | |
6 * integer arithmetic as well as number theoretic functionality. | |
7 * | |
8 * The library was designed directly after the MPI library by | |
9 * Michael Fromberger but has been written from scratch with | |
10 * additional optimizations in place. | |
11 * | |
12 * The library is free for all purposes without any express | |
13 * guarantee it works. | |
14 * | |
15 * Tom St Denis, [email protected], http://libtom.org | |
16 */ | |
17 | 5 |
18 /* determines the setup value */ | 6 /* determines the setup value */ |
19 int mp_reduce_2k_setup_l(mp_int *a, mp_int *d) | 7 mp_err mp_reduce_2k_setup_l(const mp_int *a, mp_int *d) |
20 { | 8 { |
21 int res; | 9 mp_err err; |
22 mp_int tmp; | 10 mp_int tmp; |
23 | 11 |
24 if ((res = mp_init(&tmp)) != MP_OKAY) { | 12 if ((err = mp_init(&tmp)) != MP_OKAY) { |
25 return res; | 13 return err; |
26 } | 14 } |
27 | 15 |
28 if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) { | 16 if ((err = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) { |
29 goto ERR; | 17 goto LBL_ERR; |
30 } | 18 } |
31 | 19 |
32 if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) { | 20 if ((err = s_mp_sub(&tmp, a, d)) != MP_OKAY) { |
33 goto ERR; | 21 goto LBL_ERR; |
34 } | 22 } |
35 | 23 |
36 ERR: | 24 LBL_ERR: |
37 mp_clear(&tmp); | 25 mp_clear(&tmp); |
38 return res; | 26 return err; |
39 } | 27 } |
40 #endif | 28 #endif |
41 | |
42 /* ref: $Format:%D$ */ | |
43 /* git commit: $Format:%H$ */ | |
44 /* commit time: $Format:%ai$ */ |