News for hackers. Stuff that matters.
Re:Libsodium: A modern, portable, easy to use crypto library by loup-vaillant on Friday September 15, 2023 @07:54AM (#37521629)
In addition to what sibling comments said, keeping stuff separate helps making the C API a bit more explicit and easier to intuit out of the box. For instance: https://monocypher.org/manual/aead

  void
  crypto_aead_lock(
      uint8_t *cipher_text,
      uint8_t mac[16], const uint8_t key[32], const uint8_t nonce[24],
      const uint8_t *ad,         size_t ad_size,
      const uint8_t *plain_text, size_t text_size);
Here you see that both `nonce` and `mac` are separate (libsodium calls that "detached"), which can be annoying considering you always need the mac. On the other hand:

  Plain text and cipher text buffers have the same size.
  The size of the mac   is explicit (16 bytes)
  The size of the nonce is explicit (24 bytes)
---

Yet another reason to let user specify the nonce is that portability stops me from accessing an RNG. Can’t produce random nonces without it, so I have to pass the burden to the user. (On the other hand, I get to run on tiny microcontrollers that don’t even have `malloc()`).

---

Speaking of streaming encryption, I have that too now, and unlike libsodium it’s compatible with the one-shot interface. Like libsodium, you only need to provide your nonce once.

There are no comments on this comment yet.