From 88f688184a665f5a9879790e2b6ca7e8da69c705 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 1 Dec 2018 23:44:56 -0700 Subject: [PATCH] v1.0.2: handle multiple 0x00 pads --- lib/ssh-parser.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ssh-parser.js b/lib/ssh-parser.js index 6db164d..790361a 100644 --- a/lib/ssh-parser.js +++ b/lib/ssh-parser.js @@ -39,8 +39,8 @@ SSH.parse = function (ssh) { var y = els[2].slice(1 + len, 1 + len + len); // I don't think EC keys use 0x00 padding, but just in case - if (0x00 === x[0]) { x = x.slice(1); } - if (0x00 === y[0]) { y = y.slice(1); } + while (0x00 === x[0]) { x = x.slice(1); } + while (0x00 === y[0]) { y = y.slice(1); } result.jwk.x = Enc.bufToUrlBase64(x); result.jwk.y = Enc.bufToUrlBase64(y); diff --git a/package.json b/package.json index 6935e3a..2185a97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ssh-to-jwk", - "version": "1.0.1", + "version": "1.0.2", "description": "💯 SSH to JWK in a lightweight, zero-dependency library.", "homepage": "https://git.coolaj86.com/coolaj86/ssh-to-jwk.js", "main": "index.js",