http://nacl.cr.yp.to/features.html
High-level primitives
A typical cryptographic library requires several
steps to authenticate and encrypt a message.
Consider, for example, the following typical
combination of RSA, AES, etc.:
* Generate a random AES key.
* Use the AES key to encrypt the message.
* Hash the encrypted message using SHA-256.
* Read the sender's RSA secret key from
"wire format."
* Use the sender's RSA secret key to sign the
hash.
* Read the recipient's RSA public key from wire format.
* Use the recipient's public key to encrypt the
AES key, hash, and signature.
* Convert the encrypted key, hash, and signature to wire
format.
* Concatenate with the encrypted message.
Sometimes even more steps are required for storage
allocation, error handling, etc.
NaCl provides a simple crypto_box function that
does everything in one step. The function takes the
sender's secret key, the recipient's public
key, and a message, and produces an authenticated
ciphertext. All objects are represented in wire
format, as sequences of bytes suitable for
transmission; the crypto_box function
automatically handles all necessary conversions,
initializations, etc.
Of course, "such libs have bugs" -- it is software after all. But bugs can (and will be) fixed.Somewhat unique to security and cryptography are the number of subtle bugs possible. There are both problems of actual "normal" bugs (like the Debian entropy bug) and system level design errors (like CRIME).
NaCl/Salt tries to reduce the number of errors possible by using the library wrong (as opposed to eg: openssl that has a very (some say too) rich interface). But you could still end up writing the secret key to swap. Or doing something silly with the plain text. Or expose yourself to a buffer overflow in the part of the code that renders those cute avatar-images for your chat application.
edit: formating
Another high level effort in security is meredith paterson's "language theoretic security"[1] can help you code secure protocols, to fight against this problem.
There's also a tool to help implement it called hammer[2].Not sure if fully developed yet.
[1]http://boingboing.net/2011/12/28/linguistics-turing-complete...