You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Support sha256, sha384, and sha512 for OAEP padding (#240)
Resolves#198
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.
Added oaepHash feature detection.
It is important to be prescriptive 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 initialization.
The integration tests have also been updated
to verify OAEP test vectors based on OAEP hash support in Node.js.
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+
*
4
+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5
+
* this file except in compliance with the License. A copy of the License is
6
+
* located at
7
+
*
8
+
* http://aws.amazon.com/apache2.0/
9
+
*
10
+
* or in the "license" file accompanying this file. This file is distributed on an
11
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
+
* implied. See the License for the specific language governing permissions and
13
+
* limitations under the License.
14
+
*/
15
+
16
+
/* oaepHash support was added in Node.js v12.9.1 (https://github.com/nodejs/node/pull/28335)
17
+
* However, the integration tests need to be able to verify functionality on other versions.
18
+
* There are no constants to sniff,
19
+
* and looking at the version would not catch back-ports.
20
+
* So I simply try the function.
21
+
* However there is a rub as the test might seem backwards.
22
+
* Sending an invalid hash to the version that supports oaepHash will throw an error.
23
+
* But sending an invalid hash to a version that does not support oaepHash will be ignored.
24
+
*/
25
+
26
+
import{
27
+
needs
28
+
}from'@aws-crypto/material-management-node'
29
+
30
+
import{
31
+
constants,
32
+
publicEncrypt
33
+
}from'crypto'
34
+
35
+
exportconstoaepHashSupported=(function(){
36
+
constkey='-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAs7RoNYEPAIws89VV+kra\nrVv/4wbdmUAaAKWgWuxZi5na9GJSmnhCkqyLRm7wPbQY4LCoa5/IMUxkHLsYDPdu\nudY0Qm0GcoxOlvJKHYo4RjF7HyiS34D6dvyO4Gd3aq0mZHoxSGCxW/7hf03wEMzc\niVJXWHXhaI0lD6nrzIEgLrE4L+3V2LeAQjvZsTKd+bYMqeZOL2syiVVIAU8POwAG\nGVBroJoveFm/SUp6lCiN0M2kTeyQA2ax3QTtZSAa8nwrI7U52XOzVmdMicJsy2Pg\nuW98te3MuODdK24yNkHIkYameP/Umf/SJshUJQd5a/TUp3XE+HhOWAumx22tIDlC\nvZS11cuk2fp0WeHUnXaC19N5qWKfvHEKSugzty/z3lGP7ItFhrF2X1qJHeAAsL11\nkjo6Lc48KsE1vKvbnW4VLyB3wdNiVvmUNO29tPXwaR0Q5Gbr3jk3nUzdkEHouHWQ\n41lubOHCCBN3V13mh/MgtNhESHjfmmOnh54ErD9saA1d7CjTf8g2wqmjEqvGSW6N\nq7zhcWR2tp1olflS7oHzul4/I3hnkfL6Kb2xAWWaQKvg3mtsY2OPlzFEP0tR5UcH\nPfp5CeS1Xzg7hN6vRICW6m4l3u2HJFld2akDMm1vnSz8RCbPW7jp7YBxUkWJmypM\ntG7Yv2aGZXGbUtM8o1cZarECAwEAAQ==\n-----END PUBLIC KEY-----'
0 commit comments