Skip to content

Commit 1646a71

Browse files
committed
Move PublicKeyData impl for KeyPair closer to inherent impl
1 parent 08a37f5 commit 1646a71

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

rcgen/src/key_pair.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,24 @@ impl KeyPair {
514514
}
515515
}
516516

517+
impl PublicKeyData for KeyPair {
518+
fn der_bytes(&self) -> &[u8] {
519+
match &self.kind {
520+
#[cfg(feature = "crypto")]
521+
KeyPairKind::Ec(kp) => kp.public_key().as_ref(),
522+
#[cfg(feature = "crypto")]
523+
KeyPairKind::Ed(kp) => kp.public_key().as_ref(),
524+
#[cfg(feature = "crypto")]
525+
KeyPairKind::Rsa(kp, _) => kp.public_key().as_ref(),
526+
KeyPairKind::Remote(kp) => kp.public_key(),
527+
}
528+
}
529+
530+
fn algorithm(&self) -> &SignatureAlgorithm {
531+
self.alg
532+
}
533+
}
534+
517535
#[cfg(feature = "crypto")]
518536
impl TryFrom<&[u8]> for KeyPair {
519537
type Error = Error;
@@ -636,24 +654,6 @@ pub enum RsaKeySize {
636654
_4096,
637655
}
638656

639-
impl PublicKeyData for KeyPair {
640-
fn der_bytes(&self) -> &[u8] {
641-
match &self.kind {
642-
#[cfg(feature = "crypto")]
643-
KeyPairKind::Ec(kp) => kp.public_key().as_ref(),
644-
#[cfg(feature = "crypto")]
645-
KeyPairKind::Ed(kp) => kp.public_key().as_ref(),
646-
#[cfg(feature = "crypto")]
647-
KeyPairKind::Rsa(kp, _) => kp.public_key().as_ref(),
648-
KeyPairKind::Remote(kp) => kp.public_key(),
649-
}
650-
}
651-
652-
fn algorithm(&self) -> &SignatureAlgorithm {
653-
self.alg
654-
}
655-
}
656-
657657
/// A key that can be used to sign messages
658658
///
659659
/// Trait objects based on this trait can be passed to the [`KeyPair::from_remote`] function for generating certificates

0 commit comments

Comments
 (0)