Please sign in to comment.
crypto: add key object API
This commit makes multiple important changes: 1. A new key object API is introduced. The KeyObject class itself is not exposed to users, instead, several new APIs can be used to construct key objects: createSecretKey, createPrivateKey and createPublicKey. The new API also allows to convert between different key formats, and even though the API itself is not compatible to the WebCrypto standard in any way, it makes interoperability much simpler. 2. Key objects can be used instead of the raw key material in all relevant crypto APIs. 3. The handling of asymmetric keys has been unified and greatly improved. Node.js now fully supports both PEM-encoded and DER-encoded public and private keys. 4. Conversions between buffers and strings have been moved to native code for sensitive data such as symmetric keys due to security considerations such as zeroing temporary buffers. 5. For compatibility with older versions of the crypto API, this change allows to specify Buffers and strings as the "passphrase" option when reading or writing an encoded key. Note that this can result in unexpected behavior if the password contains a null byte. PR-URL: #24234 Reviewed-By: Refael Ackermann <firstname.lastname@example.org> Reviewed-By: James M Snell <email@example.com>
- Loading branch information...
Showing with 1,998 additions and 653 deletions.
- +218 −60 doc/api/crypto.md
- +5 −0 doc/api/errors.md
- +8 −0 lib/crypto.js
- +20 −13 lib/internal/crypto/cipher.js
- +5 −4 lib/internal/crypto/hash.js
- +46 −89 lib/internal/crypto/keygen.js
- +337 −0 lib/internal/crypto/keys.js
- +18 −13 lib/internal/crypto/sig.js
- +2 −0 lib/internal/errors.js
- +1 −0 node.gyp
- +4 −0 src/env.h
- +927 −365 src/node_crypto.cc
- +160 −8 src/node_crypto.h
- +23 −0 src/util.h
- +4 −4 test/parallel/test-crypto-cipheriv-decipheriv.js
- +37 −51 test/parallel/test-crypto-hmac.js
- +107 −0 test/parallel/test-crypto-key-objects.js
- +73 −44 test/parallel/test-crypto-keygen.js
- +1 −1 test/parallel/test-crypto-rsa-dsa.js
- +1 −1 test/parallel/test-crypto-sign-verify.js
- +1 −0 tools/doc/type-parser.js
Oops, something went wrong.