Changeset 54310
- Timestamp:
- 09/26/2022 01:58:53 PM (2 years ago)
- Location:
- trunk/src/wp-includes/sodium_compat
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/sodium_compat/LICENSE
r51002 r54310 1 1 ISC License 2 2 3 Copyright (c) 2016-202 1, Paragon Initiative Enterprises <security at paragonie dot com>3 Copyright (c) 2016-2022, Paragon Initiative Enterprises <security at paragonie dot com> 4 4 Copyright (c) 2013-2019, Frank Denis <j at pureftpd dot org> 5 5 -
trunk/src/wp-includes/sodium_compat/lib/php72compat.php
r51002 r54310 111 111 /** 112 112 * @see ParagonIE_Sodium_Compat::add() 113 * @param string $ val114 * @param string $ addv113 * @param string $string1 114 * @param string $string2 115 115 * @return void 116 116 * @throws SodiumException 117 117 */ 118 function sodium_add(&$ val, $addv)119 { 120 ParagonIE_Sodium_Compat::add($ val, $addv);118 function sodium_add(&$string1, $string2) 119 { 120 ParagonIE_Sodium_Compat::add($string1, $string2); 121 121 } 122 122 } … … 166 166 /** 167 167 * @see ParagonIE_Sodium_Compat::compare() 168 * @param string $ a169 * @param string $ b168 * @param string $string1 169 * @param string $string2 170 170 * @return int 171 171 * @throws SodiumException 172 172 * @throws TypeError 173 173 */ 174 function sodium_compare($ a, $b)175 { 176 return ParagonIE_Sodium_Compat::compare($ a, $b);174 function sodium_compare($string1, $string2) 175 { 176 return ParagonIE_Sodium_Compat::compare($string1, $string2); 177 177 } 178 178 } … … 180 180 /** 181 181 * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt() 182 * @param string $ message183 * @param string $a ssocData182 * @param string $ciphertext 183 * @param string $additional_data 184 184 * @param string $nonce 185 185 * @param string $key 186 186 * @return string|bool 187 187 */ 188 function sodium_crypto_aead_aes256gcm_decrypt($ message, $assocData, $nonce, $key)188 function sodium_crypto_aead_aes256gcm_decrypt($ciphertext, $additional_data, $nonce, $key) 189 189 { 190 190 try { 191 return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key); 191 return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt( 192 $ciphertext, 193 $additional_data, 194 $nonce, 195 $key 196 ); 197 } catch (Error $ex) { 198 return false; 199 } catch (Exception $ex) { 200 if (($ex instanceof SodiumException) && ($ex->getMessage() === 'AES-256-GCM is not available')) { 201 throw $ex; 202 } 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 211 * @param string $additional_data 212 * @param string $nonce 213 * @param string $key 214 * @return string 215 * @throws SodiumException 216 * @throws TypeError 217 */ 218 function sodium_crypto_aead_aes256gcm_encrypt($message, $additional_data, $nonce, $key) 219 { 220 return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $additional_data, $nonce, $key); 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() 236 * @param string $ciphertext 237 * @param string $additional_data 238 * @param string $nonce 239 * @param string $key 240 * @return string|bool 241 */ 242 function sodium_crypto_aead_chacha20poly1305_decrypt($ciphertext, $additional_data, $nonce, $key) 243 { 244 try { 245 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt( 246 $ciphertext, 247 $additional_data, 248 $nonce, 249 $key 250 ); 192 251 } catch (Error $ex) { 193 252 return false; … … 197 256 } 198 257 } 199 if (!is_callable('sodium_crypto_aead_ aes256gcm_encrypt')) {200 /** 201 * @see ParagonIE_Sodium_Compat::crypto_aead_ aes256gcm_encrypt()202 * @param string $message 203 * @param string $a ssocData258 if (!is_callable('sodium_crypto_aead_chacha20poly1305_encrypt')) { 259 /** 260 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt() 261 * @param string $message 262 * @param string $additional_data 204 263 * @param string $nonce 205 264 * @param string $key … … 208 267 * @throws TypeError 209 268 */ 210 function sodium_crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key) 211 { 212 return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key); 213 } 214 } 215 if (!is_callable('sodium_crypto_aead_aes256gcm_is_available')) { 216 /** 217 * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available() 218 * @return bool 219 */ 220 function sodium_crypto_aead_aes256gcm_is_available() 221 { 222 return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available(); 223 } 224 } 225 if (!is_callable('sodium_crypto_aead_chacha20poly1305_decrypt')) { 226 /** 227 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt() 228 * @param string $message 229 * @param string $assocData 269 function sodium_crypto_aead_chacha20poly1305_encrypt($message, $additional_data, $nonce, $key) 270 { 271 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt( 272 $message, 273 $additional_data, 274 $nonce, 275 $key 276 ); 277 } 278 } 279 if (!is_callable('sodium_crypto_aead_chacha20poly1305_keygen')) { 280 /** 281 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen() 282 * @return string 283 * @throws Exception 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 294 * @param string $additional_data 230 295 * @param string $nonce 231 296 * @param string $key 232 297 * @return string|bool 233 298 */ 234 function sodium_crypto_aead_chacha20poly1305_ decrypt($message, $assocData, $nonce, $key)299 function sodium_crypto_aead_chacha20poly1305_ietf_decrypt($message, $additional_data, $nonce, $key) 235 300 { 236 301 try { 237 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key); 302 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt( 303 $message, 304 $additional_data, 305 $nonce, 306 $key 307 ); 238 308 } catch (Error $ex) { 239 309 return false; … … 243 313 } 244 314 } 245 if (!is_callable('sodium_crypto_aead_chacha20poly1305_ encrypt')) {246 /** 247 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ encrypt()248 * @param string $message 249 * @param string $a ssocData315 if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_encrypt')) { 316 /** 317 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt() 318 * @param string $message 319 * @param string $additional_data 250 320 * @param string $nonce 251 321 * @param string $key … … 254 324 * @throws TypeError 255 325 */ 256 function sodium_crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key) 257 { 258 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key); 259 } 260 } 261 if (!is_callable('sodium_crypto_aead_chacha20poly1305_keygen')) { 262 /** 263 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen() 264 * @return string 265 * @throws Exception 266 */ 267 function sodium_crypto_aead_chacha20poly1305_keygen() 268 { 269 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen(); 270 } 271 } 272 if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_decrypt')) { 273 /** 274 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt() 275 * @param string $message 276 * @param string $assocData 326 function sodium_crypto_aead_chacha20poly1305_ietf_encrypt($message, $additional_data, $nonce, $key) 327 { 328 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt( 329 $message, 330 $additional_data, 331 $nonce, 332 $key 333 ); 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 340 * @throws Exception 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() 350 * @param string $ciphertext 351 * @param string $additional_data 277 352 * @param string $nonce 278 353 * @param string $key 279 354 * @return string|bool 280 355 */ 281 function sodium_crypto_aead_ chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key)356 function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($ciphertext, $additional_data, $nonce, $key) 282 357 { 283 358 try { 284 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key); 359 return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt( 360 $ciphertext, 361 $additional_data, 362 $nonce, 363 $key, 364 true 365 ); 285 366 } catch (Error $ex) { 286 367 return false; … … 290 371 } 291 372 } 292 if (!is_callable('sodium_crypto_aead_ chacha20poly1305_ietf_encrypt')) {293 /** 294 * @see ParagonIE_Sodium_Compat::crypto_aead_ chacha20poly1305_ietf_encrypt()295 * @param string $message 296 * @param string $a ssocData373 if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) { 374 /** 375 * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt() 376 * @param string $message 377 * @param string $additional_data 297 378 * @param string $nonce 298 379 * @param string $key … … 301 382 * @throws TypeError 302 383 */ 303 function sodium_crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key) 304 { 305 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key); 306 } 307 } 308 if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_keygen')) { 309 /** 310 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_keygen() 311 * @return string 312 * @throws Exception 313 */ 314 function sodium_crypto_aead_chacha20poly1305_ietf_keygen() 315 { 316 return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_keygen(); 317 } 318 } 319 if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) { 320 /** 321 * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt() 322 * @param string $message 323 * @param string $assocData 384 function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt( 385 $message, 386 $additional_data, 387 $nonce, 388 $key 389 ) { 390 return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt( 391 $message, 392 $additional_data, 393 $nonce, 394 $key, 395 true 396 ); 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 403 * @throws Exception 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 428 * @throws Exception 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 324 454 * @param string $nonce 325 * @param string $key 455 * @param string $key_pair 456 * @return string 457 * @throws SodiumException 458 * @throws TypeError 459 */ 460 function sodium_crypto_box($message, $nonce, $key_pair) 461 { 462 return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $key_pair); 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() 480 * @param string $secret_key 481 * @param string $public_key 482 * @return string 483 * @throws SodiumException 484 * @throws TypeError 485 */ 486 function sodium_crypto_box_keypair_from_secretkey_and_publickey($secret_key, $public_key) 487 { 488 return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($secret_key, $public_key); 489 } 490 } 491 if (!is_callable('sodium_crypto_box_open')) { 492 /** 493 * @see ParagonIE_Sodium_Compat::crypto_box_open() 494 * @param string $ciphertext 495 * @param string $nonce 496 * @param string $key_pair 326 497 * @return string|bool 327 498 */ 328 function sodium_crypto_ aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key)499 function sodium_crypto_box_open($ciphertext, $nonce, $key_pair) 329 500 { 330 501 try { 331 return ParagonIE_Sodium_Compat::crypto_ aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key, true);502 return ParagonIE_Sodium_Compat::crypto_box_open($ciphertext, $nonce, $key_pair); 332 503 } catch (Error $ex) { 333 504 return false; … … 337 508 } 338 509 } 339 if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) { 340 /** 341 * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt() 342 * @param string $message 343 * @param string $assocData 344 * @param string $nonce 345 * @param string $key 346 * @return string 347 * @throws SodiumException 348 * @throws TypeError 349 */ 350 function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key) 351 { 352 return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key, true); 353 } 354 } 355 if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_keygen')) { 356 /** 357 * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_keygen() 358 * @return string 359 * @throws Exception 360 */ 361 function sodium_crypto_aead_xchacha20poly1305_ietf_keygen() 362 { 363 return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_keygen(); 364 } 365 } 366 if (!is_callable('sodium_crypto_auth')) { 367 /** 368 * @see ParagonIE_Sodium_Compat::crypto_auth() 369 * @param string $message 370 * @param string $key 371 * @return string 372 * @throws SodiumException 373 * @throws TypeError 374 */ 375 function sodium_crypto_auth($message, $key) 376 { 377 return ParagonIE_Sodium_Compat::crypto_auth($message, $key); 378 } 379 } 380 if (!is_callable('sodium_crypto_auth_keygen')) { 381 /** 382 * @see ParagonIE_Sodium_Compat::crypto_auth_keygen() 383 * @return string 384 * @throws Exception 385 */ 386 function sodium_crypto_auth_keygen() 387 { 388 return ParagonIE_Sodium_Compat::crypto_auth_keygen(); 389 } 390 } 391 if (!is_callable('sodium_crypto_auth_verify')) { 392 /** 393 * @see ParagonIE_Sodium_Compat::crypto_auth_verify() 394 * @param string $mac 395 * @param string $message 396 * @param string $key 397 * @return bool 398 * @throws SodiumException 399 * @throws TypeError 400 */ 401 function sodium_crypto_auth_verify($mac, $message, $key) 402 { 403 return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key); 404 } 405 } 406 if (!is_callable('sodium_crypto_box')) { 407 /** 408 * @see ParagonIE_Sodium_Compat::crypto_box() 409 * @param string $message 410 * @param string $nonce 411 * @param string $kp 412 * @return string 413 * @throws SodiumException 414 * @throws TypeError 415 */ 416 function sodium_crypto_box($message, $nonce, $kp) 417 { 418 return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp); 419 } 420 } 421 if (!is_callable('sodium_crypto_box_keypair')) { 422 /** 423 * @see ParagonIE_Sodium_Compat::crypto_box_keypair() 424 * @return string 425 * @throws SodiumException 426 * @throws TypeError 427 */ 428 function sodium_crypto_box_keypair() 429 { 430 return ParagonIE_Sodium_Compat::crypto_box_keypair(); 431 } 432 } 433 if (!is_callable('sodium_crypto_box_keypair_from_secretkey_and_publickey')) { 434 /** 435 * @see ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey() 436 * @param string $sk 437 * @param string $pk 438 * @return string 439 * @throws SodiumException 440 * @throws TypeError 441 */ 442 function sodium_crypto_box_keypair_from_secretkey_and_publickey($sk, $pk) 443 { 444 return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk); 445 } 446 } 447 if (!is_callable('sodium_crypto_box_open')) { 448 /** 449 * @see ParagonIE_Sodium_Compat::crypto_box_open() 450 * @param string $message 451 * @param string $nonce 452 * @param string $kp 510 if (!is_callable('sodium_crypto_box_publickey')) { 511 /** 512 * @see ParagonIE_Sodium_Compat::crypto_box_publickey() 513 * @param string $key_pair 514 * @return string 515 * @throws SodiumException 516 * @throws TypeError 517 */ 518 function sodium_crypto_box_publickey($key_pair) 519 { 520 return ParagonIE_Sodium_Compat::crypto_box_publickey($key_pair); 521 } 522 } 523 if (!is_callable('sodium_crypto_box_publickey_from_secretkey')) { 524 /** 525 * @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey() 526 * @param string $secret_key 527 * @return string 528 * @throws SodiumException 529 * @throws TypeError 530 */ 531 function sodium_crypto_box_publickey_from_secretkey($secret_key) 532 { 533 return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($secret_key); 534 } 535 } 536 if (!is_callable('sodium_crypto_box_seal')) { 537 /** 538 * @see ParagonIE_Sodium_Compat::crypto_box_seal() 539 * @param string $message 540 * @param string $public_key 541 * @return string 542 * @throws SodiumException 543 * @throws TypeError 544 */ 545 function sodium_crypto_box_seal($message, $public_key) 546 { 547 return ParagonIE_Sodium_Compat::crypto_box_seal($message, $public_key); 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 554 * @param string $key_pair 453 555 * @return string|bool 454 */ 455 function sodium_crypto_box_open($message, $nonce, $kp) 556 * @throws SodiumException 557 */ 558 function sodium_crypto_box_seal_open($message, $key_pair) 456 559 { 457 560 try { 458 return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp); 459 } catch (Error $ex) { 460 return false; 461 } catch (Exception $ex) { 462 return false; 463 } 464 } 465 } 466 if (!is_callable('sodium_crypto_box_publickey')) { 467 /** 468 * @see ParagonIE_Sodium_Compat::crypto_box_publickey() 469 * @param string $keypair 470 * @return string 471 * @throws SodiumException 472 * @throws TypeError 473 */ 474 function sodium_crypto_box_publickey($keypair) 475 { 476 return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair); 477 } 478 } 479 if (!is_callable('sodium_crypto_box_publickey_from_secretkey')) { 480 /** 481 * @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey() 482 * @param string $sk 483 * @return string 484 * @throws SodiumException 485 * @throws TypeError 486 */ 487 function sodium_crypto_box_publickey_from_secretkey($sk) 488 { 489 return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($sk); 490 } 491 } 492 if (!is_callable('sodium_crypto_box_seal')) { 493 /** 494 * @see ParagonIE_Sodium_Compat::crypto_box_seal() 495 * @param string $message 496 * @param string $publicKey 497 * @return string 498 * @throws SodiumException 499 * @throws TypeError 500 */ 501 function sodium_crypto_box_seal($message, $publicKey) 502 { 503 return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey); 504 } 505 } 506 if (!is_callable('sodium_crypto_box_seal_open')) { 507 /** 508 * @see ParagonIE_Sodium_Compat::crypto_box_seal_open() 509 * @param string $message 510 * @param string $kp 511 * @return string|bool 512 * @throws SodiumException 513 */ 514 function sodium_crypto_box_seal_open($message, $kp) 515 { 516 try { 517 return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp); 561 return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $key_pair); 518 562 } catch (SodiumException $ex) { 519 563 if ($ex->getMessage() === 'Argument 2 must be CRYPTO_BOX_KEYPAIRBYTES long.') { … … 527 571 /** 528 572 * @see ParagonIE_Sodium_Compat::crypto_box_secretkey() 529 * @param string $key pair530 * @return string 531 * @throws SodiumException 532 * @throws TypeError 533 */ 534 function sodium_crypto_box_secretkey($key pair)535 { 536 return ParagonIE_Sodium_Compat::crypto_box_secretkey($key pair);573 * @param string $key_pair 574 * @return string 575 * @throws SodiumException 576 * @throws TypeError 577 */ 578 function sodium_crypto_box_secretkey($key_pair) 579 { 580 return ParagonIE_Sodium_Compat::crypto_box_secretkey($key_pair); 537 581 } 538 582 } … … 555 599 * @param string $message 556 600 * @param string|null $key 557 * @param int $ outLen558 * @return string 559 * @throws SodiumException 560 * @throws TypeError 561 */ 562 function sodium_crypto_generichash($message, $key = null, $ outLen= 32)563 { 564 return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $ outLen);601 * @param int $length 602 * @return string 603 * @throws SodiumException 604 * @throws TypeError 605 */ 606 function sodium_crypto_generichash($message, $key = null, $length = 32) 607 { 608 return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $length); 565 609 } 566 610 } … … 568 612 /** 569 613 * @see ParagonIE_Sodium_Compat::crypto_generichash_final() 570 * @param string|null $ ctx614 * @param string|null $state 571 615 * @param int $outputLength 572 616 * @return string … … 574 618 * @throws TypeError 575 619 */ 576 function sodium_crypto_generichash_final(&$ ctx, $outputLength = 32)577 { 578 return ParagonIE_Sodium_Compat::crypto_generichash_final($ ctx, $outputLength);620 function sodium_crypto_generichash_final(&$state, $outputLength = 32) 621 { 622 return ParagonIE_Sodium_Compat::crypto_generichash_final($state, $outputLength); 579 623 } 580 624 } … … 583 627 * @see ParagonIE_Sodium_Compat::crypto_generichash_init() 584 628 * @param string|null $key 585 * @param int $ outLen586 * @return string 587 * @throws SodiumException 588 * @throws TypeError 589 */ 590 function sodium_crypto_generichash_init($key = null, $ outLen= 32)591 { 592 return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $ outLen);629 * @param int $length 630 * @return string 631 * @throws SodiumException 632 * @throws TypeError 633 */ 634 function sodium_crypto_generichash_init($key = null, $length = 32) 635 { 636 return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $length); 593 637 } 594 638 } … … 607 651 /** 608 652 * @see ParagonIE_Sodium_Compat::crypto_generichash_update() 609 * @param string|null $ ctx653 * @param string|null $state 610 654 * @param string $message 611 655 * @return void … … 613 657 * @throws TypeError 614 658 */ 615 function sodium_crypto_generichash_update(&$ ctx, $message = '')616 { 617 ParagonIE_Sodium_Compat::crypto_generichash_update($ ctx, $message);659 function sodium_crypto_generichash_update(&$state, $message = '') 660 { 661 ParagonIE_Sodium_Compat::crypto_generichash_update($state, $message); 618 662 } 619 663 } … … 632 676 /** 633 677 * @see ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key() 634 * @param int $subkey_len 678 * @param int $subkey_length 635 679 * @param int $subkey_id 636 680 * @param string $context … … 639 683 * @throws Exception 640 684 */ 641 function sodium_crypto_kdf_derive_from_key($subkey_len , $subkey_id, $context, $key)685 function sodium_crypto_kdf_derive_from_key($subkey_length, $subkey_id, $context, $key) 642 686 { 643 687 return ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key( 644 $subkey_len ,688 $subkey_length, 645 689 $subkey_id, 646 690 $context, … … 693 737 if (!is_callable('sodium_crypto_kx_client_session_keys')) { 694 738 /** 695 * @param string $ keypair696 * @param string $server PublicKey739 * @param string $client_key_pair 740 * @param string $server_key 697 741 * @return array{0: string, 1: string} 698 742 * @throws SodiumException 699 743 */ 700 function sodium_crypto_kx_client_session_keys($ keypair, $serverPublicKey)701 { 702 return ParagonIE_Sodium_Compat::crypto_kx_client_session_keys($ keypair, $serverPublicKey);744 function sodium_crypto_kx_client_session_keys($client_key_pair, $server_key) 745 { 746 return ParagonIE_Sodium_Compat::crypto_kx_client_session_keys($client_key_pair, $server_key); 703 747 } 704 748 } 705 749 if (!is_callable('sodium_crypto_kx_server_session_keys')) { 706 750 /** 707 * @param string $ keypair708 * @param string $client PublicKey751 * @param string $server_key_pair 752 * @param string $client_key 709 753 * @return array{0: string, 1: string} 710 754 * @throws SodiumException 711 755 */ 712 function sodium_crypto_kx_server_session_keys($ keypair, $clientPublicKey)713 { 714 return ParagonIE_Sodium_Compat::crypto_kx_server_session_keys($ keypair, $clientPublicKey);756 function sodium_crypto_kx_server_session_keys($server_key_pair, $client_key) 757 { 758 return ParagonIE_Sodium_Compat::crypto_kx_server_session_keys($server_key_pair, $client_key); 715 759 } 716 760 } 717 761 if (!is_callable('sodium_crypto_kx_secretkey')) { 718 762 /** 719 * @param string $key pair720 * @return string 721 * @throws Exception 722 */ 723 function sodium_crypto_kx_secretkey($key pair)724 { 725 return ParagonIE_Sodium_Compat::crypto_kx_secretkey($key pair);763 * @param string $key_pair 764 * @return string 765 * @throws Exception 766 */ 767 function sodium_crypto_kx_secretkey($key_pair) 768 { 769 return ParagonIE_Sodium_Compat::crypto_kx_secretkey($key_pair); 726 770 } 727 771 } 728 772 if (!is_callable('sodium_crypto_kx_publickey')) { 729 773 /** 730 * @param string $key pair731 * @return string 732 * @throws Exception 733 */ 734 function sodium_crypto_kx_publickey($key pair)735 { 736 return ParagonIE_Sodium_Compat::crypto_kx_publickey($key pair);774 * @param string $key_pair 775 * @return string 776 * @throws Exception 777 */ 778 function sodium_crypto_kx_publickey($key_pair) 779 { 780 return ParagonIE_Sodium_Compat::crypto_kx_publickey($key_pair); 737 781 } 738 782 } … … 740 784 /** 741 785 * @see ParagonIE_Sodium_Compat::crypto_pwhash() 742 * @param int $ outlen786 * @param int $length 743 787 * @param string $passwd 744 788 * @param string $salt … … 750 794 * @throws TypeError 751 795 */ 752 function sodium_crypto_pwhash($ outlen, $passwd, $salt, $opslimit, $memlimit, $algo = null)753 { 754 return ParagonIE_Sodium_Compat::crypto_pwhash($ outlen, $passwd, $salt, $opslimit, $memlimit, $algo);796 function sodium_crypto_pwhash($length, $passwd, $salt, $opslimit, $memlimit, $algo = null) 797 { 798 return ParagonIE_Sodium_Compat::crypto_pwhash($length, $passwd, $salt, $opslimit, $memlimit, $algo); 755 799 } 756 800 } … … 802 846 /** 803 847 * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256() 804 * @param int $ outlen848 * @param int $length 805 849 * @param string $passwd 806 850 * @param string $salt … … 811 855 * @throws TypeError 812 856 */ 813 function sodium_crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit) 814 { 815 return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit); 857 function sodium_crypto_pwhash_scryptsalsa208sha256($length, $passwd, $salt, $opslimit, $memlimit) 858 { 859 return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256( 860 $length, 861 $passwd, 862 $salt, 863 $opslimit, 864 $memlimit 865 ); 816 866 } 817 867 } … … 901 951 /** 902 952 * @see ParagonIE_Sodium_Compat::crypto_secretbox_open() 903 * @param string $ message953 * @param string $ciphertext 904 954 * @param string $nonce 905 955 * @param string $key 906 956 * @return string|bool 907 957 */ 908 function sodium_crypto_secretbox_open($ message, $nonce, $key)958 function sodium_crypto_secretbox_open($ciphertext, $nonce, $key) 909 959 { 910 960 try { 911 return ParagonIE_Sodium_Compat::crypto_secretbox_open($ message, $nonce, $key);961 return ParagonIE_Sodium_Compat::crypto_secretbox_open($ciphertext, $nonce, $key); 912 962 } catch (Error $ex) { 913 963 return false; … … 931 981 /** 932 982 * @param string $state 933 * @param string $m sg934 * @param string $a ad983 * @param string $message 984 * @param string $additional_data 935 985 * @param int $tag 936 986 * @return string 937 987 * @throws SodiumException 938 988 */ 939 function sodium_crypto_secretstream_xchacha20poly1305_push(&$state, $msg, $aad = '', $tag = 0) 940 { 941 return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_push($state, $msg, $aad, $tag); 989 function sodium_crypto_secretstream_xchacha20poly1305_push( 990 &$state, 991 $message, 992 $additional_data = '', 993 $tag = 0 994 ) { 995 return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_push( 996 $state, 997 $message, 998 $additional_data, 999 $tag 1000 ); 942 1001 } 943 1002 } … … 957 1016 /** 958 1017 * @param string $state 959 * @param string $cipher 960 * @param string $a ad1018 * @param string $ciphertext 1019 * @param string $additional_data 961 1020 * @return bool|array{0: string, 1: int} 962 1021 * @throws SodiumException 963 1022 */ 964 function sodium_crypto_secretstream_xchacha20poly1305_pull(&$state, $cipher, $aad = '') 965 { 966 return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_pull($state, $cipher, $aad); 1023 function sodium_crypto_secretstream_xchacha20poly1305_pull(&$state, $ciphertext, $additional_data = '') 1024 { 1025 return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_pull( 1026 $state, 1027 $ciphertext, 1028 $additional_data 1029 ); 967 1030 } 968 1031 } … … 1017 1080 * @see ParagonIE_Sodium_Compat::crypto_sign() 1018 1081 * @param string $message 1019 * @param string $s k1020 * @return string 1021 * @throws SodiumException 1022 * @throws TypeError 1023 */ 1024 function sodium_crypto_sign($message, $s k)1025 { 1026 return ParagonIE_Sodium_Compat::crypto_sign($message, $s k);1082 * @param string $secret_key 1083 * @return string 1084 * @throws SodiumException 1085 * @throws TypeError 1086 */ 1087 function sodium_crypto_sign($message, $secret_key) 1088 { 1089 return ParagonIE_Sodium_Compat::crypto_sign($message, $secret_key); 1027 1090 } 1028 1091 } … … 1031 1094 * @see ParagonIE_Sodium_Compat::crypto_sign_detached() 1032 1095 * @param string $message 1033 * @param string $s k1034 * @return string 1035 * @throws SodiumException 1036 * @throws TypeError 1037 */ 1038 function sodium_crypto_sign_detached($message, $s k)1039 { 1040 return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $s k);1096 * @param string $secret_key 1097 * @return string 1098 * @throws SodiumException 1099 * @throws TypeError 1100 */ 1101 function sodium_crypto_sign_detached($message, $secret_key) 1102 { 1103 return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $secret_key); 1041 1104 } 1042 1105 } … … 1044 1107 /** 1045 1108 * @see ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey() 1046 * @param string $s k1047 * @param string $p k1048 * @return string 1049 * @throws SodiumException 1050 * @throws TypeError 1051 */ 1052 function sodium_crypto_sign_keypair_from_secretkey_and_publickey($s k, $pk)1053 { 1054 return ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey($s k, $pk);1109 * @param string $secret_key 1110 * @param string $public_key 1111 * @return string 1112 * @throws SodiumException 1113 * @throws TypeError 1114 */ 1115 function sodium_crypto_sign_keypair_from_secretkey_and_publickey($secret_key, $public_key) 1116 { 1117 return ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey($secret_key, $public_key); 1055 1118 } 1056 1119 } … … 1071 1134 * @see ParagonIE_Sodium_Compat::crypto_sign_open() 1072 1135 * @param string $signedMessage 1073 * @param string $p k1136 * @param string $public_key 1074 1137 * @return string|bool 1075 1138 */ 1076 function sodium_crypto_sign_open($signedMessage, $p k)1139 function sodium_crypto_sign_open($signedMessage, $public_key) 1077 1140 { 1078 1141 try { 1079 return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $p k);1142 return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $public_key); 1080 1143 } catch (Error $ex) { 1081 1144 return false; … … 1088 1151 /** 1089 1152 * @see ParagonIE_Sodium_Compat::crypto_sign_publickey() 1090 * @param string $key pair1091 * @return string 1092 * @throws SodiumException 1093 * @throws TypeError 1094 */ 1095 function sodium_crypto_sign_publickey($key pair)1096 { 1097 return ParagonIE_Sodium_Compat::crypto_sign_publickey($key pair);1153 * @param string $key_pair 1154 * @return string 1155 * @throws SodiumException 1156 * @throws TypeError 1157 */ 1158 function sodium_crypto_sign_publickey($key_pair) 1159 { 1160 return ParagonIE_Sodium_Compat::crypto_sign_publickey($key_pair); 1098 1161 } 1099 1162 } … … 1101 1164 /** 1102 1165 * @see ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey() 1103 * @param string $s k1104 * @return string 1105 * @throws SodiumException 1106 * @throws TypeError 1107 */ 1108 function sodium_crypto_sign_publickey_from_secretkey($s k)1109 { 1110 return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($s k);1166 * @param string $secret_key 1167 * @return string 1168 * @throws SodiumException 1169 * @throws TypeError 1170 */ 1171 function sodium_crypto_sign_publickey_from_secretkey($secret_key) 1172 { 1173 return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($secret_key); 1111 1174 } 1112 1175 } … … 1114 1177 /** 1115 1178 * @see ParagonIE_Sodium_Compat::crypto_sign_secretkey() 1116 * @param string $key pair1117 * @return string 1118 * @throws SodiumException 1119 * @throws TypeError 1120 */ 1121 function sodium_crypto_sign_secretkey($key pair)1122 { 1123 return ParagonIE_Sodium_Compat::crypto_sign_secretkey($key pair);1179 * @param string $key_pair 1180 * @return string 1181 * @throws SodiumException 1182 * @throws TypeError 1183 */ 1184 function sodium_crypto_sign_secretkey($key_pair) 1185 { 1186 return ParagonIE_Sodium_Compat::crypto_sign_secretkey($key_pair); 1124 1187 } 1125 1188 } … … 1142 1205 * @param string $signature 1143 1206 * @param string $message 1144 * @param string $p k1207 * @param string $public_key 1145 1208 * @return bool 1146 1209 * @throws SodiumException 1147 1210 * @throws TypeError 1148 1211 */ 1149 function sodium_crypto_sign_verify_detached($signature, $message, $p k)1150 { 1151 return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $p k);1212 function sodium_crypto_sign_verify_detached($signature, $message, $public_key) 1213 { 1214 return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $public_key); 1152 1215 } 1153 1216 } … … 1155 1218 /** 1156 1219 * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519() 1157 * @param string $p k1158 * @return string 1159 * @throws SodiumException 1160 * @throws TypeError 1161 */ 1162 function sodium_crypto_sign_ed25519_pk_to_curve25519($p k)1163 { 1164 return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($p k);1220 * @param string $public_key 1221 * @return string 1222 * @throws SodiumException 1223 * @throws TypeError 1224 */ 1225 function sodium_crypto_sign_ed25519_pk_to_curve25519($public_key) 1226 { 1227 return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($public_key); 1165 1228 } 1166 1229 } … … 1168 1231 /** 1169 1232 * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519() 1170 * @param string $s k1171 * @return string 1172 * @throws SodiumException 1173 * @throws TypeError 1174 */ 1175 function sodium_crypto_sign_ed25519_sk_to_curve25519($s k)1176 { 1177 return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($s k);1233 * @param string $secret_key 1234 * @return string 1235 * @throws SodiumException 1236 * @throws TypeError 1237 */ 1238 function sodium_crypto_sign_ed25519_sk_to_curve25519($secret_key) 1239 { 1240 return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($secret_key); 1178 1241 } 1179 1242 } … … 1181 1244 /** 1182 1245 * @see ParagonIE_Sodium_Compat::crypto_stream() 1183 * @param int $len 1246 * @param int $length 1184 1247 * @param string $nonce 1185 1248 * @param string $key … … 1188 1251 * @throws TypeError 1189 1252 */ 1190 function sodium_crypto_stream($len , $nonce, $key)1191 { 1192 return ParagonIE_Sodium_Compat::crypto_stream($len , $nonce, $key);1253 function sodium_crypto_stream($length, $nonce, $key) 1254 { 1255 return ParagonIE_Sodium_Compat::crypto_stream($length, $nonce, $key); 1193 1256 } 1194 1257 } … … 1224 1287 * @see ParagonIE_Sodium_Compat::hex2bin() 1225 1288 * @param string $string 1226 * @return string 1227 * @throws SodiumException 1228 * @throws TypeError 1229 */ 1230 function sodium_hex2bin($string) 1231 { 1232 return ParagonIE_Sodium_Compat::hex2bin($string); 1289 * @param string $ignore 1290 * @return string 1291 * @throws SodiumException 1292 * @throws TypeError 1293 */ 1294 function sodium_hex2bin($string, $ignore = '') 1295 { 1296 return ParagonIE_Sodium_Compat::hex2bin($string, $ignore); 1233 1297 } 1234 1298 } … … 1279 1343 /** 1280 1344 * @see ParagonIE_Sodium_Compat::memcmp() 1281 * @param string $ a1282 * @param string $ b1345 * @param string $string1 1346 * @param string $string2 1283 1347 * @return int 1284 1348 * @throws SodiumException 1285 1349 * @throws TypeError 1286 1350 */ 1287 function sodium_memcmp($ a, $b)1288 { 1289 return ParagonIE_Sodium_Compat::memcmp($ a, $b);1351 function sodium_memcmp($string1, $string2) 1352 { 1353 return ParagonIE_Sodium_Compat::memcmp($string1, $string2); 1290 1354 } 1291 1355 } … … 1293 1357 /** 1294 1358 * @see ParagonIE_Sodium_Compat::memzero() 1295 * @param string $str 1359 * @param string $string 1296 1360 * @return void 1297 1361 * @throws SodiumException 1298 1362 * @throws TypeError 1299 1363 */ 1300 function sodium_memzero(&$str )1301 { 1302 ParagonIE_Sodium_Compat::memzero($str );1364 function sodium_memzero(&$string) 1365 { 1366 ParagonIE_Sodium_Compat::memzero($string); 1303 1367 } 1304 1368 } … … 1307 1371 * @see ParagonIE_Sodium_Compat::pad() 1308 1372 * @param string $unpadded 1309 * @param int $block Size1310 * @return int1311 * @throws SodiumException 1312 * @throws TypeError 1313 */ 1314 function sodium_pad($unpadded, $block Size)1315 { 1316 return ParagonIE_Sodium_Compat::pad($unpadded, $block Size, true);1373 * @param int $block_size 1374 * @return string 1375 * @throws SodiumException 1376 * @throws TypeError 1377 */ 1378 function sodium_pad($unpadded, $block_size) 1379 { 1380 return ParagonIE_Sodium_Compat::pad($unpadded, $block_size, true); 1317 1381 } 1318 1382 } … … 1321 1385 * @see ParagonIE_Sodium_Compat::pad() 1322 1386 * @param string $padded 1323 * @param int $block Size1324 * @return int1325 * @throws SodiumException 1326 * @throws TypeError 1327 */ 1328 function sodium_unpad($padded, $block Size)1329 { 1330 return ParagonIE_Sodium_Compat::unpad($padded, $block Size, true);1387 * @param int $block_size 1388 * @return string 1389 * @throws SodiumException 1390 * @throws TypeError 1391 */ 1392 function sodium_unpad($padded, $block_size) 1393 { 1394 return ParagonIE_Sodium_Compat::unpad($padded, $block_size, true); 1331 1395 } 1332 1396 } -
trunk/src/wp-includes/sodium_compat/lib/ristretto255.php
r51002 r54310 57 57 * @see ParagonIE_Sodium_Compat::ristretto255_from_hash() 58 58 * 59 * @param string $ r60 * @return string 61 * @throws SodiumException 62 */ 63 function sodium_crypto_core_ristretto255_from_hash($ r)64 { 65 return ParagonIE_Sodium_Compat::ristretto255_from_hash($ r, true);59 * @param string $s 60 * @return string 61 * @throws SodiumException 62 */ 63 function sodium_crypto_core_ristretto255_from_hash($s) 64 { 65 return ParagonIE_Sodium_Compat::ristretto255_from_hash($s, true); 66 66 } 67 67 } … … 70 70 * @see ParagonIE_Sodium_Compat::ristretto255_is_valid_point() 71 71 * 72 * @param string $ p72 * @param string $s 73 73 * @return bool 74 74 * @throws SodiumException 75 75 */ 76 function sodium_crypto_core_ristretto255_is_valid_point($ p)77 { 78 return ParagonIE_Sodium_Compat::ristretto255_is_valid_point($ p, true);76 function sodium_crypto_core_ristretto255_is_valid_point($s) 77 { 78 return ParagonIE_Sodium_Compat::ristretto255_is_valid_point($s, true); 79 79 } 80 80 } … … 95 95 * @see ParagonIE_Sodium_Compat::ristretto255_scalar_add() 96 96 * 97 * @param string $ p98 * @param string $ q99 * @return string 100 * @throws SodiumException 101 */ 102 function sodium_crypto_core_ristretto255_scalar_add($ p, $q)103 { 104 return ParagonIE_Sodium_Compat::ristretto255_scalar_add($ p, $q, true);97 * @param string $x 98 * @param string $y 99 * @return string 100 * @throws SodiumException 101 */ 102 function sodium_crypto_core_ristretto255_scalar_add($x, $y) 103 { 104 return ParagonIE_Sodium_Compat::ristretto255_scalar_add($x, $y, true); 105 105 } 106 106 } … … 109 109 * @see ParagonIE_Sodium_Compat::ristretto255_scalar_complement() 110 110 * 111 * @param string $ p112 * @return string 113 * @throws SodiumException 114 */ 115 function sodium_crypto_core_ristretto255_scalar_complement($ p)116 { 117 return ParagonIE_Sodium_Compat::ristretto255_scalar_complement($ p, true);111 * @param string $s 112 * @return string 113 * @throws SodiumException 114 */ 115 function sodium_crypto_core_ristretto255_scalar_complement($s) 116 { 117 return ParagonIE_Sodium_Compat::ristretto255_scalar_complement($s, true); 118 118 } 119 119 } … … 135 135 * @see ParagonIE_Sodium_Compat::ristretto255_scalar_mul() 136 136 * 137 * @param string $ p138 * @param string $ q139 * @return string 140 * @throws SodiumException 141 */ 142 function sodium_crypto_core_ristretto255_scalar_mul($ p, $q)143 { 144 return ParagonIE_Sodium_Compat::ristretto255_scalar_mul($ p, $q, true);137 * @param string $x 138 * @param string $y 139 * @return string 140 * @throws SodiumException 141 */ 142 function sodium_crypto_core_ristretto255_scalar_mul($x, $y) 143 { 144 return ParagonIE_Sodium_Compat::ristretto255_scalar_mul($x, $y, true); 145 145 } 146 146 } … … 149 149 * @see ParagonIE_Sodium_Compat::ristretto255_scalar_negate() 150 150 * 151 * @param string $ p152 * @return string 153 * @throws SodiumException 154 */ 155 function sodium_crypto_core_ristretto255_scalar_negate($ p)156 { 157 return ParagonIE_Sodium_Compat::ristretto255_scalar_negate($ p, true);151 * @param string $s 152 * @return string 153 * @throws SodiumException 154 */ 155 function sodium_crypto_core_ristretto255_scalar_negate($s) 156 { 157 return ParagonIE_Sodium_Compat::ristretto255_scalar_negate($s, true); 158 158 } 159 159 } … … 174 174 * @see ParagonIE_Sodium_Compat::ristretto255_scalar_reduce() 175 175 * 176 * @param string $ p177 * @return string 178 * @throws SodiumException 179 */ 180 function sodium_crypto_core_ristretto255_scalar_reduce($ p)181 { 182 return ParagonIE_Sodium_Compat::ristretto255_scalar_reduce($ p, true);176 * @param string $s 177 * @return string 178 * @throws SodiumException 179 */ 180 function sodium_crypto_core_ristretto255_scalar_reduce($s) 181 { 182 return ParagonIE_Sodium_Compat::ristretto255_scalar_reduce($s, true); 183 183 } 184 184 } … … 187 187 * @see ParagonIE_Sodium_Compat::ristretto255_scalar_sub() 188 188 * 189 * @param string $ p190 * @param string $ q191 * @return string 192 * @throws SodiumException 193 */ 194 function sodium_crypto_core_ristretto255_scalar_sub($ p, $q)195 { 196 return ParagonIE_Sodium_Compat::ristretto255_scalar_sub($ p, $q, true);189 * @param string $x 190 * @param string $y 191 * @return string 192 * @throws SodiumException 193 */ 194 function sodium_crypto_core_ristretto255_scalar_sub($x, $y) 195 { 196 return ParagonIE_Sodium_Compat::ristretto255_scalar_sub($x, $y, true); 197 197 } 198 198 } -
trunk/src/wp-includes/sodium_compat/lib/sodium_compat.php
r51002 r54310 779 779 * @throws \SodiumException 780 780 * @throws \TypeError 781 * 782 * @psalm-suppress MissingParamType 783 * @psalm-suppress MissingReturnType 784 * @psalm-suppress ReferenceConstraintViolation 781 785 */ 782 786 function memzero(&$str) -
trunk/src/wp-includes/sodium_compat/src/Compat.php
r54150 r54310 3220 3220 * 3221 3221 * @param string $string Hexadecimal string 3222 * @param string $ignore List of characters to ignore; useful for whitespace 3222 3223 * @return string Raw binary string 3223 3224 * @throws SodiumException … … 3226 3227 * @psalm-suppress MixedArgument 3227 3228 */ 3228 public static function hex2bin($string )3229 public static function hex2bin($string, $ignore = '') 3229 3230 { 3230 3231 /* Type checks: */ 3231 3232 ParagonIE_Sodium_Core_Util::declareScalarType($string, 'string', 1); 3233 ParagonIE_Sodium_Core_Util::declareScalarType($ignore, 'string', 2); 3232 3234 3233 3235 if (self::useNewSodiumAPI()) { 3234 3236 if (is_callable('sodium_hex2bin')) { 3235 return (string) sodium_hex2bin($string );3237 return (string) sodium_hex2bin($string, $ignore); 3236 3238 } 3237 3239 } 3238 3240 if (self::use_fallback('hex2bin')) { 3239 return (string) call_user_func('\\Sodium\\hex2bin', $string );3240 } 3241 return ParagonIE_Sodium_Core_Util::hex2bin($string );3241 return (string) call_user_func('\\Sodium\\hex2bin', $string, $ignore); 3242 } 3243 return ParagonIE_Sodium_Core_Util::hex2bin($string, $ignore); 3242 3244 } 3243 3245 -
trunk/src/wp-includes/sodium_compat/src/Core/Util.php
r52988 r54310 310 310 * 311 311 * @param string $hexString 312 * @param string $ignore 312 313 * @param bool $strictPadding 313 314 * @return string (raw binary) … … 315 316 * @throws TypeError 316 317 */ 317 public static function hex2bin($hexString, $ strictPadding = false)318 public static function hex2bin($hexString, $ignore = '', $strictPadding = false) 318 319 { 319 320 /* Type checks: */ … … 321 322 throw new TypeError('Argument 1 must be a string, ' . gettype($hexString) . ' given.'); 322 323 } 323 324 /** @var int $hex_pos */ 324 if (!is_string($ignore)) { 325 throw new TypeError('Argument 2 must be a string, ' . gettype($hexString) . ' given.'); 326 } 327 325 328 $hex_pos = 0; 326 /** @var string $bin */327 329 $bin = ''; 328 /** @var int $c_acc */329 330 $c_acc = 0; 330 /** @var int $hex_len */331 331 $hex_len = self::strlen($hexString); 332 /** @var int $state */333 332 $state = 0; 334 333 if (($hex_len & 1) !== 0) { … … 348 347 /** @var int $c */ 349 348 $c = $chunk[$hex_pos]; 350 /** @var int $c_num */351 349 $c_num = $c ^ 48; 352 /** @var int $c_num0 */353 350 $c_num0 = ($c_num - 10) >> 8; 354 /** @var int $c_alpha */355 351 $c_alpha = ($c & ~32) - 55; 356 /** @var int $c_alpha0 */357 352 $c_alpha0 = (($c_alpha - 10) ^ ($c_alpha - 16)) >> 8; 358 353 if (($c_num0 | $c_alpha0) === 0) { 354 if ($ignore && $state === 0 && strpos($ignore, self::intToChr($c)) !== false) { 355 continue; 356 } 359 357 throw new RangeException( 360 358 'hex2bin() only expects hexadecimal characters' 361 359 ); 362 360 } 363 /** @var int $c_val */364 361 $c_val = ($c_num0 & $c_num) | ($c_alpha & $c_alpha0); 365 362 if ($state === 0) { … … 383 380 public static function intArrayToString(array $ints) 384 381 { 385 /** @var array<int, int> $args */386 382 $args = $ints; 387 383 foreach ($args as $i => $v) {
Note: See TracChangeset
for help on using the changeset viewer.