diff --git a/src/ec.rs b/src/ec.rs index a6a6dc9..88dcaaf 100644 --- a/src/ec.rs +++ b/src/ec.rs @@ -908,6 +908,26 @@ impl EcKey { EcKey, ffi::d2i_ECPrivateKey } + + /// Decodes a DER-encoded elliptic curve private key structure for the specified curve. + #[corresponds(EC_KEY_parse_private_key)] + #[cfg(boringssl)] + pub fn private_key_from_der_for_group( + der: &[u8], + group: &EcGroupRef, + ) -> Result, ErrorStack> { + unsafe { + let mut cbs = ffi::CBS { + data: der.as_ptr(), + len: der.len(), + }; + cvt_p(ffi::EC_KEY_parse_private_key( + &mut cbs as *mut ffi::CBS, + group.as_ptr(), + )) + .map(|p| EcKey::from_ptr(p)) + } + } } impl Clone for EcKey {