2016-07-30 23:09:37 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var RSA = require('../').RSA;
|
|
|
|
|
|
|
|
console.log('RSA');
|
|
|
|
console.log(RSA);
|
|
|
|
|
2016-07-31 03:47:52 +00:00
|
|
|
RSA.generateKeypair(null, null, null, function (err, keys) {
|
2016-07-30 23:09:37 +00:00
|
|
|
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
|
|
|
|
};
|
2016-07-31 03:47:52 +00:00
|
|
|
RSA.generateKeypair(512, 65537, options, function (err, keys) {
|
2016-07-30 23:09:37 +00:00
|
|
|
console.log('');
|
|
|
|
console.log('keys');
|
|
|
|
console.log(keys);
|
2016-07-31 03:47:52 +00:00
|
|
|
|
|
|
|
if (
|
|
|
|
keys.publicKeyJwk
|
|
|
|
|| keys.privateKeyPem
|
|
|
|
|| keys.publicKeyPem
|
|
|
|
|| keys.thumbprint
|
|
|
|
|| keys._ursa
|
|
|
|
|| keys._forge
|
|
|
|
) {
|
|
|
|
console.error(keys);
|
|
|
|
throw new Error("Got unexpected keys");
|
|
|
|
}
|
2016-07-30 23:09:37 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|