Live data from Hacker News

Some gripes about nacl

tedunangst.com

41–47 of 47 posts

Re: Some gripes about nacl

#41
These are all very legitimate gripes, and even dangers.

One wrapper I used (think Python/Perl/Ruby), the author did not properly understand how the 0-padding was supposed to be implemented. I was scratching my head for a few hours wondering why messages I encrypted were not being received properly. Turns out, bugs in the C padding code.

The discussion of nonces really needs big flashing warning text and icons. I've seen total disasters with code trying to do nonces correctly, or not even understanding why nonces are important (one VPN package I used had the option of using null nonces, as if it were a feature!)

Re: Some gripes about nacl

#42

These are all very legitimate gripes, and even dangers. One wrapper I used (think Python/Perl/Ruby), the author did not properly understand how the 0-padding was supposed to be implemented. I was scratching my head for a few hours wondering why messages I encrypted were not being received properly. Turns out, bugs in the C padding code. The discussion of nonces really needs big flashing warning text and icons. I've s…

The ZEROBYTES padding is a source of confusion and bugs, including in bindings. Having to allocate more bytes than the unsealed message in crypto_sign_open() was also the root cause of quite a few unfortunate bugs.

And even when used properly, people always ended up writing wrappers allocating temporary buffers and moving data around in order to add/trim these bytes.

And when people start writing wrappers, it usually means that there is something wrong with the API.

For this reason, libsodium fully supports the crypto_box and crypto_secretbox in a compatible way, but doesn't document them in favor of the "easy" interface, which basically does what everybody was reinventing when writing wrappers for these functions.

How to generate nonces for each operation is described in the libsodium documentation. There are legitimate cases for having full control over the nonce, such as the dnscurve and dnscrypt protocols.

Some bindings such as the Swift bindings (Swift-Sodium) have the box() operation generate and return a nonce in addition to the ciphertext. Less flexible than leaving the responsibility to the developer, but definitely safer, and something that might be added to the library itself. On the other hand, adding more and more functions to do the same thing (because breaking backward compatibility is not an option) isn't good either.

Re: Some gripes about nacl

#43
post #25

Earlier quoted context omitted.

He's a highly reputable cryptographer, and a ... controversial ... software developer. I would trust my life to the algorithms. I wouldn't trust my appendix to the code. The software is delivered over HTTP (not HTTPS) and not cryptographically signed. I've always interpreted this as a statement that, if you're not qualified to review what you just downloaded and make sure it's not malicious and that it faithfully imp…

For years I ran vanilla qmail with two patches (AUTH support for sending authentication, and a patch to allow for a database of valid supported emails so you get rid of the backscatter issue). It was absolutely fantastic, it ran without issues for years. It was very fast and I never had issues with losing mail or behaviours that baffled me or left me scratching my head. I currently have a postfix setup, and while it…

Have you tried OpenSMTPD? It's really great. My config file is about 30 lines (and most of them are comments) – unlike with Postfix. And it's from OpenBSD, which means it has better security than others :-)

Re: Some gripes about nacl

#44
post #26
post #23

Earlier quoted context omitted.

I like nacl. I like the author of this article and think he knows what he's talking about. I like libsodium but do worry about the project getting away from them; cleaning up the API is one thing, adding new crypto primitives is another. Still: use libsodium. The person whose opinion you really want on this article is 'pbsd.

I've been worried about that too. Recently I learned that libsodium includes a way to generate crypto_box keys from a fixed argument entropy chunk. It sounds really convenient but also circumvents all of the labor around centralizing entropy generation. Is that a good thing to have? Maybe! It's convenient feeling. Is it dangerous? I have no idea—probably? Should it be part of the interface to libsodium? No clue.

It was added after a popular request: providing a simple way to derive a key pair from a secret key, itself derived from a password.

By not providing a simple way to achieve something, users end up copying/pasting random code and inventing their own crypto.

Additional functions that libsodium provides over NaCl were added after observing how developers were using NaCl in actual projects.

When you see projects that allocate temporary buffers to store signed messages, and immediately discard everything because all they actually need is the signature, you realize that developers have to work around limitations of the NaCl API.

When the maintainer of the Go bindings reports memory corruption, which turned out to be due to sign_open() requiring an output buffer larger than the unsigned message you might blame him for not having read the fine print in the NaCl documentation. But maybe the API should better match what feels intuitive to developers instead.

And when developers systematically write wrappers (for example around box() and secretbox() functions) to work around the same issues, it probably means that API could be improved.

Adding convenience functions addressing very common needs to libsodium instead of having everybody rewrite their own implementation makes it less confusing and eventually less dangerous.

Re: Some gripes about nacl

#45
post #36
post #34

The easiest way to get round the slightly odd build environment for NaCl is to just use TweetNaCl ( http://tweetnacl.cr.yp.to/software.html ) which just requires you to drop a single .c/.h file into your project - this isn't as performant as the reference code but in most cases this probably doesn't matter. The libsodium implementation seems overly complicated to me for most uses. The NaCl API is reasonably simple an…

Might also want to checkout libsodium ( https://github.com/jedisct1/libsodium ).

Except that this is the opposite of my point - the libsodium repository is 9MB with 326 .c/.h files and c.25000 lines of code.

Tweetnacl is 2 .c/.h files and c.1000 lines of code.

Re: Some gripes about nacl

#46

Earlier quoted context omitted.

For years I ran vanilla qmail with two patches (AUTH support for sending authentication, and a patch to allow for a database of valid supported emails so you get rid of the backscatter issue). It was absolutely fantastic, it ran without issues for years. It was very fast and I never had issues with losing mail or behaviours that baffled me or left me scratching my head. I currently have a postfix setup, and while it…

I also quite prefer qmail to postfix in terms of its flexibility and resilience, but it really does highlight one of the biggest problems with long term use of djb software: It always seems to reach a point where djb feels it's done (or he's done with it) and it sits there for years with no updates, while still appearing to be the authoritative version of that product. Vanilla qmail is genuinely unusable on the inter…

Unmaintained software is a problem and vanilla NaCl also left unfixed issues.

For example, the signature system was a prototype that shouldn't be used any more. The portable AES128 implementation produces incorrect output on some other platforms, one of the Curve25519 implementations performs out of bounds memory accesses, and one of the poly1305 implementations will produce incorrect output if your application changes the FP rounding mode. CurveCP was also a fantastic idea, but the NaCl implementation was just a proof of concept that cannot really be used in actual projects.

But would you rather have djb spend time addressing qmail compilation issues on Ubuntu 14.10, or keep making significant advances in applied cryptography (and security in general) instead?

In addition to organizing competitions, the amount of game-changing publications he made or contributed to is very impressive. And it might not have been the case if he didn't move on from software he wrote years ago.

Re: Some gripes about nacl

#47

Earlier quoted context omitted.

For years I ran vanilla qmail with two patches (AUTH support for sending authentication, and a patch to allow for a database of valid supported emails so you get rid of the backscatter issue). It was absolutely fantastic, it ran without issues for years. It was very fast and I never had issues with losing mail or behaviours that baffled me or left me scratching my head. I currently have a postfix setup, and while it…

Have you tried OpenSMTPD? It's really great. My config file is about 30 lines (and most of them are comments) – unlike with Postfix. And it's from OpenBSD, which means it has better security than others :-)

I really want to try OpenSMTPD, but I need it to hook into my Dovecot backend for SMTP auth (SASL would be awesome), and it needs to work with in-line email filtering (i.e. when a message is rejected as spam by amavisd I need that error to propagate back to the sending server). I haven't found good information on how to do any of that yet.

Right now my pipeline is pretty simple:

Postfix accepts -> milter (amavisd) -> dovecot for delivery

I would want to replicate something similar. Do you have any good resources or information?

Post reply on HN