Skip to content

crypto: add PublicKey::LoadFromPrivateKey and tests#1218

Open
crystarm wants to merge 1 commit intouserver-framework:developfrom
crystarm:feature/crypto-public-key-from-private
Open

crypto: add PublicKey::LoadFromPrivateKey and tests#1218
crystarm wants to merge 1 commit intouserver-framework:developfrom
crystarm:feature/crypto-public-key-from-private

Conversation

@crystarm
Copy link
Copy Markdown

This PR refers to issue #665.

Added PublicKey::LoadFromPrivateKey(const PrivateKey&) to userver::crypto to derive a public key from an already loaded private key.

Implementation is minimal and additive: it validates input, uses OpenSSL to extract/load the public key, and throws crypto::KeyParseError on failures.

Test coverage added in universal/src/crypto/public_key_test.cpp:

  1. RSA happy path (sign with private, verify with derived public)
  2. EC happy path
  3. empty PrivateKey{} -> KeyParseError

Test keys for this are reused from existing crypto tests to keep fixtures consistent: RSA key from universal/src/crypto/signature_test.cpp, EC key from universal/src/crypto/public_key_test.cpp.

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.

1 participant