summaryrefslogtreecommitdiffstats
path: root/moon-abe/pbc-0.5.14/arith/init_random.c
blob: bd040a38ee84e4fa91a6f7dbd20003648accd27b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <stdint.h> // for intptr_t
#include <stdlib.h>
#include <gmp.h>
#include "pbc_utils.h"
#include "pbc_random.h"

void pbc_init_random(void) {
  FILE *fp;
  fp = fopen("/dev/urandom", "rb");
  if (!fp) {
    pbc_warn("could not open /dev/urandom, using deterministic random number generator");
    pbc_random_set_deterministic(0);
  } else {
    pbc_random_set_file("/dev/urandom");
    fclose(fp);
  }
}