Skip to content

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

Closed
wants to merge 2 commits into from
Closed

Conversation

sgolemon
Copy link
Member

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

efree(hash);
/* {{{ proto void HashContext::__construct() */
static PHP_METHOD(HashContext, __construct) {
ZEND_ASSERT(0);
Copy link
Member

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?

Copy link
Member Author

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);
Copy link
Member

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

Copy link
Member Author

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.

realityking and others added 2 commits January 30, 2017 09:19
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)
@nikic
Copy link
Member

nikic commented Feb 3, 2017

Has been merged via b7f59be, closing.

@nikic nikic closed this Feb 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants