Commit 8b60d4a3 authored by Steven Fackler's avatar Steven Fackler
Browse files

Return Option from group

parent e58dda89
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -238,11 +238,14 @@ impl EcKeyRef {
    private_key_to_pem!(ffi::PEM_write_bio_ECPrivateKey);
    private_key_to_der!(ffi::i2d_ECPrivateKey);

    pub fn group(&self) -> &EcGroupRef {
    pub fn group(&self) -> Option<&EcGroupRef> {
        unsafe {
            let ptr = ffi::EC_KEY_get0_group(self.as_ptr());
            assert!(!ptr.is_null());
            EcGroupRef::from_ptr(ptr as *mut _)
            if ptr.is_null() {
                None
            } else {
                Some(EcGroupRef::from_ptr(ptr as *mut _))
            }
        }
    }