fix(ext/node): fix Cipheriv#update(string, undefined)
#25571
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the case when the
Cipheriv#update()
method is called with string withoutinputEncoding
specified.When the input is string and
inputEncoding
is not specified, the given string is directly passed toop_node_cipheriv_encrypt
, and the encoding result becomes a wrong value.This PR fixes it by always converting the input string with
Buffer.from
when the input is string. (ref: Node.js does the same https://github.com/nodejs/node/blob/123bb4cb22e739a039392d83d512601982f40fc0/lib/internal/crypto/cipher.js#L165-L166 )closes #25279