示例#1
0
int
ottery_init(const struct ottery_config *cfg)
{
  int n = ottery_st_init(&ottery_global_state_, cfg);
  if (n == 0)
	ottery_global_state_initialized_ = 1;
  return n;
}
示例#2
0
int
main(int argc, char **argv)
{
  (void) argc;
  (void) argv;
#ifndef NO_OPENSSL
  RAND_poll();
#endif
  struct ottery_config cfg_chacha8;
  struct ottery_config cfg_chacha12;
  struct ottery_config cfg_chacha20;
  ottery_config_init(&cfg_chacha8);
  ottery_config_force_implementation(&cfg_chacha8, OTTERY_PRF_CHACHA8);
  ottery_config_init(&cfg_chacha12);
  ottery_config_force_implementation(&cfg_chacha12, OTTERY_PRF_CHACHA12);
  ottery_config_init(&cfg_chacha20);
  ottery_config_force_implementation(&cfg_chacha20, OTTERY_PRF_CHACHA20);

  ottery_st_init(&s8, &cfg_chacha8);
  ottery_st_init(&s12, &cfg_chacha12);
  ottery_st_init(&s20, &cfg_chacha20);
  ottery_st_init_nolock(&s8nl, &cfg_chacha8);
  ottery_st_init_nolock(&s12nl, &cfg_chacha12);
  ottery_st_init_nolock(&s20nl, &cfg_chacha20);

  time_chacharand8();
  time_chacharand8_u64();
  time_chacharand8_onebyte();
  time_chacharand8_buf16();
  time_chacharand8_buf1024();

  time_chacharand12();
  time_chacharand12_u64();
  time_chacharand12_onebyte();
  time_chacharand12_buf16();
  time_chacharand12_buf1024();

  time_chacharand20();
  time_chacharand20_u64();
  time_chacharand20_onebyte();
  time_chacharand20_buf16();
  time_chacharand20_buf1024();

  time_chacharand8nl();
  time_chacharand8nl_u64();
  time_chacharand8nl_onebyte();
  time_chacharand8nl_buf16();
  time_chacharand8nl_buf1024();

  time_chacharand12nl();
  time_chacharand12nl_u64();
  time_chacharand12nl_onebyte();
  time_chacharand12nl_buf16();
  time_chacharand12nl_buf1024();

  time_chacharand20nl();
  time_chacharand20nl_u64();
  time_chacharand20nl_onebyte();
  time_chacharand20nl_buf16();
  time_chacharand20nl_buf1024();

  time_arc4random();
  time_arc4random_u64();
  time_arc4random_onebyte();
  time_arc4random_buf16();
  time_arc4random_buf1024();

  if (ottery_get_cpu_capabilities_() & OTTERY_CPUCAP_RAND) {
    time_rdrandom();
    time_rdrandom_buf16();
    time_rdrandom_buf1024();
  }

#ifndef NO_URANDOM
  urandom_fd = open("/dev/urandom", O_RDONLY);
  time_urandom();
  time_urandom_u64();
  time_urandom_buf16();
  time_urandom_buf1024();
#endif

  time_libc_random();
  time_libc_random_u64();
  time_libc_onebyte();
  time_libcrandom_buf16();
  time_libcrandom_buf1024();

  time_openssl_random();
  time_opensslrandom_buf16();
  time_opensslrandom_buf1024();

  return 0;
}