working der and pem generation #2
|
@ -3,8 +3,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Keypairs = exports.Keypairs = {};
|
var Keypairs = exports.Keypairs = {};
|
||||||
var Rasha = exports.Rasha || require('rasha');
|
var Rasha = exports.Rasha;
|
||||||
var Eckles = exports.Eckles || require('eckles');
|
var Eckles = exports.Eckles;
|
||||||
var Enc = exports.Enc || {};
|
var Enc = exports.Enc || {};
|
||||||
|
|
||||||
Keypairs._stance = "We take the stance that if you're knowledgeable enough to"
|
Keypairs._stance = "We take the stance that if you're knowledgeable enough to"
|
||||||
|
@ -34,10 +34,12 @@ Keypairs.generate = function (opts) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Chopping off the private parts is now part of the public API.
|
/**
|
||||||
// I thought it sounded a little too crude at first, but it really is the best name in every possible way.
|
* Chopping off the private parts is now part of the public API.
|
||||||
|
* I thought it sounded a little too crude at first, but it really is the best name in every possible way.
|
||||||
|
*/
|
||||||
Keypairs.neuter = Keypairs._neuter = function (opts) {
|
Keypairs.neuter = Keypairs._neuter = function (opts) {
|
||||||
// trying to find the best balance of an immutable copy with custom attributes
|
/** trying to find the best balance of an immutable copy with custom attributes */
|
||||||
var jwk = {};
|
var jwk = {};
|
||||||
Object.keys(opts.jwk).forEach(function (k) {
|
Object.keys(opts.jwk).forEach(function (k) {
|
||||||
if ('undefined' === typeof opts.jwk[k]) { return; }
|
if ('undefined' === typeof opts.jwk[k]) { return; }
|
||||||
|
@ -61,7 +63,7 @@ Keypairs.thumbprint = function (opts) {
|
||||||
Keypairs.publish = function (opts) {
|
Keypairs.publish = function (opts) {
|
||||||
if ('object' !== typeof opts.jwk || !opts.jwk.kty) { throw new Error("invalid jwk: " + JSON.stringify(opts.jwk)); }
|
if ('object' !== typeof opts.jwk || !opts.jwk.kty) { throw new Error("invalid jwk: " + JSON.stringify(opts.jwk)); }
|
||||||
|
|
||||||
// returns a copy
|
/** returns a copy */
|
||||||
var jwk = Keypairs.neuter(opts);
|
var jwk = Keypairs.neuter(opts);
|
||||||
|
|
||||||
if (jwk.exp) {
|
if (jwk.exp) {
|
||||||
|
|
|
@ -136,6 +136,10 @@
|
||||||
, ASN1('A1', ASN1.BitStr('04' + x + y)))
|
, ASN1('A1', ASN1.BitStr('04' + x + y)))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* take a private jwk and creates a der from it
|
||||||
|
* @param {*} jwk
|
||||||
|
*/
|
||||||
x509.packPkcs8 = function (jwk) {
|
x509.packPkcs8 = function (jwk) {
|
||||||
var d = Enc.base64ToHex(jwk.d);
|
var d = Enc.base64ToHex(jwk.d);
|
||||||
var x = Enc.base64ToHex(jwk.x);
|
var x = Enc.base64ToHex(jwk.x);
|
||||||
|
|
Loading…
Reference in New Issue