mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Add zend_random_bytes(), zend_random_bytes_insecure() functions (#14054)
Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
This commit is contained in:
parent
d545b1d643
commit
d1048a0869
10 changed files with 169 additions and 12 deletions
|
@ -37,7 +37,10 @@
|
|||
|
||||
PHPAPI double php_combined_lcg(void);
|
||||
|
||||
typedef struct _php_random_fallback_seed_state php_random_fallback_seed_state;
|
||||
|
||||
PHPAPI uint64_t php_random_generate_fallback_seed(void);
|
||||
PHPAPI uint64_t php_random_generate_fallback_seed_ex(php_random_fallback_seed_state *state);
|
||||
|
||||
static inline zend_long GENERATE_SEED(void)
|
||||
{
|
||||
|
@ -99,6 +102,11 @@ typedef struct _php_random_algo_with_state {
|
|||
void *state;
|
||||
} php_random_algo_with_state;
|
||||
|
||||
typedef struct _php_random_fallback_seed_state {
|
||||
bool initialized;
|
||||
unsigned char seed[20];
|
||||
} php_random_fallback_seed_state;
|
||||
|
||||
extern PHPAPI const php_random_algo php_random_algo_combinedlcg;
|
||||
extern PHPAPI const php_random_algo php_random_algo_mt19937;
|
||||
extern PHPAPI const php_random_algo php_random_algo_pcgoneseq128xslrr64;
|
||||
|
@ -197,8 +205,7 @@ PHP_RINIT_FUNCTION(random);
|
|||
ZEND_BEGIN_MODULE_GLOBALS(random)
|
||||
bool combined_lcg_seeded;
|
||||
bool mt19937_seeded;
|
||||
bool fallback_seed_initialized;
|
||||
unsigned char fallback_seed[20];
|
||||
php_random_fallback_seed_state fallback_seed_state;
|
||||
php_random_status_state_combinedlcg combined_lcg;
|
||||
php_random_status_state_mt19937 mt19937;
|
||||
ZEND_END_MODULE_GLOBALS(random)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue