@@ -514,6 +514,24 @@ impl KeyPair {
514
514
}
515
515
}
516
516
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
+
517
535
#[ cfg( feature = "crypto" ) ]
518
536
impl TryFrom < & [ u8 ] > for KeyPair {
519
537
type Error = Error ;
@@ -636,24 +654,6 @@ pub enum RsaKeySize {
636
654
_4096,
637
655
}
638
656
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
-
657
657
/// A key that can be used to sign messages
658
658
///
659
659
/// Trait objects based on this trait can be passed to the [`KeyPair::from_remote`] function for generating certificates
0 commit comments