From fbe30dbfbc47075291c95758b913bcff24686a45 Mon Sep 17 00:00:00 2001 From: lastlink Date: Sat, 27 Apr 2019 01:24:37 -0400 Subject: [PATCH] public and private --- app.js | 39 ++++++++++++++++++++++++++------------- index.html | 22 +++++++++++++++------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/app.js b/app.js index 8db2949..f2066dd 100644 --- a/app.js +++ b/app.js @@ -34,8 +34,10 @@ ev.stopPropagation(); $('.js-loading').hidden = false; $('.js-jwk').hidden = true; - $('.js-toc-der').hidden = true; - $('.js-toc-pem').hidden = true; + $('.js-toc-der-public').hidden = true; + $('.js-toc-pem-public').hidden = true; + $('.js-toc-der-private').hidden = true; + $('.js-toc-pem-private').hidden = true; $$('input').map(function ($el) { $el.disabled = true; }); $$('button').map(function ($el) { $el.disabled = true; }); var opts = { @@ -45,22 +47,33 @@ }; console.log('opts', opts); Keypairs.generate(opts).then(function (results) { - var der; + var der_public, der_private; if (opts.kty == 'EC') { - der = x509.packPkcs8(results.private); - var pem = Eckles.export({ jwk: results.private }) - $('.js-input-pem').innerText = pem; - $('.js-toc-pem').hidden = false; + der_public = x509.packSpki(results.public); + der_private = x509.packPkcs8(results.private); + var pem_private = Eckles.export({ jwk: results.private }) + var pem_public = Eckles.export({ jwk: results.public, public: true }) + $('.js-input-pem-public').innerText = pem_public; + $('.js-toc-pem-public').hidden = false; + $('.js-input-pem-private').innerText = pem_private; + $('.js-toc-pem-private').hidden = false; } else { - der = x509.packPkcs8(results.private); - var pem = Rasha.pack({ jwk: results.private }).then(function (pem) { - $('.js-input-pem').innerText = pem; - $('.js-toc-pem').hidden = false; + der_private = x509.packPkcs8(results.private); + der_public = x509.packPkcs8(results.public); + Rasha.pack({ jwk: results.private }).then(function (pem) { + $('.js-input-pem-private').innerText = pem; + $('.js-toc-pem-private').hidden = false; + }) + Rasha.pack({ jwk: results.public }).then(function (pem) { + $('.js-input-pem-public').innerText = pem; + $('.js-toc-pem-public').hidden = false; }) } - $('.js-der').innerText = der; - $('.js-toc-der').hidden = false; + $('.js-der-public').innerText = der_public; + $('.js-toc-der-public').hidden = false; + $('.js-der-private').innerText = der_private; + $('.js-toc-der-private').hidden = false; $('.js-jwk').innerText = JSON.stringify(results, null, 2); $('.js-loading').hidden = true; $('.js-jwk').hidden = false; diff --git a/index.html b/index.html index 921d6d7..047936b 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ height: 10em; } /* need to word wrap the binary no space der */ - .js-der{ + .js-der-public, .js-der-private{ white-space: pre-wrap; /* CSS3 */ white-space: -moz-pre-wrap; /* Firefox */ white-space: -pre-wrap; /* Opera <7 */ @@ -72,13 +72,21 @@ JWK Keypair
 
-