@@ -78,6 +78,78 @@ function testCipher3(key, iv) {
7878 `encryption/decryption with key ${ key } and iv ${ iv } ` ) ;
7979}
8080
81+ {
82+ const Cipheriv = crypto . Cipheriv ;
83+ const key = '123456789012345678901234' ;
84+ const iv = '12345678' ;
85+
86+ const instance = Cipheriv ( 'des-ede3-cbc' , key , iv ) ;
87+ assert ( instance instanceof Cipheriv , 'Cipheriv is expected to return a new ' +
88+ 'instance when called without `new`' ) ;
89+
90+ common . expectsError (
91+ ( ) => crypto . createCipheriv ( null ) ,
92+ {
93+ code : 'ERR_INVALID_ARG_TYPE' ,
94+ type : TypeError ,
95+ message : 'The "cipher" argument must be of type string'
96+ } ) ;
97+
98+ common . expectsError (
99+ ( ) => crypto . createCipheriv ( 'des-ede3-cbc' , null ) ,
100+ {
101+ code : 'ERR_INVALID_ARG_TYPE' ,
102+ type : TypeError ,
103+ message : 'The "key" argument must be one of type string, Buffer, ' +
104+ 'TypedArray, or DataView'
105+ } ) ;
106+
107+ common . expectsError (
108+ ( ) => crypto . createCipheriv ( 'des-ede3-cbc' , key , null ) ,
109+ {
110+ code : 'ERR_INVALID_ARG_TYPE' ,
111+ type : TypeError ,
112+ message : 'The "iv" argument must be one of type string, Buffer, ' +
113+ 'TypedArray, or DataView'
114+ } ) ;
115+ }
116+
117+ {
118+ const Decipheriv = crypto . Decipheriv ;
119+ const key = '123456789012345678901234' ;
120+ const iv = '12345678' ;
121+
122+ const instance = Decipheriv ( 'des-ede3-cbc' , key , iv ) ;
123+ assert ( instance instanceof Decipheriv , 'Decipheriv expected to return a new' +
124+ ' instance when called without `new`' ) ;
125+
126+ common . expectsError (
127+ ( ) => crypto . createDecipheriv ( null ) ,
128+ {
129+ code : 'ERR_INVALID_ARG_TYPE' ,
130+ type : TypeError ,
131+ message : 'The "cipher" argument must be of type string'
132+ } ) ;
133+
134+ common . expectsError (
135+ ( ) => crypto . createDecipheriv ( 'des-ede3-cbc' , null ) ,
136+ {
137+ code : 'ERR_INVALID_ARG_TYPE' ,
138+ type : TypeError ,
139+ message : 'The "key" argument must be one of type string, Buffer, ' +
140+ 'TypedArray, or DataView'
141+ } ) ;
142+
143+ common . expectsError (
144+ ( ) => crypto . createDecipheriv ( 'des-ede3-cbc' , key , null ) ,
145+ {
146+ code : 'ERR_INVALID_ARG_TYPE' ,
147+ type : TypeError ,
148+ message : 'The "iv" argument must be one of type string, Buffer, ' +
149+ 'TypedArray, or DataView'
150+ } ) ;
151+ }
152+
81153testCipher1 ( '0123456789abcd0123456789' , '12345678' ) ;
82154testCipher1 ( '0123456789abcd0123456789' , Buffer . from ( '12345678' ) ) ;
83155testCipher1 ( Buffer . from ( '0123456789abcd0123456789' ) , '12345678' ) ;
0 commit comments