Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
bbs_rand.h File Reference
#include <limits.h>
#include "mpi.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define BBS_RAND_MAX   UINT_MAX

Functions

void bbs_srand (unsigned char *data, int len)
unsigned int bbs_rand (void)

Variables

int bbs_seed_size

Define Documentation

#define BBS_RAND_MAX   UINT_MAX

Definition at line 49 of file bbs_rand.h.


Function Documentation

unsigned int bbs_rand ( void  )

Definition at line 71 of file bbs_rand.c.

{
  static mp_int   modulus;
  unsigned int    result = 0, ix;

  if((bbs_init & MODULUS) == 0) {
    mp_init(&modulus);
    mp_read_radix(&modulus, bbs_modulus, 16);
    bbs_init |= MODULUS;
  }

  for(ix = 0; ix < sizeof(unsigned int); ix++) {
    mp_digit   d;

    mp_sqrmod(&bbs_state, &modulus, &bbs_state);
    d = DIGIT(&bbs_state, 0);

    result = (result << CHAR_BIT) | (d & UCHAR_MAX);
  }

  return result;

} /* end bbs_rand() */
void bbs_srand ( unsigned char *  data,
int  len 
)

Definition at line 60 of file bbs_rand.c.

{
  if((bbs_init & SEED) == 0) {
    mp_init(&bbs_state);
    bbs_init |= SEED;
  }

  mp_read_raw(&bbs_state, (char *)data, len);

} /* end bbs_srand() */

Variable Documentation

Definition at line 58 of file bbs_rand.c.