diff --git a/deps/ncrypto/ncrypto.cc b/deps/ncrypto/ncrypto.cc index 290c3a816f..c6ef072e05 100644 --- a/deps/ncrypto/ncrypto.cc +++ b/deps/ncrypto/ncrypto.cc @@ -2927,6 +2927,7 @@ const Cipher Cipher::AES_256_GCM = Cipher::FromNid(NID_aes_256_gcm); const Cipher Cipher::AES_128_KW = Cipher::FromNid(NID_id_aes128_wrap); const Cipher Cipher::AES_192_KW = Cipher::FromNid(NID_id_aes192_wrap); const Cipher Cipher::AES_256_KW = Cipher::FromNid(NID_id_aes256_wrap); +const Cipher Cipher::CHACHA20_POLY1305 = Cipher::FromNid(NID_chacha20_poly1305); bool Cipher::isGcmMode() const { if (!cipher_) return false; diff --git a/deps/ncrypto/ncrypto.h b/deps/ncrypto/ncrypto.h index 3278d5612e..42f9cf6aa2 100644 --- a/deps/ncrypto/ncrypto.h +++ b/deps/ncrypto/ncrypto.h @@ -373,6 +373,7 @@ class Cipher final { static const Cipher AES_128_KW; static const Cipher AES_192_KW; static const Cipher AES_256_KW; + static const Cipher CHACHA20_POLY1305; struct CipherParams { int padding; diff --git a/doc/api/webcrypto.md b/doc/api/webcrypto.md index 28d91883e1..fb820813a9 100644 --- a/doc/api/webcrypto.md +++ b/doc/api/webcrypto.md @@ -2,6 +2,9 @@ -* `algorithm` {RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams} +* `algorithm` {RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams} * `key` {CryptoKey} * `data` {ArrayBuffer|TypedArray|DataView|Buffer} * Returns: {Promise} Fulfills with an {ArrayBuffer} upon success. @@ -725,6 +735,7 @@ The algorithms currently supported include: * `'AES-CBC'` * `'AES-CTR'` * `'AES-GCM'` +* `'ChaCha20-Poly1305'`[^modern-algos] * `'RSA-OAEP'` ### `subtle.deriveBits(algorithm, baseKey[, length])` @@ -854,9 +865,13 @@ whose value is one of the above. -* `algorithm` {RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams} +* `algorithm` {RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams} * `key` {CryptoKey} * `data` {ArrayBuffer|TypedArray|DataView|Buffer} * Returns: {Promise} Fulfills with an {ArrayBuffer} upon success. @@ -871,6 +886,7 @@ The algorithms currently supported include: * `'AES-CBC'` * `'AES-CTR'` * `'AES-GCM'` +* `'ChaCha20-Poly1305'`[^modern-algos] * `'RSA-OAEP'` ### `subtle.exportKey(format, key)` @@ -878,6 +894,9 @@ The algorithms currently supported include: * `format` {string} Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`[^modern-algos], @@ -1107,7 +1139,7 @@ added: v15.0.0 -* `unwrapAlgo` {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams} +* `unwrapAlgo` {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams} * `unwrappedKeyAlgo` {string|Algorithm|RsaHashedImportParams|EcKeyImportParams|HmacImportParams} @@ -1131,6 +1163,7 @@ The wrapping algorithms currently supported include: * `'AES-CTR'` * `'AES-GCM'` * `'AES-KW'` +* `'ChaCha20-Poly1305'`[^modern-algos] * `'RSA-OAEP'` The unwrapped key algorithms supported include: @@ -1139,6 +1172,7 @@ The unwrapped key algorithms supported include: * `'AES-CTR'` * `'AES-GCM'` * `'AES-KW'` +* `'ChaCha20-Poly1305'`[^modern-algos] * `'ECDH'` * `'ECDSA'` * `'Ed25519'` @@ -1199,6 +1233,10 @@ The algorithms currently supported include: @@ -1207,7 +1245,7 @@ added: v15.0.0 `'raw-public'`[^modern-algos], or `'raw-seed'`[^modern-algos]. * `key` {CryptoKey} * `wrappingKey` {CryptoKey} -* `wrapAlgo` {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams} +* `wrapAlgo` {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams} * Returns: {Promise} Fulfills with an {ArrayBuffer} upon success. @@ -1228,6 +1266,7 @@ The wrapping algorithms currently supported include: * `'AES-CTR'` * `'AES-GCM'` * `'AES-KW'` +* `'ChaCha20-Poly1305'`[^modern-algos] * `'RSA-OAEP'` ## Algorithm parameters @@ -1250,6 +1289,50 @@ added: v15.0.0 * Type: {string} +### Class: `AeadParams` + + + +#### `aeadParams.additionalData` + + + +* Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined} + +Extra input that is not encrypted but is included in the authentication +of the data. The use of `additionalData` is optional. + +#### `aeadParams.iv` + + + +* Type: {ArrayBuffer|TypedArray|DataView|Buffer} + +The initialization vector must be unique for every encryption operation using a +given key. + +#### `aeadParams.name` + + + +* Type: {string} Must be `'AES-GCM'` or `'ChaCha20-Poly1305'`. + +#### `aeadParams.tagLength` + + + +* Type: {number} The size in bits of the generated authentication tag. + ### Class: `AesDerivedKeyParams` - -#### `aesGcmParams.additionalData` - - - -* Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined} - -With the AES-GCM method, the `additionalData` is extra input that is not -encrypted but is included in the authentication of the data. The use of -`additionalData` is optional. - -#### `aesGcmParams.iv` - - - -* Type: {ArrayBuffer|TypedArray|DataView|Buffer} - -The initialization vector must be unique for every encryption operation using a -given key. - -Ideally, this is a deterministic 12-byte value that is computed in such a way -that it is guaranteed to be unique across all invocations that use the same key. -Alternatively, the initialization vector may consist of at least 12 -cryptographically random bytes. For more information on constructing -initialization vectors for AES-GCM, refer to Section 8 of [NIST SP 800-38D][]. - -#### `aesGcmParams.name` - - - -* Type: {string} Must be `'AES-GCM'`. - -#### `aesGcmParams.tagLength` - - - -* Type: {number} The size in bits of the generated authentication tag. - This values must be one of `32`, `64`, `96`, `104`, `112`, `120`, or - `128`. **Default:** `128`. - ### Class: `AesKeyAlgorithm`