ssl_engine_rand.c revision c12917da693bae4028a1d5a5e8224bceed8c739d
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* _ _
* _ __ ___ ___ __| | ___ ___| | mod_ssl
* | '_ ` _ \ / _ \ / _` | / __/ __| | Apache Interface to OpenSSL
* | | | | | | (_) | (_| | \__ \__ \ |
* |_| |_| |_|\___/ \__,_|___|___/___/_|
* |_____|
* Random Number Generator Seeding
*/
/* ``The generation of random
numbers is too important
to be left to chance.'' */
#include "ssl_private.h"
#if HAVE_VALGRIND
#include <valgrind.h>
#include <memcheck.h>
#endif
/* _________________________________________________________________
**
** Support for better seeding of SSL library's RNG
** _________________________________________________________________
*/
static int ssl_rand_choosenum(int, int);
{
unsigned char stackdata[256];
int nDone;
apr_file_t *fp;
int i, n, l;
mc = myModConfig(s);
nDone = 0;
for (i = 0; i < apRandSeed->nelts; i++) {
pRandSeed = &pRandSeeds[i];
/*
* seed in contents of an external file
*/
continue;
}
/*
* seed in contents generated by an external program
*/
continue;
ssl_util_ppclose(s, p, fp);
}
/*
* seed in contents provided by the external
* Entropy Gathering Daemon (EGD)
*/
continue;
nDone += n;
}
struct {
time_t t;
} my_seed;
/*
* seed in the current time (usually just 4 bytes)
*/
/*
* seed in the current process id (usually just 4 bytes)
*/
l = sizeof(my_seed);
nDone += l;
/*
* seed in some current state of the run-time stack (128 bytes)
*/
#if HAVE_VALGRIND
if (ssl_running_on_valgrind) {
}
#endif
nDone += 128;
}
}
}
if (RAND_status() == 0)
"%sPRNG still contains insufficient entropy!", prefix);
return nDone;
}
#define BUFSIZE 8192
{
nDone = 0;
while (1) {
if (nReq > 0)
break;
if (nReq > 0) {
if (nTodo <= 0)
break;
}
}
return nDone;
}
static int ssl_rand_choosenum(int l, int h)
{
int i;
char buf[50];
if (i < l) i = l;
if (i > h) i = h;
return i;
}