crypto: sort return value of getCiphers/getHashes
This commit is contained in:
parent
14a6c4efb8
commit
2fbf0612a1
@ -196,7 +196,11 @@ exports.pseudoRandomBytes = pseudoRandomBytes;
|
|||||||
exports.rng = randomBytes;
|
exports.rng = randomBytes;
|
||||||
exports.prng = pseudoRandomBytes;
|
exports.prng = pseudoRandomBytes;
|
||||||
|
|
||||||
exports.getCiphers = getCiphers;
|
|
||||||
|
exports.getCiphers = function() {
|
||||||
|
return getCiphers.call(null, arguments).sort();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
exports.getHashes = function() {
|
exports.getHashes = function() {
|
||||||
var names = getHashes.call(null, arguments);
|
var names = getHashes.call(null, arguments);
|
||||||
@ -210,5 +214,5 @@ exports.getHashes = function() {
|
|||||||
});
|
});
|
||||||
names = Object.getOwnPropertyNames(ctx);
|
names = Object.getOwnPropertyNames(ctx);
|
||||||
|
|
||||||
return names;
|
return names.sort();
|
||||||
};
|
};
|
||||||
|
@ -684,9 +684,18 @@ testPBKDF2('pass\0word', 'sa\0lt', 4096, 16,
|
|||||||
'\x56\xfa\x6a\xa7\x55\x48\x09\x9d\xcc\x37\xd7\xf0\x34' +
|
'\x56\xfa\x6a\xa7\x55\x48\x09\x9d\xcc\x37\xd7\xf0\x34' +
|
||||||
'\x25\xe0\xc3');
|
'\x25\xe0\xc3');
|
||||||
|
|
||||||
|
function assertSorted(list) {
|
||||||
|
for (var i = 0, k = list.length - 1; i < k; ++i) {
|
||||||
|
var a = list[i + 0];
|
||||||
|
var b = list[i + 1];
|
||||||
|
assert(a <= b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Assume that we have at least AES256-SHA.
|
// Assume that we have at least AES256-SHA.
|
||||||
assert.notEqual(0, crypto.getCiphers());
|
assert.notEqual(0, crypto.getCiphers());
|
||||||
assert.notEqual(-1, crypto.getCiphers().indexOf('AES256-SHA'));
|
assert.notEqual(-1, crypto.getCiphers().indexOf('AES256-SHA'));
|
||||||
|
assertSorted(crypto.getCiphers());
|
||||||
|
|
||||||
// Assert that we have sha and sha1 but not SHA and SHA1.
|
// Assert that we have sha and sha1 but not SHA and SHA1.
|
||||||
assert.notEqual(0, crypto.getHashes());
|
assert.notEqual(0, crypto.getHashes());
|
||||||
@ -694,3 +703,4 @@ assert.notEqual(-1, crypto.getHashes().indexOf('sha1'));
|
|||||||
assert.notEqual(-1, crypto.getHashes().indexOf('sha'));
|
assert.notEqual(-1, crypto.getHashes().indexOf('sha'));
|
||||||
assert.equal(-1, crypto.getHashes().indexOf('SHA1'));
|
assert.equal(-1, crypto.getHashes().indexOf('SHA1'));
|
||||||
assert.equal(-1, crypto.getHashes().indexOf('SHA'));
|
assert.equal(-1, crypto.getHashes().indexOf('SHA'));
|
||||||
|
assertSorted(crypto.getHashes());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user