Mercurial > dropbear
comparison libtommath/bn_mp_signed_rsh.c @ 1692:1051e4eea25a
Update LibTomMath to 1.2.0 (#84)
* update C files
* update other files
* update headers
* update makefiles
* remove mp_set/get_double()
* use ltm 1.2.0 API
* update ltm_desc
* use bundled tommath if system-tommath is too old
* XMALLOC etc. were changed to MP_MALLOC etc.
author | Steffen Jaeckel <s@jaeckel.eu> |
---|---|
date | Tue, 26 May 2020 17:36:47 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1691:2d3745d58843 | 1692:1051e4eea25a |
---|---|
1 #include "tommath_private.h" | |
2 #ifdef BN_MP_SIGNED_RSH_C | |
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */ | |
4 /* SPDX-License-Identifier: Unlicense */ | |
5 | |
6 /* shift right by a certain bit count with sign extension */ | |
7 mp_err mp_signed_rsh(const mp_int *a, int b, mp_int *c) | |
8 { | |
9 mp_err res; | |
10 if (a->sign == MP_ZPOS) { | |
11 return mp_div_2d(a, b, c, NULL); | |
12 } | |
13 | |
14 res = mp_add_d(a, 1uL, c); | |
15 if (res != MP_OKAY) { | |
16 return res; | |
17 } | |
18 | |
19 res = mp_div_2d(c, b, c, NULL); | |
20 return (res == MP_OKAY) ? mp_sub_d(c, 1uL, c) : res; | |
21 } | |
22 #endif |