2016-07-30 20:00:08 +00:00
|
|
|
/*!
|
|
|
|
* rsa-compat
|
|
|
|
* Copyright(c) 2016 AJ ONeal <aj@daplie.com> https://daplie.com
|
|
|
|
* Apache-2.0 OR MIT (and hence also MPL 2.0)
|
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2016-07-30 23:09:37 +00:00
|
|
|
var cryptoc = module.exports;
|
2016-07-30 20:00:08 +00:00
|
|
|
var rsaExtra = require('./rsa-extra');
|
|
|
|
var rsaForge = require('./rsa-forge');
|
2016-07-31 03:47:52 +00:00
|
|
|
var rsaUrsa;
|
2016-07-30 20:00:08 +00:00
|
|
|
|
|
|
|
try {
|
2016-07-31 03:47:52 +00:00
|
|
|
rsaUrsa = require('./rsa-ursa');
|
2016-07-30 20:00:08 +00:00
|
|
|
} catch(e) {
|
2016-07-31 03:47:52 +00:00
|
|
|
rsaUrsa = {};
|
2016-07-30 20:00:08 +00:00
|
|
|
// things will run a little slower on keygen, but it'll work on windows
|
|
|
|
// (but don't try this on raspberry pi - 20+ MINUTES key generation)
|
|
|
|
}
|
|
|
|
|
|
|
|
// order of crypto precdence is
|
|
|
|
// * native
|
|
|
|
// * ursa
|
|
|
|
// * forge extra (the new one aimed to be less-forgey)
|
|
|
|
// * forge (fallback)
|
2016-07-31 03:47:52 +00:00
|
|
|
Object.keys(rsaUrsa).forEach(function (key) {
|
2016-07-30 20:00:08 +00:00
|
|
|
if (!cryptoc[key]) {
|
2016-07-31 03:47:52 +00:00
|
|
|
cryptoc[key] = rsaUrsa[key];
|
2016-07-30 20:00:08 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-07-31 03:47:52 +00:00
|
|
|
Object.keys(rsaForge).forEach(function (key) {
|
2016-07-30 20:00:08 +00:00
|
|
|
if (!cryptoc[key]) {
|
2016-07-31 03:47:52 +00:00
|
|
|
cryptoc[key] = rsaForge[key];
|
2016-07-30 20:00:08 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-07-31 03:47:52 +00:00
|
|
|
Object.keys(rsaExtra).forEach(function (key) {
|
2016-07-30 20:00:08 +00:00
|
|
|
if (!cryptoc[key]) {
|
2016-07-31 03:47:52 +00:00
|
|
|
cryptoc[key] = rsaExtra[key];
|
2016-07-30 20:00:08 +00:00
|
|
|
}
|
|
|
|
});
|