Replies: 2 comments 6 replies
-
ECDH-ES is not meant, designed, or vetted to be used for public-key authenticated encryption. Adding an API to support such use of ECDH-ES doesn't seem like a good idea to me. You can see that in the docs that
Usually one would resort to a signed (JWS), then encrypted (JWE) structure. This of course increases the overhead and size of resulting messages. @NeilMadden was proposing a JWE algorithm for a public key authenticated encryption. I am not sure what state that I-D is in, if it's safe to use and interoperable, and if it's ever going to get published but it is something I may consider if there's wider library support for it in other languages. |
Beta Was this translation helpful? Give feedback.
-
Somewhat related: It might be a good idea to split the algorithm selection guide's "Authenticated Encryption" section into two separate sections:
|
Beta Was this translation helpful? Give feedback.
-
Sometimes, we want to ensure the authenticity of a message's origin without the need of a pre-shared secret. This can simply be achieved in JOSE by using asymmetric signatures. However, if signed data is leaked, a third party (the attacker) can also verify the message's authenticity, which is problematic in several use-cases (e.g. in the case of a leakage of signed bank details). Therefore, asymmetric signatures cannot be used when repudiation is a design goal. Ensuring the a message's origin can also be achieved using public-key authenticated encryption.
This library already implements symmetric-key authenticated encryption with associated data (AEAD). This guarantees authenticity in scenarios where a symmetric key has been exchanged beforehand via a secure channel and mitigates a number of attack vectors.
In contrast, public-key authenticated encryption using static-static elliptic curve Diffie-Hellman key agreement allows the receiver to verify a messages' origin (identified by their public key) without the need of a pre-shared-secret. However, it is currently not (easily) possible to achieve public-key authenticated encryption using this library.
By design, the ECDH* algorithms already authenticate messages using the sender's secret key and the receiver's public key (by performing a ECDH key agreement with these keys to derive a symmetric key which is then used for symmetric AEAD).
As per JWE specification, the sender includes its public key in the encrypted message (
epk
header). This later allows the receiver to derive the same symmetric key by performing a ECDH key agreement with the sender's public key and the reiceiver's private key.In order to achieve public-key authenticated encryption, it would be great if this library provided an easy way to validate that the sender's public key matches the key from the
epk
header. This could easily implemented by users of the library by manually comparing these two keys. However, this requires a lot of expert knowledge on how asymmetric AEAD works.The NaCl library provides a nice "box" interface that encourages/enforces to implicitly check the sender's public key: https://nacl.cr.yp.to/box.html
Here's a shot example that shows how this could be implemented in this library, too:
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions