diff options
author | Florian Dold <florian@dold.me> | 2021-01-07 18:56:09 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-01-07 18:56:09 +0100 |
commit | 265034104241eabffab32693f3a5a1af85cd7749 (patch) | |
tree | bce9e6b418fb23b4ca561cf6c94be8c1a0d19345 /packages/taler-wallet-core/src/crypto | |
parent | b2e213bae6c8f9d6a7629f3b9a1e474fb33bdb24 (diff) | |
download | wallet-core-265034104241eabffab32693f3a5a1af85cd7749.tar.xz |
implement backup encryption, some more CLI commands
Diffstat (limited to 'packages/taler-wallet-core/src/crypto')
-rw-r--r-- | packages/taler-wallet-core/src/crypto/primitives/nacl-fast.ts | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/crypto/primitives/nacl-fast.ts b/packages/taler-wallet-core/src/crypto/primitives/nacl-fast.ts index ceb601468..acaebf546 100644 --- a/packages/taler-wallet-core/src/crypto/primitives/nacl-fast.ts +++ b/packages/taler-wallet-core/src/crypto/primitives/nacl-fast.ts @@ -2990,7 +2990,11 @@ export function sign_ed25519_pk_to_curve25519( return x25519_pk; } -export function secretbox(msg: Uint8Array, nonce: Uint8Array, key: Uint8Array) { +export function secretbox( + msg: Uint8Array, + nonce: Uint8Array, + key: Uint8Array, +): Uint8Array { checkArrayTypes(msg, nonce, key); checkLengths(key, nonce); var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length); @@ -3005,15 +3009,15 @@ export function secretbox_open( box: Uint8Array, nonce: Uint8Array, key: Uint8Array, -) { +): Uint8Array | undefined { checkArrayTypes(box, nonce, key); checkLengths(key, nonce); var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length); var m = new Uint8Array(c.length); for (var i = 0; i < box.length; i++) c[i + crypto_secretbox_BOXZEROBYTES] = box[i]; - if (c.length < 32) return null; - if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null; + if (c.length < 32) return undefined; + if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return undefined; return m.subarray(crypto_secretbox_ZEROBYTES); } |