@@ -105,7 +105,7 @@ function testCipher3(key, iv) {
105105 } ) ;
106106
107107 common . expectsError (
108- ( ) => crypto . createCipheriv ( 'des-ede3-cbc' , key , null ) ,
108+ ( ) => crypto . createCipheriv ( 'des-ede3-cbc' , key , 10 ) ,
109109 {
110110 code : 'ERR_INVALID_ARG_TYPE' ,
111111 type : TypeError ,
@@ -141,7 +141,7 @@ function testCipher3(key, iv) {
141141 } ) ;
142142
143143 common . expectsError (
144- ( ) => crypto . createDecipheriv ( 'des-ede3-cbc' , key , null ) ,
144+ ( ) => crypto . createDecipheriv ( 'des-ede3-cbc' , key , 10 ) ,
145145 {
146146 code : 'ERR_INVALID_ARG_TYPE' ,
147147 type : TypeError ,
@@ -161,8 +161,9 @@ if (!common.hasFipsCrypto) {
161161 Buffer . from ( 'A6A6A6A6A6A6A6A6' , 'hex' ) ) ;
162162}
163163
164- // Zero-sized IV should be accepted in ECB mode.
164+ // Zero-sized IV or null should be accepted in ECB mode.
165165crypto . createCipheriv ( 'aes-128-ecb' , Buffer . alloc ( 16 ) , Buffer . alloc ( 0 ) ) ;
166+ crypto . createCipheriv ( 'aes-128-ecb' , Buffer . alloc ( 16 ) , null ) ;
166167
167168const errMessage = / I n v a l i d I V l e n g t h / ;
168169
@@ -186,6 +187,11 @@ for (let n = 0; n < 256; n += 1) {
186187 errMessage ) ;
187188}
188189
190+ // And so should null be.
191+ assert . throws ( ( ) => {
192+ crypto . createCipheriv ( 'aes-128-cbc' , Buffer . alloc ( 16 ) , null ) ;
193+ } , / M i s s i n g I V f o r c i p h e r a e s - 1 2 8 - c b c / ) ;
194+
189195// Zero-sized IV should be rejected in GCM mode.
190196assert . throws (
191197 ( ) => crypto . createCipheriv ( 'aes-128-gcm' , Buffer . alloc ( 16 ) ,
0 commit comments