Skip to content

Introduce API to parse PEM keys in a simpler way#1305

Open
DoumanAsh wants to merge 1 commit into
RustCrypto:masterfrom
DoumanAsh:introduce_generic_pem_parse
Open

Introduce API to parse PEM keys in a simpler way#1305
DoumanAsh wants to merge 1 commit into
RustCrypto:masterfrom
DoumanAsh:introduce_generic_pem_parse

Conversation

@DoumanAsh
Copy link
Copy Markdown

As per idea from RustCrypto/elliptic-curves#1733 (comment)

There is too many micro dependencies between each other but...
I cooked up SigningKey::from_pem method that parses PEM content depending on label as simple as possible
At the end of the day it requires pem, der and optionally pkcs8 with alloc
I initially thought sec1 lives on its own, but right now it seems to be Interleaved with pkcs8 so I could make it required feature instead since there is not much benefit in having code path for builds that don't have pkcs8 with alloc

@tarcieri
Copy link
Copy Markdown
Member

This should probably go in elliptic-curve and be defined on SecretKey, then ecdsa can delegate to that

@DoumanAsh
Copy link
Copy Markdown
Author

Created PR
RustCrypto/traits#2387

I see that it prefers to hide error meaning, but for now I think this case would benefit from having proper error to indicate what exactly is wrong, but let me know if I need to hide error anyway

tarcieri added a commit to RustCrypto/traits that referenced this pull request Apr 16, 2026
As suggested in RustCrypto/signatures#1305
created API to decode SecretKey from variety of PEM encodings

---------

Co-authored-by: Tony Arcieri <bascule@gmail.com>
@tarcieri
Copy link
Copy Markdown
Member

@DoumanAsh can you update this PR to delegate to the API added to elliptic-curve?

@DoumanAsh
Copy link
Copy Markdown
Author

Thanks for reminder, I will rebase PR and update it to use new method

@DoumanAsh DoumanAsh force-pushed the introduce_generic_pem_parse branch 2 times, most recently from b380788 to c37407a Compare May 11, 2026 04:09
@DoumanAsh DoumanAsh force-pushed the introduce_generic_pem_parse branch from c37407a to 36f2805 Compare May 11, 2026 04:11
@DoumanAsh
Copy link
Copy Markdown
Author

@tarcieri I rebased and implemented from_pem method using new API
I hid error from public API via generic for now but didn't add any tests since it just delegates to underlying API of SecretKey

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.

2 participants