change some parameters in the library to meet the needs of the website httpbin.org
Fork of MiniTLS-GPL by
math/bin/fp_to_unsigned_bin.c@4:cbaf466d717d, 2014-06-10 (annotated)
- Committer:
- MiniTLS
- Date:
- Tue Jun 10 14:23:09 2014 +0000
- Revision:
- 4:cbaf466d717d
- Parent:
- 0:35aa5be3b78d
Fixes for mbed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MiniTLS | 0:35aa5be3b78d | 1 | /* TomsFastMath, a fast ISO C bignum library. |
MiniTLS | 0:35aa5be3b78d | 2 | * |
MiniTLS | 0:35aa5be3b78d | 3 | * This project is meant to fill in where LibTomMath |
MiniTLS | 0:35aa5be3b78d | 4 | * falls short. That is speed ;-) |
MiniTLS | 0:35aa5be3b78d | 5 | * |
MiniTLS | 0:35aa5be3b78d | 6 | * This project is public domain and free for all purposes. |
MiniTLS | 0:35aa5be3b78d | 7 | * |
MiniTLS | 0:35aa5be3b78d | 8 | * Tom St Denis, tomstdenis@gmail.com |
MiniTLS | 0:35aa5be3b78d | 9 | */ |
MiniTLS | 0:35aa5be3b78d | 10 | #include <tfm.h> |
MiniTLS | 0:35aa5be3b78d | 11 | |
MiniTLS | 0:35aa5be3b78d | 12 | void fp_to_unsigned_bin(fp_int *a, unsigned char *b) |
MiniTLS | 0:35aa5be3b78d | 13 | { |
MiniTLS | 0:35aa5be3b78d | 14 | int x; |
MiniTLS | 0:35aa5be3b78d | 15 | fp_int t; |
MiniTLS | 0:35aa5be3b78d | 16 | |
MiniTLS | 0:35aa5be3b78d | 17 | fp_init_copy(&t, a); |
MiniTLS | 0:35aa5be3b78d | 18 | |
MiniTLS | 0:35aa5be3b78d | 19 | x = 0; |
MiniTLS | 0:35aa5be3b78d | 20 | while (fp_iszero (&t) == FP_NO) { |
MiniTLS | 0:35aa5be3b78d | 21 | b[x++] = (unsigned char) (t.dp[0] & 255); |
MiniTLS | 0:35aa5be3b78d | 22 | fp_div_2d (&t, 8, &t, NULL); |
MiniTLS | 0:35aa5be3b78d | 23 | } |
MiniTLS | 0:35aa5be3b78d | 24 | fp_reverse (b, x); |
MiniTLS | 0:35aa5be3b78d | 25 | } |
MiniTLS | 0:35aa5be3b78d | 26 | |
MiniTLS | 0:35aa5be3b78d | 27 | /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_to_unsigned_bin.c,v $ */ |
MiniTLS | 0:35aa5be3b78d | 28 | /* $Revision: 1.2 $ */ |
MiniTLS | 0:35aa5be3b78d | 29 | /* $Date: 2007/02/27 02:38:44 $ */ |