Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 47 lines (40 sloc) 1.094 kb
e549ccf added libtommath-0.32
Tom St Denis authored
1 #include <tommath.h>
2 #ifdef BN_MP_INIT_C
57354e1 added libtommath-0.12
Tom St Denis authored
3 /* LibTomMath, multiple-precision integer library -- Tom St Denis
4 *
c1da6aa added libtommath-0.25
Tom St Denis authored
5 * LibTomMath is a library that provides multiple-precision
57354e1 added libtommath-0.12
Tom St Denis authored
6 * integer arithmetic as well as number theoretic functionality.
7 *
c1da6aa added libtommath-0.25
Tom St Denis authored
8 * The library was designed directly after the MPI library by
9 * Michael Fromberger but has been written from scratch with
57354e1 added libtommath-0.12
Tom St Denis authored
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
15 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
57354e1 added libtommath-0.12
Tom St Denis authored
16 */
17
8eaa988 added libtommath-0.31
Tom St Denis authored
18 /* init a new mp_int */
455bb4d added libtommath-0.28
Tom St Denis authored
19 int mp_init (mp_int * a)
57354e1 added libtommath-0.12
Tom St Denis authored
20 {
8eaa988 added libtommath-0.31
Tom St Denis authored
21 int i;
22
c1da6aa added libtommath-0.25
Tom St Denis authored
23 /* allocate memory required and clear it */
8eaa988 added libtommath-0.31
Tom St Denis authored
24 a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC);
57354e1 added libtommath-0.12
Tom St Denis authored
25 if (a->dp == NULL) {
26 return MP_MEM;
27 }
28
8eaa988 added libtommath-0.31
Tom St Denis authored
29 /* set the digits to zero */
30 for (i = 0; i < MP_PREC; i++) {
31 a->dp[i] = 0;
32 }
33
0ef44ce added libtommath-0.18
Tom St Denis authored
34 /* set the used to zero, allocated digits to the default precision
57354e1 added libtommath-0.12
Tom St Denis authored
35 * and sign to positive */
14161e8 added libtommath-0.16
Tom St Denis authored
36 a->used = 0;
57354e1 added libtommath-0.12
Tom St Denis authored
37 a->alloc = MP_PREC;
14161e8 added libtommath-0.16
Tom St Denis authored
38 a->sign = MP_ZPOS;
57354e1 added libtommath-0.12
Tom St Denis authored
39
40 return MP_OKAY;
41 }
e549ccf added libtommath-0.32
Tom St Denis authored
42 #endif
9294e79 added libtommath-0.36
Tom St Denis authored
43
44 /* $Source$ */
45 /* $Revision$ */
46 /* $Date$ */
Something went wrong with that request. Please try again.