0.0.1 • Published 1 year ago

hambo v0.0.1

Weekly downloads
-
License
WTFPL
Repository
-
Last release
1 year ago

Hambo

Stream cipher based on the Salsa20 mixing core placed in a sponge construction.

How to use

Encrypt and decrypt buffers

(or actually, Uint8Array).

import hambo from 'hambo'

const e = hambo('key')
const d = hambo('key')

const plaintext = new TextEncoder().encode('some text')
const ciphertext = e.encrypt(plaintext)

const recoveredPlaintext = d.decrypt(ciphertext)

Note that ciphertext will contain a random nonce and will be 4 bytes longer. Due to this, encrypt and decrypt are different operations.

Encrypt and decrypt streams

(specifically, ReadableStream, note: NOT Node's stream.Readable)

import hambo from 'hambo'

const e = hambo('key')
const d = hambo('key')

const plaintextStream = <Some kind of ReadableStream>
const cipherStream = e.encryptStream(plaintextStream)
const recoveredPlaintextStream = d.decryptStream(ciphertextStream)
// and then read from recoveredPlaintextStream

As above, encryptStream will add a 4-byte nonce.

Security discussion

Salsa20 is a solid cipher. However I don't think that it was ever supposed to be used in sponge. Because of this, an 8x8 S-box (permutation of the numbers 0-255) is used to mask the output from the sponge. This likely does not help. In other words I have no idea. Enjoy :)