diff options
author | Fedor Indutny <fedor.indutny@gmail.com> | 2013-12-14 15:28:07 +0400 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2014-01-05 16:42:33 +0400 |
commit | 92b6417098371259730c00360979101ce38cbe12 (patch) | |
tree | c1417151c0c4d5f01e1debcc4e5d2e210e39c750 /lib/crypto.js | |
parent | a40b46367406deb0e3c67dff8c5d609d1334519b (diff) | |
download | android-node-v8-92b6417098371259730c00360979101ce38cbe12.tar.gz android-node-v8-92b6417098371259730c00360979101ce38cbe12.tar.bz2 android-node-v8-92b6417098371259730c00360979101ce38cbe12.zip |
crypto: introduce .setEngine(engine, [flags])
Diffstat (limited to 'lib/crypto.js')
-rw-r--r-- | lib/crypto.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/crypto.js b/lib/crypto.js index add6a79d78..33baa40467 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -35,6 +35,7 @@ try { throw new Error('node.js not compiled with openssl crypto support.'); } +var constants = require('constants'); var stream = require('stream'); var util = require('util'); @@ -621,6 +622,21 @@ Certificate.prototype.exportChallenge = function(object, encoding) { }; +exports.setEngine = function setEngine(id, flags) { + if (!util.isString(id)) + throw new TypeError('id should be a string'); + + if (flags && !util.isNumber(flags)) + throw new TypeError('flags should be a number, if present'); + flags = flags >>> 0; + + // Use provided engine for everything by default + if (flags === 0) + flags = constants.ENGINE_METHOD_ALL; + + return binding.setEngine(id, flags); +}; + exports.randomBytes = randomBytes; exports.pseudoRandomBytes = pseudoRandomBytes; |