paragonie / sodium_compat

Pure PHP polyfill for ext/sodium

Home Page:https://paragonie.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call to undefined function sodium_crypto_secretbox_keygen()

ilnurshax opened this issue · comments

Hello to all!

Call to undefined function sodium_crypto_secretbox_keygen()

I didn't find this function when search this text on Sodium package. But another functions from _secretbox exists in Sodium package:

  • sodium_crypto_secretbox
  • sodium_crypto_secretbox_open

How to generate secret key for sodium_crypto_secretbox if sodium_crypto_secretbox_keygen() function does not exist?
 

P.S. I found that this code could be the solution, but is this solution safe enough?
$secret_key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES);
@paragonie-scott

commented

Yes, random_bytes() is exactly what you want.

Forgive the oversight. I'll get these in 1.4.0, due to be released on or before November 30 (PHP 7.2 release date).

Thanks a lot!

commented

The unit tests are still running, but it should be fixed in 8843e0d which will be included in v1.4.0 once it's released. If any tests fail, I'll fix it tonight.