Skip to content

Commit 98ed2ca

Browse files
committed
Add convenience method for private -> public
The existing support through `impl AsRef<RsaPublicKey> for RsaPrivateKey` was initially difficult to find.
1 parent 7ae85c1 commit 98ed2ca

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/key.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,13 @@ impl RsaPrivateKey {
465465
Self::from_components(n.get(), public_exponent, d, primes)
466466
}
467467

468+
/// Get the public key from the private key.
469+
///
470+
/// Specific alternative to [`AsRef::as_ref`].
471+
pub fn as_public_key(&self) -> &RsaPublicKey {
472+
&self.pubkey_components
473+
}
474+
468475
/// Get the public key from the private key, cloning `n` and `e`.
469476
///
470477
/// Generally this is not needed since `RsaPrivateKey` implements the `PublicKey` trait,

0 commit comments

Comments
 (0)