Skip to content
Newer
Older
100644 42 lines (36 sloc) 1.02 KB
e549ccf added libtommath-0.32
Tom St Denis authored Oct 29, 2004
1 #include <tommath.h>
2 #ifdef BN_MP_READ_SIGNED_BIN_C
57354e1 added libtommath-0.12
Tom St Denis authored Feb 28, 2003
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis
4 *
c1da6aa added libtommath-0.25
Tom St Denis authored Aug 5, 2003
5 * LibTomMath is a library that provides multiple-precision
57354e1 added libtommath-0.12
Tom St Denis authored Feb 28, 2003
6 * integer arithmetic as well as number theoretic functionality.
7 *
c1da6aa added libtommath-0.25
Tom St Denis authored Aug 5, 2003
8 * The library was designed directly after the MPI library by
57354e1 added libtommath-0.12
Tom St Denis authored Feb 28, 2003
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 *
333aebc added libtommath-0.41
Tom St Denis authored Apr 18, 2007
15 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
57354e1 added libtommath-0.12
Tom St Denis authored Feb 28, 2003
16 */
17
18 /* read signed bin, big endian, first byte is 0==positive or 1==negative */
9294e79 added libtommath-0.36
Tom St Denis authored Aug 1, 2005
19 int mp_read_signed_bin (mp_int * a, const unsigned char *b, int c)
57354e1 added libtommath-0.12
Tom St Denis authored Feb 28, 2003
20 {
b66471f added libtommath-0.13
Tom St Denis authored Feb 28, 2003
21 int res;
57354e1 added libtommath-0.12
Tom St Denis authored Feb 28, 2003
22
6e73234 added libtommath-0.26
Tom St Denis authored Aug 29, 2003
23 /* read magnitude */
57354e1 added libtommath-0.12
Tom St Denis authored Feb 28, 2003
24 if ((res = mp_read_unsigned_bin (a, b + 1, c - 1)) != MP_OKAY) {
25 return res;
26 }
6e73234 added libtommath-0.26
Tom St Denis authored Aug 29, 2003
27
28 /* first byte is 0 for positive, non-zero for negative */
29 if (b[0] == 0) {
30 a->sign = MP_ZPOS;
31 } else {
32 a->sign = MP_NEG;
33 }
34
57354e1 added libtommath-0.12
Tom St Denis authored Feb 28, 2003
35 return MP_OKAY;
36 }
e549ccf added libtommath-0.32
Tom St Denis authored Oct 29, 2004
37 #endif
9294e79 added libtommath-0.36
Tom St Denis authored Aug 1, 2005
38
39 /* $Source$ */
40 /* $Revision$ */
41 /* $Date$ */
Something went wrong with that request. Please try again.