by CiPHPerCoder · 10y ago · 0 comments
I've been working on this project for a year now, and looking to push for a version 3 release before 2016 is over.
Halite takes a lot of guesswork out of cryptography. You don't even need to know what a nonce is to use it successfully.
I'd like to get more feedback from other developers if possible.
I suppose there might be instances where the cipher-text without the salt might be useful -- but I can't immediately think of any. Keeping the salt "semi-secret" is akin to using a two-key system: the password the user knows, and the salt that the server knows -- but it strikes me as a brittle way of doing things, and provides unclear promises wrt. availability etc (can the user always recover the data, only remembering the password?).
One could of course construct such a function on top of the primitives provided here - but I think it would make a lot of sense to provide something along the lines of:
* sym_enc(password, plaintext) >
-> returns "box" autogenerated-salt|ciphertext
-> possibly with a version header, indicating
KDF (&enc algo) used (could just be a magic
number)
Should obviously use an AEAD mode
* syn_dec(password, box)
-> retrieves key by getting KDF, salt from
box, regenerating key
-> and returns decrypted plaintext
There's nothing wrong with exposing the KDF-functions I suppose, but it feels like it's aiming a bit low, in close proximity to ones feet.Generally you want to just do this once:
$key = KeyFactory::generateEncryptionKey();
KeyFactory::save($key, '/path/outside/webroot');
And from then on: $key = KeyFactory::loadEncryptionKey('/path/outside/webroot');
Encryption typically never touches a password (although you can derive one from a password and salt if you so choose). The normal way of doing things is to just use a random key.(My takeaway is: the README for v3 probably needs work to make this more clear.)
Thanks for the feedback! :)