Copy over getter macros

This commit is contained in:
Steven Fackler 2016-08-08 20:37:48 -07:00
parent bf07dd9a4e
commit 522447378e
3 changed files with 18 additions and 6 deletions

View File

@ -600,6 +600,18 @@ pub unsafe fn SSL_set_tlsext_host_name(s: *mut SSL, name: *mut c_char) -> c_long
SSL_ctrl(s, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, name as *mut c_void) SSL_ctrl(s, SSL_CTRL_SET_TLSEXT_HOSTNAME, TLSEXT_NAMETYPE_host_name, name as *mut c_void)
} }
pub unsafe fn EVP_CIPHER_block_size(e: *const EVP_CIPHER) -> c_int {
(*e).block_size
}
pub unsafe fn EVP_CIPHER_key_length(e: *const EVP_CIPHER) -> c_int {
(*e).key_len
}
pub unsafe fn EVP_CIPHER_iv_length(e: *const EVP_CIPHER) -> c_int {
(*e).iv_len
}
// True functions // True functions
extern "C" { extern "C" {
pub fn ASN1_INTEGER_set(dest: *mut ASN1_INTEGER, value: c_long) -> c_int; pub fn ASN1_INTEGER_set(dest: *mut ASN1_INTEGER, value: c_long) -> c_int;

View File

@ -17,11 +17,11 @@ pub struct KeyIvPair {
/// ///
/// If specified `salt` must be 8 bytes in length. /// If specified `salt` must be 8 bytes in length.
/// ///
/// If the total key and IV length is less than 16 bytes and MD5 is used then /// If the total key and IV length is less than 16 bytes and MD5 is used then
/// the algorithm is compatible with the key derivation algorithm from PKCS#5 /// the algorithm is compatible with the key derivation algorithm from PKCS#5
/// v1.5 or PBKDF1 from PKCS#5 v2.0. /// v1.5 or PBKDF1 from PKCS#5 v2.0.
/// ///
/// New applications should not use this and instead use `pbkdf2_hmac_sha1` or /// New applications should not use this and instead use `pbkdf2_hmac_sha1` or
/// another more modern key derivation algorithm. /// another more modern key derivation algorithm.
pub fn evp_bytes_to_key_pbkdf1_compatible(typ: symm::Type, pub fn evp_bytes_to_key_pbkdf1_compatible(typ: symm::Type,
message_digest_type: hash::Type, message_digest_type: hash::Type,

View File

@ -79,7 +79,7 @@ impl Type {
/// Returns the length of keys used with this cipher. /// Returns the length of keys used with this cipher.
pub fn key_len(&self) -> usize { pub fn key_len(&self) -> usize {
unsafe { unsafe {
(*self.as_ptr()).key_len as usize ffi::EVP_CIPHER_key_length(self.as_ptr()) as usize
} }
} }
@ -87,7 +87,7 @@ impl Type {
/// cipher does not use an IV. /// cipher does not use an IV.
pub fn iv_len(&self) -> Option<usize> { pub fn iv_len(&self) -> Option<usize> {
unsafe { unsafe {
let len = (*self.as_ptr()).iv_len as usize; let len = ffi::EVP_CIPHER_iv_length(self.as_ptr()) as usize;
if len == 0 { if len == 0 {
None None
} else { } else {
@ -103,7 +103,7 @@ impl Type {
/// Stream ciphers such as RC4 have a block size of 1. /// Stream ciphers such as RC4 have a block size of 1.
pub fn block_size(&self) -> usize { pub fn block_size(&self) -> usize {
unsafe { unsafe {
(*self.as_ptr()).block_size as usize ffi::EVP_CIPHER_block_size(self.as_ptr()) as usize
} }
} }
} }