4 ms·
NaCL: https://nacl.cr.yp.to https://nacl.cr.yp.to Is a crypto library designed to do exactly this, have a sensible API that does not expose any internal detail
by snops 8y ago
NaCL: https://nacl.cr.yp.to https://nacl.cr.yp.to
Is a crypto library designed to do exactly this, have a sensible API that does not expose any internal details for misuse, and generally gives you only one way to do things based on best practice algorithms.
It's got some big names behind it, and has probably quite mature since it's been going for several years.
There is also a popular fork, libsodium: https://libsodium.gitbook.io/doc/ https://libsodium.gitbook.io/doc/, which I think is more portable.
- skrebbel 8y agoI like the idea of NaCl, but IMO it doesn't go far enough. For a concrete example, it lacks PHP's password_hash and password_hash_verify functions, essentially being one level of abstraction lower. Also the documentation does not mention much in the way of how to _use_ the library. Do I send the nonce along with the ciphertext? Do I need to authenticate the nonce as well, then? To me it looks like NaCl and libsodium are still very much written by and for cryptographers. Eg, many functions take nonces. Correct me if I'm wrong, but why can't they generate those nonces for me? Return a struct with the ciphertext and the nonce? Or have a make_nonce function generate a Nonce struct and only accepting that instead of a string? I recognize that some of crypto, especially much other stuff than password hashing, is just intrinsically hard. But the APIs should expose only this intrinsic hardness and design the rest simply so you can't use it wrong. It's the exact same critique as a database client library that makes passing data separately harder than putting them right inside the query string (eg PHP's original mysql_query). Those are crap APIs and crypto APIs that let me screw up without even so much as a warning are also crap APIs. Finally, to get into some classic HN style bikeshedding: 'NaCl (pronounced "salt")', really? So the idea is that when Bob recommends that Alice "just use salt", she understands that Bob means NaCl and not "just use a salt", the much more probable and totally wrong interpretation. Nonsense like this does not give me much faith that a library is designed for real world use by normal engineers.
- skrebbel 8y agoUpdate: wow, the libsodium docs got a lot better since last time I looked at it. Eg [0] is clearly written for normal developers and not for crypto people. Cool! I'd still love a library at a higher level of abstraction like I described above, but nevertheless I think this is cool. [0] https://download.libsodium.org/doc/secret-key_cryptography/authenticated_encryption https://download.libsodium.org/doc/secret-key_cryptography/a...