we had a few ways versions of looking for support before executing a test. this commit unifies them as well as add the check for all tests that previously lacked them. found by running `./configure --without-ssl && make test`. also, produce tap skip output if the test is skipped. PR-URL: https://github.com/iojs/io.js/pull/1049 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
28 lines
840 B
JavaScript
28 lines
840 B
JavaScript
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
console.log('1..0 # Skipped: missing crypto');
|
|
process.exit();
|
|
}
|
|
var crypto = require('crypto');
|
|
|
|
crypto.DEFAULT_ENCODING = 'buffer';
|
|
|
|
// Testing whether EVP_CipherInit_ex is functioning correctly.
|
|
// Reference: bug#1997
|
|
|
|
(function() {
|
|
var encrypt = crypto.createCipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR', '');
|
|
var hex = encrypt.update('Hello World!', 'ascii', 'hex');
|
|
hex += encrypt.final('hex');
|
|
assert.equal(hex.toUpperCase(), '6D385F424AAB0CFBF0BB86E07FFB7D71');
|
|
}());
|
|
|
|
(function() {
|
|
var decrypt = crypto.createDecipheriv('BF-ECB', 'SomeRandomBlahz0c5GZVnR',
|
|
'');
|
|
var msg = decrypt.update('6D385F424AAB0CFBF0BB86E07FFB7D71', 'hex', 'ascii');
|
|
msg += decrypt.final('ascii');
|
|
assert.equal(msg, 'Hello World!');
|
|
}());
|