Mercurial > dropbear
annotate bn_mp_to_unsigned_bin_n.c @ 201:c0bf626ee437 libtommath
Bringing back the original ltc 0.35 makefile
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 11 May 2005 16:23:24 +0000 |
parents | d8254fc979e9 |
children | 97db060d0ef5 |
rev | line source |
---|---|
190
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
1 #include <tommath.h> |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
2 #ifdef BN_MP_TO_UNSIGNED_BIN_N_C |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
4 * |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
5 * LibTomMath is a library that provides multiple-precision |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
6 * integer arithmetic as well as number theoretic functionality. |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
7 * |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
8 * The library was designed directly after the MPI library by |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
9 * Michael Fromberger but has been written from scratch with |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
10 * additional optimizations in place. |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
11 * |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
12 * The library is free for all purposes without any express |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
13 * guarantee it works. |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
14 * |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
15 * Tom St Denis, [email protected], http://math.libtomcrypt.org |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
16 */ |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
17 |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
18 /* store in unsigned [big endian] format */ |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
19 int mp_to_unsigned_bin_n (mp_int * a, unsigned char *b, unsigned long *outlen) |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
20 { |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
21 if (*outlen < (unsigned long)mp_unsigned_bin_size(a)) { |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
22 return MP_VAL; |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
23 } |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
24 *outlen = mp_unsigned_bin_size(a); |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
25 return mp_to_unsigned_bin(a, b); |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
26 } |
d8254fc979e9
Initial import of libtommath 0.35
Matt Johnston <matt@ucc.asn.au>
parents:
diff
changeset
|
27 #endif |