Mercurial > dropbear
comparison libtommath/bn_mp_from_sbin.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_FROM_SBIN_C | |
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis */ | |
4 /* SPDX-License-Identifier: Unlicense */ | |
5 | |
6 /* read signed bin, big endian, first byte is 0==positive or 1==negative */ | |
7 mp_err mp_from_sbin(mp_int *a, const unsigned char *buf, size_t size) | |
8 { | |
9 mp_err err; | |
10 | |
11 /* read magnitude */ | |
12 if ((err = mp_from_ubin(a, buf + 1, size - 1u)) != MP_OKAY) { | |
13 return err; | |
14 } | |
15 | |
16 /* first byte is 0 for positive, non-zero for negative */ | |
17 if (buf[0] == (unsigned char)0) { | |
18 a->sign = MP_ZPOS; | |
19 } else { | |
20 a->sign = MP_NEG; | |
21 } | |
22 | |
23 return MP_OKAY; | |
24 } | |
25 #endif |