From ea13bda0567f926c5691ebd27565b690d33b30b1 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 19 Nov 2018 22:28:17 -0700 Subject: [PATCH] v0.7.2: update docs --- README.md | 50 +++++++++++++++++++++++++++++++------------------- package.json | 2 +- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 284f2b2..6889f80 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,13 @@ eckles.js ECDSA tools. Lightweight. Zero Dependencies. Universal compatibility. -> I _just_ cleaned up the PEM-to-JWK functionality enough to publish. -> I also have the JWK-to-PEM functionality _mostly_ built, but not enough to publish. +* [x] PEM-to-JWK +* [ ] JWK-to-PEM (partial) -* P-256 (prime256v1, secp256r1) -* P-384 (secp384r1) -* SPKI/PKIX -* PKCS#8 -* SEC1/X9.62 -* PEM-to-JWK -* JWK-to-PEM +### PEM-to-JWK + +* [x] SEC1/X9.62, PKCS#8, SPKI/PKIX +* [x] P-256 (prime256v1, secp256r1), P-384 (secp384r1) ```js var eckles = require('eckles'); @@ -20,25 +17,40 @@ var pem = require('fs').readFileSync('./fixtures/privkey-ec-p256.sec1.pem', 'asc eckles.import({ pem: pem }).then(function (jwk) { console.log(jwk); - /* - { - "kty": "EC", - "crv": "P-256", - "d": "iYydo27aNGO9DBUWeGEPD8oNi1LZDqfxPmQlieLBjVQ", - "x": "IT1SWLxsacPiE5Z16jkopAn8_-85rMjgyCokrnjDft4", - "y": "mP2JwOAOdMmXuwpxbKng3KZz27mz-nKWIlXJ3rzSGMo" - } - */ }); ``` +```js +{ + "kty": "EC", + "crv": "P-256", + "d": "iYydo27aNGO9DBUWeGEPD8oNi1LZDqfxPmQlieLBjVQ", + "x": "IT1SWLxsacPiE5Z16jkopAn8_-85rMjgyCokrnjDft4", + "y": "mP2JwOAOdMmXuwpxbKng3KZz27mz-nKWIlXJ3rzSGMo" +} +``` + +### JWK-to-PEM + +* [x] SEC1/X9.62 +* [x] P-256 (prime256v1, secp256r1), P-384 (secp384r1) + + ```js eckles.export({ jwk: jwk }).then(function (pem) { - // PEM in pkcs#8 format + // PEM in sec1 (x9.62) format console.log(pem); }); ``` +``` +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIImMnaNu2jRjvQwVFnhhDw/KDYtS2Q6n8T5kJYniwY1UoAoGCCqGSM49 +AwEHoUQDQgAEIT1SWLxsacPiE5Z16jkopAn8/+85rMjgyCokrnjDft6Y/YnA4A50 +yZe7CnFsqeDcpnPbubP6cpYiVcnevNIYyg== +-----END EC PRIVATE KEY----- +``` +