php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
engine_secure.c
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: Sammy Kaye Powers <me@sammyk.me> |
14 | Go Kudo <zeriyoshi@php.net> |
15 +----------------------------------------------------------------------+
16*/
17
18#ifdef HAVE_CONFIG_H
19# include "config.h"
20#endif
21
22#include "php.h"
23#include "php_random.h"
24#include "php_random_csprng.h"
25
27
28static php_random_result generate(void *state)
29{
30 zend_ulong r = 0;
31
32 php_random_bytes_throw(&r, sizeof(r));
33
34 return (php_random_result){
35 .size = sizeof(zend_ulong),
36 .result = r,
37 };
38}
39
40static zend_long range(void *state, zend_long min, zend_long max)
41{
42 zend_long result = 0;
43
44 php_random_int_throw(min, max, &result);
45
46 return result;
47}
48
50 0,
51 generate,
52 range,
53 NULL,
54 NULL
55};
PHPAPI const php_random_algo php_random_algo_secure
#define max(a, b)
Definition exif.c:60
#define NULL
Definition gdcache.h:45
#define PHPAPI
Definition php.h:71
#define min(a, b)
struct _php_random_algo php_random_algo
struct _php_random_result php_random_result
int32_t zend_long
Definition zend_long.h:42
uint32_t zend_ulong
Definition zend_long.h:43
bool result