From 1b01c2c4132f3db552f32ad56d92f4670d6365db Mon Sep 17 00:00:00 2001 From: lastlink Date: Fri, 26 Apr 2019 23:27:08 -0400 Subject: [PATCH 1/7] working der generation --- app.js | 3 +++ index.html | 4 +++- lib/bluecrypt-encoding.js | 2 +- lib/x509.js | 6 +++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index fcacb77..1738a2c 100644 --- a/app.js +++ b/app.js @@ -43,6 +43,9 @@ function run() { }; console.log('opts', opts); Keypairs.generate(opts).then(function (results) { + var der = x509.packPkcs8(results.private); + console.log(der) + // Pem.encode(x509.packPkcs8(privateJwk)) $('.js-jwk').innerText = JSON.stringify(results, null, 2); // $('.js-loading').hidden = true; diff --git a/index.html b/index.html index da066a9..0d35e9a 100644 --- a/index.html +++ b/index.html @@ -66,8 +66,10 @@ ACME Account Response
- + + + diff --git a/lib/bluecrypt-encoding.js b/lib/bluecrypt-encoding.js index d3f2292..7dc1073 100644 --- a/lib/bluecrypt-encoding.js +++ b/lib/bluecrypt-encoding.js @@ -1,6 +1,6 @@ (function (exports) { -var Enc = exports.BluecryptEncoding = {}; +var Enc = exports.Enc = {}; Enc.bufToBin = function (buf) { var bin = ''; diff --git a/lib/x509.js b/lib/x509.js index 63d1a7d..114375d 100644 --- a/lib/x509.js +++ b/lib/x509.js @@ -128,7 +128,7 @@ var x = Enc.base64ToHex(jwk.x); var y = Enc.base64ToHex(jwk.y); var objId = ('P-256' === jwk.crv) ? OBJ_ID_EC : OBJ_ID_EC_384; - return Enc.hexToUint8( + return Enc.hexToBuf( ASN1('30' , ASN1.UInt('01') , ASN1('04', d) @@ -141,7 +141,7 @@ var x = Enc.base64ToHex(jwk.x); var y = Enc.base64ToHex(jwk.y); var objId = ('P-256' === jwk.crv) ? OBJ_ID_EC : OBJ_ID_EC_384; - return Enc.hexToUint8( + return Enc.hexToBuf( ASN1('30' , ASN1.UInt('00') , ASN1('30' @@ -159,7 +159,7 @@ var x = Enc.base64ToHex(jwk.x); var y = Enc.base64ToHex(jwk.y); var objId = ('P-256' === jwk.crv) ? OBJ_ID_EC : OBJ_ID_EC_384; - return Enc.hexToUint8( + return Enc.hexToBuf( ASN1('30' , ASN1('30' , OBJ_ID_EC_PUB -- 2.38.5 From 735ec948da2f15c9b0c269340270f82f3a3b66dd Mon Sep 17 00:00:00 2001 From: lastlink Date: Sat, 27 Apr 2019 00:02:57 -0400 Subject: [PATCH 2/7] working pem generation --- app.js | 8 ++++++-- index.html | 14 +++++++++++++ lib/ecdsa.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 1738a2c..097d710 100644 --- a/app.js +++ b/app.js @@ -44,15 +44,19 @@ function run() { console.log('opts', opts); Keypairs.generate(opts).then(function (results) { var der = x509.packPkcs8(results.private); - console.log(der) - // Pem.encode(x509.packPkcs8(privateJwk)) + var pem = Eckles.export({jwk:results.private}) + $('.js-jwk').innerText = JSON.stringify(results, null, 2); + $('.js-der').innerText = JSON.stringify(der, null, 2); + $('.js-input-pem').innerText = pem; // $('.js-loading').hidden = true; $('.js-jwk').hidden = false; $$('input').map(function ($el) { $el.disabled = false; }); $$('button').map(function ($el) { $el.disabled = false; }); $('.js-toc-jwk').hidden = false; + $('.js-toc-der').hidden = false; + $('.js-toc-pem').hidden = false; }); }); diff --git a/index.html b/index.html index 0d35e9a..d4fec55 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,12 @@ BlueCrypt +

BlueCrypt for the Browser

@@ -58,6 +64,14 @@ JWK Keypair
 
+ + -