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

crypto: optimize sign.update() and verify.update() #31767

Closed
wants to merge 3 commits into from

Commits on Feb 13, 2020

  1. crypto: make update(buf, enc) ignore encoding

    Make the cipher/decipher/hash/hmac update() methods ignore the input
    encoding when the input is a buffer.
    
    This is the documented behavior but some inputs were rejected, notably
    when the specified encoding is 'hex' and the buffer has an odd length
    (because a _string_ with an odd length is never a valid hex string.)
    
    The sign/verify update() methods work okay because they use different
    validation logic.
    
    Fixes: nodejs#31751
    bnoordhuis committed Feb 13, 2020
    Configuration menu
    Copy the full SHA
    badfa84 View commit details
    Browse the repository at this point in the history
  2. crypto: optimize sign.update() and verify.update()

    Use `StringBytes::InlineDecoder` to decode strings inputs in C++ land
    instead of decoding them to buffers in JS land before passing them on
    to the C++ layer. This is what the other update() methods already did.
    bnoordhuis committed Feb 13, 2020
    Configuration menu
    Copy the full SHA
    66f6326 View commit details
    Browse the repository at this point in the history
  3. src: DRY crypto Update() methods

    Factor out the common logic into a template function.
    Removes approximately six instances of copy/pasted code.
    bnoordhuis committed Feb 13, 2020
    Configuration menu
    Copy the full SHA
    f87e658 View commit details
    Browse the repository at this point in the history