Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sodium_crypto_generichash* always produce a non-empty-string #1981

Merged
merged 1 commit into from Nov 8, 2022

Conversation

Slamdunk
Copy link
Contributor

@Slamdunk Slamdunk commented Nov 7, 2022

'sodium_crypto_generichash_keygen' => ['string'],
'sodium_crypto_generichash_update' => ['bool', 'state'=>'string', 'string'=>'string'],
'sodium_crypto_generichash' => ['non-empty-string', 'msg'=>'string', 'key='=>'?string', 'length='=>'?int'],
'sodium_crypto_generichash_final' => ['non-empty-string', 'state'=>'non-empty-string', 'length='=>'?int'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaring parameter as non-empty-string gives me a little pause - what happens when the function receives an empty string? Unless it crashes, I wouldn't require it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's indeed what happens when you pass an empty string variable:

PHP Fatal error:  Uncaught SodiumException: incorrect state length

libsodium is very reliable

@ondrejmirtes ondrejmirtes merged commit 74796d1 into phpstan:1.9.x Nov 8, 2022
@ondrejmirtes
Copy link
Member

Thank you.

@Slamdunk Slamdunk deleted the patch-2 branch November 8, 2022 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants