sfackler / rust-openssl

OpenSSL bindings for Rust
1.4k stars 752 forks source link

Call EC_KEY_get_conv_form? #2305

Open jorgecarleitao opened 2 months ago

jorgecarleitao commented 2 months ago

Hi, I could not find an interface for EC_KEY_get_conv_form. Specifically, it seems that is not possible today to do something like this:

use openssl::{nid, ec, bn};

fn generate_some_bytes_from_ec() -> Result<Vec<u8>, ErrorStack> {
    let group = ec::EcGroup::from_curve_name(nid::Nid::X9_62_PRIME192V1)?;
    let key = ec::EcKey::generate(&group)?;
    key.public_key()
        .to_bytes(&group, EC_KEY_get_conv_form(&key), bn::BigNumContext::new()?.deref_mut())
}

To my understanding, the form exists in the key.