Live data from Hacker News

Cryptographic Best Practices

gist.github.com

51–53 of 53 posts

Re: Cryptographic Best Practices

#51

What is the state of the art for doing encryption with ECC? The author just says "use NaCl" here but what should I do if I am not in a position to do that but can still use ECC? My understanding of ECC is that it is not really suitable for encryption as-is, as RSA was, rather it is used for key agreement (somehow through a multi-step process that I do not understand). But it is unclear how much of this is just rumor…

> The author just says "use NaCl" here but what should I do if I am not in a position to do that but can still use ECC?

Not being in a position to use even a single-file C library like Monocypher (well, 2 compilation units if you want the optional parts), is… well, unusual.

> My understanding of ECC is that it is not really suitable for encryption as-is, as RSA was, rather it is used for key agreement (somehow through a multi-step process that I do not understand)

The steps are: once you’ve done key agreement, you have a shared key. You can then use authenticated encryption with that key. One caveat though is that key agreement often don’t give you an actual key, but a statistically biased shared secret. So the actual steps are:

  1. Do key agreement. You now have a shared secret.
  2. Hash your shared secret. You now have a key.
  3. Encrypt your messages with your key. Use AEAD for this.
Caveat: I omitted a number of important details, most notably forward secrecy.

Re: Cryptographic Best Practices

#52
post #46

I am a bit confused about the KMS advice. KMS makes sense for encryption of data in cloud, since the companies already have access to data. It’s usually an additional layer of access control, monitoring and compliance. But it seems a bad practice to have an external company create and manage cryptographic keys, and/or manage encryption of on-premise or personal data (like encrypting your backups with an AWS KMS key,…

I also am confused somewhat here. With KMS, if you need to encrypt larger payloads, KMS itself is of no help except to generate a data key to use and you are left to either use AwsCrypto, or roll your own encryption using the data key which itself is encrypted by AWS KMS. If you happen to be using a language that does not have a port of the AwsCrypto library I am unclear if say AES CBC is okay or not.

If you are able to use AwsCrypto with KMS, I am assuming that is the recommended pathway as that is the default that AWS provides and I am hoping that AWS has thought it through enough to have a sensible default.

Re: Cryptographic Best Practices

#53

I’m not crazy about this guide to be honest. For symmetric encryption, if you’re recommending Salsa20/ChaCha20, it is absolutely necessary to discuss nonce management, since this is a major footgun people coming from AES may not be familiar with. You should always use the extended nonce variants of these algorithms (XSalsa20/XChaCha20) if possible, with a random nonce for every message. If not, you will have to be ce…

This is a fork of tptacek's 2015's Cryptographic Right Answers Gist [1]. I think the original 2015 file is somewhat better than this fork. The fork is more up-to-date, but just offers too many options and is probably to confusing for a beginner. As far as I know, the latest "official" update to Cryptographic Right Answers is the Latacora blog post from 2018 [2]. Both the the 2015 version of Right Answers and the OP b…

> monocypher does not seem to offer an asymmetric encryption primitive.

Neither do NaCl and Libsodium. Their `crypto_box()` is a construction that does key exchange, derives a key from the resulting key exchange, and finally use that key to perform symmetric authenticated encryption. I simply omitted that particular construction for Monocypher.

I've often asked be why. My reason is that the NaCl libraries (all 3 of them) are low-level, and a straightforward application of `crypto_box()` lacks the security properties we've now come to expect of modern key exchanges, most notably forward secrecy. To get up to that level would require implementing Noise, and I personally feel that's a tad out of scope. I reckon however that higher-level libraries that implement full protocols however are sorely needed.

Post reply on HN