Unverified Commit 0a0da84f authored by Steven Fackler's avatar Steven Fackler Committed by GitHub
Browse files

Merge pull request #1342 from hidekatsu-izuno/support-ecx

Add ecx (X25519, X448) support
parents 15419c24 c4cbf496
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -11,8 +11,12 @@ pub const EVP_PKEY_DSA: c_int = NID_dsa;
pub const EVP_PKEY_DH: c_int = NID_dhKeyAgreement;
pub const EVP_PKEY_EC: c_int = NID_X9_62_id_ecPublicKey;
#[cfg(ossl111)]
pub const EVP_PKEY_X25519: c_int = NID_X25519;
#[cfg(ossl111)]
pub const EVP_PKEY_ED25519: c_int = NID_ED25519;
#[cfg(ossl111)]
pub const EVP_PKEY_X448: c_int = NID_X448;
#[cfg(ossl111)]
pub const EVP_PKEY_ED448: c_int = NID_ED448;
pub const EVP_PKEY_HMAC: c_int = NID_hmac;
pub const EVP_PKEY_CMAC: c_int = NID_cmac;
+4 −0
Original line number Diff line number Diff line
@@ -913,6 +913,10 @@ pub const NID_aes_128_cbc_hmac_sha1: c_int = 916;
pub const NID_aes_192_cbc_hmac_sha1: c_int = 917;
pub const NID_aes_256_cbc_hmac_sha1: c_int = 918;
#[cfg(ossl111)]
pub const NID_X25519: c_int = 1034;
#[cfg(ossl111)]
pub const NID_X448: c_int = 1035;
#[cfg(ossl111)]
pub const NID_ED25519: c_int = 1087;
#[cfg(ossl111)]
pub const NID_ED448: c_int = 1088;
+16 −0
Original line number Diff line number Diff line
@@ -88,6 +88,10 @@ impl Id {
    pub const ED25519: Id = Id(ffi::EVP_PKEY_ED25519);
    #[cfg(ossl111)]
    pub const ED448: Id = Id(ffi::EVP_PKEY_ED448);
    #[cfg(ossl111)]
    pub const X25519: Id = Id(ffi::EVP_PKEY_X25519);
    #[cfg(ossl111)]
    pub const X448: Id = Id(ffi::EVP_PKEY_X448);

    /// Creates a `Id` from an integer representation.
    pub fn from_raw(value: c_int) -> Id {
@@ -494,6 +498,18 @@ impl PKey<Private> {
        }
    }

    /// Generates a new private Ed25519 key
    #[cfg(ossl111)]
    pub fn generate_x25519() -> Result<PKey<Private>, ErrorStack> {
        PKey::generate_eddsa(ffi::EVP_PKEY_X25519)
    }

    /// Generates a new private Ed448 key
    #[cfg(ossl111)]
    pub fn generate_x448() -> Result<PKey<Private>, ErrorStack> {
        PKey::generate_eddsa(ffi::EVP_PKEY_X448)
    }

    /// Generates a new private Ed25519 key
    #[cfg(ossl111)]
    pub fn generate_ed25519() -> Result<PKey<Private>, ErrorStack> {