-
Notifications
You must be signed in to change notification settings - Fork 32
Post-Quantum Cryptography #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
5c1ccde
e636dcf
2984834
1256243
3d2613c
ae56508
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,12 +6,12 @@ use serde::{de::Visitor, ser::SerializeMap, Deserialize, Serialize}; | |
| use zeroize::Zeroize; | ||
|
|
||
| pub use crate::Bytes; | ||
| use crate::{ | ||
| config::{MAX_KEY_MATERIAL_LENGTH, MAX_SERIALIZED_KEY_LENGTH}, | ||
| Error, | ||
| }; | ||
| use crate::Error; | ||
| use trussed_core::config::MAX_SERIALIZED_KEY_LENGTH; | ||
|
|
||
| pub type Material = Vec<u8, { MAX_KEY_MATERIAL_LENGTH }>; | ||
| // Keys are often stored in serialized format (e.g. PKCS#8 used by the RSA backend), | ||
| // so material max length must be serialized max length. | ||
| pub type Material = Vec<u8, { MAX_SERIALIZED_KEY_LENGTH }>; | ||
|
Comment on lines
+12
to
+14
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be changed, max
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There seems to be an issue with the
Among others. I've tried to dig into this, but given that the mismatch for the last example is between 7519 bytes and 7523 bytes, which correspond to the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that looks like the issue of using type aliases instead of newtypes, which means that there doesn't need to be explicit conversions between types. I'm looking into it. |
||
| pub type SerializedKeyBytes = Vec<u8, { MAX_SERIALIZED_KEY_LENGTH }>; | ||
|
|
||
| // We don't implement serde to make sure nobody inadvertently still uses it | ||
|
|
@@ -77,6 +77,13 @@ pub enum Kind { | |
| BrainpoolP512R1, | ||
| X255, | ||
| Secp256k1, | ||
| // Post-quantum cryptography algorithms | ||
| #[cfg(feature = "mldsa44")] | ||
| Mldsa44, | ||
| #[cfg(feature = "mldsa65")] | ||
| Mldsa65, | ||
| #[cfg(feature = "mldsa87")] | ||
| Mldsa87, | ||
| } | ||
|
|
||
| bitflags::bitflags! { | ||
|
|
@@ -223,6 +230,12 @@ impl Kind { | |
| Kind::BrainpoolP384R1 => 13, | ||
| Kind::BrainpoolP512R1 => 14, | ||
| Kind::Secp256k1 => 15, | ||
| #[cfg(feature = "mldsa44")] | ||
| Kind::Mldsa44 => 16, | ||
| #[cfg(feature = "mldsa65")] | ||
| Kind::Mldsa65 => 17, | ||
| #[cfg(feature = "mldsa87")] | ||
| Kind::Mldsa87 => 18, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -243,6 +256,12 @@ impl Kind { | |
| 13 => Kind::BrainpoolP384R1, | ||
| 14 => Kind::BrainpoolP512R1, | ||
| 15 => Kind::Secp256k1, | ||
| #[cfg(feature = "mldsa44")] | ||
| 16 => Kind::Mldsa44, | ||
| #[cfg(feature = "mldsa65")] | ||
| 17 => Kind::Mldsa65, | ||
| #[cfg(feature = "mldsa87")] | ||
| 18 => Kind::Mldsa87, | ||
| _ => return Err(Error::InvalidSerializedKey), | ||
| }) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,13 @@ use littlefs2_core::{path, PathBuf}; | |
| use rand_chacha::ChaCha8Rng; | ||
|
|
||
| use crate::{ | ||
| config::MAX_KEY_MATERIAL_LENGTH, | ||
| error::{Error, Result}, | ||
| key, | ||
| store::{self, Store}, | ||
| types::{KeyId, Location}, | ||
| Bytes, | ||
| }; | ||
| use trussed_core::config::MAX_SERIALIZED_KEY_LENGTH; | ||
|
|
||
| pub type ClientId = PathBuf; | ||
|
|
||
|
|
@@ -181,7 +181,7 @@ impl<S: Store> Keystore for ClientKeystore<S> { | |
|
|
||
| let location = self.location(secrecy, id).ok_or(Error::NoSuchKey)?; | ||
|
|
||
| let bytes: Bytes<{ MAX_KEY_MATERIAL_LENGTH }> = store::read(&self.store, location, &path)?; | ||
| let bytes: Bytes<{ MAX_SERIALIZED_KEY_LENGTH }> = store::read(&self.store, location, &path)?; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
|
|
||
| let key = key::Key::try_deserialize(&bytes)?; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.