x448: initial import#1250
Conversation
48849e0 to
c67e30d
Compare
c67e30d to
8675b5f
Compare
|
This kind of broke when we merged #1284 cc @daxpedda I'm confused. I don't understand how https://www.rfc-editor.org/rfc/rfc7748#section-5 asks for the scalar to be a 56-bytes string and now the Am I supposed to use the |
|
Apologies, I noticed indeed that this should have been Feel free to fix this in this PR. |
|
No worries, I'm not sure I'm following what you're saying, I guess I'll wait for your PR ^^ |
89ee8ef to
2280752
Compare
2280752 to
7368a67
Compare
875180d to
f8cd31a
Compare
|
I have a new and improved PR up for |
42c40da to
9138194
Compare
|
@baloo is there a specific reason this is still draft? It'd be good to get it landed so we make sure it gets updated when |
36aa271 to
87d027d
Compare
I struggled for a bit with various I'll keep rebasing and testing along with the merges until we can get this out of draft :) |
a9bb6e9 to
0c69dd6
Compare
|
I guess the scalar wasn't that hard to figure out in the end. I've sent a PR over to @daxpedda 's branch to migrate over to |
0c69dd6 to
7f10832
Compare
7f10832 to
254c30a
Compare
|
Is there anything else required here? |
All of the original authors have agreed to make this change
254c30a to
15dd588
Compare
tarcieri
left a comment
There was a problem hiding this comment.
Since this has been dragging on for awhile, I'm going to go ahead and merge it, but I have a few notes on the API I'll leave afterward and maybe we can make some followup changes.
| /// Performs a Diffie-hellman key exchange between the secret key and an external public key | ||
| pub fn as_diffie_hellman(&self, public_key: &PublicKey) -> Option<SharedSecret> { | ||
| // Check if the point is one of the low order points | ||
| if public_key.0.is_low_order() { | ||
| return None; | ||
| } | ||
| let shared_key = &public_key.0 * &self.as_scalar(); | ||
| Some(SharedSecret(shared_key)) | ||
| } | ||
|
|
||
| /// Performs a Diffie-hellman key exchange once between the secret key and an external public key | ||
| pub fn to_diffie_hellman(self, public_key: &PublicKey) -> Option<SharedSecret> { | ||
| self.as_diffie_hellman(public_key) | ||
| } |
There was a problem hiding this comment.
This doesn't seem like a helpful distinction. I think we should just have the borrowing version. Even for ephemeral D-H keys, there are valid reasons to perform more than one D-H operation (i.e. 3DH)
| // First check if we have 56 bytes | ||
| if bytes.len() != 56 { | ||
| return None; | ||
| } | ||
|
|
||
| let secret = Secret::from(slice_to_array(bytes)); | ||
| Some(secret) |
There was a problem hiding this comment.
Seems like this could use TryFrom
| /// Converts a secret into a byte array | ||
| pub fn as_bytes(&self) -> &[u8; 56] { | ||
| &self.0 | ||
| } |
There was a problem hiding this comment.
We should probably have different types for ephemeral vs static secrets ala x25519-dalek. For ephemeral secrets ideally the caller couldn't export this value (for forward secrecy).
This imports https://crates.io/crates/x448 in https://github.com/RustCrypto/elliptic-curves/