From fc34f5cae23989fcc98efd6fe8056090b578e7f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 7 Feb 2018 16:20:21 +0100 Subject: [PATCH] crypto: allow passing null as IV unless required Backport-PR-URL: https://github.com/nodejs/node/pull/19347 PR-URL: https://github.com/nodejs/node/pull/18644 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- doc/api/crypto.md | 16 +++++++- src/node_crypto.cc | 39 ++++++++++++++----- .../test-crypto-cipheriv-decipheriv.js | 8 +++- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 86266156dc6da5..a0df0fe3a0de08 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1219,6 +1219,11 @@ Adversaries][] for details. ### crypto.createCipheriv(algorithm, key, iv[, options]) - `algorithm` {string} - `key` {string | Buffer | TypedArray | DataView} @@ -1234,7 +1239,8 @@ available cipher algorithms. The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector][]. Both arguments must be `'utf8'` encoded strings, -[Buffers][`Buffer`], `TypedArray`, or `DataView`s. +[Buffers][`Buffer`], `TypedArray`, or `DataView`s. If the cipher does not need +an initialization vector, `iv` may be `null`. ### crypto.createCredentials(details) - `algorithm` {string} - `key` {string | Buffer | TypedArray | DataView} @@ -1296,7 +1307,8 @@ available cipher algorithms. The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector][]. Both arguments must be `'utf8'` encoded strings, -[Buffers][`Buffer`], `TypedArray`, or `DataView`s. +[Buffers][`Buffer`], `TypedArray`, or `DataView`s. If the cipher does not need +an initialization vector, `iv` may be `null`. ### crypto.createDiffieHellman(prime[, primeEncoding][, generator][, generatorEncoding])