@@ -25,6 +25,9 @@ use crate::SubjectPublicKeyInfo;
2525pub trait DecodePublicKey : Sized {
2626 /// Deserialize object from ASN.1 DER-encoded [`SubjectPublicKeyInfo`]
2727 /// (binary format).
28+ ///
29+ /// # Errors
30+ /// Returns decoding errors specific to the concrete type which impls this trait.
2831 fn from_public_key_der ( bytes : & [ u8 ] ) -> Result < Self > ;
2932
3033 /// Deserialize PEM-encoded [`SubjectPublicKeyInfo`].
@@ -34,6 +37,9 @@ pub trait DecodePublicKey: Sized {
3437 /// ```text
3538 /// -----BEGIN PUBLIC KEY-----
3639 /// ```
40+ ///
41+ /// # Errors
42+ /// Returns decoding errors specific to the concrete type which impls this trait.
3743 #[ cfg( feature = "pem" ) ]
3844 fn from_public_key_pem ( s : & str ) -> Result < Self > {
3945 let ( label, doc) = Document :: from_pem ( s) ?;
@@ -43,13 +49,19 @@ pub trait DecodePublicKey: Sized {
4349
4450 /// Load public key object from an ASN.1 DER-encoded file on the local
4551 /// filesystem (binary format).
52+ ///
53+ /// # Errors
54+ /// Returns decoding errors specific to the concrete type which impls this trait.
4655 #[ cfg( feature = "std" ) ]
4756 fn read_public_key_der_file ( path : impl AsRef < Path > ) -> Result < Self > {
4857 let doc = Document :: read_der_file ( path) ?;
4958 Self :: from_public_key_der ( doc. as_bytes ( ) )
5059 }
5160
5261 /// Load public key object from a PEM-encoded file on the local filesystem.
62+ ///
63+ /// # Errors
64+ /// Returns decoding errors specific to the concrete type which impls this trait.
5365 #[ cfg( all( feature = "pem" , feature = "std" ) ) ]
5466 fn read_public_key_pem_file ( path : impl AsRef < Path > ) -> Result < Self > {
5567 let ( label, doc) = Document :: read_pem_file ( path) ?;
@@ -71,22 +83,34 @@ where
7183#[ cfg( feature = "alloc" ) ]
7284pub trait EncodePublicKey {
7385 /// Serialize a [`Document`] containing a SPKI-encoded public key.
86+ ///
87+ /// # Errors
88+ /// Returns encoding errors specific to the concrete type which impls this trait.
7489 fn to_public_key_der ( & self ) -> Result < Document > ;
7590
7691 /// Serialize this public key as PEM-encoded SPKI with the given [`LineEnding`].
92+ ///
93+ /// # Errors
94+ /// Returns encoding errors specific to the concrete type which impls this trait.
7795 #[ cfg( feature = "pem" ) ]
7896 fn to_public_key_pem ( & self , line_ending : LineEnding ) -> Result < String > {
7997 let doc = self . to_public_key_der ( ) ?;
8098 Ok ( doc. to_pem ( SubjectPublicKeyInfoRef :: PEM_LABEL , line_ending) ?)
8199 }
82100
83- /// Write ASN.1 DER-encoded public key to the given path
101+ /// Write ASN.1 DER-encoded public key to the given path.
102+ ///
103+ /// # Errors
104+ /// Returns encoding errors specific to the concrete type which impls this trait.
84105 #[ cfg( feature = "std" ) ]
85106 fn write_public_key_der_file ( & self , path : impl AsRef < Path > ) -> Result < ( ) > {
86107 Ok ( self . to_public_key_der ( ) ?. write_der_file ( path) ?)
87108 }
88109
89- /// Write ASN.1 PEM-encoded public key to the given path
110+ /// Write ASN.1 PEM-encoded public key to the given path.
111+ ///
112+ /// # Errors
113+ /// Returns encoding errors specific to the concrete type which impls this trait.
90114 #[ cfg( all( feature = "pem" , feature = "std" ) ) ]
91115 fn write_public_key_pem_file (
92116 & self ,
@@ -115,6 +139,9 @@ pub trait AssociatedAlgorithmIdentifier {
115139#[ cfg( feature = "alloc" ) ]
116140pub trait DynAssociatedAlgorithmIdentifier {
117141 /// `AlgorithmIdentifier` for this structure.
142+ ///
143+ /// # Errors
144+ /// Returns errors specific to the concrete type which impls this trait.
118145 fn algorithm_identifier ( & self ) -> Result < AlgorithmIdentifierOwned > ;
119146}
120147
@@ -135,9 +162,9 @@ where
135162 }
136163}
137164
138- /// Returns `AlgorithmIdentifier` associated with the signature system.
165+ /// Returns [ `AlgorithmIdentifier`] associated with the signature system.
139166///
140- /// Unlike AssociatedAlgorithmIdentifier this is intended to be implemented for public and/or
167+ /// Unlike [` AssociatedAlgorithmIdentifier`] this is intended to be implemented for public and/or
141168/// private keys.
142169pub trait SignatureAlgorithmIdentifier {
143170 /// Algorithm parameters.
@@ -147,13 +174,16 @@ pub trait SignatureAlgorithmIdentifier {
147174 const SIGNATURE_ALGORITHM_IDENTIFIER : AlgorithmIdentifier < Self :: Params > ;
148175}
149176
150- /// Returns `AlgorithmIdentifier` associated with the signature system.
177+ /// Returns [`AlgorithmIdentifierOwned`] associated with the signature system.
151178///
152- /// Unlike AssociatedAlgorithmIdentifier this is intended to be implemented for public and/or
179+ /// Unlike [` AssociatedAlgorithmIdentifier`] this is intended to be implemented for public and/or
153180/// private keys.
154181#[ cfg( feature = "alloc" ) ]
155182pub trait DynSignatureAlgorithmIdentifier {
156183 /// `AlgorithmIdentifier` for the corresponding signature system.
184+ ///
185+ /// # Errors
186+ /// Returns errors specific to the concrete type which impls this trait.
157187 fn signature_algorithm_identifier ( & self ) -> Result < AlgorithmIdentifierOwned > ;
158188}
159189
@@ -174,11 +204,14 @@ where
174204 }
175205}
176206
177- /// Returns the `BitString` encoding of the signature.
207+ /// Returns the [ `BitString`] encoding of the signature.
178208///
179- /// X.509 and CSR structures require signatures to be BitString encoded.
209+ /// X.509 and CSR structures require signatures to be ` BitString` encoded.
180210#[ cfg( feature = "alloc" ) ]
181211pub trait SignatureBitStringEncoding {
182212 /// `BitString` encoding for this signature.
213+ ///
214+ /// # Errors
215+ /// Returns errors specific to the concrete type which impls this trait.
183216 fn to_bitstring ( & self ) -> der:: Result < BitString > ;
184217}
0 commit comments