45 lines
967 B
JavaScript
45 lines
967 B
JavaScript
/*!
|
|
* 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';
|
|
|
|
var cryptoc = {};
|
|
var rsaExtra = require('./rsa-extra');
|
|
var rsaForge = require('./rsa-forge');
|
|
var ursac;
|
|
|
|
try {
|
|
ursac = require('./rsa-ursa');
|
|
} catch(e) {
|
|
ursac = {};
|
|
// 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)
|
|
Object.keys(ursac).forEach(function (key) {
|
|
if (!cryptoc[key]) {
|
|
cryptoc[key] = ursac[key];
|
|
}
|
|
});
|
|
|
|
Object.keys(rsaExtra).forEach(function (key) {
|
|
if (!cryptoc[key]) {
|
|
cryptoc[key] = rsaExtra[key];
|
|
}
|
|
});
|
|
|
|
Object.keys(rsaForge).forEach(function (key) {
|
|
if (!cryptoc[key]) {
|
|
cryptoc[key] = rsaForge[key];
|
|
}
|
|
});
|
|
|
|
module.exports.cryptoc = cryptoc;
|