mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
* Make common.skip() exit. Also add common.printSkipMessage() for partial skips. * Don't make needless things before skip Backport-PR-URL: https://github.com/nodejs/node/pull/14838 PR-URL: https://github.com/nodejs/node/pull/14021 Fixes: https://github.com/nodejs/node/issues/14016 Reviewed-By: Refael Ackermann <refack@gmail.com>
32 lines
889 B
JavaScript
32 lines
889 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
if (common.hasFipsCrypto)
|
|
common.skip('BF-ECB is not FIPS 140-2 compatible');
|
|
|
|
const assert = require('assert');
|
|
const crypto = require('crypto');
|
|
|
|
crypto.DEFAULT_ENCODING = 'buffer';
|
|
|
|
// Testing whether EVP_CipherInit_ex is functioning correctly.
|
|
// Reference: bug#1997
|
|
|
|
{
|
|
const encrypt =
|
|
crypto.createCipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', '');
|
|
let hex = encrypt.update('Hello World!', 'ascii', 'hex');
|
|
hex += encrypt.final('hex');
|
|
assert.strictEqual(hex.toUpperCase(), '6D385F424AAB0CFBF0BB86E07FFB7D71');
|
|
}
|
|
|
|
{
|
|
const decrypt =
|
|
crypto.createDecipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', '');
|
|
let msg = decrypt.update('6D385F424AAB0CFBF0BB86E07FFB7D71', 'hex', 'ascii');
|
|
msg += decrypt.final('ascii');
|
|
assert.strictEqual(msg, 'Hello World!');
|
|
}
|