-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Refactor HashContext into an Object #2309
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
Conversation
efree(hash); | ||
/* {{{ proto void HashContext::__construct() */ | ||
static PHP_METHOD(HashContext, __construct) { | ||
ZEND_ASSERT(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks unsafe wrt reflection. Maybe throw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
God damned reflection...
} | ||
|
||
if (hash->key) { | ||
memset(hash->key, 0, hash->ops->block_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not your code, but ZEND_SECURE_ZERO would be good here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I'll pile that on as a separate diff to keep the changes separate though.
This allows better type hinting as well as potentially adding methods in a followup diff. Original patch by Rouven Weßling (github.com/realityking) Heavily modified by Sara Golemon (github.com/sgolemon)
Has been merged via b7f59be, closing. |
This PR contains two commits.
The first is a refactor of @realityking's original PR.
The second adds the ability to call hash_final() multiple times (or update after final) and lets the object act a bit more objecty.
I don't necessarily think the second patch is necessary (or best), but I'm including it for review.
See RFC at: https://wiki.php.net/rfc/hash-context.as-resource