Skip to content

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

Merged
ondrejmirtes merged 1 commit intophpstan:1.9.xfrom
Slamdunk:patch-2
Nov 8, 2022
Merged

sodium_crypto_generichash* always produce a non-empty-string#1981
ondrejmirtes merged 1 commit intophpstan:1.9.xfrom
Slamdunk:patch-2

Conversation

@Slamdunk
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

2 participants