summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/crypto.js11
-rw-r--r--test/simple/test-crypto.js2
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/crypto.js b/lib/crypto.js
index 22141ff8a..d1c9eb5d2 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -608,8 +608,13 @@ function filterDuplicates(names) {
// for example, 'sha1' instead of 'SHA1'.
var ctx = {};
names.forEach(function(name) {
- if (/^[0-9A-Z\-]+$/.test(name)) name = name.toLowerCase();
- ctx[name] = true;
+ var key = name;
+ if (/^[0-9A-Z\-]+$/.test(key)) key = key.toLowerCase();
+ if (!ctx.hasOwnProperty(key) || ctx[key] < name)
+ ctx[key] = name;
});
- return Object.getOwnPropertyNames(ctx).sort();
+
+ return Object.getOwnPropertyNames(ctx).map(function(key) {
+ return ctx[key];
+ }).sort();
}
diff --git a/test/simple/test-crypto.js b/test/simple/test-crypto.js
index 96a269f4d..25bb35919 100644
--- a/test/simple/test-crypto.js
+++ b/test/simple/test-crypto.js
@@ -867,6 +867,8 @@ assert.notEqual(-1, crypto.getHashes().indexOf('sha1'));
assert.notEqual(-1, crypto.getHashes().indexOf('sha'));
assert.equal(-1, crypto.getHashes().indexOf('SHA1'));
assert.equal(-1, crypto.getHashes().indexOf('SHA'));
+assert.notEqual(-1, crypto.getHashes().indexOf('RSA-SHA1'));
+assert.equal(-1, crypto.getHashes().indexOf('rsa-sha1'));
assertSorted(crypto.getHashes());
// Base64 padding regression test, see #4837.