mirror of
https://github.com/amark/gun.git
synced 2025-06-07 14:46:44 +00:00
test heroic?
This commit is contained in:
parent
a6cf6218fd
commit
f72f0fb0a7
1
Procfile.js
Normal file
1
Procfile.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
web: node --optimize_for_size --max_old_space_size=460 --gc_interval=100 examples/http.js
|
8
sea.js
8
sea.js
@ -485,7 +485,7 @@
|
|||||||
// Derive shared secret from other's pub and my epub/epriv
|
// Derive shared secret from other's pub and my epub/epriv
|
||||||
async derive(pub, { epub, epriv }) {
|
async derive(pub, { epub, epriv }) {
|
||||||
try {
|
try {
|
||||||
const { importKey, deriveKey, exportKey } = wc.ossl || subtle
|
const sub = wc.ossl || subtle
|
||||||
const keystoecdhjwk = (pub, priv) => {
|
const keystoecdhjwk = (pub, priv) => {
|
||||||
const [ x, y ] = Buffer.from(pub, 'base64').toString('utf8').split(':')
|
const [ x, y ] = Buffer.from(pub, 'base64').toString('utf8').split(':')
|
||||||
const jwk = priv ? { d: priv, key_ops: ['decrypt'] } : { key_ops: ['encrypt'] }
|
const jwk = priv ? { d: priv, key_ops: ['decrypt'] } : { key_ops: ['encrypt'] }
|
||||||
@ -497,12 +497,12 @@
|
|||||||
y
|
y
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const pubLic = await importKey('jwk', keystoecdhjwk(pub), ecdhKeyProps, false, ['deriveKey'])
|
const pubLic = await sub.importKey('jwk', keystoecdhjwk(pub), ecdhKeyProps, false, ['deriveKey'])
|
||||||
const props = Object.assign({}, ecdhKeyProps, { public: pubLic })
|
const props = Object.assign({}, ecdhKeyProps, { public: pubLic })
|
||||||
const derived = await importKey('jwk', keystoecdhjwk(epub, epriv), ecdhKeyProps, false, ['deriveKey'])
|
const derived = await sub.importKey('jwk', keystoecdhjwk(epub, epriv), ecdhKeyProps, false, ['deriveKey'])
|
||||||
.then(async (privKey) => {
|
.then(async (privKey) => {
|
||||||
// privateKey scope doesn't leak out from here!
|
// privateKey scope doesn't leak out from here!
|
||||||
const derivedKey = await deriveKey(props, privKey, { name: 'AES-CBC', length: 256 }, true, [ 'encrypt', 'decrypt' ])
|
const derivedKey = await sub.deriveKey(props, privKey, { name: 'AES-CBC', length: 256 }, true, [ 'encrypt', 'decrypt' ])
|
||||||
return exportKey('jwk', derivedKey).then(({ k }) => k)
|
return exportKey('jwk', derivedKey).then(({ k }) => k)
|
||||||
})
|
})
|
||||||
return derived
|
return derived
|
||||||
|
Loading…
x
Reference in New Issue
Block a user