Skip to content

security: zeroize pem encoded key#504

Open
boxdot wants to merge 2 commits intoKeats:masterfrom
boxdot:zeroize-pem-key
Open

security: zeroize pem encoded key#504
boxdot wants to merge 2 commits intoKeats:masterfrom
boxdot:zeroize-pem-key

Conversation

@boxdot
Copy link
Copy Markdown
Contributor

@boxdot boxdot commented Apr 18, 2026

PemEncodedKey is now zeroized and no longer contains ASN.1 parsed
data. Because Vec<simple_asn1::ASN1Block> owns the underlying bytes
and does not support zeroization, the full ASN.1 parsing has been
replaced by a custom partial ASN.1 implementation. This parsing is
performed only to classify the key type during construction and to
extract the key bytes on access.

This change also allows the removal of the simple_asn1 dependency.

Closes #337 after #483 is merged.

@boxdot
Copy link
Copy Markdown
Contributor Author

boxdot commented Apr 18, 2026

I had quite some fun while implementing this, especially recalling the TLV encoding and writing a custom recursive parser.

@arckoor arckoor self-requested a review April 18, 2026 19:57
`PemEncodedKey` is now zeroized and no longer contains ASN.1 parsed
data. Because `Vec<simple_asn1::ASN1Block>` owns the underlying bytes
and does not support zeroization, the full ASN.1 parsing has been
replaced by a custom partial ASN.1 implementation. This parsing is
performed only to classify the key type during construction and to
extract the key bytes on access.

This change also allows the removal of the `simple_asn1` dependency.
@arckoor
Copy link
Copy Markdown
Collaborator

arckoor commented Apr 18, 2026

This will likely take me a while to review, my ASN.1 skills are rusty at best
For at least one of the keys I'd also like to see a test that directly compares the parsed point to the expected value (i.e. you manually extract them with your cryptographic library of choice, openssl, botan, ... and compare to that)
Some comments to relevant RFCs would also be helpful
May also want to throw a fuzzer at this, though that would be something to consider in general for this library
As a convenient side benefit, by no longer depending on simple_asn1 it would allow dropping the MSRV back down 🤔

@boxdot
Copy link
Copy Markdown
Contributor Author

boxdot commented Apr 18, 2026

Let me

  • add comments about parsing (e.g. RFCs), and
  • make tests less fuzzy

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.

Adding secrecy or zeroize for EncodingKey and DecodingKey

2 participants