Grey Area

🔒 Manual approval

@greyarea@mitra.vpclmulqdq.moe · Joined ⁨Aug⁩ ⁨2023⁩

脳を焼かれた独立傭兵
荒事と情報戦
Applied Cryptography/System Programming
You are cordially invited to a night at the opera.

Replying to @⁨silverpill@mitra.social⁩

@silverpill

With NIKE (Non-Interactive-Key-Exchange) one sided forward secrecy is the best you can get. AFAIK the fediverse model strongly favors 0-RTT messaging, so I think the FEP as designed is close to ideal, as something simple that fits the use-case.

I will be the first to admit that my knowledge in the protocol is severely lacking, but if you have cryptography related questions, please let me know.

Replying to @⁨greyarea@mitra.vpclmulqdq.moe⁩

@silverpill

Think 5.1.3 (AuthEncap) is better since it still uses an ephemeral key, but does an extra DH to authenticate the sender. 5.1.1 (Encap) is simpler, but unless the aad contains at least the sender's identity, there is nothing preventing someone from extracting a ciphertext, and re-signing it (forging the origin).

Having a trivial amount of AAD is computationally cheaper than doing the extra DH, but the extra DH would be sub 100 usec, so this is "pick something to taste".

ps: Spent the day chasing LLVM bugs, errors in this would be all mine.

Replying to @⁨silverpill@mitra.social⁩

@silverpill

Ah , mea culpa, you're right. 5.1.1 avoids the nonce reuse issue and provides imperfect forward secrecy. I've been fighting u-boot on "new" exotic target the last day so my thinking isn't as sharp as it should be.

Replies should go through the same process (avoids sender having to store the shared secret, less state is more better in this case).

Replying to @⁨silverpill@mitra.social⁩

@silverpill

No, the recipient would also generates an ephemeral key, and uses that when replying.

So it's always a one shot ephemeral (sender)/static (recipient) HPKE exchange, with sender authenticity guaranteed by the signature. Could also use the shared secret from the original post but force a different IV, but "replies are just the sender and receiver being flipped, code path is the same" is easier.

Replying to @⁨silverpill@mitra.social⁩

@silverpill

Of an envelope. If actor being changed mid-transit isn't a problem, then omit it from the aad. Including the from/to as part of the AAD binds the ciphertext to the origin/recipient (the HPKE ciphertext does not carry any of this information).

It is worth noting that, as the FEP is specified now, using the sender and recipient's keypairs to do HPKE will result in the same shared secret being generated for every message. This is catastrophic to security as the nonce for the symmetric portion of the HPKE encryption is deterministic (RFC 9180 5.1).

This can be avoided by either: having the sender generate an ephemeral keypair (include the public key envelope), or using a unique HPKE info per envelope. The former is better as it gives imperfect forward secrecy (sender identity key compromise does not reveal past plaintexts), the latter is cheaper to do.

Replying to @⁨silverpill@mitra.social⁩

@silverpill

The primitive choices are sensible.

The "aad" is sent in the clear (or just public as it is now) so you could do something like "fep-0806-aad" | ':' | <id> | ':' | <actor> |':' | <to>. If the proof covers all of that then it's not strictly needed, but it's cheap paranoia.

I was going to say add version info to the labels, but fep0806:cipherAlgorithm covers that.

Replying to @⁨silverpill@mitra.social⁩

@silverpill @raucao @lain @sozialwelten @koteisaev

WhatsApp.

It's biggest claim to fame is non-group messaging (WireGuard), and the fact that the designer based it on the Signal wire protocol design (same person). The latter research that adds concrete security proofs is an added bonus, as well as decent library availability.

But, there's only so many ways to do NIKE (Non-Interactive Key Exchange), and the IETF/IRTF has a preference for reusing their own standards.

TLDR: Noise over HPKE is a personal preference, I think it's harder to blow your foot off with Noise and it's easier to implement (having done multiple Noise impls, and dealt with HPKE more than I should), but honestly either is a reasonable choice, and if you want something more standardized, HPKE is reasonable.

Replying to @⁨silverpill@mitra.social⁩

@silverpill @raucao @lain @sozialwelten @koteisaev

HPKE has the benefit of being standardized, and imperfect forward secrecy is the best you can do with 0-RTT (which probably fits the fediverse model better).

Just be very careful about the "use correctly" and it's "fine". I'm partial to Noise (https://noiseprotocol.org/) for these sort of use cases because it has less foot+guns and there's more flexibility, but I wouldn't freak out or scream if I saw HPKE in use.

As a side note, it is indeed safe to convert ed25519 keys to X25519 keys assuming a common sense step is taken when using the latter (https://eprint.iacr.org/2021/509).

noiseprotocol.orgNoise Protocol Framework

Replying to @⁨silverpill@mitra.social⁩

@silverpill @raucao @lain @sozialwelten @koteisaev

Sorry for the delayed response, but yes.

The naive approach would be:

- Convert both party's Ed25519 keys to X25519 keys
- ECDH(Sender static, Recipient static) -> k
- HKDF(k) -> Shared secret

The problem with this approach is that, if either side's private key gets compromised, all historical traffic is trivially decryptable. (Static-Static ECDH)

Perfect forward secrecy (compromise of either key does not give attacker the ability to read past messages) requires at least one extra round trip, which is not great in this setting.

The tweak I suggested is:

- Convert both party's Ed25519 keys to X25519 keys
- Sender generates a ephemeral (throw away) X25519 key
- ECDH(Sender static, Recipient static) -> k_1
- ECDH(Sender ephemeral, Recipient static) -> k_2
- HKDF(k_1 | k_2) -> Shared secret
- Sender discards the ephemeral key

With this improvement, sender long term key compromise does not allow decryption of past traffic, because the ephemeral keypair is long gone into the void (one-way forward secrecy, Static-Static + Ephemeral-Static ECDH).

Note: While the theoretical safety of reusing a Ed25519 key for also doing X25519 was an open question, there are proofs that it is safe.