@@ -234,6 +234,11 @@ struct _zend_class_entry {
234
234
} info ;
235
235
};
236
236
237
+ typedef union {
238
+ zend_max_align_t align ;
239
+ uint64_t opaque [5 ];
240
+ } zend_utility_random_bytes_insecure_state ;
241
+
237
242
typedef struct _zend_utility_functions {
238
243
void (* error_function )(int type , zend_string * error_filename , const uint32_t error_lineno , zend_string * message );
239
244
size_t (* printf_function )(const char * format , ...) ZEND_ATTRIBUTE_PTR_FORMAT (printf , 1 , 2 );
@@ -248,6 +253,8 @@ typedef struct _zend_utility_functions {
248
253
void (* printf_to_smart_str_function )(smart_str * buf , const char * format , va_list ap );
249
254
char * (* getenv_function )(const char * name , size_t name_len );
250
255
zend_string * (* resolve_path_function )(zend_string * filename );
256
+ zend_result (* random_bytes_function )(void * bytes , size_t size , char * errstr , size_t errstr_size );
257
+ zend_result (* random_bytes_insecure_function )(zend_utility_random_bytes_insecure_state * state , void * bytes , size_t size );
251
258
} zend_utility_functions ;
252
259
253
260
typedef struct _zend_utility_values {
@@ -340,6 +347,14 @@ extern void (*zend_printf_to_smart_string)(smart_string *buf, const char *format
340
347
extern void (* zend_printf_to_smart_str )(smart_str * buf , const char * format , va_list ap );
341
348
extern ZEND_API char * (* zend_getenv )(const char * name , size_t name_len );
342
349
extern ZEND_API zend_string * (* zend_resolve_path )(zend_string * filename );
350
+ /* Generate 'size' random bytes into 'bytes' with the OS CSPRNG. */
351
+ extern ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result (* zend_random_bytes )(
352
+ void * bytes , size_t size , char * errstr , size_t errstr_size );
353
+ /* Generate 'size' random bytes into 'bytes' with a general purpose PRNG (not
354
+ * crypto safe). 'state' must be zeroed before the first call and can be reused.
355
+ */
356
+ extern ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result (* zend_random_bytes_insecure )(
357
+ zend_utility_random_bytes_insecure_state * state , void * bytes , size_t size );
343
358
344
359
/* These two callbacks are especially for opcache */
345
360
extern ZEND_API zend_result (* zend_post_startup_cb )(void );
0 commit comments