Skip to content
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

simplify reading of EC keys #185

Merged

Conversation

kleinmrk
Copy link
Contributor

This MR slightly changes how EC keys are read.

Currently, both private and public keys are read (if provided), but the public key has no effect and the internally used openssl structure is overridden by the private part. Thus the public key has no effecton the final ecdsa object other than possibly throwing exceptions in the constructor.

This MR reads the keys the same way as they are read for RSA key, i.e., prefer private key if present, and completely ignore public part.

I also switched from PEM_read_bio_EC_PUBKEY to PEM_read_bio_PUBKEY, and from PEM_read_bio_ECPrivateKey to PEM_read_bio_PrivateKey. This change made it obvious that one could use the same code for reading RSA and EC keys. The functions only differ in type of errors they report, e.g., error::ecdsa_error::create_mem_bio_failed vs. error::rsa_error::create_mem_bio_failed.

@prince-chrismc
Copy link
Collaborator

prince-chrismc commented Nov 19, 2021

We should deprecate/remove the older helpers and rename them to have RSA in the name.

inline std::shared_ptr<EVP_PKEY> load_public_key_from_string(const std::string& key,

inline std::shared_ptr<EVP_PKEY> load_private_key_from_string(const std::string& key,

@prince-chrismc prince-chrismc merged commit 66eea98 into Thalhammer:master Nov 19, 2021
@kleinmrk kleinmrk deleted the simplify-loading-of-ec-keys branch November 20, 2021 22:22
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