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

Hash.prototype._flush does not set state[kFinalized] #38727

Closed
misos1 opened this issue May 18, 2021 · 1 comment
Closed

Hash.prototype._flush does not set state[kFinalized] #38727

misos1 opened this issue May 18, 2021 · 1 comment
Labels
crypto Issues and PRs related to the crypto subsystem.

Comments

@misos1
Copy link

misos1 commented May 18, 2021

  • Version: v16.1.0
  • Platform: Darwin Kernel Version 20.4.0
  • Subsystem: crypto

What steps will reproduce the bug?

https://github.com/nodejs/node/blob/master/lib/internal/crypto/hash.js#L90-L93

When using the stream interface of hash it will call this[kHandle].digest() in Hash.prototype._flush. After that it is possible to call Hash.prototype.digest which will call this[kHandle].digest() again. If that is ok then why is Hash.prototype.digest made in a way that it is not possible to call it more than once?

How often does it reproduce? Is there a required condition?

What is the expected behavior?

What do you see instead?

Additional information

@Lxxyx Lxxyx added the crypto Issues and PRs related to the crypto subsystem. label May 19, 2021
@tniessen
Copy link
Member

tniessen commented Apr 2, 2022

I believe this is to enable piping into a Hash object but still being able to call digest() to obtain the hash value instead of reading from the Hash object using the stream API, whereas calling digest() multiple times is usually unnecessary and might indicate a bug.

Possibly related: #28251

I am going to close this since there has been no activity in quite a while and I don't think this is really a bug, but please do feel free to reopen or comment if you think this warrants more discussion! :)

@tniessen tniessen closed this as completed Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants