static void *persona_create_svr_config(apr_pool_t *p, server_rec *s)
{
  persona_config_t *conf = apr_palloc(p, sizeof(*conf));
  apr_random_t *prng = apr_random_standard_new(p);
  while (apr_random_secure_ready(prng) == APR_ENOTENOUGHENTROPY) {
    unsigned char randbuf[RAND_BYTES_AT_A_TIME];
    apr_generate_random_bytes(randbuf, RAND_BYTES_AT_A_TIME);
    apr_random_add_entropy(prng, randbuf, RAND_BYTES_AT_A_TIME);
  }

  char *secret = apr_palloc(p, PERSONA_SECRET_SIZE);
  apr_random_secure_bytes(prng, secret, PERSONA_SECRET_SIZE);
  conf->secret = apr_palloc(p, sizeof(buffer_t));
  conf->secret->len = PERSONA_SECRET_SIZE;
  conf->secret->data = secret;

  conf->logout_path = apr_palloc(p, sizeof(buffer_t));
  conf->logout_path->len = 0;
  conf->logout_path->data = NULL;

  return conf;
}
Esempio n. 2
0
static void rand_seed_short(abts_case *tc, void *data)
{
    r = apr_random_standard_new(p);
    rand_run_seed_short(tc, apr_random_insecure_bytes, r, 32);
}