@@ -14,22 +14,32 @@ DEFINE_BSS_GET(const struct entropy_source_methods *, entropy_source_methods_ove
1414DEFINE_BSS_GET (int , allow_entropy_source_methods_override )
1515DEFINE_STATIC_MUTEX (global_entropy_source_lock )
1616
17- static int entropy_get_prediction_resistance (
18- const struct entropy_source_t * entropy_source ,
19- uint8_t pred_resistance [RAND_PRED_RESISTANCE_LEN ]) {
17+ static int entropy_cpu_get_entropy (uint8_t * entropy , size_t entropy_len ) {
2018#if defined(OPENSSL_X86_64 )
21- if (rdrand_multiple8 (pred_resistance , RAND_PRED_RESISTANCE_LEN ) == 1 ) {
19+ if (rdrand_multiple8 (entropy , entropy_len ) == 1 ) {
2220 return 1 ;
2321 }
2422#elif defined(OPENSSL_AARCH64 )
25- if (rndr_multiple8 (pred_resistance , RAND_PRED_RESISTANCE_LEN ) == 1 ) {
23+ if (rndr_multiple8 (entropy , entropy_len ) == 1 ) {
2624 return 1 ;
2725 }
2826#endif
2927 return 0 ;
3028}
3129
32- static int entropy_get_extra_entropy (
30+ static int entropy_cpu_get_prediction_resistance (
31+ const struct entropy_source_t * entropy_source ,
32+ uint8_t pred_resistance [RAND_PRED_RESISTANCE_LEN ]) {
33+ return entropy_cpu_get_entropy (pred_resistance , RAND_PRED_RESISTANCE_LEN );
34+ }
35+
36+ static int entropy_cpu_get_extra_entropy (
37+ const struct entropy_source_t * entropy_source ,
38+ uint8_t extra_entropy [CTR_DRBG_ENTROPY_LEN ]) {
39+ return entropy_cpu_get_entropy (extra_entropy , CTR_DRBG_ENTROPY_LEN );
40+ }
41+
42+ static int entropy_os_get_extra_entropy (
3343 const struct entropy_source_t * entropy_source ,
3444 uint8_t extra_entropy [CTR_DRBG_ENTROPY_LEN ]) {
3545 CRYPTO_sysrand (extra_entropy , CTR_DRBG_ENTROPY_LEN );
@@ -47,10 +57,10 @@ DEFINE_LOCAL_DATA(struct entropy_source_methods, tree_jitter_entropy_source_meth
4757 out -> zeroize_thread = tree_jitter_zeroize_thread_drbg ;
4858 out -> free_thread = tree_jitter_free_thread_drbg ;
4959 out -> get_seed = tree_jitter_get_seed ;
50- out -> get_extra_entropy = entropy_get_extra_entropy ;
60+ out -> get_extra_entropy = entropy_os_get_extra_entropy ;
5161 if (have_hw_rng_x86_64 () == 1 ||
5262 have_hw_rng_aarch64 () == 1 ) {
53- out -> get_prediction_resistance = entropy_get_prediction_resistance ;
63+ out -> get_prediction_resistance = entropy_cpu_get_prediction_resistance ;
5464 } else {
5565 out -> get_prediction_resistance = NULL ;
5666 }
@@ -103,7 +113,7 @@ DEFINE_LOCAL_DATA(struct entropy_source_methods, opt_out_cpu_jitter_entropy_sour
103113 out -> get_seed = opt_out_cpu_jitter_get_seed_wrap ;
104114 if (have_hw_rng_x86_64 () == 1 ||
105115 have_hw_rng_aarch64 () == 1 ) {
106- out -> get_extra_entropy = entropy_get_prediction_resistance ;
116+ out -> get_extra_entropy = entropy_cpu_get_extra_entropy ;
107117 } else {
108118 // Fall back to seed source because a second source must always be present.
109119 out -> get_extra_entropy = opt_out_cpu_jitter_get_seed_wrap ;
0 commit comments