Compare commits

...

5 Commits

Author SHA1 Message Date
8bc9439f2b simplify 2018-12-03 17:14:51 -07:00
6bd98c7518 add link to node version 2018-12-03 17:10:45 -07:00
72158cb60f v1.0.3: handle multiple 0x00 pads 2018-12-01 23:46:29 -07:00
19274dfe1b v1.0.2: add screenshot 2018-12-01 22:29:46 -07:00
a0e798debd v1.0.1: update README 2018-12-01 22:25:44 -07:00
4 changed files with 27 additions and 8 deletions

View File

@ -1,4 +1,4 @@
# Bluecrypt&trade SSH to JWK (for Browsers) # Bluecrypt SSH to JWK (for Browsers)
A minimal library to parse an SSH public key (`id_rsa.pub`) A minimal library to parse an SSH public key (`id_rsa.pub`)
and convert it into a public JWK using Vanilla JS. and convert it into a public JWK using Vanilla JS.
@ -16,6 +16,7 @@ Works for RSA and ECDSA public keys.
* P-384 (secp384r1) * P-384 (secp384r1)
* [x] node.js version * [x] node.js version
* [ssh-to-jwk.js](https://git.coolaj86.com/coolaj86/ssh-to-jwk.js) * [ssh-to-jwk.js](https://git.coolaj86.com/coolaj86/ssh-to-jwk.js)
* [x] on npm as [bluecrypt-jwk-to-ssh](https://www.npmjs.com/package/bluecrypt-ssh-to-jwk)
### Need SSH Private Keys? ### Need SSH Private Keys?
@ -26,6 +27,8 @@ so you can use Eckles or Rasha, as mentioned above.
<https://coolaj86.com/demos/ssh-to-jwk/> <https://coolaj86.com/demos/ssh-to-jwk/>
<img border="1" src="https://i.imgur.com/g35NuLP.png" />
```bash ```bash
git clone https://git.coolaj86.com/coolaj86/bluecrypt-ssh-to-jwk.js git clone https://git.coolaj86.com/coolaj86/bluecrypt-ssh-to-jwk.js
pushd bluecrypt-ssh-to-jwk.js/ pushd bluecrypt-ssh-to-jwk.js/
@ -35,14 +38,24 @@ pushd bluecrypt-ssh-to-jwk.js/
open index.html open index.html
``` ```
# Usage # Install
You can also use it as a library: You can use it as a plain-old javascript library:
```html ```html
<script src="https://git.coolaj86.com/coolaj86/bluecrypt-ssh-to-jwk.js/raw/branch/master/ssh-to-jwk.js"></script> <script src="https://git.coolaj86.com/coolaj86/bluecrypt-ssh-to-jwk.js/raw/branch/master/ssh-to-jwk.js"></script>
``` ```
It's also on npm:
```bash
npm install bluecrypt-ssh-to-jwk
```
# Usage
Very simple:
```js ```js
var pub = 'ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCE9Uli8bGnD4hOWdeo5KKQJ/P/vOazI4MgqJK54w37emP2JwOAOdMmXuwpxbKng3KZz27mz+nKWIlXJ3rzSGMo= root@localhost'; var pub = 'ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCE9Uli8bGnD4hOWdeo5KKQJ/P/vOazI4MgqJK54w37emP2JwOAOdMmXuwpxbKng3KZz27mz+nKWIlXJ3rzSGMo= root@localhost';
@ -53,7 +66,7 @@ console.info(ssh.jwk);
# Other Tools in the Bluecrypt Suite # Other Tools in the Bluecrypt Suite
* [Bluecrypt JWK to SSH](https://git.coolaj86.com/coolaj86/jwk-to-ssh.js) (RSA, EC, SSH) * [Bluecrypt JWK to SSH](https://git.coolaj86.com/coolaj86/bluecrypt-jwk-to-ssh.js) (RSA, EC, SSH)
* [Bluecrypt ASN.1 decoder](https://git.coolaj86.com/coolaj86/asn1-parser.js) (x509, RSA, EC, etc) * [Bluecrypt ASN.1 decoder](https://git.coolaj86.com/coolaj86/asn1-parser.js) (x509, RSA, EC, etc)
* [Bluecrypt ASN.1 builder](https://git.coolaj86.com/coolaj86/asn1-packer.js) (x509, RSA, EC, etc) * [Bluecrypt ASN.1 builder](https://git.coolaj86.com/coolaj86/asn1-packer.js) (x509, RSA, EC, etc)
@ -63,3 +76,5 @@ console.info(ssh.jwk);
MPL-2.0 | MPL-2.0 |
[Terms of Use](https://therootcompany.com/legal/#terms) | [Terms of Use](https://therootcompany.com/legal/#terms) |
[Privacy Policy](https://therootcompany.com/legal/#privacy) [Privacy Policy](https://therootcompany.com/legal/#privacy)
Bluecrypt&trade; is owned by AJ ONeal

View File

@ -19,7 +19,8 @@
<pre><code class="js-jwk"> </code></pre> <pre><code class="js-jwk"> </code></pre>
<br> <br>
<p>Made with <a href="https://git.coolaj86.com/coolaj86/bluecrypt-ssh-to-jwk.js/">ssh-to-jwk.js</a></p> <p>Made with <a href="https://git.coolaj86.com/coolaj86/bluecrypt-ssh-to-jwk.js/">ssh-to-jwk.js</a> (Browser friendly)</p>
<p>Also available for node.js: <a href="https://git.coolaj86.com/coolaj86/ssh-to-jwk.js/">ssh-to-jwk.js</a></p>
<script src="./ssh-to-jwk.js"></script> <script src="./ssh-to-jwk.js"></script>
<script> <script>

View File

@ -1,6 +1,6 @@
{ {
"name": "bluecrypt-ssh-to-jwk", "name": "bluecrypt-ssh-to-jwk",
"version": "1.0.0", "version": "1.0.3",
"description": "SSH to JWK in < 150 lines of VanillaJS.", "description": "SSH to JWK in < 150 lines of VanillaJS.",
"homepage": "https://git.coolaj86.com/coolaj86/bluecrypt-ssh-to-jwk.js", "homepage": "https://git.coolaj86.com/coolaj86/bluecrypt-ssh-to-jwk.js",
"main": "ssh-to-jwk.js", "main": "ssh-to-jwk.js",

View File

@ -1,3 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
;(function (exports) { ;(function (exports) {
'use strict'; 'use strict';
@ -91,8 +94,8 @@ SSH.parsePublicKey = function (ssh) {
var y = els[2].slice(1 + len, 1 + len + len); var y = els[2].slice(1 + len, 1 + len + len);
// I don't think EC keys use 0x00 padding, but just in case // I don't think EC keys use 0x00 padding, but just in case
if (0x00 === x[0]) { x = x.slice(1); } while (0x00 === x[0]) { x = x.slice(1); }
if (0x00 === y[0]) { y = y.slice(1); } while (0x00 === y[0]) { y = y.slice(1); }
ssh.jwk.x = Enc.bufToUrlBase64(x); ssh.jwk.x = Enc.bufToUrlBase64(x);
ssh.jwk.y = Enc.bufToUrlBase64(y); ssh.jwk.y = Enc.bufToUrlBase64(y);