1 /*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Tim Düsterhus <timwolla@php.net> |
14 | Go Kudo <zeriyoshi@php.net> |
15 +----------------------------------------------------------------------+
16 */
17
18 #ifndef PHP_RANDOM_CSPRNG_H
19 # define PHP_RANDOM_CSPRNG_H
20
21 # include "php.h"
22
23 PHPAPI zend_result php_random_bytes(void *bytes, size_t size, bool should_throw);
24 PHPAPI zend_result php_random_int(zend_long min, zend_long max, zend_long *result, bool should_throw);
25
php_random_bytes_throw(void * bytes,size_t size)26 static inline zend_result php_random_bytes_throw(void *bytes, size_t size)
27 {
28 return php_random_bytes(bytes, size, true);
29 }
30
php_random_bytes_silent(void * bytes,size_t size)31 static inline zend_result php_random_bytes_silent(void *bytes, size_t size)
32 {
33 return php_random_bytes(bytes, size, false);
34 }
35
php_random_int_throw(zend_long min,zend_long max,zend_long * result)36 static inline zend_result php_random_int_throw(zend_long min, zend_long max, zend_long *result)
37 {
38 return php_random_int(min, max, result, true);
39 }
40
php_random_int_silent(zend_long min,zend_long max,zend_long * result)41 static inline zend_result php_random_int_silent(zend_long min, zend_long max, zend_long *result)
42 {
43 return php_random_int(min, max, result, false);
44 }
45
46 #endif /* PHP_RANDOM_CSPRNG_H */
47