more partial implementation

This commit is contained in:
AJ ONeal 2016-07-30 19:09:37 -04:00
parent 26595e7539
commit a1c998a4be
5 changed files with 47 additions and 11 deletions

View File

@ -5,7 +5,7 @@
*/
'use strict';
var cryptoc = {};
var cryptoc = module.exports;
var rsaExtra = require('./rsa-extra');
var rsaForge = require('./rsa-forge');
var ursac;
@ -40,5 +40,3 @@ Object.keys(rsaForge).forEach(function (key) {
cryptoc[key] = rsaForge[key];
}
});
module.exports.cryptoc = cryptoc;

View File

@ -28,7 +28,7 @@ function importPublicKey(publicKey) {
}
*/
var forgec = {
var forgec = module.exports = {
@ -126,5 +126,3 @@ var forgec = {
};
return forgec;

View File

@ -6,7 +6,7 @@ function notToJson() {
return undefined;
}
var ursac = {
var ursac = module.exports = {
@ -37,7 +37,7 @@ var ursac = {
// Generate New Keypair
//
, generateKeypair: function (bitlen, exp, options, cb) {
var keypair = ursa.generatePrivateKey(bitlen || 2048, exp || 6553);
var keypair = ursa.generatePrivateKey(bitlen || 2048, exp || 65537);
keypair.toJSON = notToJson;
@ -116,5 +116,3 @@ var ursac = {
};
return ursac;

View File

@ -20,7 +20,7 @@ function create(deps) {
var forge = require("node-forge");
return new Buffer(forge.util.bytesToHex(bytes), "hex");
};
RSA._internal = require('./lib/node').create(deps);
RSA._internal = require('./lib/node');//.create(deps);
RSA.thumbprint = function (jwk) {
jwk = jwk.privateKeyJwk || jwk.publicKeyJwk || jwk;

42
tests/generate-key.js Normal file
View File

@ -0,0 +1,42 @@
'use strict';
var RSA = require('../').RSA;
console.log('RSA');
console.log(RSA);
RSA.generateKeypair(null, null, null, function (keys) {
console.log('');
console.log('keys');
console.log(keys);
if (!keys.privateKeyJwk) {
throw new Error("Expected privateKeyJwk, but it is missing");
}
if (
keys.publicKeyJwk
|| keys.privateKeyPem
|| keys.publicKeyPem
|| keys.thumbprint
|| keys._ursa
|| keys._forge
) {
console.error(keys);
throw new Error("Got unexpected keys");
}
var options = {
public: true // export public keys
, pem: true // export pems
, jwk: false // export jwks
, internal: true // preserve internal intermediate formats (_ursa, _forge)
, thumbprint: true // JWK sha256 thumbprint
};
RSA.generateKeypair(512, 65537, options, function (keys) {
console.log('');
console.log('keys');
console.log(keys);
});
});