author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
9 | 1 |
<?php |
2 |
namespace Sodium; |
|
3 |
||
16 | 4 |
require_once dirname(dirname(__FILE__)) . '/autoload.php'; |
5 |
||
9 | 6 |
use ParagonIE_Sodium_Compat; |
7 |
||
8 |
/** |
|
9 |
* This file will monkey patch the pure-PHP implementation in place of the |
|
10 |
* PECL functions, but only if they do not already exist. |
|
11 |
* |
|
12 |
* Thus, the functions just proxy to the appropriate ParagonIE_Sodium_Compat |
|
13 |
* method. |
|
14 |
*/ |
|
15 |
if (!is_callable('\\Sodium\\bin2hex')) { |
|
16 |
/** |
|
17 |
* @see ParagonIE_Sodium_Compat::bin2hex() |
|
18 |
* @param string $string |
|
19 |
* @return string |
|
20 |
* @throws \SodiumException |
|
21 |
* @throws \TypeError |
|
22 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
23 |
function bin2hex( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
24 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
25 |
$string |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
26 |
) { |
9 | 27 |
return ParagonIE_Sodium_Compat::bin2hex($string); |
28 |
} |
|
29 |
} |
|
30 |
if (!is_callable('\\Sodium\\compare')) { |
|
31 |
/** |
|
32 |
* @see ParagonIE_Sodium_Compat::compare() |
|
33 |
* @param string $a |
|
34 |
* @param string $b |
|
35 |
* @return int |
|
36 |
* @throws \SodiumException |
|
37 |
* @throws \TypeError |
|
38 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
39 |
function compare( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
40 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
41 |
$a, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
42 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
43 |
$b |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
44 |
) { |
9 | 45 |
return ParagonIE_Sodium_Compat::compare($a, $b); |
46 |
} |
|
47 |
} |
|
48 |
if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_decrypt')) { |
|
49 |
/** |
|
50 |
* @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt() |
|
51 |
* @param string $message |
|
52 |
* @param string $assocData |
|
53 |
* @param string $nonce |
|
54 |
* @param string $key |
|
55 |
* @return string|bool |
|
56 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
57 |
function crypto_aead_aes256gcm_decrypt( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
58 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
59 |
$assocData, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
60 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
61 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
62 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
63 |
) { |
9 | 64 |
try { |
65 |
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key); |
|
66 |
} catch (\TypeError $ex) { |
|
67 |
return false; |
|
68 |
} catch (\SodiumException $ex) { |
|
69 |
return false; |
|
70 |
} |
|
71 |
} |
|
72 |
} |
|
73 |
if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_encrypt')) { |
|
74 |
/** |
|
75 |
* @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt() |
|
76 |
* @param string $message |
|
77 |
* @param string $assocData |
|
78 |
* @param string $nonce |
|
79 |
* @param string $key |
|
80 |
* @return string |
|
81 |
* @throws \SodiumException |
|
82 |
* @throws \TypeError |
|
83 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
84 |
function crypto_aead_aes256gcm_encrypt( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
85 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
86 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
87 |
$assocData, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
88 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
89 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
90 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
91 |
) { |
9 | 92 |
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key); |
93 |
} |
|
94 |
} |
|
95 |
if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_is_available')) { |
|
96 |
/** |
|
97 |
* @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available() |
|
98 |
* @return bool |
|
99 |
*/ |
|
100 |
function crypto_aead_aes256gcm_is_available() |
|
101 |
{ |
|
102 |
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available(); |
|
103 |
} |
|
104 |
} |
|
105 |
if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_decrypt')) { |
|
106 |
/** |
|
107 |
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt() |
|
108 |
* @param string $message |
|
109 |
* @param string $assocData |
|
110 |
* @param string $nonce |
|
111 |
* @param string $key |
|
112 |
* @return string|bool |
|
113 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
114 |
function crypto_aead_chacha20poly1305_decrypt( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
115 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
116 |
$assocData, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
117 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
118 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
119 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
120 |
) { |
9 | 121 |
try { |
122 |
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key); |
|
123 |
} catch (\TypeError $ex) { |
|
124 |
return false; |
|
125 |
} catch (\SodiumException $ex) { |
|
126 |
return false; |
|
127 |
} |
|
128 |
} |
|
129 |
} |
|
130 |
if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_encrypt')) { |
|
131 |
/** |
|
132 |
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt() |
|
133 |
* @param string $message |
|
134 |
* @param string $assocData |
|
135 |
* @param string $nonce |
|
136 |
* @param string $key |
|
137 |
* @return string |
|
138 |
* @throws \SodiumException |
|
139 |
* @throws \TypeError |
|
140 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
141 |
function crypto_aead_chacha20poly1305_encrypt( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
142 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
143 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
144 |
$assocData, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
145 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
146 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
147 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
148 |
) { |
9 | 149 |
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key); |
150 |
} |
|
151 |
} |
|
152 |
if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_decrypt')) { |
|
153 |
/** |
|
154 |
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt() |
|
155 |
* @param string $message |
|
156 |
* @param string $assocData |
|
157 |
* @param string $nonce |
|
158 |
* @param string $key |
|
159 |
* @return string|bool |
|
160 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
161 |
function crypto_aead_chacha20poly1305_ietf_decrypt( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
162 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
163 |
$assocData, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
164 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
165 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
166 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
167 |
) { |
9 | 168 |
try { |
169 |
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key); |
|
170 |
} catch (\TypeError $ex) { |
|
171 |
return false; |
|
172 |
} catch (\SodiumException $ex) { |
|
173 |
return false; |
|
174 |
} |
|
175 |
} |
|
176 |
} |
|
177 |
if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_encrypt')) { |
|
178 |
/** |
|
179 |
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt() |
|
180 |
* @param string $message |
|
181 |
* @param string $assocData |
|
182 |
* @param string $nonce |
|
183 |
* @param string $key |
|
184 |
* @return string |
|
185 |
* @throws \SodiumException |
|
186 |
* @throws \TypeError |
|
187 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
188 |
function crypto_aead_chacha20poly1305_ietf_encrypt( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
189 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
190 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
191 |
$assocData, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
192 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
193 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
194 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
195 |
) { |
9 | 196 |
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key); |
197 |
} |
|
198 |
} |
|
199 |
if (!is_callable('\\Sodium\\crypto_auth')) { |
|
200 |
/** |
|
201 |
* @see ParagonIE_Sodium_Compat::crypto_auth() |
|
202 |
* @param string $message |
|
203 |
* @param string $key |
|
204 |
* @return string |
|
205 |
* @throws \SodiumException |
|
206 |
* @throws \TypeError |
|
207 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
208 |
function crypto_auth( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
209 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
210 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
211 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
212 |
) { |
9 | 213 |
return ParagonIE_Sodium_Compat::crypto_auth($message, $key); |
214 |
} |
|
215 |
} |
|
216 |
if (!is_callable('\\Sodium\\crypto_auth_verify')) { |
|
217 |
/** |
|
218 |
* @see ParagonIE_Sodium_Compat::crypto_auth_verify() |
|
219 |
* @param string $mac |
|
220 |
* @param string $message |
|
221 |
* @param string $key |
|
222 |
* @return bool |
|
223 |
* @throws \SodiumException |
|
224 |
* @throws \TypeError |
|
225 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
226 |
function crypto_auth_verify( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
227 |
$mac, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
228 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
229 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
230 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
231 |
) { |
9 | 232 |
return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key); |
233 |
} |
|
234 |
} |
|
235 |
if (!is_callable('\\Sodium\\crypto_box')) { |
|
236 |
/** |
|
237 |
* @see ParagonIE_Sodium_Compat::crypto_box() |
|
238 |
* @param string $message |
|
239 |
* @param string $nonce |
|
240 |
* @param string $kp |
|
241 |
* @return string |
|
242 |
* @throws \SodiumException |
|
243 |
* @throws \TypeError |
|
244 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
245 |
function crypto_box( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
246 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
247 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
248 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
249 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
250 |
$kp |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
251 |
) { |
9 | 252 |
return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp); |
253 |
} |
|
254 |
} |
|
255 |
if (!is_callable('\\Sodium\\crypto_box_keypair')) { |
|
256 |
/** |
|
257 |
* @see ParagonIE_Sodium_Compat::crypto_box_keypair() |
|
258 |
* @return string |
|
259 |
* @throws \SodiumException |
|
260 |
* @throws \TypeError |
|
261 |
*/ |
|
262 |
function crypto_box_keypair() |
|
263 |
{ |
|
264 |
return ParagonIE_Sodium_Compat::crypto_box_keypair(); |
|
265 |
} |
|
266 |
} |
|
267 |
if (!is_callable('\\Sodium\\crypto_box_keypair_from_secretkey_and_publickey')) { |
|
268 |
/** |
|
269 |
* @see ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey() |
|
270 |
* @param string $sk |
|
271 |
* @param string $pk |
|
272 |
* @return string |
|
273 |
* @throws \SodiumException |
|
274 |
* @throws \TypeError |
|
275 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
276 |
function crypto_box_keypair_from_secretkey_and_publickey( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
277 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
278 |
$sk, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
279 |
$pk |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
280 |
) { |
9 | 281 |
return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk); |
282 |
} |
|
283 |
} |
|
284 |
if (!is_callable('\\Sodium\\crypto_box_open')) { |
|
285 |
/** |
|
286 |
* @see ParagonIE_Sodium_Compat::crypto_box_open() |
|
287 |
* @param string $message |
|
288 |
* @param string $nonce |
|
289 |
* @param string $kp |
|
290 |
* @return string|bool |
|
291 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
292 |
function crypto_box_open( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
293 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
294 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
295 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
296 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
297 |
$kp |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
298 |
) { |
9 | 299 |
try { |
300 |
return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp); |
|
301 |
} catch (\TypeError $ex) { |
|
302 |
return false; |
|
303 |
} catch (\SodiumException $ex) { |
|
304 |
return false; |
|
305 |
} |
|
306 |
} |
|
307 |
} |
|
308 |
if (!is_callable('\\Sodium\\crypto_box_publickey')) { |
|
309 |
/** |
|
310 |
* @see ParagonIE_Sodium_Compat::crypto_box_publickey() |
|
311 |
* @param string $keypair |
|
312 |
* @return string |
|
313 |
* @throws \SodiumException |
|
314 |
* @throws \TypeError |
|
315 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
316 |
function crypto_box_publickey( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
317 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
318 |
$keypair |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
319 |
) { |
9 | 320 |
return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair); |
321 |
} |
|
322 |
} |
|
323 |
if (!is_callable('\\Sodium\\crypto_box_publickey_from_secretkey')) { |
|
324 |
/** |
|
325 |
* @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey() |
|
326 |
* @param string $sk |
|
327 |
* @return string |
|
328 |
* @throws \SodiumException |
|
329 |
* @throws \TypeError |
|
330 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
331 |
function crypto_box_publickey_from_secretkey( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
332 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
333 |
$sk |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
334 |
) { |
9 | 335 |
return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($sk); |
336 |
} |
|
337 |
} |
|
338 |
if (!is_callable('\\Sodium\\crypto_box_seal')) { |
|
339 |
/** |
|
340 |
* @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
|
341 |
* @param string $message |
|
342 |
* @param string $publicKey |
|
343 |
* @return string |
|
344 |
* @throws \SodiumException |
|
345 |
* @throws \TypeError |
|
346 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
347 |
function crypto_box_seal( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
348 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
349 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
350 |
$publicKey |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
351 |
) { |
9 | 352 |
return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey); |
353 |
} |
|
354 |
} |
|
355 |
if (!is_callable('\\Sodium\\crypto_box_seal_open')) { |
|
356 |
/** |
|
357 |
* @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
|
358 |
* @param string $message |
|
359 |
* @param string $kp |
|
360 |
* @return string|bool |
|
361 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
362 |
function crypto_box_seal_open( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
363 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
364 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
365 |
$kp |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
366 |
) { |
9 | 367 |
try { |
368 |
return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp); |
|
369 |
} catch (\TypeError $ex) { |
|
370 |
return false; |
|
371 |
} catch (\SodiumException $ex) { |
|
372 |
return false; |
|
373 |
} |
|
374 |
} |
|
375 |
} |
|
376 |
if (!is_callable('\\Sodium\\crypto_box_secretkey')) { |
|
377 |
/** |
|
378 |
* @see ParagonIE_Sodium_Compat::crypto_box_secretkey() |
|
379 |
* @param string $keypair |
|
380 |
* @return string |
|
381 |
* @throws \SodiumException |
|
382 |
* @throws \TypeError |
|
383 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
384 |
function crypto_box_secretkey( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
385 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
386 |
$keypair |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
387 |
) { |
9 | 388 |
return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair); |
389 |
} |
|
390 |
} |
|
391 |
if (!is_callable('\\Sodium\\crypto_generichash')) { |
|
392 |
/** |
|
393 |
* @see ParagonIE_Sodium_Compat::crypto_generichash() |
|
394 |
* @param string $message |
|
395 |
* @param string|null $key |
|
396 |
* @param int $outLen |
|
397 |
* @return string |
|
398 |
* @throws \SodiumException |
|
399 |
* @throws \TypeError |
|
400 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
401 |
function crypto_generichash( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
402 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
403 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
404 |
$key = null, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
405 |
$outLen = 32 |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
406 |
) { |
9 | 407 |
return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen); |
408 |
} |
|
409 |
} |
|
410 |
if (!is_callable('\\Sodium\\crypto_generichash_final')) { |
|
411 |
/** |
|
412 |
* @see ParagonIE_Sodium_Compat::crypto_generichash_final() |
|
413 |
* @param string|null $ctx |
|
414 |
* @param int $outputLength |
|
415 |
* @return string |
|
416 |
* @throws \SodiumException |
|
417 |
* @throws \TypeError |
|
418 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
419 |
function crypto_generichash_final( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
420 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
421 |
&$ctx, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
422 |
$outputLength = 32 |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
423 |
) { |
9 | 424 |
return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength); |
425 |
} |
|
426 |
} |
|
427 |
if (!is_callable('\\Sodium\\crypto_generichash_init')) { |
|
428 |
/** |
|
429 |
* @see ParagonIE_Sodium_Compat::crypto_generichash_init() |
|
430 |
* @param string|null $key |
|
431 |
* @param int $outLen |
|
432 |
* @return string |
|
433 |
* @throws \SodiumException |
|
434 |
* @throws \TypeError |
|
435 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
436 |
function crypto_generichash_init( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
437 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
438 |
$key = null, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
439 |
$outLen = 32 |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
440 |
) { |
9 | 441 |
return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen); |
442 |
} |
|
443 |
} |
|
444 |
if (!is_callable('\\Sodium\\crypto_generichash_update')) { |
|
445 |
/** |
|
446 |
* @see ParagonIE_Sodium_Compat::crypto_generichash_update() |
|
447 |
* @param string|null $ctx |
|
448 |
* @param string $message |
|
449 |
* @return void |
|
450 |
* @throws \SodiumException |
|
451 |
* @throws \TypeError |
|
452 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
453 |
function crypto_generichash_update( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
454 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
455 |
&$ctx, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
456 |
$message = '' |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
457 |
) { |
9 | 458 |
ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message); |
459 |
} |
|
460 |
} |
|
461 |
if (!is_callable('\\Sodium\\crypto_kx')) { |
|
462 |
/** |
|
463 |
* @see ParagonIE_Sodium_Compat::crypto_kx() |
|
464 |
* @param string $my_secret |
|
465 |
* @param string $their_public |
|
466 |
* @param string $client_public |
|
467 |
* @param string $server_public |
|
468 |
* @return string |
|
469 |
* @throws \SodiumException |
|
470 |
* @throws \TypeError |
|
471 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
472 |
function crypto_kx( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
473 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
474 |
$my_secret, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
475 |
$their_public, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
476 |
$client_public, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
477 |
$server_public |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
478 |
) { |
9 | 479 |
return ParagonIE_Sodium_Compat::crypto_kx( |
480 |
$my_secret, |
|
481 |
$their_public, |
|
482 |
$client_public, |
|
18 | 483 |
$server_public, |
484 |
true |
|
9 | 485 |
); |
486 |
} |
|
487 |
} |
|
488 |
if (!is_callable('\\Sodium\\crypto_pwhash')) { |
|
489 |
/** |
|
490 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash() |
|
491 |
* @param int $outlen |
|
492 |
* @param string $passwd |
|
493 |
* @param string $salt |
|
494 |
* @param int $opslimit |
|
495 |
* @param int $memlimit |
|
496 |
* @return string |
|
497 |
* @throws \SodiumException |
|
498 |
* @throws \TypeError |
|
499 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
500 |
function crypto_pwhash( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
501 |
$outlen, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
502 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
503 |
$passwd, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
504 |
$salt, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
505 |
$opslimit, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
506 |
$memlimit |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
507 |
) { |
9 | 508 |
return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit); |
509 |
} |
|
510 |
} |
|
511 |
if (!is_callable('\\Sodium\\crypto_pwhash_str')) { |
|
512 |
/** |
|
513 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_str() |
|
514 |
* @param string $passwd |
|
515 |
* @param int $opslimit |
|
516 |
* @param int $memlimit |
|
517 |
* @return string |
|
518 |
* @throws \SodiumException |
|
519 |
* @throws \TypeError |
|
520 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
521 |
function crypto_pwhash_str( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
522 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
523 |
$passwd, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
524 |
$opslimit, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
525 |
$memlimit |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
526 |
) { |
9 | 527 |
return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit); |
528 |
} |
|
529 |
} |
|
530 |
if (!is_callable('\\Sodium\\crypto_pwhash_str_verify')) { |
|
531 |
/** |
|
532 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify() |
|
533 |
* @param string $passwd |
|
534 |
* @param string $hash |
|
535 |
* @return bool |
|
536 |
* @throws \SodiumException |
|
537 |
* @throws \TypeError |
|
538 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
539 |
function crypto_pwhash_str_verify( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
540 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
541 |
$passwd, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
542 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
543 |
$hash |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
544 |
) { |
9 | 545 |
return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash); |
546 |
} |
|
547 |
} |
|
548 |
if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256')) { |
|
549 |
/** |
|
550 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256() |
|
551 |
* @param int $outlen |
|
552 |
* @param string $passwd |
|
553 |
* @param string $salt |
|
554 |
* @param int $opslimit |
|
555 |
* @param int $memlimit |
|
556 |
* @return string |
|
557 |
* @throws \SodiumException |
|
558 |
* @throws \TypeError |
|
559 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
560 |
function crypto_pwhash_scryptsalsa208sha256( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
561 |
$outlen, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
562 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
563 |
$passwd, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
564 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
565 |
$salt, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
566 |
$opslimit, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
567 |
$memlimit |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
568 |
) { |
9 | 569 |
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit); |
570 |
} |
|
571 |
} |
|
572 |
if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str')) { |
|
573 |
/** |
|
574 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str() |
|
575 |
* @param string $passwd |
|
576 |
* @param int $opslimit |
|
577 |
* @param int $memlimit |
|
578 |
* @return string |
|
579 |
* @throws \SodiumException |
|
580 |
* @throws \TypeError |
|
581 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
582 |
function crypto_pwhash_scryptsalsa208sha256_str( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
583 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
584 |
$passwd, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
585 |
$opslimit, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
586 |
$memlimit |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
587 |
) { |
9 | 588 |
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit); |
589 |
} |
|
590 |
} |
|
591 |
if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify')) { |
|
592 |
/** |
|
593 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify() |
|
594 |
* @param string $passwd |
|
595 |
* @param string $hash |
|
596 |
* @return bool |
|
597 |
* @throws \SodiumException |
|
598 |
* @throws \TypeError |
|
599 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
600 |
function crypto_pwhash_scryptsalsa208sha256_str_verify( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
601 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
602 |
$passwd, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
603 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
604 |
$hash |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
605 |
) { |
9 | 606 |
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash); |
607 |
} |
|
608 |
} |
|
609 |
if (!is_callable('\\Sodium\\crypto_scalarmult')) { |
|
610 |
/** |
|
611 |
* @see ParagonIE_Sodium_Compat::crypto_scalarmult() |
|
612 |
* @param string $n |
|
613 |
* @param string $p |
|
614 |
* @return string |
|
615 |
* @throws \SodiumException |
|
616 |
* @throws \TypeError |
|
617 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
618 |
function crypto_scalarmult( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
619 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
620 |
$n, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
621 |
$p |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
622 |
) { |
9 | 623 |
return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p); |
624 |
} |
|
625 |
} |
|
626 |
if (!is_callable('\\Sodium\\crypto_scalarmult_base')) { |
|
627 |
/** |
|
628 |
* @see ParagonIE_Sodium_Compat::crypto_scalarmult_base() |
|
629 |
* @param string $n |
|
630 |
* @return string |
|
631 |
* @throws \SodiumException |
|
632 |
* @throws \TypeError |
|
633 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
634 |
function crypto_scalarmult_base( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
635 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
636 |
$n |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
637 |
) { |
9 | 638 |
return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n); |
639 |
} |
|
640 |
} |
|
641 |
if (!is_callable('\\Sodium\\crypto_secretbox')) { |
|
642 |
/** |
|
643 |
* @see ParagonIE_Sodium_Compat::crypto_secretbox() |
|
644 |
* @param string $message |
|
645 |
* @param string $nonce |
|
646 |
* @param string $key |
|
647 |
* @return string |
|
648 |
* @throws \SodiumException |
|
649 |
* @throws \TypeError |
|
650 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
651 |
function crypto_secretbox( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
652 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
653 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
654 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
655 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
656 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
657 |
) { |
9 | 658 |
return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key); |
659 |
} |
|
660 |
} |
|
661 |
if (!is_callable('\\Sodium\\crypto_secretbox_open')) { |
|
662 |
/** |
|
663 |
* @see ParagonIE_Sodium_Compat::crypto_secretbox_open() |
|
664 |
* @param string $message |
|
665 |
* @param string $nonce |
|
666 |
* @param string $key |
|
667 |
* @return string|bool |
|
668 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
669 |
function crypto_secretbox_open( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
670 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
671 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
672 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
673 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
674 |
) { |
9 | 675 |
try { |
676 |
return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key); |
|
677 |
} catch (\TypeError $ex) { |
|
678 |
return false; |
|
679 |
} catch (\SodiumException $ex) { |
|
680 |
return false; |
|
681 |
} |
|
682 |
} |
|
683 |
} |
|
684 |
if (!is_callable('\\Sodium\\crypto_shorthash')) { |
|
685 |
/** |
|
686 |
* @see ParagonIE_Sodium_Compat::crypto_shorthash() |
|
687 |
* @param string $message |
|
688 |
* @param string $key |
|
689 |
* @return string |
|
690 |
* @throws \SodiumException |
|
691 |
* @throws \TypeError |
|
692 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
693 |
function crypto_shorthash( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
694 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
695 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
696 |
$key = '' |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
697 |
) { |
9 | 698 |
return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key); |
699 |
} |
|
700 |
} |
|
701 |
if (!is_callable('\\Sodium\\crypto_sign')) { |
|
702 |
/** |
|
703 |
* @see ParagonIE_Sodium_Compat::crypto_sign() |
|
704 |
* @param string $message |
|
705 |
* @param string $sk |
|
706 |
* @return string |
|
707 |
* @throws \SodiumException |
|
708 |
* @throws \TypeError |
|
709 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
710 |
function crypto_sign( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
711 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
712 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
713 |
$sk |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
714 |
) { |
9 | 715 |
return ParagonIE_Sodium_Compat::crypto_sign($message, $sk); |
716 |
} |
|
717 |
} |
|
718 |
if (!is_callable('\\Sodium\\crypto_sign_detached')) { |
|
719 |
/** |
|
720 |
* @see ParagonIE_Sodium_Compat::crypto_sign_detached() |
|
721 |
* @param string $message |
|
722 |
* @param string $sk |
|
723 |
* @return string |
|
724 |
* @throws \SodiumException |
|
725 |
* @throws \TypeError |
|
726 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
727 |
function crypto_sign_detached( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
728 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
729 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
730 |
$sk |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
731 |
) { |
9 | 732 |
return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk); |
733 |
} |
|
734 |
} |
|
735 |
if (!is_callable('\\Sodium\\crypto_sign_keypair')) { |
|
736 |
/** |
|
737 |
* @see ParagonIE_Sodium_Compat::crypto_sign_keypair() |
|
738 |
* @return string |
|
739 |
* @throws \SodiumException |
|
740 |
* @throws \TypeError |
|
741 |
*/ |
|
742 |
function crypto_sign_keypair() |
|
743 |
{ |
|
744 |
return ParagonIE_Sodium_Compat::crypto_sign_keypair(); |
|
745 |
} |
|
746 |
} |
|
747 |
if (!is_callable('\\Sodium\\crypto_sign_open')) { |
|
748 |
/** |
|
749 |
* @see ParagonIE_Sodium_Compat::crypto_sign_open() |
|
750 |
* @param string $signedMessage |
|
751 |
* @param string $pk |
|
752 |
* @return string|bool |
|
753 |
*/ |
|
754 |
function crypto_sign_open($signedMessage, $pk) |
|
755 |
{ |
|
756 |
try { |
|
757 |
return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $pk); |
|
758 |
} catch (\TypeError $ex) { |
|
759 |
return false; |
|
760 |
} catch (\SodiumException $ex) { |
|
761 |
return false; |
|
762 |
} |
|
763 |
} |
|
764 |
} |
|
765 |
if (!is_callable('\\Sodium\\crypto_sign_publickey')) { |
|
766 |
/** |
|
767 |
* @see ParagonIE_Sodium_Compat::crypto_sign_publickey() |
|
768 |
* @param string $keypair |
|
769 |
* @return string |
|
770 |
* @throws \SodiumException |
|
771 |
* @throws \TypeError |
|
772 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
773 |
function crypto_sign_publickey( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
774 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
775 |
$keypair |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
776 |
) { |
9 | 777 |
return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair); |
778 |
} |
|
779 |
} |
|
780 |
if (!is_callable('\\Sodium\\crypto_sign_publickey_from_secretkey')) { |
|
781 |
/** |
|
782 |
* @see ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey() |
|
783 |
* @param string $sk |
|
784 |
* @return string |
|
785 |
* @throws \SodiumException |
|
786 |
* @throws \TypeError |
|
787 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
788 |
function crypto_sign_publickey_from_secretkey( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
789 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
790 |
$sk |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
791 |
) { |
9 | 792 |
return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk); |
793 |
} |
|
794 |
} |
|
795 |
if (!is_callable('\\Sodium\\crypto_sign_secretkey')) { |
|
796 |
/** |
|
797 |
* @see ParagonIE_Sodium_Compat::crypto_sign_secretkey() |
|
798 |
* @param string $keypair |
|
799 |
* @return string |
|
800 |
* @throws \SodiumException |
|
801 |
* @throws \TypeError |
|
802 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
803 |
function crypto_sign_secretkey( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
804 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
805 |
$keypair |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
806 |
) { |
9 | 807 |
return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair); |
808 |
} |
|
809 |
} |
|
810 |
if (!is_callable('\\Sodium\\crypto_sign_seed_keypair')) { |
|
811 |
/** |
|
812 |
* @see ParagonIE_Sodium_Compat::crypto_sign_seed_keypair() |
|
813 |
* @param string $seed |
|
814 |
* @return string |
|
815 |
* @throws \SodiumException |
|
816 |
* @throws \TypeError |
|
817 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
818 |
function crypto_sign_seed_keypair( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
819 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
820 |
$seed |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
821 |
) { |
9 | 822 |
return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed); |
823 |
} |
|
824 |
} |
|
825 |
if (!is_callable('\\Sodium\\crypto_sign_verify_detached')) { |
|
826 |
/** |
|
827 |
* @see ParagonIE_Sodium_Compat::crypto_sign_verify_detached() |
|
828 |
* @param string $signature |
|
829 |
* @param string $message |
|
830 |
* @param string $pk |
|
831 |
* @return bool |
|
832 |
* @throws \SodiumException |
|
833 |
* @throws \TypeError |
|
834 |
*/ |
|
835 |
function crypto_sign_verify_detached($signature, $message, $pk) |
|
836 |
{ |
|
837 |
return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $pk); |
|
838 |
} |
|
839 |
} |
|
840 |
if (!is_callable('\\Sodium\\crypto_sign_ed25519_pk_to_curve25519')) { |
|
841 |
/** |
|
842 |
* @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519() |
|
843 |
* @param string $pk |
|
844 |
* @return string |
|
845 |
* @throws \SodiumException |
|
846 |
* @throws \TypeError |
|
847 |
*/ |
|
848 |
function crypto_sign_ed25519_pk_to_curve25519($pk) |
|
849 |
{ |
|
850 |
return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($pk); |
|
851 |
} |
|
852 |
} |
|
853 |
if (!is_callable('\\Sodium\\crypto_sign_ed25519_sk_to_curve25519')) { |
|
854 |
/** |
|
855 |
* @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519() |
|
856 |
* @param string $sk |
|
857 |
* @return string |
|
858 |
* @throws \SodiumException |
|
859 |
* @throws \TypeError |
|
860 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
861 |
function crypto_sign_ed25519_sk_to_curve25519( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
862 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
863 |
$sk |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
864 |
) { |
9 | 865 |
return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($sk); |
866 |
} |
|
867 |
} |
|
868 |
if (!is_callable('\\Sodium\\crypto_stream')) { |
|
869 |
/** |
|
870 |
* @see ParagonIE_Sodium_Compat::crypto_stream() |
|
871 |
* @param int $len |
|
872 |
* @param string $nonce |
|
873 |
* @param string $key |
|
874 |
* @return string |
|
875 |
* @throws \SodiumException |
|
876 |
* @throws \TypeError |
|
877 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
878 |
function crypto_stream( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
879 |
$len, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
880 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
881 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
882 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
883 |
) { |
9 | 884 |
return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key); |
885 |
} |
|
886 |
} |
|
887 |
if (!is_callable('\\Sodium\\crypto_stream_xor')) { |
|
888 |
/** |
|
889 |
* @see ParagonIE_Sodium_Compat::crypto_stream_xor() |
|
890 |
* @param string $message |
|
891 |
* @param string $nonce |
|
892 |
* @param string $key |
|
893 |
* @return string |
|
894 |
* @throws \SodiumException |
|
895 |
* @throws \TypeError |
|
896 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
897 |
function crypto_stream_xor( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
898 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
899 |
$message, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
900 |
$nonce, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
901 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
902 |
$key |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
903 |
) { |
9 | 904 |
return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key); |
905 |
} |
|
906 |
} |
|
907 |
if (!is_callable('\\Sodium\\hex2bin')) { |
|
908 |
/** |
|
909 |
* @see ParagonIE_Sodium_Compat::hex2bin() |
|
910 |
* @param string $string |
|
911 |
* @return string |
|
912 |
* @throws \SodiumException |
|
913 |
* @throws \TypeError |
|
914 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
915 |
function hex2bin( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
916 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
917 |
$string |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
918 |
) { |
9 | 919 |
return ParagonIE_Sodium_Compat::hex2bin($string); |
920 |
} |
|
921 |
} |
|
922 |
if (!is_callable('\\Sodium\\memcmp')) { |
|
923 |
/** |
|
924 |
* @see ParagonIE_Sodium_Compat::memcmp() |
|
925 |
* @param string $a |
|
926 |
* @param string $b |
|
927 |
* @return int |
|
928 |
* @throws \SodiumException |
|
929 |
* @throws \TypeError |
|
930 |
*/ |
|
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
931 |
function memcmp( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
932 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
933 |
$a, |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
934 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
935 |
$b |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
936 |
) { |
9 | 937 |
return ParagonIE_Sodium_Compat::memcmp($a, $b); |
938 |
} |
|
939 |
} |
|
940 |
if (!is_callable('\\Sodium\\memzero')) { |
|
941 |
/** |
|
942 |
* @see ParagonIE_Sodium_Compat::memzero() |
|
943 |
* @param string $str |
|
944 |
* @return void |
|
945 |
* @throws \SodiumException |
|
946 |
* @throws \TypeError |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
947 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
948 |
* @psalm-suppress MissingParamType |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
949 |
* @psalm-suppress MissingReturnType |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
950 |
* @psalm-suppress ReferenceConstraintViolation |
9 | 951 |
*/ |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
952 |
function memzero( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
953 |
#[\SensitiveParameter] |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
954 |
&$str |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
955 |
) { |
9 | 956 |
ParagonIE_Sodium_Compat::memzero($str); |
957 |
} |
|
958 |
} |
|
959 |
if (!is_callable('\\Sodium\\randombytes_buf')) { |
|
960 |
/** |
|
961 |
* @see ParagonIE_Sodium_Compat::randombytes_buf() |
|
962 |
* @param int $amount |
|
963 |
* @return string |
|
964 |
* @throws \TypeError |
|
965 |
*/ |
|
966 |
function randombytes_buf($amount) |
|
967 |
{ |
|
968 |
return ParagonIE_Sodium_Compat::randombytes_buf($amount); |
|
969 |
} |
|
970 |
} |
|
971 |
||
972 |
if (!is_callable('\\Sodium\\randombytes_uniform')) { |
|
973 |
/** |
|
974 |
* @see ParagonIE_Sodium_Compat::randombytes_uniform() |
|
975 |
* @param int $upperLimit |
|
976 |
* @return int |
|
977 |
* @throws \SodiumException |
|
978 |
* @throws \Error |
|
979 |
*/ |
|
980 |
function randombytes_uniform($upperLimit) |
|
981 |
{ |
|
982 |
return ParagonIE_Sodium_Compat::randombytes_uniform($upperLimit); |
|
983 |
} |
|
984 |
} |
|
985 |
||
986 |
if (!is_callable('\\Sodium\\randombytes_random16')) { |
|
987 |
/** |
|
988 |
* @see ParagonIE_Sodium_Compat::randombytes_random16() |
|
989 |
* @return int |
|
990 |
*/ |
|
991 |
function randombytes_random16() |
|
992 |
{ |
|
993 |
return ParagonIE_Sodium_Compat::randombytes_random16(); |
|
994 |
} |
|
995 |
} |
|
996 |
||
997 |
if (!defined('\\Sodium\\CRYPTO_AUTH_BYTES')) { |
|
998 |
require_once dirname(__FILE__) . '/constants.php'; |
|
999 |
} |