extern int rand_fork_count;
/* Hardware-based seeding functions. */
-void rand_read_tsc(RAND_poll_fn cb, void *arg);
-int rand_read_cpu(RAND_poll_fn cb, void *arg);
+void rand_read_tsc(RAND_poll_cb rand_add, void *arg);
+int rand_read_cpu(RAND_poll_cb rand_add, void *arg);
/* DRBG entropy callbacks. */
void drbg_release_entropy(RAND_DRBG *drbg, unsigned char *out);
* it's not sufficient to indicate whether or not the seeding was
* done.
*/
-void rand_read_tsc(RAND_poll_fn cb, void *arg)
+void rand_read_tsc(RAND_poll_cb rand_add, void *arg)
{
unsigned char c;
int i;
if ((OPENSSL_ia32cap_P[0] & (1 << 4)) != 0) {
for (i = 0; i < TSC_READ_COUNT; i++) {
c = (unsigned char)(OPENSSL_rdtsc() & 0xFF);
- cb(arg, &c, 1, 0.5);
+ rand_add(arg, &c, 1, 0.5);
}
}
}
extern unsigned int OPENSSL_ia32cap_P[];
-int rand_read_cpu(RAND_poll_fn cb, void *arg)
+int rand_read_cpu(RAND_poll_cb rand_add, void *arg)
{
char buff[RANDOMNESS_NEEDED];
/* If RDSEED is available, use that. */
if ((OPENSSL_ia32cap_P[2] & (1 << 18)) != 0) {
if (OPENSSL_ia32_rdseed_bytes(buff, sizeof(buff)) == sizeof(buff)) {
- cb(arg, buff, (int)sizeof(buff), sizeof(buff));
+ rand_add(arg, buff, (int)sizeof(buff), sizeof(buff));
return 1;
}
}
/* Second choice is RDRAND. */
if ((OPENSSL_ia32cap_P[1] & (1 << (62 - 32))) != 0) {
if (OPENSSL_ia32_rdrand_bytes(buff, sizeof(buff)) == sizeof(buff)) {
- cb(arg, buff, (int)sizeof(buff), sizeof(buff));
+ rand_add(arg, buff, (int)sizeof(buff), sizeof(buff));
return 1;
}
}
* As a precaution, we generate four times the required amount of seed
* data.
*/
-int RAND_poll_ex(RAND_poll_fn cb, void *arg)
+int RAND_poll_ex(RAND_poll_cb rand_add, void *arg)
{
short int code;
gid_t curr_gid;
* different processes.
*/
curr_gid = getgid();
- cb(arg, &curr_gid, sizeof curr_gid, 0);
+ rand_add(arg, &curr_gid, sizeof curr_gid, 0);
curr_pid = getpid();
- cb(arg, &curr_pid, sizeof curr_pid, 0);
+ rand_add(arg, &curr_pid, sizeof curr_pid, 0);
curr_uid = getuid();
- cb(arg, &curr_uid, sizeof curr_uid, 0);
+ rand_add(arg, &curr_uid, sizeof curr_uid, 0);
for (i = 0; i < (RANDOMNESS_NEEDED * 4); i++) {
/*
/* Get wall clock time, take 8 bits. */
clock_gettime(CLOCK_REALTIME, &ts);
v = (unsigned char)(ts.tv_nsec & 0xFF);
- cb(arg, &v, sizeof v, 1);
+ rand_add(arg, &v, sizeof v, 1);
}
return 1;
}
/*
* Try the various seeding methods in turn, exit when succesful.
*/
-int RAND_poll_ex(RAND_poll_fn cb, void *arg)
+int RAND_poll_ex(RAND_poll_cb rand_add, void *arg)
{
# ifdef OPENSSL_RAND_SEED_NONE
return 0;
int i = getrandom(temp, TEMPSIZE, 0);
if (i >= 0) {
- cb(arg, temp, i, i);
+ rand_add(arg, temp, i, i);
if (i == TEMPSIZE)
goto done;
}
continue;
setbuf(fp, NULL);
if (fread(temp, 1, TEMPSIZE, fp) == TEMPSIZE) {
- cb(arg, temp, TEMPSIZE, TEMPSIZE);
+ rand_add(arg, temp, TEMPSIZE, TEMPSIZE);
fclose(fp);
goto done;
}
for (i = 0; paths[i] != NULL; i++) {
if (RAND_query_egd_bytes(paths[i], temp, TEMPSIZE) == TEMPSIZE) {
- cb(arg, temp, TEMPSIZE, TEMPSIZE);
+ rand_add(arg, temp, TEMPSIZE, TEMPSIZE);
goto done;
}
}
{0, 0}
};
-int RAND_poll_ex(RAND_poll_fn cb, void *arg)
+int RAND_poll_ex(RAND_poll_cb rand_add, void *arg)
{
/* determine the number of items in the JPI array */
struct items_data_st item_entry;
total_length += (tmp_length - 1);
/* size of seed is total_length*4 bytes (64bytes) */
- cb(arg, (PTR_T)data_buffer, total_length * 4, total_length * 2);
+ rand_add(arg, (PTR_T)data_buffer, total_length * 4, total_length * 2);
return 1;
}
# define INTEL_DEF_PROV L"Intel Hardware Cryptographic Service Provider"
# endif
-int RAND_poll_ex(RAND_poll_fn cb, void *arg)
+int RAND_poll_ex(RAND_poll_cb rand_add, void *arg)
{
# ifndef USE_BCRYPTGENRANDOM
HCRYPTPROV hProvider;
# ifdef USE_BCRYPTGENRANDOM
if (BCryptGenRandom(NULL, buf, (ULONG)sizeof(buf),
BCRYPT_USE_SYSTEM_PREFERRED_RNG) == STATUS_SUCCESS) {
- cb(arg, buf, sizeof(buf), sizeof(buf));
+ rand_add(arg, buf, sizeof(buf), sizeof(buf));
return 1;
}
# else
if (CryptAcquireContextW(&hProvider, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT | CRYPT_SILENT) != 0) {
if (CryptGenRandom(hProvider, (DWORD)sizeof(buf), buf) != 0) {
- cb(arg, buf, sizeof(buf), sizeof(buf));
+ rand_add(arg, buf, sizeof(buf), sizeof(buf));
ok = 1;
}
CryptReleaseContext(hProvider, 0);
if (CryptAcquireContextW(&hProvider, NULL, INTEL_DEF_PROV, PROV_INTEL_SEC,
CRYPT_VERIFYCONTEXT | CRYPT_SILENT) != 0) {
if (CryptGenRandom(hProvider, (DWORD)sizeof(buf), buf) != 0) {
- cb(arg, buf, sizeof(buf), sizeof(buf));
+ rand_add(arg, buf, sizeof(buf), sizeof(buf));
ok = 1;
}
CryptReleaseContext(hProvider, 0);
=head1 NAME
-RAND_add, RAND_poll, RAND_poll_ex, RAND_poll_fn,
+RAND_add, RAND_poll, RAND_poll_ex, RAND_poll_cb,
RAND_seed, RAND_status, RAND_event, RAND_screen
- add randomness to the PRNG or get its status
int RAND_status(void);
- typedef void (*RAND_poll_fn)(void *arg,
+ typedef void (*RAND_poll_cb)(void *arg,
const void *buf, int num, double randomness);
- int RAND_poll_ex(RAND_poll_fn cb, void *arg);
+ int RAND_poll_ex(RAND_poll_cb cb, void *arg);
int RAND_poll();
void RAND_add(const void *buf, int num, double randomness);
int RAND_egd_bytes(const char *path, int bytes);
# endif
-typedef void (*RAND_poll_fn)(void *arg,
+typedef void (*RAND_poll_cb)(void *arg,
const void *buf, int num, double randomness);
int RAND_poll(void);
-int RAND_poll_ex(RAND_poll_fn cb, void *arg);
+int RAND_poll_ex(RAND_poll_cb rand_add, void *arg);
# if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H))
/* application has to include <windows.h> in order to use these */
OSSL_STORE_load_fn datatype
OSSL_STORE_open_fn datatype
OSSL_STORE_post_process_info_fn datatype
-RAND_poll_fn datatype
+RAND_poll_cb datatype
SSL_CTX_keylog_cb_func datatype
SSL_early_cb_fn datatype
SSL_psk_client_cb_func datatype