The cutest secure JavaScript authenticated encryption container.
npm install nermalNermal does private-key authenticated encryption with a trusted algorithm
([AES-256][aes]/[GCM][gcm]) implemented by a trusted library ([SJCL][sjcl]) with
a pretty good key-derivation system ([scrypt][scrypt]). It keeps track of salts
for its keys, and automatically generates random nonces. It also pads the data
with a random number of random bytes, which makes it harder to determine what
sort of operations are being performed on the data: inserts and deletions become
harder to detect as the file length is known to randomly fluctuate.
Authenticated encryption basically means that when you decrypt the data, you can
be confident that it's something which you encrypted, in the format that you
encrypted it in. Nermal also authenticates and stores a namespace string, so
that there is a nice place for you to store version numbers so that you can
reorganize your data format later.
Nermal boxes are newline-separated ASCII strings[note 1], so you can
save them to disk or transmit them as JSON or whatever you want, interoperably.
npm install nermal
To use with the browser, you will need to load the files for [SJCL][sjcl] and
[scrypt][scrypt] in your HTML file first, then include nermal.js or nermal-1.1.2_browser.min.js with a script tag -- it will initialize scrypt
for you. I may eventually release a packed version which contains all of the
source for the browser.
encrypt and decrypt, nermal provides newKey and getKey forFull docs are available in nermal/API.md. The types and argument orders of the
most common functions are:
encrypt: (ns: string, data: $bin, key: string | $key, nonce: $bin?) -> $nermal_box!
decrypt: (box: $nermal_box, key: string | $key, raw: boolean?) -> $bin
newKey: (pass: string) -> $key!
getKey: (box: $nermal_box, pass: string) -> $key
version: string
JSON.stringify(ns).slice(1, -1)[aes]: https://en.wikipedia.org/wiki/Advanced_Encryption_Standard "Advanced Encryption Standard"
[gcm]: https://en.wikipedia.org/wiki/Galois/Counter_Mode "Galois/Counter Mode"
[sjcl]: https://github.com/bitwiseshiftleft/sjcl "Stanford JavaScript Crypto Library"
[scrypt]: https://github.com/tonyg/js-scrypt "Emscripten-compiled scrypt"
[node]: http://nodejs.org/ "node.js"
[uint8]: https://developer.mozilla.org/en-US/docs/Web/API/Uint8Array "Uint8Array - Web API interfaces | MDN"