18 * @param string $string |
18 * @param string $string |
19 * @return string |
19 * @return string |
20 * @throws \SodiumException |
20 * @throws \SodiumException |
21 * @throws \TypeError |
21 * @throws \TypeError |
22 */ |
22 */ |
23 function bin2hex($string) |
23 function bin2hex( |
24 { |
24 #[\SensitiveParameter] |
|
25 $string |
|
26 ) { |
25 return ParagonIE_Sodium_Compat::bin2hex($string); |
27 return ParagonIE_Sodium_Compat::bin2hex($string); |
26 } |
28 } |
27 } |
29 } |
28 if (!is_callable('\\Sodium\\compare')) { |
30 if (!is_callable('\\Sodium\\compare')) { |
29 /** |
31 /** |
32 * @param string $b |
34 * @param string $b |
33 * @return int |
35 * @return int |
34 * @throws \SodiumException |
36 * @throws \SodiumException |
35 * @throws \TypeError |
37 * @throws \TypeError |
36 */ |
38 */ |
37 function compare($a, $b) |
39 function compare( |
38 { |
40 #[\SensitiveParameter] |
|
41 $a, |
|
42 #[\SensitiveParameter] |
|
43 $b |
|
44 ) { |
39 return ParagonIE_Sodium_Compat::compare($a, $b); |
45 return ParagonIE_Sodium_Compat::compare($a, $b); |
40 } |
46 } |
41 } |
47 } |
42 if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_decrypt')) { |
48 if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_decrypt')) { |
43 /** |
49 /** |
46 * @param string $assocData |
52 * @param string $assocData |
47 * @param string $nonce |
53 * @param string $nonce |
48 * @param string $key |
54 * @param string $key |
49 * @return string|bool |
55 * @return string|bool |
50 */ |
56 */ |
51 function crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key) |
57 function crypto_aead_aes256gcm_decrypt( |
52 { |
58 $message, |
|
59 $assocData, |
|
60 $nonce, |
|
61 #[\SensitiveParameter] |
|
62 $key |
|
63 ) { |
53 try { |
64 try { |
54 return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key); |
65 return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key); |
55 } catch (\TypeError $ex) { |
66 } catch (\TypeError $ex) { |
56 return false; |
67 return false; |
57 } catch (\SodiumException $ex) { |
68 } catch (\SodiumException $ex) { |
68 * @param string $key |
79 * @param string $key |
69 * @return string |
80 * @return string |
70 * @throws \SodiumException |
81 * @throws \SodiumException |
71 * @throws \TypeError |
82 * @throws \TypeError |
72 */ |
83 */ |
73 function crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key) |
84 function crypto_aead_aes256gcm_encrypt( |
74 { |
85 #[\SensitiveParameter] |
|
86 $message, |
|
87 $assocData, |
|
88 $nonce, |
|
89 #[\SensitiveParameter] |
|
90 $key |
|
91 ) { |
75 return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key); |
92 return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key); |
76 } |
93 } |
77 } |
94 } |
78 if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_is_available')) { |
95 if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_is_available')) { |
79 /** |
96 /** |
92 * @param string $assocData |
109 * @param string $assocData |
93 * @param string $nonce |
110 * @param string $nonce |
94 * @param string $key |
111 * @param string $key |
95 * @return string|bool |
112 * @return string|bool |
96 */ |
113 */ |
97 function crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key) |
114 function crypto_aead_chacha20poly1305_decrypt( |
98 { |
115 $message, |
|
116 $assocData, |
|
117 $nonce, |
|
118 #[\SensitiveParameter] |
|
119 $key |
|
120 ) { |
99 try { |
121 try { |
100 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key); |
122 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key); |
101 } catch (\TypeError $ex) { |
123 } catch (\TypeError $ex) { |
102 return false; |
124 return false; |
103 } catch (\SodiumException $ex) { |
125 } catch (\SodiumException $ex) { |
114 * @param string $key |
136 * @param string $key |
115 * @return string |
137 * @return string |
116 * @throws \SodiumException |
138 * @throws \SodiumException |
117 * @throws \TypeError |
139 * @throws \TypeError |
118 */ |
140 */ |
119 function crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key) |
141 function crypto_aead_chacha20poly1305_encrypt( |
120 { |
142 #[\SensitiveParameter] |
|
143 $message, |
|
144 $assocData, |
|
145 $nonce, |
|
146 #[\SensitiveParameter] |
|
147 $key |
|
148 ) { |
121 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key); |
149 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key); |
122 } |
150 } |
123 } |
151 } |
124 if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_decrypt')) { |
152 if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_decrypt')) { |
125 /** |
153 /** |
128 * @param string $assocData |
156 * @param string $assocData |
129 * @param string $nonce |
157 * @param string $nonce |
130 * @param string $key |
158 * @param string $key |
131 * @return string|bool |
159 * @return string|bool |
132 */ |
160 */ |
133 function crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key) |
161 function crypto_aead_chacha20poly1305_ietf_decrypt( |
134 { |
162 $message, |
|
163 $assocData, |
|
164 $nonce, |
|
165 #[\SensitiveParameter] |
|
166 $key |
|
167 ) { |
135 try { |
168 try { |
136 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key); |
169 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key); |
137 } catch (\TypeError $ex) { |
170 } catch (\TypeError $ex) { |
138 return false; |
171 return false; |
139 } catch (\SodiumException $ex) { |
172 } catch (\SodiumException $ex) { |
150 * @param string $key |
183 * @param string $key |
151 * @return string |
184 * @return string |
152 * @throws \SodiumException |
185 * @throws \SodiumException |
153 * @throws \TypeError |
186 * @throws \TypeError |
154 */ |
187 */ |
155 function crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key) |
188 function crypto_aead_chacha20poly1305_ietf_encrypt( |
156 { |
189 #[\SensitiveParameter] |
|
190 $message, |
|
191 $assocData, |
|
192 $nonce, |
|
193 #[\SensitiveParameter] |
|
194 $key |
|
195 ) { |
157 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key); |
196 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key); |
158 } |
197 } |
159 } |
198 } |
160 if (!is_callable('\\Sodium\\crypto_auth')) { |
199 if (!is_callable('\\Sodium\\crypto_auth')) { |
161 /** |
200 /** |
164 * @param string $key |
203 * @param string $key |
165 * @return string |
204 * @return string |
166 * @throws \SodiumException |
205 * @throws \SodiumException |
167 * @throws \TypeError |
206 * @throws \TypeError |
168 */ |
207 */ |
169 function crypto_auth($message, $key) |
208 function crypto_auth( |
170 { |
209 $message, |
|
210 #[\SensitiveParameter] |
|
211 $key |
|
212 ) { |
171 return ParagonIE_Sodium_Compat::crypto_auth($message, $key); |
213 return ParagonIE_Sodium_Compat::crypto_auth($message, $key); |
172 } |
214 } |
173 } |
215 } |
174 if (!is_callable('\\Sodium\\crypto_auth_verify')) { |
216 if (!is_callable('\\Sodium\\crypto_auth_verify')) { |
175 /** |
217 /** |
179 * @param string $key |
221 * @param string $key |
180 * @return bool |
222 * @return bool |
181 * @throws \SodiumException |
223 * @throws \SodiumException |
182 * @throws \TypeError |
224 * @throws \TypeError |
183 */ |
225 */ |
184 function crypto_auth_verify($mac, $message, $key) |
226 function crypto_auth_verify( |
185 { |
227 $mac, |
|
228 $message, |
|
229 #[\SensitiveParameter] |
|
230 $key |
|
231 ) { |
186 return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key); |
232 return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key); |
187 } |
233 } |
188 } |
234 } |
189 if (!is_callable('\\Sodium\\crypto_box')) { |
235 if (!is_callable('\\Sodium\\crypto_box')) { |
190 /** |
236 /** |
194 * @param string $kp |
240 * @param string $kp |
195 * @return string |
241 * @return string |
196 * @throws \SodiumException |
242 * @throws \SodiumException |
197 * @throws \TypeError |
243 * @throws \TypeError |
198 */ |
244 */ |
199 function crypto_box($message, $nonce, $kp) |
245 function crypto_box( |
200 { |
246 #[\SensitiveParameter] |
|
247 $message, |
|
248 $nonce, |
|
249 #[\SensitiveParameter] |
|
250 $kp |
|
251 ) { |
201 return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp); |
252 return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp); |
202 } |
253 } |
203 } |
254 } |
204 if (!is_callable('\\Sodium\\crypto_box_keypair')) { |
255 if (!is_callable('\\Sodium\\crypto_box_keypair')) { |
205 /** |
256 /** |
220 * @param string $pk |
271 * @param string $pk |
221 * @return string |
272 * @return string |
222 * @throws \SodiumException |
273 * @throws \SodiumException |
223 * @throws \TypeError |
274 * @throws \TypeError |
224 */ |
275 */ |
225 function crypto_box_keypair_from_secretkey_and_publickey($sk, $pk) |
276 function crypto_box_keypair_from_secretkey_and_publickey( |
226 { |
277 #[\SensitiveParameter] |
|
278 $sk, |
|
279 $pk |
|
280 ) { |
227 return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk); |
281 return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk); |
228 } |
282 } |
229 } |
283 } |
230 if (!is_callable('\\Sodium\\crypto_box_open')) { |
284 if (!is_callable('\\Sodium\\crypto_box_open')) { |
231 /** |
285 /** |
233 * @param string $message |
287 * @param string $message |
234 * @param string $nonce |
288 * @param string $nonce |
235 * @param string $kp |
289 * @param string $kp |
236 * @return string|bool |
290 * @return string|bool |
237 */ |
291 */ |
238 function crypto_box_open($message, $nonce, $kp) |
292 function crypto_box_open( |
239 { |
293 #[\SensitiveParameter] |
|
294 $message, |
|
295 $nonce, |
|
296 #[\SensitiveParameter] |
|
297 $kp |
|
298 ) { |
240 try { |
299 try { |
241 return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp); |
300 return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp); |
242 } catch (\TypeError $ex) { |
301 } catch (\TypeError $ex) { |
243 return false; |
302 return false; |
244 } catch (\SodiumException $ex) { |
303 } catch (\SodiumException $ex) { |
252 * @param string $keypair |
311 * @param string $keypair |
253 * @return string |
312 * @return string |
254 * @throws \SodiumException |
313 * @throws \SodiumException |
255 * @throws \TypeError |
314 * @throws \TypeError |
256 */ |
315 */ |
257 function crypto_box_publickey($keypair) |
316 function crypto_box_publickey( |
258 { |
317 #[\SensitiveParameter] |
|
318 $keypair |
|
319 ) { |
259 return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair); |
320 return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair); |
260 } |
321 } |
261 } |
322 } |
262 if (!is_callable('\\Sodium\\crypto_box_publickey_from_secretkey')) { |
323 if (!is_callable('\\Sodium\\crypto_box_publickey_from_secretkey')) { |
263 /** |
324 /** |
279 * @param string $publicKey |
342 * @param string $publicKey |
280 * @return string |
343 * @return string |
281 * @throws \SodiumException |
344 * @throws \SodiumException |
282 * @throws \TypeError |
345 * @throws \TypeError |
283 */ |
346 */ |
284 function crypto_box_seal($message, $publicKey) |
347 function crypto_box_seal( |
285 { |
348 #[\SensitiveParameter] |
|
349 $message, |
|
350 $publicKey |
|
351 ) { |
286 return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey); |
352 return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey); |
287 } |
353 } |
288 } |
354 } |
289 if (!is_callable('\\Sodium\\crypto_box_seal_open')) { |
355 if (!is_callable('\\Sodium\\crypto_box_seal_open')) { |
290 /** |
356 /** |
291 * @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
357 * @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
292 * @param string $message |
358 * @param string $message |
293 * @param string $kp |
359 * @param string $kp |
294 * @return string|bool |
360 * @return string|bool |
295 */ |
361 */ |
296 function crypto_box_seal_open($message, $kp) |
362 function crypto_box_seal_open( |
297 { |
363 $message, |
|
364 #[\SensitiveParameter] |
|
365 $kp |
|
366 ) { |
298 try { |
367 try { |
299 return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp); |
368 return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp); |
300 } catch (\TypeError $ex) { |
369 } catch (\TypeError $ex) { |
301 return false; |
370 return false; |
302 } catch (\SodiumException $ex) { |
371 } catch (\SodiumException $ex) { |
310 * @param string $keypair |
379 * @param string $keypair |
311 * @return string |
380 * @return string |
312 * @throws \SodiumException |
381 * @throws \SodiumException |
313 * @throws \TypeError |
382 * @throws \TypeError |
314 */ |
383 */ |
315 function crypto_box_secretkey($keypair) |
384 function crypto_box_secretkey( |
316 { |
385 #[\SensitiveParameter] |
|
386 $keypair |
|
387 ) { |
317 return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair); |
388 return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair); |
318 } |
389 } |
319 } |
390 } |
320 if (!is_callable('\\Sodium\\crypto_generichash')) { |
391 if (!is_callable('\\Sodium\\crypto_generichash')) { |
321 /** |
392 /** |
325 * @param int $outLen |
396 * @param int $outLen |
326 * @return string |
397 * @return string |
327 * @throws \SodiumException |
398 * @throws \SodiumException |
328 * @throws \TypeError |
399 * @throws \TypeError |
329 */ |
400 */ |
330 function crypto_generichash($message, $key = null, $outLen = 32) |
401 function crypto_generichash( |
331 { |
402 $message, |
|
403 #[\SensitiveParameter] |
|
404 $key = null, |
|
405 $outLen = 32 |
|
406 ) { |
332 return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen); |
407 return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen); |
333 } |
408 } |
334 } |
409 } |
335 if (!is_callable('\\Sodium\\crypto_generichash_final')) { |
410 if (!is_callable('\\Sodium\\crypto_generichash_final')) { |
336 /** |
411 /** |
339 * @param int $outputLength |
414 * @param int $outputLength |
340 * @return string |
415 * @return string |
341 * @throws \SodiumException |
416 * @throws \SodiumException |
342 * @throws \TypeError |
417 * @throws \TypeError |
343 */ |
418 */ |
344 function crypto_generichash_final(&$ctx, $outputLength = 32) |
419 function crypto_generichash_final( |
345 { |
420 #[\SensitiveParameter] |
|
421 &$ctx, |
|
422 $outputLength = 32 |
|
423 ) { |
346 return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength); |
424 return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength); |
347 } |
425 } |
348 } |
426 } |
349 if (!is_callable('\\Sodium\\crypto_generichash_init')) { |
427 if (!is_callable('\\Sodium\\crypto_generichash_init')) { |
350 /** |
428 /** |
353 * @param int $outLen |
431 * @param int $outLen |
354 * @return string |
432 * @return string |
355 * @throws \SodiumException |
433 * @throws \SodiumException |
356 * @throws \TypeError |
434 * @throws \TypeError |
357 */ |
435 */ |
358 function crypto_generichash_init($key = null, $outLen = 32) |
436 function crypto_generichash_init( |
359 { |
437 #[\SensitiveParameter] |
|
438 $key = null, |
|
439 $outLen = 32 |
|
440 ) { |
360 return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen); |
441 return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen); |
361 } |
442 } |
362 } |
443 } |
363 if (!is_callable('\\Sodium\\crypto_generichash_update')) { |
444 if (!is_callable('\\Sodium\\crypto_generichash_update')) { |
364 /** |
445 /** |
367 * @param string $message |
448 * @param string $message |
368 * @return void |
449 * @return void |
369 * @throws \SodiumException |
450 * @throws \SodiumException |
370 * @throws \TypeError |
451 * @throws \TypeError |
371 */ |
452 */ |
372 function crypto_generichash_update(&$ctx, $message = '') |
453 function crypto_generichash_update( |
373 { |
454 #[\SensitiveParameter] |
|
455 &$ctx, |
|
456 $message = '' |
|
457 ) { |
374 ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message); |
458 ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message); |
375 } |
459 } |
376 } |
460 } |
377 if (!is_callable('\\Sodium\\crypto_kx')) { |
461 if (!is_callable('\\Sodium\\crypto_kx')) { |
378 /** |
462 /** |
406 * @param int $memlimit |
495 * @param int $memlimit |
407 * @return string |
496 * @return string |
408 * @throws \SodiumException |
497 * @throws \SodiumException |
409 * @throws \TypeError |
498 * @throws \TypeError |
410 */ |
499 */ |
411 function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit) |
500 function crypto_pwhash( |
412 { |
501 $outlen, |
|
502 #[\SensitiveParameter] |
|
503 $passwd, |
|
504 $salt, |
|
505 $opslimit, |
|
506 $memlimit |
|
507 ) { |
413 return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit); |
508 return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit); |
414 } |
509 } |
415 } |
510 } |
416 if (!is_callable('\\Sodium\\crypto_pwhash_str')) { |
511 if (!is_callable('\\Sodium\\crypto_pwhash_str')) { |
417 /** |
512 /** |
421 * @param int $memlimit |
516 * @param int $memlimit |
422 * @return string |
517 * @return string |
423 * @throws \SodiumException |
518 * @throws \SodiumException |
424 * @throws \TypeError |
519 * @throws \TypeError |
425 */ |
520 */ |
426 function crypto_pwhash_str($passwd, $opslimit, $memlimit) |
521 function crypto_pwhash_str( |
427 { |
522 #[\SensitiveParameter] |
|
523 $passwd, |
|
524 $opslimit, |
|
525 $memlimit |
|
526 ) { |
428 return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit); |
527 return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit); |
429 } |
528 } |
430 } |
529 } |
431 if (!is_callable('\\Sodium\\crypto_pwhash_str_verify')) { |
530 if (!is_callable('\\Sodium\\crypto_pwhash_str_verify')) { |
432 /** |
531 /** |
435 * @param string $hash |
534 * @param string $hash |
436 * @return bool |
535 * @return bool |
437 * @throws \SodiumException |
536 * @throws \SodiumException |
438 * @throws \TypeError |
537 * @throws \TypeError |
439 */ |
538 */ |
440 function crypto_pwhash_str_verify($passwd, $hash) |
539 function crypto_pwhash_str_verify( |
441 { |
540 #[\SensitiveParameter] |
|
541 $passwd, |
|
542 #[\SensitiveParameter] |
|
543 $hash |
|
544 ) { |
442 return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash); |
545 return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash); |
443 } |
546 } |
444 } |
547 } |
445 if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256')) { |
548 if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256')) { |
446 /** |
549 /** |
452 * @param int $memlimit |
555 * @param int $memlimit |
453 * @return string |
556 * @return string |
454 * @throws \SodiumException |
557 * @throws \SodiumException |
455 * @throws \TypeError |
558 * @throws \TypeError |
456 */ |
559 */ |
457 function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit) |
560 function crypto_pwhash_scryptsalsa208sha256( |
458 { |
561 $outlen, |
|
562 #[\SensitiveParameter] |
|
563 $passwd, |
|
564 #[\SensitiveParameter] |
|
565 $salt, |
|
566 $opslimit, |
|
567 $memlimit |
|
568 ) { |
459 return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit); |
569 return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit); |
460 } |
570 } |
461 } |
571 } |
462 if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str')) { |
572 if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str')) { |
463 /** |
573 /** |
467 * @param int $memlimit |
577 * @param int $memlimit |
468 * @return string |
578 * @return string |
469 * @throws \SodiumException |
579 * @throws \SodiumException |
470 * @throws \TypeError |
580 * @throws \TypeError |
471 */ |
581 */ |
472 function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit) |
582 function crypto_pwhash_scryptsalsa208sha256_str( |
473 { |
583 #[\SensitiveParameter] |
|
584 $passwd, |
|
585 $opslimit, |
|
586 $memlimit |
|
587 ) { |
474 return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit); |
588 return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit); |
475 } |
589 } |
476 } |
590 } |
477 if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify')) { |
591 if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify')) { |
478 /** |
592 /** |
481 * @param string $hash |
595 * @param string $hash |
482 * @return bool |
596 * @return bool |
483 * @throws \SodiumException |
597 * @throws \SodiumException |
484 * @throws \TypeError |
598 * @throws \TypeError |
485 */ |
599 */ |
486 function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash) |
600 function crypto_pwhash_scryptsalsa208sha256_str_verify( |
487 { |
601 #[\SensitiveParameter] |
|
602 $passwd, |
|
603 #[\SensitiveParameter] |
|
604 $hash |
|
605 ) { |
488 return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash); |
606 return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash); |
489 } |
607 } |
490 } |
608 } |
491 if (!is_callable('\\Sodium\\crypto_scalarmult')) { |
609 if (!is_callable('\\Sodium\\crypto_scalarmult')) { |
492 /** |
610 /** |
495 * @param string $p |
613 * @param string $p |
496 * @return string |
614 * @return string |
497 * @throws \SodiumException |
615 * @throws \SodiumException |
498 * @throws \TypeError |
616 * @throws \TypeError |
499 */ |
617 */ |
500 function crypto_scalarmult($n, $p) |
618 function crypto_scalarmult( |
501 { |
619 #[\SensitiveParameter] |
|
620 $n, |
|
621 $p |
|
622 ) { |
502 return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p); |
623 return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p); |
503 } |
624 } |
504 } |
625 } |
505 if (!is_callable('\\Sodium\\crypto_scalarmult_base')) { |
626 if (!is_callable('\\Sodium\\crypto_scalarmult_base')) { |
506 /** |
627 /** |
523 * @param string $key |
646 * @param string $key |
524 * @return string |
647 * @return string |
525 * @throws \SodiumException |
648 * @throws \SodiumException |
526 * @throws \TypeError |
649 * @throws \TypeError |
527 */ |
650 */ |
528 function crypto_secretbox($message, $nonce, $key) |
651 function crypto_secretbox( |
529 { |
652 #[\SensitiveParameter] |
|
653 $message, |
|
654 $nonce, |
|
655 #[\SensitiveParameter] |
|
656 $key |
|
657 ) { |
530 return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key); |
658 return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key); |
531 } |
659 } |
532 } |
660 } |
533 if (!is_callable('\\Sodium\\crypto_secretbox_open')) { |
661 if (!is_callable('\\Sodium\\crypto_secretbox_open')) { |
534 /** |
662 /** |
536 * @param string $message |
664 * @param string $message |
537 * @param string $nonce |
665 * @param string $nonce |
538 * @param string $key |
666 * @param string $key |
539 * @return string|bool |
667 * @return string|bool |
540 */ |
668 */ |
541 function crypto_secretbox_open($message, $nonce, $key) |
669 function crypto_secretbox_open( |
542 { |
670 $message, |
|
671 $nonce, |
|
672 #[\SensitiveParameter] |
|
673 $key |
|
674 ) { |
543 try { |
675 try { |
544 return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key); |
676 return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key); |
545 } catch (\TypeError $ex) { |
677 } catch (\TypeError $ex) { |
546 return false; |
678 return false; |
547 } catch (\SodiumException $ex) { |
679 } catch (\SodiumException $ex) { |
556 * @param string $key |
688 * @param string $key |
557 * @return string |
689 * @return string |
558 * @throws \SodiumException |
690 * @throws \SodiumException |
559 * @throws \TypeError |
691 * @throws \TypeError |
560 */ |
692 */ |
561 function crypto_shorthash($message, $key = '') |
693 function crypto_shorthash( |
562 { |
694 $message, |
|
695 #[\SensitiveParameter] |
|
696 $key = '' |
|
697 ) { |
563 return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key); |
698 return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key); |
564 } |
699 } |
565 } |
700 } |
566 if (!is_callable('\\Sodium\\crypto_sign')) { |
701 if (!is_callable('\\Sodium\\crypto_sign')) { |
567 /** |
702 /** |
570 * @param string $sk |
705 * @param string $sk |
571 * @return string |
706 * @return string |
572 * @throws \SodiumException |
707 * @throws \SodiumException |
573 * @throws \TypeError |
708 * @throws \TypeError |
574 */ |
709 */ |
575 function crypto_sign($message, $sk) |
710 function crypto_sign( |
576 { |
711 $message, |
|
712 #[\SensitiveParameter] |
|
713 $sk |
|
714 ) { |
577 return ParagonIE_Sodium_Compat::crypto_sign($message, $sk); |
715 return ParagonIE_Sodium_Compat::crypto_sign($message, $sk); |
578 } |
716 } |
579 } |
717 } |
580 if (!is_callable('\\Sodium\\crypto_sign_detached')) { |
718 if (!is_callable('\\Sodium\\crypto_sign_detached')) { |
581 /** |
719 /** |
584 * @param string $sk |
722 * @param string $sk |
585 * @return string |
723 * @return string |
586 * @throws \SodiumException |
724 * @throws \SodiumException |
587 * @throws \TypeError |
725 * @throws \TypeError |
588 */ |
726 */ |
589 function crypto_sign_detached($message, $sk) |
727 function crypto_sign_detached( |
590 { |
728 $message, |
|
729 #[\SensitiveParameter] |
|
730 $sk |
|
731 ) { |
591 return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk); |
732 return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk); |
592 } |
733 } |
593 } |
734 } |
594 if (!is_callable('\\Sodium\\crypto_sign_keypair')) { |
735 if (!is_callable('\\Sodium\\crypto_sign_keypair')) { |
595 /** |
736 /** |
627 * @param string $keypair |
768 * @param string $keypair |
628 * @return string |
769 * @return string |
629 * @throws \SodiumException |
770 * @throws \SodiumException |
630 * @throws \TypeError |
771 * @throws \TypeError |
631 */ |
772 */ |
632 function crypto_sign_publickey($keypair) |
773 function crypto_sign_publickey( |
633 { |
774 #[\SensitiveParameter] |
|
775 $keypair |
|
776 ) { |
634 return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair); |
777 return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair); |
635 } |
778 } |
636 } |
779 } |
637 if (!is_callable('\\Sodium\\crypto_sign_publickey_from_secretkey')) { |
780 if (!is_callable('\\Sodium\\crypto_sign_publickey_from_secretkey')) { |
638 /** |
781 /** |
640 * @param string $sk |
783 * @param string $sk |
641 * @return string |
784 * @return string |
642 * @throws \SodiumException |
785 * @throws \SodiumException |
643 * @throws \TypeError |
786 * @throws \TypeError |
644 */ |
787 */ |
645 function crypto_sign_publickey_from_secretkey($sk) |
788 function crypto_sign_publickey_from_secretkey( |
646 { |
789 #[\SensitiveParameter] |
|
790 $sk |
|
791 ) { |
647 return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk); |
792 return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk); |
648 } |
793 } |
649 } |
794 } |
650 if (!is_callable('\\Sodium\\crypto_sign_secretkey')) { |
795 if (!is_callable('\\Sodium\\crypto_sign_secretkey')) { |
651 /** |
796 /** |
653 * @param string $keypair |
798 * @param string $keypair |
654 * @return string |
799 * @return string |
655 * @throws \SodiumException |
800 * @throws \SodiumException |
656 * @throws \TypeError |
801 * @throws \TypeError |
657 */ |
802 */ |
658 function crypto_sign_secretkey($keypair) |
803 function crypto_sign_secretkey( |
659 { |
804 #[\SensitiveParameter] |
|
805 $keypair |
|
806 ) { |
660 return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair); |
807 return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair); |
661 } |
808 } |
662 } |
809 } |
663 if (!is_callable('\\Sodium\\crypto_sign_seed_keypair')) { |
810 if (!is_callable('\\Sodium\\crypto_sign_seed_keypair')) { |
664 /** |
811 /** |
666 * @param string $seed |
813 * @param string $seed |
667 * @return string |
814 * @return string |
668 * @throws \SodiumException |
815 * @throws \SodiumException |
669 * @throws \TypeError |
816 * @throws \TypeError |
670 */ |
817 */ |
671 function crypto_sign_seed_keypair($seed) |
818 function crypto_sign_seed_keypair( |
672 { |
819 #[\SensitiveParameter] |
|
820 $seed |
|
821 ) { |
673 return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed); |
822 return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed); |
674 } |
823 } |
675 } |
824 } |
676 if (!is_callable('\\Sodium\\crypto_sign_verify_detached')) { |
825 if (!is_callable('\\Sodium\\crypto_sign_verify_detached')) { |
677 /** |
826 /** |
722 * @param string $key |
873 * @param string $key |
723 * @return string |
874 * @return string |
724 * @throws \SodiumException |
875 * @throws \SodiumException |
725 * @throws \TypeError |
876 * @throws \TypeError |
726 */ |
877 */ |
727 function crypto_stream($len, $nonce, $key) |
878 function crypto_stream( |
728 { |
879 $len, |
|
880 $nonce, |
|
881 #[\SensitiveParameter] |
|
882 $key |
|
883 ) { |
729 return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key); |
884 return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key); |
730 } |
885 } |
731 } |
886 } |
732 if (!is_callable('\\Sodium\\crypto_stream_xor')) { |
887 if (!is_callable('\\Sodium\\crypto_stream_xor')) { |
733 /** |
888 /** |
737 * @param string $key |
892 * @param string $key |
738 * @return string |
893 * @return string |
739 * @throws \SodiumException |
894 * @throws \SodiumException |
740 * @throws \TypeError |
895 * @throws \TypeError |
741 */ |
896 */ |
742 function crypto_stream_xor($message, $nonce, $key) |
897 function crypto_stream_xor( |
743 { |
898 #[\SensitiveParameter] |
|
899 $message, |
|
900 $nonce, |
|
901 #[\SensitiveParameter] |
|
902 $key |
|
903 ) { |
744 return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key); |
904 return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key); |
745 } |
905 } |
746 } |
906 } |
747 if (!is_callable('\\Sodium\\hex2bin')) { |
907 if (!is_callable('\\Sodium\\hex2bin')) { |
748 /** |
908 /** |
750 * @param string $string |
910 * @param string $string |
751 * @return string |
911 * @return string |
752 * @throws \SodiumException |
912 * @throws \SodiumException |
753 * @throws \TypeError |
913 * @throws \TypeError |
754 */ |
914 */ |
755 function hex2bin($string) |
915 function hex2bin( |
756 { |
916 #[\SensitiveParameter] |
|
917 $string |
|
918 ) { |
757 return ParagonIE_Sodium_Compat::hex2bin($string); |
919 return ParagonIE_Sodium_Compat::hex2bin($string); |
758 } |
920 } |
759 } |
921 } |
760 if (!is_callable('\\Sodium\\memcmp')) { |
922 if (!is_callable('\\Sodium\\memcmp')) { |
761 /** |
923 /** |
764 * @param string $b |
926 * @param string $b |
765 * @return int |
927 * @return int |
766 * @throws \SodiumException |
928 * @throws \SodiumException |
767 * @throws \TypeError |
929 * @throws \TypeError |
768 */ |
930 */ |
769 function memcmp($a, $b) |
931 function memcmp( |
770 { |
932 #[\SensitiveParameter] |
|
933 $a, |
|
934 #[\SensitiveParameter] |
|
935 $b |
|
936 ) { |
771 return ParagonIE_Sodium_Compat::memcmp($a, $b); |
937 return ParagonIE_Sodium_Compat::memcmp($a, $b); |
772 } |
938 } |
773 } |
939 } |
774 if (!is_callable('\\Sodium\\memzero')) { |
940 if (!is_callable('\\Sodium\\memzero')) { |
775 /** |
941 /** |
781 * |
947 * |
782 * @psalm-suppress MissingParamType |
948 * @psalm-suppress MissingParamType |
783 * @psalm-suppress MissingReturnType |
949 * @psalm-suppress MissingReturnType |
784 * @psalm-suppress ReferenceConstraintViolation |
950 * @psalm-suppress ReferenceConstraintViolation |
785 */ |
951 */ |
786 function memzero(&$str) |
952 function memzero( |
787 { |
953 #[\SensitiveParameter] |
|
954 &$str |
|
955 ) { |
788 ParagonIE_Sodium_Compat::memzero($str); |
956 ParagonIE_Sodium_Compat::memzero($str); |
789 } |
957 } |
790 } |
958 } |
791 if (!is_callable('\\Sodium\\randombytes_buf')) { |
959 if (!is_callable('\\Sodium\\randombytes_buf')) { |
792 /** |
960 /** |