From c5dae7a1a4a9ae0ae86e3d9cb812686f2f1648cb Mon Sep 17 00:00:00 2001 From: Elmar Langholz Date: Thu, 11 Oct 2018 12:26:05 -0700 Subject: [PATCH] Fix SEA sha1hash for ossl and keyid --- sea.js | 4 ++-- sea/sea.js | 2 +- sea/sha1.js | 2 +- test/sea/sea.html | 18 ++++++++++++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/sea.js b/sea.js index cd40e6c6..3f4b4a91 100644 --- a/sea.js +++ b/sea.js @@ -272,7 +272,7 @@ // This internal func returns SHA-1 hashed data for KeyID generation const __shim = USE('./shim') const subtle = __shim.subtle - const ossl = __shim.ossl ? __shim.__ossl : subtle + const ossl = __shim.ossl ? __shim.ossl : subtle const sha1hash = (b) => ossl.digest({name: 'SHA-1'}, new ArrayBuffer(b)) module.exports = sha1hash })(USE, './sha1'); @@ -629,7 +629,7 @@ try { // base64('base64(x):base64(y)') => Buffer(xy) const pb = Buffer.concat( - Buffer.from(pub, 'base64').toString('utf8').split(':') + pub.replace(/-/g, '+').replace(/_/g, '/').split('.') .map((t) => Buffer.from(t, 'base64')) ) // id is PGPv4 compliant raw key diff --git a/sea/sea.js b/sea/sea.js index f85b9a3b..77032638 100644 --- a/sea/sea.js +++ b/sea/sea.js @@ -49,7 +49,7 @@ try { // base64('base64(x):base64(y)') => Buffer(xy) const pb = Buffer.concat( - Buffer.from(pub, 'base64').toString('utf8').split(':') + pub.replace(/-/g, '+').replace(/_/g, '/').split('.') .map((t) => Buffer.from(t, 'base64')) ) // id is PGPv4 compliant raw key diff --git a/sea/sha1.js b/sea/sha1.js index c18ba691..9272cffc 100644 --- a/sea/sha1.js +++ b/sea/sha1.js @@ -2,7 +2,7 @@ // This internal func returns SHA-1 hashed data for KeyID generation const __shim = require('./shim') const subtle = __shim.subtle - const ossl = __shim.ossl ? __shim.__ossl : subtle + const ossl = __shim.ossl ? __shim.ossl : subtle const sha1hash = (b) => ossl.digest({name: 'SHA-1'}, new ArrayBuffer(b)) module.exports = sha1hash \ No newline at end of file diff --git a/test/sea/sea.html b/test/sea/sea.html index 82c16de7..72aaea9e 100644 --- a/test/sea/sea.html +++ b/test/sea/sea.html @@ -1,6 +1,6 @@ - - - + + +