Compare commits

..

No commits in common. "master" and "v1.0.0" have entirely different histories.

4 changed files with 8 additions and 27 deletions

View File

@ -1,4 +1,4 @@
# Bluecrypt SSH to JWK (for Browsers) # Bluecrypt&trade 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,7 +16,6 @@ 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?
@ -27,8 +26,6 @@ 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/
@ -38,24 +35,14 @@ pushd bluecrypt-ssh-to-jwk.js/
open index.html open index.html
``` ```
# Install # Usage
You can use it as a plain-old javascript library: You can also use it as a 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';
@ -66,7 +53,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/bluecrypt-jwk-to-ssh.js) (RSA, EC, SSH) * [Bluecrypt JWK to SSH](https://git.coolaj86.com/coolaj86/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)
@ -76,5 +63,3 @@ 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,8 +19,7 @@
<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> (Browser friendly)</p> <p>Made with <a href="https://git.coolaj86.com/coolaj86/bluecrypt-ssh-to-jwk.js/">ssh-to-jwk.js</a></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.3", "version": "1.0.0",
"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,6 +1,3 @@
/* 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';
@ -94,8 +91,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
while (0x00 === x[0]) { x = x.slice(1); } if (0x00 === x[0]) { x = x.slice(1); }
while (0x00 === y[0]) { y = y.slice(1); } if (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);