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

feat: Support sha256 and sha512 oaep algorithms #240

Merged
merged 7 commits into from
Jan 24, 2020

Commits on Jan 15, 2020

  1. test: broken test with UnhandledPromiseRejection

    We want to check that the async onDecrypt function returns a promise
    that rejects.
    
    We were trying to use chai-as-promised's rejectedWith matcher for this,
    but within an `async` function.
    
    It looks like mocha isn't clever enough to wait for the promise to
    reject and run the assertion unless we return the promise from the
    function. It prints a warning about the uncaught promise rejection
    instead.
    
    Once we fix the test to return the promise it fails, because the promise
    is not actually being rejected, so I'm excluding it while I work on a
    fix.
    richardTowers committed Jan 15, 2020
    Configuration menu
    Copy the full SHA
    310a767 View commit details
    Browse the repository at this point in the history
  2. test: test private key must be defined

    This test was excluded because the precondition wasn't hit when calling
    `keyring.onDecrypt` (I think due to another precondition somewhere
    else).
    
    It might be a bit sneaky to call the "private" method (`_unwrapKey`) in
    the tests, but it hits the precondition we're trying to test more
    directly.
    richardTowers committed Jan 15, 2020
    Configuration menu
    Copy the full SHA
    0a3107b View commit details
    Browse the repository at this point in the history
  3. feat: Support sha256 and sha512 oaep algorithms

    This is particularly useful because CloudFront's Field Level Encryption
    uses RSA_OAEP_SHA256_MGF1, which this library doesn't support yet.
    
    Support for oaepHash was added in node 12.9 (nodejs/node#28335), so this
    won't work for older node versions. It's still a backwards compatible
    change because by default `oaepHash` will be undefined, as before.
    
    I've updated the tests to cover use of the new parameter, but they're
    not very strict because they both encrypt and decrypt using the same
    parameter.
    
    This means if node silently ignores the oaepHash parameter (as it will
    in versions < 12.9) the tests will still pass, which isn't great.
    
    On the other hand, I think this project may still be being tested on an
    older version of node, so perhaps the fact the tests won't break is an
    unexpected blessing.
    
    I've also tested this manually against AWS CloudFront's Field Level
    Encryption and it seems to work.
    
    Resolves aws#198
    richardTowers committed Jan 15, 2020
    Configuration menu
    Copy the full SHA
    3065ac0 View commit details
    Browse the repository at this point in the history

Commits on Jan 16, 2020

  1. feat: add support for oaep sha384

    Judging from the types in the test, this is supported by other
    libraries, and it looks like it also works in node.
    richardTowers committed Jan 16, 2020
    Configuration menu
    Copy the full SHA
    01741ce View commit details
    Browse the repository at this point in the history
  2. test: support OAEP hashes in integration tests

    I haven't been able to run these tests myself to confirm they work
    because there's a fair bit of setup I don't know how to do.
    
    I'd expect the tests to fail on versions of node < 12.9, which may be a
    problem for CI.
    richardTowers committed Jan 16, 2020
    Configuration menu
    Copy the full SHA
    77c9934 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d8caf36 View commit details
    Browse the repository at this point in the history

Commits on Jan 21, 2020

  1. fix: oaepHash feature detection

    It is important to be perscriptive in what options will work.
    Node.js versions that do not support `oaepHash` will silently encrypt data.
    This means that the encrypted data key would not have the security properties requested.
    So, `oaep_hash_supported.ts` will attempt to encrypt
    and report the success.
    This will happen only once, on initializaion.
    
    Both the tests, and the integration tests have been updated honor `oaepHashSupported` values
    seebees committed Jan 21, 2020
    Configuration menu
    Copy the full SHA
    8cd6b26 View commit details
    Browse the repository at this point in the history