From 781d7e77cf6fa857611c5a4f2fa2530d2660f622 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 1/2] crypto: allow passing null as IV unless required --- doc/api/crypto.md | 16 ++++++++++++-- lib/internal/crypto/cipher.js | 4 ++-- src/node_crypto.cc | 22 ++++++++++++++++--- .../test-crypto-cipheriv-decipheriv.js | 12 +++++++--- 4 files changed, 44 insertions(+), 10 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])