Snap for 9066636 from a12920058060382d99ab4ac946563de09064e593 to gki13-boot-release
Change-Id: I81ec3b63b6240fdfbf540a5757d599ad52f6f04b
diff --git a/openssl/src/ec.rs b/openssl/src/ec.rs
index 13f8bb3..4731836 100644
--- a/openssl/src/ec.rs
+++ b/openssl/src/ec.rs
@@ -848,6 +848,26 @@
EcKey<Private>,
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<EcKey<Private>, 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<T> Clone for EcKey<T> {