ARM Shanghai IoT Team (Internal) / newMiniTLS-GPL

Fork of MiniTLS-GPL by Donatien Garnier

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fp_to_unsigned_bin.c Source File

fp_to_unsigned_bin.c

00001 /* TomsFastMath, a fast ISO C bignum library.
00002  * 
00003  * This project is meant to fill in where LibTomMath
00004  * falls short.  That is speed ;-)
00005  *
00006  * This project is public domain and free for all purposes.
00007  * 
00008  * Tom St Denis, tomstdenis@gmail.com
00009  */
00010 #include <tfm.h>
00011 
00012 void fp_to_unsigned_bin(fp_int *a, unsigned char *b)
00013 {
00014   int     x;
00015   fp_int  t;
00016 
00017   fp_init_copy(&t, a);
00018 
00019   x = 0;
00020   while (fp_iszero (&t) == FP_NO) {
00021       b[x++] = (unsigned char) (t.dp[0] & 255);
00022       fp_div_2d (&t, 8, &t, NULL);
00023   }
00024   fp_reverse (b, x);
00025 }
00026 
00027 /* $Source: /cvs/libtom/tomsfastmath/src/bin/fp_to_unsigned_bin.c,v $ */
00028 /* $Revision: 1.2 $ */
00029 /* $Date: 2007/02/27 02:38:44 $ */