@@ -534,13 +534,8 @@ const expectedWarnings = common.hasFipsCrypto ?
534534 [ 'Use Cipheriv for counter mode of aes-256-ccm' , common . noWarnCode ]
535535 ] ;
536536
537- const expectedDeprecationWarnings = [ 0 , 1 , 2 , 6 , 9 , 10 , 11 , 17 ]
538- . map ( ( i ) => [ `Permitting authentication tag lengths of ${ i } bytes is ` +
539- 'deprecated. Valid GCM tag lengths are 4, 8, 12, 13, 14, 15, 16.' ,
540- 'DEP0090' ] ) ;
541-
542- expectedDeprecationWarnings . push ( [ 'crypto.DEFAULT_ENCODING is deprecated.' ,
543- 'DEP0091' ] ) ;
537+ const expectedDeprecationWarnings = [ 'crypto.DEFAULT_ENCODING is deprecated.' ,
538+ 'DEP0091' ] ;
544539
545540common . expectWarning ( {
546541 Warning : expectedWarnings ,
@@ -719,13 +714,18 @@ for (const test of TEST_CASES) {
719714}
720715
721716// GCM only supports specific authentication tag lengths, invalid lengths should
722- // produce warnings .
717+ // throw .
723718{
724- for ( const length of [ 0 , 1 , 2 , 4 , 6 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 ] ) {
725- const decrypt = crypto . createDecipheriv ( 'aes-256-gcm' ,
726- 'FxLKsqdmv0E9xrQhp0b1ZgI0K7JFZJM8' ,
727- 'qkuZpJWCewa6Szih' ) ;
728- decrypt . setAuthTag ( Buffer . from ( '1' . repeat ( length ) ) ) ;
719+ for ( const length of [ 0 , 1 , 2 , 6 , 9 , 10 , 11 , 17 ] ) {
720+ common . expectsError ( ( ) => {
721+ const decrypt = crypto . createDecipheriv ( 'aes-128-gcm' ,
722+ 'FxLKsqdmv0E9xrQh' ,
723+ 'qkuZpJWCewa6Szih' ) ;
724+ decrypt . setAuthTag ( Buffer . from ( '1' . repeat ( length ) ) ) ;
725+ } , {
726+ type : Error ,
727+ message : `Invalid GCM authentication tag length: ${ length } `
728+ } ) ;
729729 }
730730}
731731
0 commit comments