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 ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_random_bytes(void *bytes, size_t size, bool should_throw);
24 ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_random_bytes_ex(void *bytes, size_t size, char *errstr, size_t errstr_size);
25
26 ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_random_int(zend_long min, zend_long max, zend_long *result, bool should_throw);
27
php_random_bytes_throw(void * bytes,size_t size)28 ZEND_ATTRIBUTE_NONNULL static inline zend_result php_random_bytes_throw(void *bytes, size_t size)
29 {
30 return php_random_bytes(bytes, size, true);
31 }
32
php_random_bytes_silent(void * bytes,size_t size)33 ZEND_ATTRIBUTE_NONNULL static inline zend_result php_random_bytes_silent(void *bytes, size_t size)
34 {
35 return php_random_bytes(bytes, size, false);
36 }
37
php_random_int_throw(zend_long min,zend_long max,zend_long * result)38 ZEND_ATTRIBUTE_NONNULL static inline zend_result php_random_int_throw(zend_long min, zend_long max, zend_long *result)
39 {
40 return php_random_int(min, max, result, true);
41 }
42
php_random_int_silent(zend_long min,zend_long max,zend_long * result)43 ZEND_ATTRIBUTE_NONNULL static inline zend_result php_random_int_silent(zend_long min, zend_long max, zend_long *result)
44 {
45 return php_random_int(min, max, result, false);
46 }
47
48 PHPAPI void php_random_csprng_shutdown(void);
49
50 #endif /* PHP_RANDOM_CSPRNG_H */
51