File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,6 +124,33 @@ where
124124 }
125125}
126126
127+ #[ cfg( feature = "pem" ) ]
128+ impl < C > SigningKey < C >
129+ where
130+ C : EcdsaCurve + AssociatedOid + CurveArithmetic ,
131+ AffinePoint < C > : FromSec1Point < C > + ToSec1Point < C > ,
132+ FieldBytesSize < C > : sec1:: ModulusSize ,
133+ Scalar < C > : Invert < Output = CtOption < Scalar < C > > > ,
134+ SignatureSize < C > : ArraySize ,
135+ {
136+ #[ inline]
137+ /// Parse [`SigningKey`] from PEM-encoded private key.
138+ ///
139+ /// Supported formats:
140+ /// - `SEC1` - requires feature `sec1`
141+ /// - `PKCS#8` - requires feature `pkcs8`
142+ ///
143+ /// # Errors
144+ /// - If `pem` is not valid PEM encoded private key
145+ /// - If label within `pem` is not known valid label
146+ /// - If label is valid, but unable to decode DER content of the PEM file
147+ pub fn from_pem (
148+ pem : & str ,
149+ ) -> :: core:: result:: Result < Self , impl core:: error:: Error + Send + Sync + ' static > {
150+ SecretKey :: < C > :: from_pem ( pem) . map ( Into :: into)
151+ }
152+ }
153+
127154impl < C > Generate for SigningKey < C >
128155where
129156 C : EcdsaCurve + CurveArithmetic ,
You can’t perform that action at this time.
0 commit comments