php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_libsodium.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: Frank Denis <jedisct1@php.net> |
14 +----------------------------------------------------------------------+
15*/
16
17#ifndef PHP_LIBSODIUM_H
18#define PHP_LIBSODIUM_H
19
21#define phpext_sodium_ptr &sodium_module_entry
22
23#define PHP_SODIUM_VERSION PHP_VERSION
24
25#ifdef ZTS
26# include "TSRM.h"
27#endif
28
29#include <sodium.h>
30
31#define SODIUM_LIBRARY_VERSION() (char *) (void *) sodium_version_string()
32
33#define SODIUM_CRYPTO_BOX_KEYPAIRBYTES() crypto_box_SECRETKEYBYTES + crypto_box_PUBLICKEYBYTES
34
35#define SODIUM_CRYPTO_KX_KEYPAIRBYTES() crypto_kx_SECRETKEYBYTES + crypto_kx_PUBLICKEYBYTES
36
37#define SODIUM_CRYPTO_SIGN_KEYPAIRBYTES() crypto_sign_SECRETKEYBYTES + crypto_sign_PUBLICKEYBYTES
38
39#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6)
40
49#if defined(PHP_PASSWORD_ARGON2_MEMORY_COST)
50#define PHP_SODIUM_PWHASH_MEMLIMIT PHP_PASSWORD_ARGON2_MEMORY_COST
51#else
52#define PHP_SODIUM_PWHASH_MEMLIMIT (64 << 10)
53#endif
54#if defined(PHP_PASSWORD_ARGON2_TIME_COST)
55#define PHP_SODIUM_PWHASH_OPSLIMIT PHP_PASSWORD_ARGON2_TIME_COST
56#else
57#define PHP_SODIUM_PWHASH_OPSLIMIT 4
58#endif
59#if defined(PHP_SODIUM_PWHASH_THREADS)
60#define PHP_SODIUM_PWHASH_THREADS PHP_SODIUM_PWHASH_THREADS
61#else
62#define PHP_SODIUM_PWHASH_THREADS 1
63#endif
64
65#endif
66
67PHP_MINIT_FUNCTION(sodium);
68PHP_MINIT_FUNCTION(sodium_password_hash);
72PHP_MINFO_FUNCTION(sodium);
73
74#endif /* PHP_LIBSODIUM_H */
zend_module_entry sodium_module_entry
Definition libsodium.c:104
#define PHP_MSHUTDOWN_FUNCTION
Definition php.h:401
#define PHP_MINIT_FUNCTION
Definition php.h:400
#define PHP_MINFO_FUNCTION
Definition php.h:404
#define PHP_RINIT_FUNCTION
Definition php.h:402
#define PHP_RSHUTDOWN_FUNCTION
Definition php.h:403
struct _zend_module_entry zend_module_entry