Browse Source

beginning to take shape

tags/v1.0.0
AJ ONeal 11 months ago
parent
commit
1d2a4d7b9e

+ 20
- 0
bin/keypairs.js View File

@@ -0,0 +1,20 @@
1
+'use strict';
2
+
3
+var keypairs = require('../');
4
+
5
+var infile = process.argv[2];
6
+var key = require('fs').readFileSync(infile).toString('ascii');
7
+var pem;
8
+var jwk;
9
+
10
+try {
11
+  jwk = JSON.parse(key);
12
+} catch(e) {
13
+  pem = key;
14
+}
15
+
16
+keypairs.import({ jwk: jwk, pem: pem }).then(function (keypair) {
17
+  console.log(keypair);
18
+}).catch(function (e) {
19
+  console.error(e);
20
+});

+ 7
- 0
fixtures/privkey-ec-p256.jwk.json View File

@@ -0,0 +1,7 @@
1
+{
2
+  "kty": "EC",
3
+  "crv": "P-256",
4
+  "d": "iYydo27aNGO9DBUWeGEPD8oNi1LZDqfxPmQlieLBjVQ",
5
+  "x": "IT1SWLxsacPiE5Z16jkopAn8_-85rMjgyCokrnjDft4",
6
+  "y": "mP2JwOAOdMmXuwpxbKng3KZz27mz-nKWIlXJ3rzSGMo"
7
+}

+ 5
- 0
fixtures/privkey-ec-p256.pkcs8.pem View File

@@ -0,0 +1,5 @@
1
+-----BEGIN PRIVATE KEY-----
2
+MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgiYydo27aNGO9DBUW
3
+eGEPD8oNi1LZDqfxPmQlieLBjVShRANCAAQhPVJYvGxpw+ITlnXqOSikCfz/7zms
4
+yODIKiSueMN+3pj9icDgDnTJl7sKcWyp4Nymc9u5s/pyliJVyd680hjK
5
+-----END PRIVATE KEY-----

+ 5
- 0
fixtures/privkey-ec-p256.sec1.pem View File

@@ -0,0 +1,5 @@
1
+-----BEGIN EC PRIVATE KEY-----
2
+MHcCAQEEIImMnaNu2jRjvQwVFnhhDw/KDYtS2Q6n8T5kJYniwY1UoAoGCCqGSM49
3
+AwEHoUQDQgAEIT1SWLxsacPiE5Z16jkopAn8/+85rMjgyCokrnjDft6Y/YnA4A50
4
+yZe7CnFsqeDcpnPbubP6cpYiVcnevNIYyg==
5
+-----END EC PRIVATE KEY-----

+ 7
- 0
fixtures/privkey-ec-p384.jwk.json View File

@@ -0,0 +1,7 @@
1
+{
2
+  "kty": "EC",
3
+  "crv": "P-384",
4
+  "d": "XlyuCEWSTTS8U79O_Mz05z18vh4kb10szvu_7pdXuGWV6lfEyPExyUYWsA6A2kdV",
5
+  "x": "2zEU0bKCa7ejKLIJ8oPGnLhqhxyiv4_w38K2a0SPC6dsSd9_glNJ8lcqv0sff5Gb",
6
+  "y": "VD4jnu83S6scn6_TeAj3EZOREGbOs6dzoVpaugn-XQMMyC9O4VLbDDFGBZTJlMsb"
7
+}

+ 6
- 0
fixtures/privkey-ec-p384.pkcs8.pem View File

@@ -0,0 +1,6 @@
1
+-----BEGIN PRIVATE KEY-----
2
+MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDBeXK4IRZJNNLxTv078
3
+zPTnPXy+HiRvXSzO+7/ul1e4ZZXqV8TI8THJRhawDoDaR1WhZANiAATbMRTRsoJr
4
+t6Mosgnyg8acuGqHHKK/j/DfwrZrRI8Lp2xJ33+CU0nyVyq/Sx9/kZtUPiOe7zdL
5
+qxyfr9N4CPcRk5EQZs6zp3OhWlq6Cf5dAwzIL07hUtsMMUYFlMmUyxs=
6
+-----END PRIVATE KEY-----

+ 6
- 0
fixtures/privkey-ec-p384.sec1.pem View File

@@ -0,0 +1,6 @@
1
+-----BEGIN EC PRIVATE KEY-----
2
+MIGkAgEBBDBeXK4IRZJNNLxTv078zPTnPXy+HiRvXSzO+7/ul1e4ZZXqV8TI8THJ
3
+RhawDoDaR1WgBwYFK4EEACKhZANiAATbMRTRsoJrt6Mosgnyg8acuGqHHKK/j/Df
4
+wrZrRI8Lp2xJ33+CU0nyVyq/Sx9/kZtUPiOe7zdLqxyfr9N4CPcRk5EQZs6zp3Oh
5
+Wlq6Cf5dAwzIL07hUtsMMUYFlMmUyxs=
6
+-----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tures/pub-ec-p256.jwk.json View File

@@ -0,0 +1,6 @@
1
+{
2
+  "kty": "EC",
3
+  "crv": "P-256",
4
+  "x": "IT1SWLxsacPiE5Z16jkopAn8_-85rMjgyCokrnjDft4",
5
+  "y": "mP2JwOAOdMmXuwpxbKng3KZz27mz-nKWIlXJ3rzSGMo"
6
+}

+ 4
- 0
fixtures/pub-ec-p256.spki.pem View File

@@ -0,0 +1,4 @@
1
+-----BEGIN PUBLIC KEY-----
2
+MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIT1SWLxsacPiE5Z16jkopAn8/+85
3
+rMjgyCokrnjDft6Y/YnA4A50yZe7CnFsqeDcpnPbubP6cpYiVcnevNIYyg==
4
+-----END PUBLIC KEY-----

+ 1
- 0
fixtures/pub-ec-p256.ssh.pub View File

@@ -0,0 +1 @@
1
+ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCE9Uli8bGnD4hOWdeo5KKQJ/P/vOazI4MgqJK54w37emP2JwOAOdMmXuwpxbKng3KZz27mz+nKWIlXJ3rzSGMo= P-256@localhost

+ 6
- 0
fixtures/pub-ec-p384.jwk.json View File

@@ -0,0 +1,6 @@
1
+{
2
+  "kty": "EC",
3
+  "crv": "P-384",
4
+  "x": "2zEU0bKCa7ejKLIJ8oPGnLhqhxyiv4_w38K2a0SPC6dsSd9_glNJ8lcqv0sff5Gb",
5
+  "y": "VD4jnu83S6scn6_TeAj3EZOREGbOs6dzoVpaugn-XQMMyC9O4VLbDDFGBZTJlMsb"
6
+}

+ 5
- 0
fixtures/pub-ec-p384.spki.pem View File

@@ -0,0 +1,5 @@
1
+-----BEGIN PUBLIC KEY-----
2
+MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE2zEU0bKCa7ejKLIJ8oPGnLhqhxyiv4/w
3
+38K2a0SPC6dsSd9/glNJ8lcqv0sff5GbVD4jnu83S6scn6/TeAj3EZOREGbOs6dz
4
+oVpaugn+XQMMyC9O4VLbDDFGBZTJlMsb
5
+-----END PUBLIC KEY-----

+ 1
- 0
fixtures/pub-ec-p384.ssh.pub View File

@@ -0,0 +1 @@
1
+ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBNsxFNGygmu3oyiyCfKDxpy4aoccor+P8N/CtmtEjwunbEnff4JTSfJXKr9LH3+Rm1Q+I57vN0urHJ+v03gI9xGTkRBmzrOnc6FaWroJ/l0DDMgvTuFS2wwxRgWUyZTLGw== P-384@localhost

+ 5
- 0
fixtures/pub-rsa-2048.jwk.json View File

@@ -0,0 +1,5 @@
1
+{
2
+  "kty": "RSA",
3
+  "n": "m2ttVBxPlWw06ZmGBWVDlfjkPAJ4DgnY0TrDwtCohHzLxGhDNzUJefLukC-xu0LBKylYojT5vTkxaOhxeSYo31syu4WhxbkTBLICOFcCGMob6pSQ38P8LdAIlb0pqDHxEJ9adWomjuFf0SUhN1cP7s9m8Yk9trkpEqjskocn2BOnTB57qAZM6-I70on0_iDZm7-jcqOPgADAmbWHhy67BXkk4yy_YzD4yOGZFXZcNp915_TW5bRd__AKPHUHxJasPiyEFqlNKBR2DSD-LbX5eTmzCh2ikrwTMja7mUdBJf2bK3By5AB0Qi49OykUCfNZeQlEz7UNNj9RGps_50-CNw",
4
+  "e": "AQAB"
5
+}

+ 8
- 0
fixtures/pub-rsa-2048.pkcs1.pem View File

@@ -0,0 +1,8 @@
1
+-----BEGIN RSA PUBLIC KEY-----
2
+MIIBCgKCAQEAm2ttVBxPlWw06ZmGBWVDlfjkPAJ4DgnY0TrDwtCohHzLxGhDNzUJ
3
+efLukC+xu0LBKylYojT5vTkxaOhxeSYo31syu4WhxbkTBLICOFcCGMob6pSQ38P8
4
+LdAIlb0pqDHxEJ9adWomjuFf0SUhN1cP7s9m8Yk9trkpEqjskocn2BOnTB57qAZM
5
+6+I70on0/iDZm7+jcqOPgADAmbWHhy67BXkk4yy/YzD4yOGZFXZcNp915/TW5bRd
6
+//AKPHUHxJasPiyEFqlNKBR2DSD+LbX5eTmzCh2ikrwTMja7mUdBJf2bK3By5AB0
7
+Qi49OykUCfNZeQlEz7UNNj9RGps/50+CNwIDAQAB
8
+-----END RSA PUBLIC KEY-----

+ 9
- 0
fixtures/pub-rsa-2048.spki.pem View File

@@ -0,0 +1,9 @@
1
+-----BEGIN PUBLIC KEY-----
2
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2ttVBxPlWw06ZmGBWVD
3
+lfjkPAJ4DgnY0TrDwtCohHzLxGhDNzUJefLukC+xu0LBKylYojT5vTkxaOhxeSYo
4
+31syu4WhxbkTBLICOFcCGMob6pSQ38P8LdAIlb0pqDHxEJ9adWomjuFf0SUhN1cP
5
+7s9m8Yk9trkpEqjskocn2BOnTB57qAZM6+I70on0/iDZm7+jcqOPgADAmbWHhy67
6
+BXkk4yy/YzD4yOGZFXZcNp915/TW5bRd//AKPHUHxJasPiyEFqlNKBR2DSD+LbX5
7
+eTmzCh2ikrwTMja7mUdBJf2bK3By5AB0Qi49OykUCfNZeQlEz7UNNj9RGps/50+C
8
+NwIDAQAB
9
+-----END PUBLIC KEY-----

+ 1
- 0
fixtures/pub-rsa-2048.ssh.pub View File

@@ -0,0 +1 @@
1
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCba21UHE+VbDTpmYYFZUOV+OQ8AngOCdjROsPC0KiEfMvEaEM3NQl58u6QL7G7QsErKViiNPm9OTFo6HF5JijfWzK7haHFuRMEsgI4VwIYyhvqlJDfw/wt0AiVvSmoMfEQn1p1aiaO4V/RJSE3Vw/uz2bxiT22uSkSqOyShyfYE6dMHnuoBkzr4jvSifT+INmbv6Nyo4+AAMCZtYeHLrsFeSTjLL9jMPjI4ZkVdlw2n3Xn9NbltF3/8Ao8dQfElqw+LIQWqU0oFHYNIP4ttfl5ObMKHaKSvBMyNruZR0El/ZsrcHLkAHRCLj07KRQJ81l5CUTPtQ02P1Eamz/nT4I3 rsa@localhost

+ 2
- 1
lib/asn1-packer.js View File

@@ -90,7 +90,8 @@ Enc.bufToBase64 = function (u8) {
90 90
   u8.forEach(function (i) {
91 91
     bin += String.fromCharCode(i);
92 92
   });
93
-  return btoa(bin);
93
+  return Buffer.from(bin, 'binary').toString('base64');
94
+  //return btoa(bin);
94 95
 };
95 96
 
96 97
 Enc.hexToBuf = function (hex) {

+ 3
- 0
lib/crypto.js View File

@@ -0,0 +1,3 @@
1
+'use strict';
2
+
3
+var wrap = module.exports;

+ 4
- 2
lib/keypairs.js View File

@@ -13,6 +13,7 @@ var ASN1 = require('./asn1-parser.js');
13 13
 ASN1.pack = require('./asn1-packer.js').pack;
14 14
 
15 15
 var x509 = require('./x509-parser.js');
16
+//x509 = require('./x509-packer.js').pack;
16 17
 
17 18
 var SSH = require('./ssh-parser.js');
18 19
 SSH.pack = require('./ssh-packer.js').pack;
@@ -71,13 +72,14 @@ keypairs.import = function (opts) {
71 72
         jwk = SSH.parse(pem);
72 73
       } else {
73 74
         der = pem.bytes;
74
-        jwk = x509.parse(der);
75
+        jwk = x509.parse({ der: der });
75 76
       }
76 77
     }
77 78
     if (opts.ssh) {
78 79
       jwk = SSH.parse(opts.ssh);
79 80
     }
80
-    if (jwk) {
81
+    // TODO re-export to PKCS8 just because
82
+    if (jwk && !pem) {
81 83
       // Both RSA and EC use 'd' as part of the private key
82 84
       if (jwk.d) {
83 85
         typ = 'PRIVATE KEY';

+ 4
- 0
lib/x509-ec-parser.js View File

@@ -51,12 +51,15 @@ x509.parseSec1 = function parseEcOnlyPrivkey(u8, jwk) {
51 51
 };
52 52
 
53 53
 x509.parsePkcs8 = function parseEcPkcs8(u8, jwk) {
54
+  console.log("here", u8);
54 55
   var index = 24 + (OBJ_ID_EC_256.length/2);
55 56
   var len = 32;
57
+  /*
56 58
   if ("P-384" === jwk.crv) {
57 59
     index = 24 + (OBJ_ID_EC_384.length/2) + 2;
58 60
     len = 48;
59 61
   }
62
+  */
60 63
 
61 64
   //console.log(index, u8.slice(index));
62 65
   if (0x04 !== u8[index]) {
@@ -75,6 +78,7 @@ x509.parsePkcs8 = function parseEcPkcs8(u8, jwk) {
75 78
     throw new Error("invalid compression bit (expected 0x04 or 0x02)");
76 79
   }
77 80
 
81
+  var jwk = {};
78 82
   return {
79 83
     kty: jwk.kty
80 84
   , crv: jwk.crv

+ 2
- 1
lib/x509-parser.js View File

@@ -7,6 +7,7 @@ var EC = require('./x509-ec-parser.js');
7 7
 var RSA = require('./x509-rsa-parser.js');
8 8
 
9 9
 x509.parse = function (opts) {
10
+  console.log(opts);
10 11
   var pem = opts.pem;
11 12
   var der = opts.der;
12 13
   if ('string' === opts.key) {
@@ -25,7 +26,7 @@ x509.parse = function (opts) {
25 26
 
26 27
   // Try EC Private and Public keys
27 28
   if (!rsa && !pub) {
28
-    try { return EC.parsePkcs8(der); } catch(e) { /*ignore*/ }
29
+    try { return EC.parsePkcs8(der); } catch(e) { console.error(e); /*ignore*/ }
29 30
     try { return EC.parseSec1(der); } catch(e) { /*ignore*/ }
30 31
   } else if (!rsa && !prv) {
31 32
     try { return EC.parseSpki(der); } catch(e) { /*ignore*/ }

+ 3
- 0
lib/x509-rsa-parser.js View File

@@ -0,0 +1,3 @@
1
+'use strict';
2
+
3
+var RSA = module.exports;

Loading…
Cancel
Save