php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_random_csprng.h
Go to the documentation of this file.
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
23ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_random_bytes(void *bytes, size_t size, bool should_throw);
24ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_random_bytes_ex(void *bytes, size_t size, char *errstr, size_t errstr_size);
25
27
28ZEND_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
33ZEND_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
38ZEND_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
43ZEND_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
49
50#endif /* PHP_RANDOM_CSPRNG_H */
#define max(a, b)
Definition exif.c:60
new_type size
Definition ffi.c:4365
#define PHPAPI
Definition php.h:71
#define min(a, b)
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_random_bytes_ex(void *bytes, size_t size, char *errstr, size_t errstr_size)
Definition csprng.c:69
PHPAPI void php_random_csprng_shutdown(void)
Definition csprng.c:267
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_random_int(zend_long min, zend_long max, zend_long *result, bool should_throw)
Definition csprng.c:225
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_random_bytes(void *bytes, size_t size, bool should_throw)
Definition csprng.c:213
int32_t zend_long
Definition zend_long.h:42
#define ZEND_ATTRIBUTE_NONNULL
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
bool result