From 38bac4266a4f7adcfdd9832934aa57c564da1179 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 PR-URL: https://github.com/nodejs/node/pull/18644 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- doc/api/crypto.md | 16 +++++++-- lib/internal/crypto/cipher.js | 4 +-- src/node_crypto.cc | 34 ++++++++++++++----- .../test-crypto-cipheriv-decipheriv.js | 12 +++++-- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 3eb4519d9f9503..9adc9082fc2fc2 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1286,6 +1286,11 @@ Adversaries][] for details. ### crypto.createCipheriv(algorithm, key, iv[, options]) - `algorithm` {string} - `key` {string | Buffer | TypedArray | DataView} @@ -1301,7 +1306,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} @@ -1363,7 +1374,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])