diff options
author | Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> | 2017-08-25 22:39:33 +0200 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-08-28 08:52:02 -0400 |
commit | 4871fa49cdd0d4473b6a815fc01fbde3e6ced339 (patch) | |
tree | 11f329d58a4da8426c2e1942a3251d279bf1e81f /crypto/rand | |
parent | aa048aef0b9146f90c06333dedfc105d1f9e2c22 (diff) |
RAND: Rename the RAND_poll_ex() callback and its typedef
With the introduction of RAND_poll_ex(), the `RAND_add()` calls were
replaced by meaningless cb(...). This commit changes the 'cb(...)'
calls back to 'rand_add(...)' calls by changing the signature as follows:
-int RAND_poll_ex(RAND_poll_fn cb, void *arg);
+int RAND_poll_ex(RAND_poll_cb rand_add, void *arg);
Changed the function typedef name to 'RAND_poll_cb' to emphasize the fact
that the function type represents a callback function.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4266)
Diffstat (limited to 'crypto/rand')
-rw-r--r-- | crypto/rand/rand_lcl.h | 4 | ||||
-rw-r--r-- | crypto/rand/rand_lib.c | 10 | ||||
-rw-r--r-- | crypto/rand/rand_unix.c | 18 | ||||
-rw-r--r-- | crypto/rand/rand_vms.c | 4 | ||||
-rw-r--r-- | crypto/rand/rand_win.c | 8 |
5 files changed, 22 insertions, 22 deletions
diff --git a/crypto/rand/rand_lcl.h b/crypto/rand/rand_lcl.h index 0d85934533..20c0ee930b 100644 --- a/crypto/rand/rand_lcl.h +++ b/crypto/rand/rand_lcl.h @@ -153,8 +153,8 @@ extern RAND_DRBG priv_drbg; 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); diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c index 0d1e3f6a07..909f30426f 100644 --- a/crypto/rand/rand_lib.c +++ b/crypto/rand/rand_lib.c @@ -42,7 +42,7 @@ int rand_fork_count; * 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; @@ -50,7 +50,7 @@ void rand_read_tsc(RAND_poll_fn cb, void *arg) 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); } } } @@ -62,14 +62,14 @@ size_t OPENSSL_ia32_rdrand_bytes(char *buf, size_t len); 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; } } @@ -77,7 +77,7 @@ int rand_read_cpu(RAND_poll_fn cb, void *arg) /* 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; } } diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c index eecd544aee..8090987a2a 100644 --- a/crypto/rand/rand_unix.c +++ b/crypto/rand/rand_unix.c @@ -50,7 +50,7 @@ * 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; @@ -72,11 +72,11 @@ int RAND_poll_ex(RAND_poll_fn cb, void *arg) * 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++) { /* @@ -99,7 +99,7 @@ int RAND_poll_ex(RAND_poll_fn cb, void *arg) /* 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; } @@ -130,7 +130,7 @@ int RAND_poll_ex(RAND_poll_fn cb, void *arg) /* * 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; @@ -144,7 +144,7 @@ int RAND_poll_ex(RAND_poll_fn cb, void *arg) 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; } @@ -168,7 +168,7 @@ int RAND_poll_ex(RAND_poll_fn cb, void *arg) 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; } @@ -193,7 +193,7 @@ int RAND_poll_ex(RAND_poll_fn cb, void *arg) 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; } } diff --git a/crypto/rand/rand_vms.c b/crypto/rand/rand_vms.c index a6bb76d1d0..773373d1a6 100644 --- a/crypto/rand/rand_vms.c +++ b/crypto/rand/rand_vms.c @@ -54,7 +54,7 @@ static struct items_data_st { {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; @@ -113,7 +113,7 @@ int RAND_poll_ex(RAND_poll_fn cb, void *arg) 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; } diff --git a/crypto/rand/rand_win.c b/crypto/rand/rand_win.c index 457e2ade39..8637ca4185 100644 --- a/crypto/rand/rand_win.c +++ b/crypto/rand/rand_win.c @@ -39,7 +39,7 @@ # 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; @@ -58,7 +58,7 @@ int RAND_poll_ex(RAND_poll_fn cb, void *arg) # 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 @@ -66,7 +66,7 @@ int RAND_poll_ex(RAND_poll_fn cb, void *arg) 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); @@ -78,7 +78,7 @@ int RAND_poll_ex(RAND_poll_fn cb, void *arg) 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); |