author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 18 | be944660c56a |
child 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
9 | 1 |
<?php |
2 |
||
16 | 3 |
require_once dirname(dirname(__FILE__)) . '/autoload.php'; |
4 |
||
9 | 5 |
/** |
6 |
* This file will monkey patch the pure-PHP implementation in place of the |
|
7 |
* PECL functions and constants, but only if they do not already exist. |
|
8 |
* |
|
9 |
* Thus, the functions or constants just proxy to the appropriate |
|
10 |
* ParagonIE_Sodium_Compat method or class constant, respectively. |
|
11 |
*/ |
|
12 |
foreach (array( |
|
16 | 13 |
'BASE64_VARIANT_ORIGINAL', |
14 |
'BASE64_VARIANT_ORIGINAL_NO_PADDING', |
|
15 |
'BASE64_VARIANT_URLSAFE', |
|
16 |
'BASE64_VARIANT_URLSAFE_NO_PADDING', |
|
9 | 17 |
'CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES', |
18 |
'CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES', |
|
19 |
'CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES', |
|
20 |
'CRYPTO_AEAD_CHACHA20POLY1305_ABYTES', |
|
21 |
'CRYPTO_AEAD_AES256GCM_KEYBYTES', |
|
22 |
'CRYPTO_AEAD_AES256GCM_NSECBYTES', |
|
23 |
'CRYPTO_AEAD_AES256GCM_NPUBBYTES', |
|
24 |
'CRYPTO_AEAD_AES256GCM_ABYTES', |
|
25 |
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES', |
|
26 |
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES', |
|
27 |
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES', |
|
28 |
'CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES', |
|
18 | 29 |
'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES', |
30 |
'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES', |
|
31 |
'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES', |
|
32 |
'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES', |
|
9 | 33 |
'CRYPTO_AUTH_BYTES', |
34 |
'CRYPTO_AUTH_KEYBYTES', |
|
35 |
'CRYPTO_BOX_SEALBYTES', |
|
36 |
'CRYPTO_BOX_SECRETKEYBYTES', |
|
37 |
'CRYPTO_BOX_PUBLICKEYBYTES', |
|
38 |
'CRYPTO_BOX_KEYPAIRBYTES', |
|
39 |
'CRYPTO_BOX_MACBYTES', |
|
40 |
'CRYPTO_BOX_NONCEBYTES', |
|
41 |
'CRYPTO_BOX_SEEDBYTES', |
|
16 | 42 |
'CRYPTO_KDF_BYTES_MIN', |
43 |
'CRYPTO_KDF_BYTES_MAX', |
|
44 |
'CRYPTO_KDF_CONTEXTBYTES', |
|
45 |
'CRYPTO_KDF_KEYBYTES', |
|
9 | 46 |
'CRYPTO_KX_BYTES', |
16 | 47 |
'CRYPTO_KX_KEYPAIRBYTES', |
48 |
'CRYPTO_KX_PRIMITIVE', |
|
9 | 49 |
'CRYPTO_KX_SEEDBYTES', |
50 |
'CRYPTO_KX_PUBLICKEYBYTES', |
|
51 |
'CRYPTO_KX_SECRETKEYBYTES', |
|
16 | 52 |
'CRYPTO_KX_SESSIONKEYBYTES', |
9 | 53 |
'CRYPTO_GENERICHASH_BYTES', |
54 |
'CRYPTO_GENERICHASH_BYTES_MIN', |
|
55 |
'CRYPTO_GENERICHASH_BYTES_MAX', |
|
56 |
'CRYPTO_GENERICHASH_KEYBYTES', |
|
57 |
'CRYPTO_GENERICHASH_KEYBYTES_MIN', |
|
58 |
'CRYPTO_GENERICHASH_KEYBYTES_MAX', |
|
59 |
'CRYPTO_PWHASH_SALTBYTES', |
|
60 |
'CRYPTO_PWHASH_STRPREFIX', |
|
61 |
'CRYPTO_PWHASH_ALG_ARGON2I13', |
|
62 |
'CRYPTO_PWHASH_ALG_ARGON2ID13', |
|
63 |
'CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE', |
|
64 |
'CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE', |
|
65 |
'CRYPTO_PWHASH_MEMLIMIT_MODERATE', |
|
66 |
'CRYPTO_PWHASH_OPSLIMIT_MODERATE', |
|
67 |
'CRYPTO_PWHASH_MEMLIMIT_SENSITIVE', |
|
68 |
'CRYPTO_PWHASH_OPSLIMIT_SENSITIVE', |
|
18 | 69 |
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES', |
70 |
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX', |
|
71 |
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE', |
|
72 |
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE', |
|
73 |
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE', |
|
74 |
'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE', |
|
9 | 75 |
'CRYPTO_SCALARMULT_BYTES', |
76 |
'CRYPTO_SCALARMULT_SCALARBYTES', |
|
77 |
'CRYPTO_SHORTHASH_BYTES', |
|
78 |
'CRYPTO_SHORTHASH_KEYBYTES', |
|
79 |
'CRYPTO_SECRETBOX_KEYBYTES', |
|
80 |
'CRYPTO_SECRETBOX_MACBYTES', |
|
81 |
'CRYPTO_SECRETBOX_NONCEBYTES', |
|
16 | 82 |
'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES', |
83 |
'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES', |
|
84 |
'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES', |
|
85 |
'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PUSH', |
|
86 |
'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PULL', |
|
87 |
'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY', |
|
88 |
'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL', |
|
89 |
'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX', |
|
9 | 90 |
'CRYPTO_SIGN_BYTES', |
91 |
'CRYPTO_SIGN_SEEDBYTES', |
|
92 |
'CRYPTO_SIGN_PUBLICKEYBYTES', |
|
93 |
'CRYPTO_SIGN_SECRETKEYBYTES', |
|
94 |
'CRYPTO_SIGN_KEYPAIRBYTES', |
|
95 |
'CRYPTO_STREAM_KEYBYTES', |
|
96 |
'CRYPTO_STREAM_NONCEBYTES', |
|
18 | 97 |
'CRYPTO_STREAM_XCHACHA20_KEYBYTES', |
98 |
'CRYPTO_STREAM_XCHACHA20_NONCEBYTES', |
|
99 |
'LIBRARY_MAJOR_VERSION', |
|
100 |
'LIBRARY_MINOR_VERSION', |
|
9 | 101 |
'LIBRARY_VERSION_MAJOR', |
102 |
'LIBRARY_VERSION_MINOR', |
|
103 |
'VERSION_STRING' |
|
104 |
) as $constant |
|
105 |
) { |
|
16 | 106 |
if (!defined("SODIUM_$constant") && defined("ParagonIE_Sodium_Compat::$constant")) { |
9 | 107 |
define("SODIUM_$constant", constant("ParagonIE_Sodium_Compat::$constant")); |
108 |
} |
|
109 |
} |
|
16 | 110 |
if (!is_callable('sodium_add')) { |
111 |
/** |
|
112 |
* @see ParagonIE_Sodium_Compat::add() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
113 |
* @param string $string1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
114 |
* @param string $string2 |
16 | 115 |
* @return void |
116 |
* @throws SodiumException |
|
117 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
118 |
function sodium_add(&$string1, $string2) |
16 | 119 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
120 |
ParagonIE_Sodium_Compat::add($string1, $string2); |
16 | 121 |
} |
122 |
} |
|
123 |
if (!is_callable('sodium_base642bin')) { |
|
124 |
/** |
|
125 |
* @see ParagonIE_Sodium_Compat::bin2base64() |
|
126 |
* @param string $string |
|
127 |
* @param int $variant |
|
128 |
* @param string $ignore |
|
129 |
* @return string |
|
130 |
* @throws SodiumException |
|
131 |
* @throws TypeError |
|
132 |
*/ |
|
133 |
function sodium_base642bin($string, $variant, $ignore ='') |
|
134 |
{ |
|
135 |
return ParagonIE_Sodium_Compat::base642bin($string, $variant, $ignore); |
|
136 |
} |
|
137 |
} |
|
138 |
if (!is_callable('sodium_bin2base64')) { |
|
139 |
/** |
|
140 |
* @see ParagonIE_Sodium_Compat::bin2base64() |
|
141 |
* @param string $string |
|
142 |
* @param int $variant |
|
143 |
* @return string |
|
144 |
* @throws SodiumException |
|
145 |
* @throws TypeError |
|
146 |
*/ |
|
147 |
function sodium_bin2base64($string, $variant) |
|
148 |
{ |
|
149 |
return ParagonIE_Sodium_Compat::bin2base64($string, $variant); |
|
150 |
} |
|
151 |
} |
|
9 | 152 |
if (!is_callable('sodium_bin2hex')) { |
153 |
/** |
|
154 |
* @see ParagonIE_Sodium_Compat::hex2bin() |
|
155 |
* @param string $string |
|
156 |
* @return string |
|
157 |
* @throws SodiumException |
|
158 |
* @throws TypeError |
|
159 |
*/ |
|
160 |
function sodium_bin2hex($string) |
|
161 |
{ |
|
162 |
return ParagonIE_Sodium_Compat::bin2hex($string); |
|
163 |
} |
|
164 |
} |
|
165 |
if (!is_callable('sodium_compare')) { |
|
166 |
/** |
|
167 |
* @see ParagonIE_Sodium_Compat::compare() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
168 |
* @param string $string1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
169 |
* @param string $string2 |
9 | 170 |
* @return int |
171 |
* @throws SodiumException |
|
172 |
* @throws TypeError |
|
173 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
174 |
function sodium_compare($string1, $string2) |
9 | 175 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
176 |
return ParagonIE_Sodium_Compat::compare($string1, $string2); |
9 | 177 |
} |
178 |
} |
|
179 |
if (!is_callable('sodium_crypto_aead_aes256gcm_decrypt')) { |
|
180 |
/** |
|
181 |
* @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
182 |
* @param string $ciphertext |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
183 |
* @param string $additional_data |
9 | 184 |
* @param string $nonce |
185 |
* @param string $key |
|
186 |
* @return string|bool |
|
187 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
188 |
function sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $additional_data, $nonce, $key) |
9 | 189 |
{ |
190 |
try { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
191 |
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
192 |
$ciphertext, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
193 |
$additional_data, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
194 |
$nonce, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
195 |
$key |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
196 |
); |
9 | 197 |
} catch (Error $ex) { |
198 |
return false; |
|
199 |
} catch (Exception $ex) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
200 |
if (($ex instanceof SodiumException) && ($ex->getMessage() === 'AES-256-GCM is not available')) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
201 |
throw $ex; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
202 |
} |
9 | 203 |
return false; |
204 |
} |
|
205 |
} |
|
206 |
} |
|
207 |
if (!is_callable('sodium_crypto_aead_aes256gcm_encrypt')) { |
|
208 |
/** |
|
209 |
* @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt() |
|
210 |
* @param string $message |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
211 |
* @param string $additional_data |
9 | 212 |
* @param string $nonce |
213 |
* @param string $key |
|
214 |
* @return string |
|
215 |
* @throws SodiumException |
|
216 |
* @throws TypeError |
|
217 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
218 |
function sodium_crypto_aead_aes256gcm_encrypt($message, $additional_data, $nonce, $key) |
9 | 219 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
220 |
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $additional_data, $nonce, $key); |
9 | 221 |
} |
222 |
} |
|
223 |
if (!is_callable('sodium_crypto_aead_aes256gcm_is_available')) { |
|
224 |
/** |
|
225 |
* @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available() |
|
226 |
* @return bool |
|
227 |
*/ |
|
228 |
function sodium_crypto_aead_aes256gcm_is_available() |
|
229 |
{ |
|
230 |
return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available(); |
|
231 |
} |
|
232 |
} |
|
233 |
if (!is_callable('sodium_crypto_aead_chacha20poly1305_decrypt')) { |
|
234 |
/** |
|
235 |
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
236 |
* @param string $ciphertext |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
237 |
* @param string $additional_data |
9 | 238 |
* @param string $nonce |
239 |
* @param string $key |
|
240 |
* @return string|bool |
|
241 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
242 |
function sodium_crypto_aead_chacha20poly1305_decrypt($ciphertext, $additional_data, $nonce, $key) |
9 | 243 |
{ |
244 |
try { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
245 |
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
246 |
$ciphertext, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
247 |
$additional_data, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
248 |
$nonce, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
249 |
$key |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
250 |
); |
9 | 251 |
} catch (Error $ex) { |
252 |
return false; |
|
253 |
} catch (Exception $ex) { |
|
254 |
return false; |
|
255 |
} |
|
256 |
} |
|
257 |
} |
|
258 |
if (!is_callable('sodium_crypto_aead_chacha20poly1305_encrypt')) { |
|
259 |
/** |
|
260 |
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt() |
|
261 |
* @param string $message |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
262 |
* @param string $additional_data |
9 | 263 |
* @param string $nonce |
264 |
* @param string $key |
|
265 |
* @return string |
|
266 |
* @throws SodiumException |
|
267 |
* @throws TypeError |
|
268 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
269 |
function sodium_crypto_aead_chacha20poly1305_encrypt($message, $additional_data, $nonce, $key) |
9 | 270 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
271 |
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
272 |
$message, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
273 |
$additional_data, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
274 |
$nonce, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
275 |
$key |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
276 |
); |
9 | 277 |
} |
278 |
} |
|
279 |
if (!is_callable('sodium_crypto_aead_chacha20poly1305_keygen')) { |
|
280 |
/** |
|
281 |
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen() |
|
282 |
* @return string |
|
16 | 283 |
* @throws Exception |
9 | 284 |
*/ |
285 |
function sodium_crypto_aead_chacha20poly1305_keygen() |
|
286 |
{ |
|
287 |
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen(); |
|
288 |
} |
|
289 |
} |
|
290 |
if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_decrypt')) { |
|
291 |
/** |
|
292 |
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt() |
|
293 |
* @param string $message |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
294 |
* @param string $additional_data |
9 | 295 |
* @param string $nonce |
296 |
* @param string $key |
|
297 |
* @return string|bool |
|
298 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
299 |
function sodium_crypto_aead_chacha20poly1305_ietf_decrypt($message, $additional_data, $nonce, $key) |
9 | 300 |
{ |
301 |
try { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
302 |
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
303 |
$message, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
304 |
$additional_data, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
305 |
$nonce, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
306 |
$key |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
307 |
); |
9 | 308 |
} catch (Error $ex) { |
309 |
return false; |
|
310 |
} catch (Exception $ex) { |
|
311 |
return false; |
|
312 |
} |
|
313 |
} |
|
314 |
} |
|
315 |
if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_encrypt')) { |
|
316 |
/** |
|
317 |
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt() |
|
318 |
* @param string $message |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
319 |
* @param string $additional_data |
9 | 320 |
* @param string $nonce |
321 |
* @param string $key |
|
322 |
* @return string |
|
323 |
* @throws SodiumException |
|
324 |
* @throws TypeError |
|
325 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
326 |
function sodium_crypto_aead_chacha20poly1305_ietf_encrypt($message, $additional_data, $nonce, $key) |
9 | 327 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
328 |
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
329 |
$message, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
330 |
$additional_data, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
331 |
$nonce, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
332 |
$key |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
333 |
); |
9 | 334 |
} |
335 |
} |
|
336 |
if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_keygen')) { |
|
337 |
/** |
|
338 |
* @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_keygen() |
|
339 |
* @return string |
|
16 | 340 |
* @throws Exception |
9 | 341 |
*/ |
342 |
function sodium_crypto_aead_chacha20poly1305_ietf_keygen() |
|
343 |
{ |
|
344 |
return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_keygen(); |
|
345 |
} |
|
346 |
} |
|
347 |
if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) { |
|
348 |
/** |
|
349 |
* @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
350 |
* @param string $ciphertext |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
351 |
* @param string $additional_data |
9 | 352 |
* @param string $nonce |
353 |
* @param string $key |
|
354 |
* @return string|bool |
|
355 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
356 |
function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($ciphertext, $additional_data, $nonce, $key) |
9 | 357 |
{ |
358 |
try { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
359 |
return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
360 |
$ciphertext, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
361 |
$additional_data, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
362 |
$nonce, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
363 |
$key, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
364 |
true |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
365 |
); |
9 | 366 |
} catch (Error $ex) { |
367 |
return false; |
|
368 |
} catch (Exception $ex) { |
|
369 |
return false; |
|
370 |
} |
|
371 |
} |
|
372 |
} |
|
373 |
if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) { |
|
374 |
/** |
|
375 |
* @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt() |
|
376 |
* @param string $message |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
377 |
* @param string $additional_data |
9 | 378 |
* @param string $nonce |
379 |
* @param string $key |
|
380 |
* @return string |
|
381 |
* @throws SodiumException |
|
382 |
* @throws TypeError |
|
383 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
384 |
function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
385 |
$message, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
386 |
$additional_data, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
387 |
$nonce, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
388 |
$key |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
389 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
390 |
return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
391 |
$message, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
392 |
$additional_data, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
393 |
$nonce, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
394 |
$key, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
395 |
true |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
396 |
); |
9 | 397 |
} |
398 |
} |
|
399 |
if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_keygen')) { |
|
400 |
/** |
|
401 |
* @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_keygen() |
|
402 |
* @return string |
|
16 | 403 |
* @throws Exception |
9 | 404 |
*/ |
405 |
function sodium_crypto_aead_xchacha20poly1305_ietf_keygen() |
|
406 |
{ |
|
407 |
return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_keygen(); |
|
408 |
} |
|
409 |
} |
|
410 |
if (!is_callable('sodium_crypto_auth')) { |
|
411 |
/** |
|
412 |
* @see ParagonIE_Sodium_Compat::crypto_auth() |
|
413 |
* @param string $message |
|
414 |
* @param string $key |
|
415 |
* @return string |
|
416 |
* @throws SodiumException |
|
417 |
* @throws TypeError |
|
418 |
*/ |
|
419 |
function sodium_crypto_auth($message, $key) |
|
420 |
{ |
|
421 |
return ParagonIE_Sodium_Compat::crypto_auth($message, $key); |
|
422 |
} |
|
423 |
} |
|
424 |
if (!is_callable('sodium_crypto_auth_keygen')) { |
|
425 |
/** |
|
426 |
* @see ParagonIE_Sodium_Compat::crypto_auth_keygen() |
|
427 |
* @return string |
|
16 | 428 |
* @throws Exception |
9 | 429 |
*/ |
430 |
function sodium_crypto_auth_keygen() |
|
431 |
{ |
|
432 |
return ParagonIE_Sodium_Compat::crypto_auth_keygen(); |
|
433 |
} |
|
434 |
} |
|
435 |
if (!is_callable('sodium_crypto_auth_verify')) { |
|
436 |
/** |
|
437 |
* @see ParagonIE_Sodium_Compat::crypto_auth_verify() |
|
438 |
* @param string $mac |
|
439 |
* @param string $message |
|
440 |
* @param string $key |
|
441 |
* @return bool |
|
442 |
* @throws SodiumException |
|
443 |
* @throws TypeError |
|
444 |
*/ |
|
445 |
function sodium_crypto_auth_verify($mac, $message, $key) |
|
446 |
{ |
|
447 |
return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key); |
|
448 |
} |
|
449 |
} |
|
450 |
if (!is_callable('sodium_crypto_box')) { |
|
451 |
/** |
|
452 |
* @see ParagonIE_Sodium_Compat::crypto_box() |
|
453 |
* @param string $message |
|
454 |
* @param string $nonce |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
455 |
* @param string $key_pair |
9 | 456 |
* @return string |
457 |
* @throws SodiumException |
|
458 |
* @throws TypeError |
|
459 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
460 |
function sodium_crypto_box($message, $nonce, $key_pair) |
9 | 461 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
462 |
return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $key_pair); |
9 | 463 |
} |
464 |
} |
|
465 |
if (!is_callable('sodium_crypto_box_keypair')) { |
|
466 |
/** |
|
467 |
* @see ParagonIE_Sodium_Compat::crypto_box_keypair() |
|
468 |
* @return string |
|
469 |
* @throws SodiumException |
|
470 |
* @throws TypeError |
|
471 |
*/ |
|
472 |
function sodium_crypto_box_keypair() |
|
473 |
{ |
|
474 |
return ParagonIE_Sodium_Compat::crypto_box_keypair(); |
|
475 |
} |
|
476 |
} |
|
477 |
if (!is_callable('sodium_crypto_box_keypair_from_secretkey_and_publickey')) { |
|
478 |
/** |
|
479 |
* @see ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
480 |
* @param string $secret_key |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
481 |
* @param string $public_key |
9 | 482 |
* @return string |
483 |
* @throws SodiumException |
|
484 |
* @throws TypeError |
|
485 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
486 |
function sodium_crypto_box_keypair_from_secretkey_and_publickey($secret_key, $public_key) |
9 | 487 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
488 |
return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($secret_key, $public_key); |
9 | 489 |
} |
490 |
} |
|
491 |
if (!is_callable('sodium_crypto_box_open')) { |
|
492 |
/** |
|
493 |
* @see ParagonIE_Sodium_Compat::crypto_box_open() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
494 |
* @param string $ciphertext |
9 | 495 |
* @param string $nonce |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
496 |
* @param string $key_pair |
9 | 497 |
* @return string|bool |
498 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
499 |
function sodium_crypto_box_open($ciphertext, $nonce, $key_pair) |
9 | 500 |
{ |
501 |
try { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
502 |
return ParagonIE_Sodium_Compat::crypto_box_open($ciphertext, $nonce, $key_pair); |
9 | 503 |
} catch (Error $ex) { |
504 |
return false; |
|
505 |
} catch (Exception $ex) { |
|
506 |
return false; |
|
507 |
} |
|
508 |
} |
|
509 |
} |
|
510 |
if (!is_callable('sodium_crypto_box_publickey')) { |
|
511 |
/** |
|
512 |
* @see ParagonIE_Sodium_Compat::crypto_box_publickey() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
513 |
* @param string $key_pair |
9 | 514 |
* @return string |
515 |
* @throws SodiumException |
|
516 |
* @throws TypeError |
|
517 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
518 |
function sodium_crypto_box_publickey($key_pair) |
9 | 519 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
520 |
return ParagonIE_Sodium_Compat::crypto_box_publickey($key_pair); |
9 | 521 |
} |
522 |
} |
|
523 |
if (!is_callable('sodium_crypto_box_publickey_from_secretkey')) { |
|
524 |
/** |
|
525 |
* @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
526 |
* @param string $secret_key |
9 | 527 |
* @return string |
528 |
* @throws SodiumException |
|
529 |
* @throws TypeError |
|
530 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
531 |
function sodium_crypto_box_publickey_from_secretkey($secret_key) |
9 | 532 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
533 |
return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($secret_key); |
9 | 534 |
} |
535 |
} |
|
536 |
if (!is_callable('sodium_crypto_box_seal')) { |
|
537 |
/** |
|
538 |
* @see ParagonIE_Sodium_Compat::crypto_box_seal() |
|
539 |
* @param string $message |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
540 |
* @param string $public_key |
9 | 541 |
* @return string |
542 |
* @throws SodiumException |
|
543 |
* @throws TypeError |
|
544 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
545 |
function sodium_crypto_box_seal($message, $public_key) |
9 | 546 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
547 |
return ParagonIE_Sodium_Compat::crypto_box_seal($message, $public_key); |
9 | 548 |
} |
549 |
} |
|
550 |
if (!is_callable('sodium_crypto_box_seal_open')) { |
|
551 |
/** |
|
552 |
* @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
|
553 |
* @param string $message |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
554 |
* @param string $key_pair |
9 | 555 |
* @return string|bool |
556 |
* @throws SodiumException |
|
557 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
558 |
function sodium_crypto_box_seal_open($message, $key_pair) |
9 | 559 |
{ |
560 |
try { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
561 |
return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $key_pair); |
9 | 562 |
} catch (SodiumException $ex) { |
563 |
if ($ex->getMessage() === 'Argument 2 must be CRYPTO_BOX_KEYPAIRBYTES long.') { |
|
564 |
throw $ex; |
|
565 |
} |
|
566 |
return false; |
|
567 |
} |
|
568 |
} |
|
569 |
} |
|
570 |
if (!is_callable('sodium_crypto_box_secretkey')) { |
|
571 |
/** |
|
572 |
* @see ParagonIE_Sodium_Compat::crypto_box_secretkey() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
573 |
* @param string $key_pair |
9 | 574 |
* @return string |
575 |
* @throws SodiumException |
|
576 |
* @throws TypeError |
|
577 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
578 |
function sodium_crypto_box_secretkey($key_pair) |
9 | 579 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
580 |
return ParagonIE_Sodium_Compat::crypto_box_secretkey($key_pair); |
9 | 581 |
} |
582 |
} |
|
583 |
if (!is_callable('sodium_crypto_box_seed_keypair')) { |
|
584 |
/** |
|
585 |
* @see ParagonIE_Sodium_Compat::crypto_box_seed_keypair() |
|
586 |
* @param string $seed |
|
587 |
* @return string |
|
588 |
* @throws SodiumException |
|
589 |
* @throws TypeError |
|
590 |
*/ |
|
591 |
function sodium_crypto_box_seed_keypair($seed) |
|
592 |
{ |
|
593 |
return ParagonIE_Sodium_Compat::crypto_box_seed_keypair($seed); |
|
594 |
} |
|
595 |
} |
|
596 |
if (!is_callable('sodium_crypto_generichash')) { |
|
597 |
/** |
|
598 |
* @see ParagonIE_Sodium_Compat::crypto_generichash() |
|
599 |
* @param string $message |
|
600 |
* @param string|null $key |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
601 |
* @param int $length |
9 | 602 |
* @return string |
603 |
* @throws SodiumException |
|
604 |
* @throws TypeError |
|
605 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
606 |
function sodium_crypto_generichash($message, $key = null, $length = 32) |
9 | 607 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
608 |
return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $length); |
9 | 609 |
} |
610 |
} |
|
611 |
if (!is_callable('sodium_crypto_generichash_final')) { |
|
612 |
/** |
|
613 |
* @see ParagonIE_Sodium_Compat::crypto_generichash_final() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
614 |
* @param string|null $state |
9 | 615 |
* @param int $outputLength |
616 |
* @return string |
|
617 |
* @throws SodiumException |
|
618 |
* @throws TypeError |
|
619 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
620 |
function sodium_crypto_generichash_final(&$state, $outputLength = 32) |
9 | 621 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
622 |
return ParagonIE_Sodium_Compat::crypto_generichash_final($state, $outputLength); |
9 | 623 |
} |
624 |
} |
|
625 |
if (!is_callable('sodium_crypto_generichash_init')) { |
|
626 |
/** |
|
627 |
* @see ParagonIE_Sodium_Compat::crypto_generichash_init() |
|
628 |
* @param string|null $key |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
629 |
* @param int $length |
9 | 630 |
* @return string |
631 |
* @throws SodiumException |
|
632 |
* @throws TypeError |
|
633 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
634 |
function sodium_crypto_generichash_init($key = null, $length = 32) |
9 | 635 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
636 |
return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $length); |
9 | 637 |
} |
638 |
} |
|
639 |
if (!is_callable('sodium_crypto_generichash_keygen')) { |
|
640 |
/** |
|
641 |
* @see ParagonIE_Sodium_Compat::crypto_generichash_keygen() |
|
642 |
* @return string |
|
16 | 643 |
* @throws Exception |
9 | 644 |
*/ |
645 |
function sodium_crypto_generichash_keygen() |
|
646 |
{ |
|
647 |
return ParagonIE_Sodium_Compat::crypto_generichash_keygen(); |
|
648 |
} |
|
649 |
} |
|
650 |
if (!is_callable('sodium_crypto_generichash_update')) { |
|
651 |
/** |
|
652 |
* @see ParagonIE_Sodium_Compat::crypto_generichash_update() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
653 |
* @param string|null $state |
9 | 654 |
* @param string $message |
655 |
* @return void |
|
656 |
* @throws SodiumException |
|
657 |
* @throws TypeError |
|
658 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
659 |
function sodium_crypto_generichash_update(&$state, $message = '') |
9 | 660 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
661 |
ParagonIE_Sodium_Compat::crypto_generichash_update($state, $message); |
9 | 662 |
} |
663 |
} |
|
16 | 664 |
if (!is_callable('sodium_crypto_kdf_keygen')) { |
665 |
/** |
|
666 |
* @see ParagonIE_Sodium_Compat::crypto_kdf_keygen() |
|
667 |
* @return string |
|
668 |
* @throws Exception |
|
669 |
*/ |
|
670 |
function sodium_crypto_kdf_keygen() |
|
671 |
{ |
|
672 |
return ParagonIE_Sodium_Compat::crypto_kdf_keygen(); |
|
673 |
} |
|
674 |
} |
|
675 |
if (!is_callable('sodium_crypto_kdf_derive_from_key')) { |
|
676 |
/** |
|
677 |
* @see ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
678 |
* @param int $subkey_length |
16 | 679 |
* @param int $subkey_id |
680 |
* @param string $context |
|
681 |
* @param string $key |
|
682 |
* @return string |
|
683 |
* @throws Exception |
|
684 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
685 |
function sodium_crypto_kdf_derive_from_key($subkey_length, $subkey_id, $context, $key) |
16 | 686 |
{ |
687 |
return ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key( |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
688 |
$subkey_length, |
16 | 689 |
$subkey_id, |
690 |
$context, |
|
691 |
$key |
|
692 |
); |
|
693 |
} |
|
694 |
} |
|
9 | 695 |
if (!is_callable('sodium_crypto_kx')) { |
696 |
/** |
|
697 |
* @see ParagonIE_Sodium_Compat::crypto_kx() |
|
698 |
* @param string $my_secret |
|
699 |
* @param string $their_public |
|
700 |
* @param string $client_public |
|
701 |
* @param string $server_public |
|
702 |
* @return string |
|
703 |
* @throws SodiumException |
|
704 |
* @throws TypeError |
|
705 |
*/ |
|
706 |
function sodium_crypto_kx($my_secret, $their_public, $client_public, $server_public) |
|
707 |
{ |
|
708 |
return ParagonIE_Sodium_Compat::crypto_kx( |
|
709 |
$my_secret, |
|
710 |
$their_public, |
|
711 |
$client_public, |
|
712 |
$server_public |
|
713 |
); |
|
714 |
} |
|
715 |
} |
|
16 | 716 |
if (!is_callable('sodium_crypto_kx_seed_keypair')) { |
717 |
/** |
|
718 |
* @param string $seed |
|
719 |
* @return string |
|
720 |
* @throws Exception |
|
721 |
*/ |
|
722 |
function sodium_crypto_kx_seed_keypair($seed) |
|
723 |
{ |
|
724 |
return ParagonIE_Sodium_Compat::crypto_kx_seed_keypair($seed); |
|
725 |
} |
|
726 |
} |
|
727 |
if (!is_callable('sodium_crypto_kx_keypair')) { |
|
728 |
/** |
|
729 |
* @return string |
|
730 |
* @throws Exception |
|
731 |
*/ |
|
732 |
function sodium_crypto_kx_keypair() |
|
733 |
{ |
|
734 |
return ParagonIE_Sodium_Compat::crypto_kx_keypair(); |
|
735 |
} |
|
736 |
} |
|
737 |
if (!is_callable('sodium_crypto_kx_client_session_keys')) { |
|
738 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
739 |
* @param string $client_key_pair |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
740 |
* @param string $server_key |
16 | 741 |
* @return array{0: string, 1: string} |
742 |
* @throws SodiumException |
|
743 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
744 |
function sodium_crypto_kx_client_session_keys($client_key_pair, $server_key) |
16 | 745 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
746 |
return ParagonIE_Sodium_Compat::crypto_kx_client_session_keys($client_key_pair, $server_key); |
16 | 747 |
} |
748 |
} |
|
749 |
if (!is_callable('sodium_crypto_kx_server_session_keys')) { |
|
750 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
751 |
* @param string $server_key_pair |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
752 |
* @param string $client_key |
16 | 753 |
* @return array{0: string, 1: string} |
754 |
* @throws SodiumException |
|
755 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
756 |
function sodium_crypto_kx_server_session_keys($server_key_pair, $client_key) |
16 | 757 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
758 |
return ParagonIE_Sodium_Compat::crypto_kx_server_session_keys($server_key_pair, $client_key); |
16 | 759 |
} |
760 |
} |
|
761 |
if (!is_callable('sodium_crypto_kx_secretkey')) { |
|
762 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
763 |
* @param string $key_pair |
16 | 764 |
* @return string |
765 |
* @throws Exception |
|
766 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
767 |
function sodium_crypto_kx_secretkey($key_pair) |
16 | 768 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
769 |
return ParagonIE_Sodium_Compat::crypto_kx_secretkey($key_pair); |
16 | 770 |
} |
771 |
} |
|
772 |
if (!is_callable('sodium_crypto_kx_publickey')) { |
|
773 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
774 |
* @param string $key_pair |
16 | 775 |
* @return string |
776 |
* @throws Exception |
|
777 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
778 |
function sodium_crypto_kx_publickey($key_pair) |
16 | 779 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
780 |
return ParagonIE_Sodium_Compat::crypto_kx_publickey($key_pair); |
16 | 781 |
} |
782 |
} |
|
9 | 783 |
if (!is_callable('sodium_crypto_pwhash')) { |
784 |
/** |
|
785 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
786 |
* @param int $length |
9 | 787 |
* @param string $passwd |
788 |
* @param string $salt |
|
789 |
* @param int $opslimit |
|
790 |
* @param int $memlimit |
|
791 |
* @param int|null $algo |
|
792 |
* @return string |
|
793 |
* @throws SodiumException |
|
794 |
* @throws TypeError |
|
795 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
796 |
function sodium_crypto_pwhash($length, $passwd, $salt, $opslimit, $memlimit, $algo = null) |
9 | 797 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
798 |
return ParagonIE_Sodium_Compat::crypto_pwhash($length, $passwd, $salt, $opslimit, $memlimit, $algo); |
9 | 799 |
} |
800 |
} |
|
801 |
if (!is_callable('sodium_crypto_pwhash_str')) { |
|
802 |
/** |
|
803 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_str() |
|
804 |
* @param string $passwd |
|
805 |
* @param int $opslimit |
|
806 |
* @param int $memlimit |
|
807 |
* @return string |
|
808 |
* @throws SodiumException |
|
809 |
* @throws TypeError |
|
810 |
*/ |
|
811 |
function sodium_crypto_pwhash_str($passwd, $opslimit, $memlimit) |
|
812 |
{ |
|
813 |
return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit); |
|
814 |
} |
|
815 |
} |
|
16 | 816 |
if (!is_callable('sodium_crypto_pwhash_str_needs_rehash')) { |
817 |
/** |
|
818 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash() |
|
819 |
* @param string $hash |
|
820 |
* @param int $opslimit |
|
821 |
* @param int $memlimit |
|
822 |
* @return bool |
|
823 |
* |
|
824 |
* @throws SodiumException |
|
825 |
*/ |
|
826 |
function sodium_crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit) |
|
827 |
{ |
|
828 |
return ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit); |
|
829 |
} |
|
830 |
} |
|
9 | 831 |
if (!is_callable('sodium_crypto_pwhash_str_verify')) { |
832 |
/** |
|
833 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify() |
|
834 |
* @param string $passwd |
|
835 |
* @param string $hash |
|
836 |
* @return bool |
|
837 |
* @throws SodiumException |
|
838 |
* @throws TypeError |
|
839 |
*/ |
|
840 |
function sodium_crypto_pwhash_str_verify($passwd, $hash) |
|
841 |
{ |
|
842 |
return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash); |
|
843 |
} |
|
844 |
} |
|
845 |
if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256')) { |
|
846 |
/** |
|
847 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
848 |
* @param int $length |
9 | 849 |
* @param string $passwd |
850 |
* @param string $salt |
|
851 |
* @param int $opslimit |
|
852 |
* @param int $memlimit |
|
853 |
* @return string |
|
854 |
* @throws SodiumException |
|
855 |
* @throws TypeError |
|
856 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
857 |
function sodium_crypto_pwhash_scryptsalsa208sha256($length, $passwd, $salt, $opslimit, $memlimit) |
9 | 858 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
859 |
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
860 |
$length, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
861 |
$passwd, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
862 |
$salt, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
863 |
$opslimit, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
864 |
$memlimit |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
865 |
); |
9 | 866 |
} |
867 |
} |
|
868 |
if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256_str')) { |
|
869 |
/** |
|
870 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str() |
|
871 |
* @param string $passwd |
|
872 |
* @param int $opslimit |
|
873 |
* @param int $memlimit |
|
874 |
* @return string |
|
875 |
* @throws SodiumException |
|
876 |
* @throws TypeError |
|
877 |
*/ |
|
878 |
function sodium_crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit) |
|
879 |
{ |
|
880 |
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit); |
|
881 |
} |
|
882 |
} |
|
883 |
if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256_str_verify')) { |
|
884 |
/** |
|
885 |
* @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify() |
|
886 |
* @param string $passwd |
|
887 |
* @param string $hash |
|
888 |
* @return bool |
|
889 |
* @throws SodiumException |
|
890 |
* @throws TypeError |
|
891 |
*/ |
|
892 |
function sodium_crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash) |
|
893 |
{ |
|
894 |
return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash); |
|
895 |
} |
|
896 |
} |
|
897 |
if (!is_callable('sodium_crypto_scalarmult')) { |
|
898 |
/** |
|
899 |
* @see ParagonIE_Sodium_Compat::crypto_scalarmult() |
|
900 |
* @param string $n |
|
901 |
* @param string $p |
|
902 |
* @return string |
|
903 |
* @throws SodiumException |
|
904 |
* @throws TypeError |
|
905 |
*/ |
|
906 |
function sodium_crypto_scalarmult($n, $p) |
|
907 |
{ |
|
908 |
return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p); |
|
909 |
} |
|
910 |
} |
|
911 |
if (!is_callable('sodium_crypto_scalarmult_base')) { |
|
912 |
/** |
|
913 |
* @see ParagonIE_Sodium_Compat::crypto_scalarmult_base() |
|
914 |
* @param string $n |
|
915 |
* @return string |
|
916 |
* @throws SodiumException |
|
917 |
* @throws TypeError |
|
918 |
*/ |
|
919 |
function sodium_crypto_scalarmult_base($n) |
|
920 |
{ |
|
921 |
return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n); |
|
922 |
} |
|
923 |
} |
|
924 |
if (!is_callable('sodium_crypto_secretbox')) { |
|
925 |
/** |
|
926 |
* @see ParagonIE_Sodium_Compat::crypto_secretbox() |
|
927 |
* @param string $message |
|
928 |
* @param string $nonce |
|
929 |
* @param string $key |
|
930 |
* @return string |
|
931 |
* @throws SodiumException |
|
932 |
* @throws TypeError |
|
933 |
*/ |
|
934 |
function sodium_crypto_secretbox($message, $nonce, $key) |
|
935 |
{ |
|
936 |
return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key); |
|
937 |
} |
|
938 |
} |
|
939 |
if (!is_callable('sodium_crypto_secretbox_keygen')) { |
|
940 |
/** |
|
941 |
* @see ParagonIE_Sodium_Compat::crypto_secretbox_keygen() |
|
942 |
* @return string |
|
16 | 943 |
* @throws Exception |
9 | 944 |
*/ |
945 |
function sodium_crypto_secretbox_keygen() |
|
946 |
{ |
|
947 |
return ParagonIE_Sodium_Compat::crypto_secretbox_keygen(); |
|
948 |
} |
|
949 |
} |
|
950 |
if (!is_callable('sodium_crypto_secretbox_open')) { |
|
951 |
/** |
|
952 |
* @see ParagonIE_Sodium_Compat::crypto_secretbox_open() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
953 |
* @param string $ciphertext |
9 | 954 |
* @param string $nonce |
955 |
* @param string $key |
|
956 |
* @return string|bool |
|
957 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
958 |
function sodium_crypto_secretbox_open($ciphertext, $nonce, $key) |
9 | 959 |
{ |
960 |
try { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
961 |
return ParagonIE_Sodium_Compat::crypto_secretbox_open($ciphertext, $nonce, $key); |
9 | 962 |
} catch (Error $ex) { |
963 |
return false; |
|
964 |
} catch (Exception $ex) { |
|
965 |
return false; |
|
966 |
} |
|
967 |
} |
|
968 |
} |
|
16 | 969 |
if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_init_push')) { |
970 |
/** |
|
971 |
* @param string $key |
|
972 |
* @return array<int, string> |
|
973 |
* @throws SodiumException |
|
974 |
*/ |
|
975 |
function sodium_crypto_secretstream_xchacha20poly1305_init_push($key) |
|
976 |
{ |
|
977 |
return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_push($key); |
|
978 |
} |
|
979 |
} |
|
980 |
if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_push')) { |
|
981 |
/** |
|
982 |
* @param string $state |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
983 |
* @param string $message |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
984 |
* @param string $additional_data |
16 | 985 |
* @param int $tag |
986 |
* @return string |
|
987 |
* @throws SodiumException |
|
988 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
989 |
function sodium_crypto_secretstream_xchacha20poly1305_push( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
990 |
&$state, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
991 |
$message, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
992 |
$additional_data = '', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
993 |
$tag = 0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
994 |
) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
995 |
return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_push( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
996 |
$state, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
997 |
$message, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
998 |
$additional_data, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
999 |
$tag |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1000 |
); |
16 | 1001 |
} |
1002 |
} |
|
1003 |
if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_init_pull')) { |
|
1004 |
/** |
|
1005 |
* @param string $header |
|
1006 |
* @param string $key |
|
1007 |
* @return string |
|
1008 |
* @throws Exception |
|
1009 |
*/ |
|
1010 |
function sodium_crypto_secretstream_xchacha20poly1305_init_pull($header, $key) |
|
1011 |
{ |
|
1012 |
return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_pull($header, $key); |
|
1013 |
} |
|
1014 |
} |
|
1015 |
if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_pull')) { |
|
1016 |
/** |
|
1017 |
* @param string $state |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1018 |
* @param string $ciphertext |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1019 |
* @param string $additional_data |
16 | 1020 |
* @return bool|array{0: string, 1: int} |
1021 |
* @throws SodiumException |
|
1022 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1023 |
function sodium_crypto_secretstream_xchacha20poly1305_pull(&$state, $ciphertext, $additional_data = '') |
16 | 1024 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1025 |
return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_pull( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1026 |
$state, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1027 |
$ciphertext, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1028 |
$additional_data |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1029 |
); |
16 | 1030 |
} |
1031 |
} |
|
1032 |
if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_rekey')) { |
|
1033 |
/** |
|
1034 |
* @param string $state |
|
1035 |
* @return void |
|
1036 |
* @throws SodiumException |
|
1037 |
*/ |
|
1038 |
function sodium_crypto_secretstream_xchacha20poly1305_rekey(&$state) |
|
1039 |
{ |
|
1040 |
ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_rekey($state); |
|
1041 |
} |
|
1042 |
} |
|
1043 |
if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_keygen')) { |
|
1044 |
/** |
|
1045 |
* @return string |
|
1046 |
* @throws Exception |
|
1047 |
*/ |
|
1048 |
function sodium_crypto_secretstream_xchacha20poly1305_keygen() |
|
1049 |
{ |
|
1050 |
return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_keygen(); |
|
1051 |
} |
|
1052 |
} |
|
9 | 1053 |
if (!is_callable('sodium_crypto_shorthash')) { |
1054 |
/** |
|
1055 |
* @see ParagonIE_Sodium_Compat::crypto_shorthash() |
|
1056 |
* @param string $message |
|
1057 |
* @param string $key |
|
1058 |
* @return string |
|
1059 |
* @throws SodiumException |
|
1060 |
* @throws TypeError |
|
1061 |
*/ |
|
1062 |
function sodium_crypto_shorthash($message, $key = '') |
|
1063 |
{ |
|
1064 |
return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key); |
|
1065 |
} |
|
1066 |
} |
|
1067 |
if (!is_callable('sodium_crypto_shorthash_keygen')) { |
|
1068 |
/** |
|
1069 |
* @see ParagonIE_Sodium_Compat::crypto_shorthash_keygen() |
|
1070 |
* @return string |
|
16 | 1071 |
* @throws Exception |
9 | 1072 |
*/ |
1073 |
function sodium_crypto_shorthash_keygen() |
|
1074 |
{ |
|
1075 |
return ParagonIE_Sodium_Compat::crypto_shorthash_keygen(); |
|
1076 |
} |
|
1077 |
} |
|
1078 |
if (!is_callable('sodium_crypto_sign')) { |
|
1079 |
/** |
|
1080 |
* @see ParagonIE_Sodium_Compat::crypto_sign() |
|
1081 |
* @param string $message |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1082 |
* @param string $secret_key |
9 | 1083 |
* @return string |
1084 |
* @throws SodiumException |
|
1085 |
* @throws TypeError |
|
1086 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1087 |
function sodium_crypto_sign($message, $secret_key) |
9 | 1088 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1089 |
return ParagonIE_Sodium_Compat::crypto_sign($message, $secret_key); |
9 | 1090 |
} |
1091 |
} |
|
1092 |
if (!is_callable('sodium_crypto_sign_detached')) { |
|
1093 |
/** |
|
1094 |
* @see ParagonIE_Sodium_Compat::crypto_sign_detached() |
|
1095 |
* @param string $message |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1096 |
* @param string $secret_key |
9 | 1097 |
* @return string |
1098 |
* @throws SodiumException |
|
1099 |
* @throws TypeError |
|
1100 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1101 |
function sodium_crypto_sign_detached($message, $secret_key) |
9 | 1102 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1103 |
return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $secret_key); |
9 | 1104 |
} |
1105 |
} |
|
16 | 1106 |
if (!is_callable('sodium_crypto_sign_keypair_from_secretkey_and_publickey')) { |
1107 |
/** |
|
1108 |
* @see ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1109 |
* @param string $secret_key |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1110 |
* @param string $public_key |
16 | 1111 |
* @return string |
1112 |
* @throws SodiumException |
|
1113 |
* @throws TypeError |
|
1114 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1115 |
function sodium_crypto_sign_keypair_from_secretkey_and_publickey($secret_key, $public_key) |
16 | 1116 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1117 |
return ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey($secret_key, $public_key); |
16 | 1118 |
} |
1119 |
} |
|
9 | 1120 |
if (!is_callable('sodium_crypto_sign_keypair')) { |
1121 |
/** |
|
1122 |
* @see ParagonIE_Sodium_Compat::crypto_sign_keypair() |
|
1123 |
* @return string |
|
1124 |
* @throws SodiumException |
|
1125 |
* @throws TypeError |
|
1126 |
*/ |
|
1127 |
function sodium_crypto_sign_keypair() |
|
1128 |
{ |
|
1129 |
return ParagonIE_Sodium_Compat::crypto_sign_keypair(); |
|
1130 |
} |
|
1131 |
} |
|
1132 |
if (!is_callable('sodium_crypto_sign_open')) { |
|
1133 |
/** |
|
1134 |
* @see ParagonIE_Sodium_Compat::crypto_sign_open() |
|
1135 |
* @param string $signedMessage |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1136 |
* @param string $public_key |
9 | 1137 |
* @return string|bool |
1138 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1139 |
function sodium_crypto_sign_open($signedMessage, $public_key) |
9 | 1140 |
{ |
1141 |
try { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1142 |
return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $public_key); |
9 | 1143 |
} catch (Error $ex) { |
1144 |
return false; |
|
1145 |
} catch (Exception $ex) { |
|
1146 |
return false; |
|
1147 |
} |
|
1148 |
} |
|
1149 |
} |
|
1150 |
if (!is_callable('sodium_crypto_sign_publickey')) { |
|
1151 |
/** |
|
1152 |
* @see ParagonIE_Sodium_Compat::crypto_sign_publickey() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1153 |
* @param string $key_pair |
9 | 1154 |
* @return string |
1155 |
* @throws SodiumException |
|
1156 |
* @throws TypeError |
|
1157 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1158 |
function sodium_crypto_sign_publickey($key_pair) |
9 | 1159 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1160 |
return ParagonIE_Sodium_Compat::crypto_sign_publickey($key_pair); |
9 | 1161 |
} |
1162 |
} |
|
1163 |
if (!is_callable('sodium_crypto_sign_publickey_from_secretkey')) { |
|
1164 |
/** |
|
1165 |
* @see ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1166 |
* @param string $secret_key |
9 | 1167 |
* @return string |
1168 |
* @throws SodiumException |
|
1169 |
* @throws TypeError |
|
1170 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1171 |
function sodium_crypto_sign_publickey_from_secretkey($secret_key) |
9 | 1172 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1173 |
return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($secret_key); |
9 | 1174 |
} |
1175 |
} |
|
1176 |
if (!is_callable('sodium_crypto_sign_secretkey')) { |
|
1177 |
/** |
|
1178 |
* @see ParagonIE_Sodium_Compat::crypto_sign_secretkey() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1179 |
* @param string $key_pair |
9 | 1180 |
* @return string |
1181 |
* @throws SodiumException |
|
1182 |
* @throws TypeError |
|
1183 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1184 |
function sodium_crypto_sign_secretkey($key_pair) |
9 | 1185 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1186 |
return ParagonIE_Sodium_Compat::crypto_sign_secretkey($key_pair); |
9 | 1187 |
} |
1188 |
} |
|
1189 |
if (!is_callable('sodium_crypto_sign_seed_keypair')) { |
|
1190 |
/** |
|
1191 |
* @see ParagonIE_Sodium_Compat::crypto_sign_seed_keypair() |
|
1192 |
* @param string $seed |
|
1193 |
* @return string |
|
1194 |
* @throws SodiumException |
|
1195 |
* @throws TypeError |
|
1196 |
*/ |
|
1197 |
function sodium_crypto_sign_seed_keypair($seed) |
|
1198 |
{ |
|
1199 |
return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed); |
|
1200 |
} |
|
1201 |
} |
|
1202 |
if (!is_callable('sodium_crypto_sign_verify_detached')) { |
|
1203 |
/** |
|
1204 |
* @see ParagonIE_Sodium_Compat::crypto_sign_verify_detached() |
|
1205 |
* @param string $signature |
|
1206 |
* @param string $message |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1207 |
* @param string $public_key |
9 | 1208 |
* @return bool |
1209 |
* @throws SodiumException |
|
1210 |
* @throws TypeError |
|
1211 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1212 |
function sodium_crypto_sign_verify_detached($signature, $message, $public_key) |
9 | 1213 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1214 |
return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $public_key); |
9 | 1215 |
} |
1216 |
} |
|
1217 |
if (!is_callable('sodium_crypto_sign_ed25519_pk_to_curve25519')) { |
|
1218 |
/** |
|
1219 |
* @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1220 |
* @param string $public_key |
9 | 1221 |
* @return string |
1222 |
* @throws SodiumException |
|
1223 |
* @throws TypeError |
|
1224 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1225 |
function sodium_crypto_sign_ed25519_pk_to_curve25519($public_key) |
9 | 1226 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1227 |
return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($public_key); |
9 | 1228 |
} |
1229 |
} |
|
1230 |
if (!is_callable('sodium_crypto_sign_ed25519_sk_to_curve25519')) { |
|
1231 |
/** |
|
1232 |
* @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1233 |
* @param string $secret_key |
9 | 1234 |
* @return string |
1235 |
* @throws SodiumException |
|
1236 |
* @throws TypeError |
|
1237 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1238 |
function sodium_crypto_sign_ed25519_sk_to_curve25519($secret_key) |
9 | 1239 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1240 |
return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($secret_key); |
9 | 1241 |
} |
1242 |
} |
|
1243 |
if (!is_callable('sodium_crypto_stream')) { |
|
1244 |
/** |
|
1245 |
* @see ParagonIE_Sodium_Compat::crypto_stream() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1246 |
* @param int $length |
9 | 1247 |
* @param string $nonce |
1248 |
* @param string $key |
|
1249 |
* @return string |
|
1250 |
* @throws SodiumException |
|
1251 |
* @throws TypeError |
|
1252 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1253 |
function sodium_crypto_stream($length, $nonce, $key) |
9 | 1254 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1255 |
return ParagonIE_Sodium_Compat::crypto_stream($length, $nonce, $key); |
9 | 1256 |
} |
1257 |
} |
|
1258 |
if (!is_callable('sodium_crypto_stream_keygen')) { |
|
1259 |
/** |
|
1260 |
* @see ParagonIE_Sodium_Compat::crypto_stream_keygen() |
|
1261 |
* @return string |
|
16 | 1262 |
* @throws Exception |
9 | 1263 |
*/ |
1264 |
function sodium_crypto_stream_keygen() |
|
1265 |
{ |
|
1266 |
return ParagonIE_Sodium_Compat::crypto_stream_keygen(); |
|
1267 |
} |
|
1268 |
} |
|
1269 |
if (!is_callable('sodium_crypto_stream_xor')) { |
|
1270 |
/** |
|
1271 |
* @see ParagonIE_Sodium_Compat::crypto_stream_xor() |
|
1272 |
* @param string $message |
|
1273 |
* @param string $nonce |
|
1274 |
* @param string $key |
|
1275 |
* @return string |
|
1276 |
* @throws SodiumException |
|
1277 |
* @throws TypeError |
|
1278 |
*/ |
|
1279 |
function sodium_crypto_stream_xor($message, $nonce, $key) |
|
1280 |
{ |
|
1281 |
return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key); |
|
1282 |
} |
|
1283 |
} |
|
18 | 1284 |
require_once dirname(__FILE__) . '/stream-xchacha20.php'; |
9 | 1285 |
if (!is_callable('sodium_hex2bin')) { |
1286 |
/** |
|
1287 |
* @see ParagonIE_Sodium_Compat::hex2bin() |
|
1288 |
* @param string $string |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1289 |
* @param string $ignore |
9 | 1290 |
* @return string |
1291 |
* @throws SodiumException |
|
1292 |
* @throws TypeError |
|
1293 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1294 |
function sodium_hex2bin($string, $ignore = '') |
9 | 1295 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1296 |
return ParagonIE_Sodium_Compat::hex2bin($string, $ignore); |
9 | 1297 |
} |
1298 |
} |
|
1299 |
if (!is_callable('sodium_increment')) { |
|
1300 |
/** |
|
1301 |
* @see ParagonIE_Sodium_Compat::increment() |
|
1302 |
* @param string $string |
|
1303 |
* @return void |
|
1304 |
* @throws SodiumException |
|
1305 |
* @throws TypeError |
|
1306 |
*/ |
|
1307 |
function sodium_increment(&$string) |
|
1308 |
{ |
|
1309 |
ParagonIE_Sodium_Compat::increment($string); |
|
1310 |
} |
|
1311 |
} |
|
1312 |
if (!is_callable('sodium_library_version_major')) { |
|
1313 |
/** |
|
1314 |
* @see ParagonIE_Sodium_Compat::library_version_major() |
|
1315 |
* @return int |
|
1316 |
*/ |
|
1317 |
function sodium_library_version_major() |
|
1318 |
{ |
|
1319 |
return ParagonIE_Sodium_Compat::library_version_major(); |
|
1320 |
} |
|
1321 |
} |
|
1322 |
if (!is_callable('sodium_library_version_minor')) { |
|
1323 |
/** |
|
1324 |
* @see ParagonIE_Sodium_Compat::library_version_minor() |
|
1325 |
* @return int |
|
1326 |
*/ |
|
1327 |
function sodium_library_version_minor() |
|
1328 |
{ |
|
1329 |
return ParagonIE_Sodium_Compat::library_version_minor(); |
|
1330 |
} |
|
1331 |
} |
|
1332 |
if (!is_callable('sodium_version_string')) { |
|
1333 |
/** |
|
1334 |
* @see ParagonIE_Sodium_Compat::version_string() |
|
1335 |
* @return string |
|
1336 |
*/ |
|
1337 |
function sodium_version_string() |
|
1338 |
{ |
|
1339 |
return ParagonIE_Sodium_Compat::version_string(); |
|
1340 |
} |
|
1341 |
} |
|
1342 |
if (!is_callable('sodium_memcmp')) { |
|
1343 |
/** |
|
1344 |
* @see ParagonIE_Sodium_Compat::memcmp() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1345 |
* @param string $string1 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1346 |
* @param string $string2 |
9 | 1347 |
* @return int |
1348 |
* @throws SodiumException |
|
1349 |
* @throws TypeError |
|
1350 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1351 |
function sodium_memcmp($string1, $string2) |
9 | 1352 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1353 |
return ParagonIE_Sodium_Compat::memcmp($string1, $string2); |
9 | 1354 |
} |
1355 |
} |
|
1356 |
if (!is_callable('sodium_memzero')) { |
|
1357 |
/** |
|
1358 |
* @see ParagonIE_Sodium_Compat::memzero() |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1359 |
* @param string $string |
9 | 1360 |
* @return void |
1361 |
* @throws SodiumException |
|
1362 |
* @throws TypeError |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1363 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1364 |
* @psalm-suppress ReferenceConstraintViolation |
9 | 1365 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1366 |
function sodium_memzero(&$string) |
9 | 1367 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1368 |
ParagonIE_Sodium_Compat::memzero($string); |
9 | 1369 |
} |
1370 |
} |
|
16 | 1371 |
if (!is_callable('sodium_pad')) { |
1372 |
/** |
|
1373 |
* @see ParagonIE_Sodium_Compat::pad() |
|
1374 |
* @param string $unpadded |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1375 |
* @param int $block_size |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1376 |
* @return string |
16 | 1377 |
* @throws SodiumException |
1378 |
* @throws TypeError |
|
1379 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1380 |
function sodium_pad($unpadded, $block_size) |
16 | 1381 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1382 |
return ParagonIE_Sodium_Compat::pad($unpadded, $block_size, true); |
16 | 1383 |
} |
1384 |
} |
|
1385 |
if (!is_callable('sodium_unpad')) { |
|
1386 |
/** |
|
1387 |
* @see ParagonIE_Sodium_Compat::pad() |
|
1388 |
* @param string $padded |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1389 |
* @param int $block_size |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1390 |
* @return string |
16 | 1391 |
* @throws SodiumException |
1392 |
* @throws TypeError |
|
1393 |
*/ |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1394 |
function sodium_unpad($padded, $block_size) |
16 | 1395 |
{ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
18
diff
changeset
|
1396 |
return ParagonIE_Sodium_Compat::unpad($padded, $block_size, true); |
16 | 1397 |
} |
1398 |
} |
|
9 | 1399 |
if (!is_callable('sodium_randombytes_buf')) { |
1400 |
/** |
|
1401 |
* @see ParagonIE_Sodium_Compat::randombytes_buf() |
|
1402 |
* @param int $amount |
|
1403 |
* @return string |
|
1404 |
* @throws Exception |
|
1405 |
*/ |
|
1406 |
function sodium_randombytes_buf($amount) |
|
1407 |
{ |
|
1408 |
return ParagonIE_Sodium_Compat::randombytes_buf($amount); |
|
1409 |
} |
|
1410 |
} |
|
1411 |
||
1412 |
if (!is_callable('sodium_randombytes_uniform')) { |
|
1413 |
/** |
|
1414 |
* @see ParagonIE_Sodium_Compat::randombytes_uniform() |
|
1415 |
* @param int $upperLimit |
|
1416 |
* @return int |
|
1417 |
* @throws Exception |
|
1418 |
*/ |
|
1419 |
function sodium_randombytes_uniform($upperLimit) |
|
1420 |
{ |
|
1421 |
return ParagonIE_Sodium_Compat::randombytes_uniform($upperLimit); |
|
1422 |
} |
|
1423 |
} |
|
1424 |
||
1425 |
if (!is_callable('sodium_randombytes_random16')) { |
|
1426 |
/** |
|
1427 |
* @see ParagonIE_Sodium_Compat::randombytes_random16() |
|
1428 |
* @return int |
|
16 | 1429 |
* @throws Exception |
9 | 1430 |
*/ |
1431 |
function sodium_randombytes_random16() |
|
1432 |
{ |
|
1433 |
return ParagonIE_Sodium_Compat::randombytes_random16(); |
|
1434 |
} |
|
1435 |
} |