@ -1,6 +1,6 @@
'use strict' ;
'use strict' ;
var common = require ( '../common' ) ;
const common = require ( '../common' ) ;
var assert = require ( 'assert' ) ;
const assert = require ( 'assert' ) ;
if ( ! common . hasCrypto ) {
if ( ! common . hasCrypto ) {
common . skip ( 'missing crypto' ) ;
common . skip ( 'missing crypto' ) ;
@ -10,24 +10,25 @@ if (common.hasFipsCrypto) {
common . skip ( 'BF-ECB is not FIPS 140-2 compatible' ) ;
common . skip ( 'BF-ECB is not FIPS 140-2 compatible' ) ;
return ;
return ;
}
}
var crypto = require ( 'crypto' ) ;
const crypto = require ( 'crypto' ) ;
crypto . DEFAULT_ENCODING = 'buffer' ;
crypto . DEFAULT_ENCODING = 'buffer' ;
// Testing whether EVP_CipherInit_ex is functioning correctly.
// Testing whether EVP_CipherInit_ex is functioning correctly.
// Reference: bug#1997
// Reference: bug#1997
( function ( ) {
{
var encrypt = crypto . createCipheriv ( 'BF-ECB' , 'SomeRandomBlahz0c5GZVnR' , '' ) ;
const encrypt =
var hex = encrypt . update ( 'Hello World!' , 'ascii' , 'hex' ) ;
crypto . createCipheriv ( 'BF-ECB' , 'SomeRandomBlahz0c5GZVnR' , '' ) ;
let hex = encrypt . update ( 'Hello World!' , 'ascii' , 'hex' ) ;
hex += encrypt . final ( 'hex' ) ;
hex += encrypt . final ( 'hex' ) ;
assert . strictEqual ( hex . toUpperCase ( ) , '6D385F424AAB0CFBF0BB86E07FFB7D71' ) ;
assert . strictEqual ( hex . toUpperCase ( ) , '6D385F424AAB0CFBF0BB86E07FFB7D71' ) ;
} ( ) ) ;
}
( function ( ) {
{
var decrypt = crypto . createDecipheriv ( 'BF-ECB' , 'SomeRandomBlahz0c5GZVnR' ,
const decrypt =
'' ) ;
crypto . createDecipheriv ( 'BF-ECB' , 'SomeRandomBlahz0c5GZVnR' , '' ) ;
var msg = decrypt . update ( '6D385F424AAB0CFBF0BB86E07FFB7D71' , 'hex' , 'ascii' ) ;
let msg = decrypt . update ( '6D385F424AAB0CFBF0BB86E07FFB7D71' , 'hex' , 'ascii' ) ;
msg += decrypt . final ( 'ascii' ) ;
msg += decrypt . final ( 'ascii' ) ;
assert . strictEqual ( msg , 'Hello World!' ) ;
assert . strictEqual ( msg , 'Hello World!' ) ;
} ( ) ) ;
}