Fix SEA sha1hash for ossl and keyid

This commit is contained in:
Elmar Langholz 2018-10-11 12:26:05 -07:00
parent 5be08a08ff
commit c5dae7a1a4
4 changed files with 18 additions and 8 deletions

4
sea.js
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,6 +1,6 @@
<script src="../gun.js"></script>
<script src="../lib/cryptomodules.js"></script>
<script src="../sea.js"></script>
<script src="../../gun.js"></script>
<script src="../../lib/cryptomodules.js"></script>
<script src="../../sea.js"></script>
<script>
;(function(){
localStorage.clear();
@ -12,7 +12,17 @@
function login(ack){
console.log("login...");
user.auth('alice', 'unsafepassword', write);
user.auth('alice', 'unsafepassword', keys);
}
function keys(data){
console.log("keys...");
const keys = user.pair();
console.log(keys);
Gun.SEA.keyid(keys.pub).then(function (keyid) {
console.log("Public key KeyID (PGPv4): " + keyid);
write(keys);
});
}
function write(data){