stream-xchacha20.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. if (!is_callable('sodium_crypto_stream_xchacha20')) {
  3. /**
  4. * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20()
  5. * @param int $len
  6. * @param string $nonce
  7. * @param string $key
  8. * @return string
  9. * @throws SodiumException
  10. * @throws TypeError
  11. */
  12. function sodium_crypto_stream_xchacha20($len, $nonce, $key)
  13. {
  14. return ParagonIE_Sodium_Compat::crypto_stream_xchacha20($len, $nonce, $key, true);
  15. }
  16. }
  17. if (!is_callable('sodium_crypto_stream_xchacha20_keygen')) {
  18. /**
  19. * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen()
  20. * @return string
  21. * @throws Exception
  22. */
  23. function sodium_crypto_stream_xchacha20_keygen()
  24. {
  25. return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen();
  26. }
  27. }
  28. if (!is_callable('sodium_crypto_stream_xchacha20_xor')) {
  29. /**
  30. * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor()
  31. * @param string $message
  32. * @param string $nonce
  33. * @param string $key
  34. * @return string
  35. * @throws SodiumException
  36. * @throws TypeError
  37. */
  38. function sodium_crypto_stream_xchacha20_xor($message, $nonce, $key)
  39. {
  40. return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor($message, $nonce, $key, true);
  41. }
  42. }
  43. if (!is_callable('sodium_crypto_stream_xchacha20_xor_ic')) {
  44. /**
  45. * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor_ic()
  46. * @param string $message
  47. * @param string $nonce
  48. * @param int $counter
  49. * @param string $key
  50. * @return string
  51. * @throws SodiumException
  52. * @throws TypeError
  53. */
  54. function sodium_crypto_stream_xchacha20_xor_ic($message, $nonce, $counter, $key)
  55. {
  56. return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor_ic($message, $nonce, $counter, $key, true);
  57. }
  58. }