bignum.h File Reference

Big number math. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct bignum * bignum_init (void)
 Allocate memory for bignum.
void bignum_deinit (struct bignum *n)
 Free bignum.
size_t bignum_get_unsigned_bin_len (struct bignum *n)
 Get length of bignum as an unsigned binary buffer.
int bignum_get_unsigned_bin (const struct bignum *n, u8 *buf, size_t *len)
 Set binary buffer to unsigned bignum.
int bignum_set_unsigned_bin (struct bignum *n, const u8 *buf, size_t len)
 Set bignum based on unsigned binary buffer.
int bignum_cmp (const struct bignum *a, const struct bignum *b)
 Signed comparison.
int bignum_cmp_d (const struct bignum *a, unsigned long b)
 Compare bignum to standard integer.
int bignum_add (const struct bignum *a, const struct bignum *b, struct bignum *c)
 c = a + b
int bignum_sub (const struct bignum *a, const struct bignum *b, struct bignum *c)
 c = a - b
int bignum_mul (const struct bignum *a, const struct bignum *b, struct bignum *c)
 c = a * b
int bignum_mulmod (const struct bignum *a, const struct bignum *b, const struct bignum *c, struct bignum *d)
 d = a * b (mod c)
int bignum_exptmod (const struct bignum *a, const struct bignum *b, const struct bignum *c, struct bignum *d)
 Modular exponentiation: d = a^b (mod c).

Detailed Description

Big number math.

Copyright
Copyright (c) 2006, Jouni Malinen <j@w1.fi>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

Alternatively, this software may be distributed under the terms of BSD license.

See README and COPYING for more details.

Definition in file bignum.h.


Function Documentation

int bignum_add ( const struct bignum *  a,
const struct bignum *  b,
struct bignum *  c 
)

c = a + b

Parameters:
a Bignum from bignum_init()
b Bignum from bignum_init()
c Bignum from bignum_init(); used to store the result of a + b
Returns:
0 on success, -1 on failure

Definition at line 155 of file bignum.c.

Here is the call graph for this function:

int bignum_cmp ( const struct bignum *  a,
const struct bignum *  b 
)

Signed comparison.

Parameters:
a Bignum from bignum_init()
b Bignum from bignum_init()
Returns:
0 on success, -1 on failure

Definition at line 128 of file bignum.c.

int bignum_cmp_d ( const struct bignum *  a,
unsigned long  b 
)

Compare bignum to standard integer.

Parameters:
a Bignum from bignum_init()
b Small integer
Returns:
0 on success, -1 on failure

Definition at line 141 of file bignum.c.

void bignum_deinit ( struct bignum *  n  ) 

Free bignum.

Parameters:
n Bignum from bignum_init()

Definition at line 56 of file bignum.c.

int bignum_exptmod ( const struct bignum *  a,
const struct bignum *  b,
const struct bignum *  c,
struct bignum *  d 
)

Modular exponentiation: d = a^b (mod c).

Parameters:
a Bignum from bignum_init(); base
b Bignum from bignum_init(); exponent
c Bignum from bignum_init(); modulus
d Bignum from bignum_init(); used to store the result of a^b (mod c)
Returns:
0 on success, -1 on failure

Definition at line 234 of file bignum.c.

Here is the call graph for this function:

int bignum_get_unsigned_bin ( const struct bignum *  n,
u8 *  buf,
size_t *  len 
)

Set binary buffer to unsigned bignum.

Parameters:
n Bignum from bignum_init()
buf Buffer for the binary number
len Length of the buffer, can be NULL if buffer is known to be long enough. Set to used buffer length on success if not NULL.
Returns:
0 on success, -1 on failure

Definition at line 86 of file bignum.c.

Here is the call graph for this function:

size_t bignum_get_unsigned_bin_len ( struct bignum *  n  ) 

Get length of bignum as an unsigned binary buffer.

Parameters:
n Bignum from bignum_init()
Returns:
Length of n if written to a binary buffer

Definition at line 71 of file bignum.c.

struct bignum* bignum_init ( void   )  [read]

Allocate memory for bignum.

Returns:
Pointer to allocated bignum or NULL on failure

Definition at line 38 of file bignum.c.

Here is the call graph for this function:

int bignum_mul ( const struct bignum *  a,
const struct bignum *  b,
struct bignum *  c 
)

c = a * b

Parameters:
a Bignum from bignum_init()
b Bignum from bignum_init()
c Bignum from bignum_init(); used to store the result of a * b
Returns:
0 on success, -1 on failure

Definition at line 193 of file bignum.c.

Here is the call graph for this function:

int bignum_mulmod ( const struct bignum *  a,
const struct bignum *  b,
const struct bignum *  c,
struct bignum *  d 
)

d = a * b (mod c)

Parameters:
a Bignum from bignum_init()
b Bignum from bignum_init()
c Bignum from bignum_init(); modulus
d Bignum from bignum_init(); used to store the result of a * b (mod c)
Returns:
0 on success, -1 on failure

Definition at line 213 of file bignum.c.

Here is the call graph for this function:

int bignum_set_unsigned_bin ( struct bignum *  n,
const u8 *  buf,
size_t  len 
)

Set bignum based on unsigned binary buffer.

Parameters:
n Bignum from bignum_init(); to be set to the given value
buf Buffer with unsigned binary value
len Length of buf in octets
Returns:
0 on success, -1 on failure

Definition at line 111 of file bignum.c.

Here is the call graph for this function:

int bignum_sub ( const struct bignum *  a,
const struct bignum *  b,
struct bignum *  c 
)

c = a - b

Parameters:
a Bignum from bignum_init()
b Bignum from bignum_init()
c Bignum from bignum_init(); used to store the result of a - b
Returns:
0 on success, -1 on failure

Definition at line 174 of file bignum.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Sat Nov 21 23:22:30 2009 for hostapd by  doxygen 1.6.1