Skip to content

Conversation

datdenkikniet
Copy link

@datdenkikniet datdenkikniet commented Aug 24, 2025

Fixes #1960, supersedes #1962

I've tried my best to dig into the associated parts here, and it seems that the der::Document encoding used as intermediate step is the culprit.

Sadly I don't have enough insight to validate my TODO's. Will leave separate comments on those that I hope RustCrypto maintainers have better answers to.

@@ -436,6 +458,7 @@ where
let public_key_bytes = self.to_encoded_point(false);
let subject_public_key = der::asn1::BitStringRef::new(0, public_key_bytes.as_bytes())?;

// TODO: use `encode_as_der` here?
Copy link
Author

@datdenkikniet datdenkikniet Aug 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using encode_as_der seemed like a hassle here. Is there a better approach than encode_as_der followed directly by Document::decode().unwrap()?

Also suffers from the encoding length question, and this specific conversion will require alloc anyways (because der::Document contains a Vec<u8>)

@@ -483,7 +506,11 @@ where
where
S: ser::Serializer,
{
let der = self.to_public_key_der().map_err(ser::Error::custom)?;
// TODO: can we determine DER encoding length up-front? Using `MockCurve` gives
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to collect this information from some associated const? Was hard to figure out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Does elliptic-curve with only the serde feature enabled still require alloc?
1 participant