Commit 6ae47248 authored by Steven Fackler's avatar Steven Fackler
Browse files

Support HMAC PKeys and remove hmac module

parent cce1d44f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ pub const CRYPTO_LOCK: c_int = 1;

pub const EVP_MAX_MD_SIZE: c_uint = 64;
pub const EVP_PKEY_RSA: c_int = NID_rsaEncryption;
pub const EVP_PKEY_HMAC: c_int = NID_hmac;

pub const MBSTRING_ASC:  c_int = MBSTRING_FLAG | 1;
pub const MBSTRING_BMP:  c_int = MBSTRING_FLAG | 2;
@@ -119,6 +120,7 @@ pub const MBSTRING_UTF8: c_int = MBSTRING_FLAG;
pub const NID_rsaEncryption: c_int = 6;
pub const NID_ext_key_usage: c_int = 126;
pub const NID_key_usage:     c_int = 83;
pub const NID_hmac:          c_int = 855;

pub const PKCS5_SALT_LEN: c_int = 8;

@@ -515,6 +517,10 @@ extern {
    pub fn EVP_PKEY_get1_RSA(k: *mut EVP_PKEY) -> *mut RSA;
    pub fn EVP_PKEY_set1_RSA(k: *mut EVP_PKEY, r: *mut RSA) -> c_int;
    pub fn EVP_PKEY_cmp(a: *const EVP_PKEY, b: *const EVP_PKEY) -> c_int;
    pub fn EVP_PKEY_new_mac_key(type_: c_int,
                                e: *mut ENGINE,
                                key: *const c_uchar,
                                keylen: c_int) -> *mut EVP_PKEY;

    pub fn HMAC_CTX_copy(dst: *mut HMAC_CTX, src: *mut HMAC_CTX) -> c_int;

openssl/src/crypto/hmac.rs

deleted100644 → 0
+0 −565

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
mod util;
pub mod dsa;
pub mod hash;
pub mod hmac;
pub mod memcmp;
pub mod pkcs12;
pub mod pkcs5;
+13 −1
Original line number Diff line number Diff line
use libc::{c_void, c_char};
use libc::{c_void, c_char, c_int};
use std::ptr;
use std::mem;
use ffi;
@@ -26,6 +26,18 @@ impl PKey {
        }
    }

    /// Create a new `PKey` containing an HAMC key.
    pub fn hmac(key: &[u8]) -> Result<PKey, ErrorStack> {
        unsafe {
            assert!(key.len() <= c_int::max_value() as usize);
            let key = try_ssl_null!(ffi::EVP_PKEY_new_mac_key(ffi::EVP_PKEY_HMAC,
                                                              ptr::null_mut(),
                                                              key.as_ptr() as *const _,
                                                              key.len() as c_int));
            Ok(PKey(key))
        }
    }

    pub unsafe fn from_ptr(handle: *mut ffi::EVP_PKEY) -> PKey {
        PKey(handle)
    }
+74 −0

File changed.

Preview size limit exceeded, changes collapsed.