~ubuntu-branches/debian/lenny/dropbear/lenny

« back to all changes in this revision

Viewing changes to libtommath/bn_mp_init.c

  • Committer: Bazaar Package Importer
  • Author(s): Gerrit Pape
  • Date: 2005-05-25 22:38:17 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050525223817-fdl653extybmz1zb
Tags: 0.45-3
* debian/dropbear.init: init script prints human readable message in case
  it's disabled (closes: #309099).
* debian/dropbear.postinst: configure: restart service through init script
  instead of start.
* debian/dropbear.prerm: set -u -> set -e.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <tommath.h>
 
2
#ifdef BN_MP_INIT_C
1
3
/* LibTomMath, multiple-precision integer library -- Tom St Denis
2
4
 *
3
5
 * LibTomMath is a library that provides multiple-precision
12
14
 *
13
15
 * Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
14
16
 */
15
 
#include <tommath.h>
16
17
 
17
 
/* init a new bigint */
 
18
/* init a new mp_int */
18
19
int mp_init (mp_int * a)
19
20
{
 
21
  int i;
 
22
 
20
23
  /* allocate memory required and clear it */
21
 
  a->dp = OPT_CAST(mp_digit) XCALLOC (sizeof (mp_digit), MP_PREC);
 
24
  a->dp = OPT_CAST(mp_digit) XMALLOC (sizeof (mp_digit) * MP_PREC);
22
25
  if (a->dp == NULL) {
23
26
    return MP_MEM;
24
27
  }
25
28
 
 
29
  /* set the digits to zero */
 
30
  for (i = 0; i < MP_PREC; i++) {
 
31
      a->dp[i] = 0;
 
32
  }
 
33
 
26
34
  /* set the used to zero, allocated digits to the default precision
27
35
   * and sign to positive */
28
36
  a->used  = 0;
31
39
 
32
40
  return MP_OKAY;
33
41
}
 
42
#endif