aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2015-06-27 15:23:19 -0700
committerSteven Fackler <[email protected]>2015-06-27 15:23:19 -0700
commitcb7248d8cb1596f48cb916fe36aa3be2d7b91164 (patch)
tree5c69f04f545822e118b3a2f471d82c826207df6a
parentMove macro replicas into C shim (diff)
downloadrust-openssl-cb7248d8cb1596f48cb916fe36aa3be2d7b91164.tar.xz
rust-openssl-cb7248d8cb1596f48cb916fe36aa3be2d7b91164.zip
Import shim'd HMAC stuff with the original name
-rw-r--r--openssl-sys/src/lib.rs10
-rw-r--r--openssl/src/crypto/hmac.rs18
2 files changed, 19 insertions, 9 deletions
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs
index ce8e6e37..20185e5a 100644
--- a/openssl-sys/src/lib.rs
+++ b/openssl-sys/src/lib.rs
@@ -415,10 +415,20 @@ extern "C" {
pub fn HMAC_CTX_copy(dst: *mut HMAC_CTX, src: *const HMAC_CTX) -> c_int;
// Pre-1.0 versions of these didn't return anything, so the shims bridge that gap
+ #[cfg_attr(not(target_os = "nacl"), link_name = "HMAC_Init_ex_shim")]
+ pub fn HMAC_Init_ex(ctx: *mut HMAC_CTX, key: *const u8, keylen: c_int, md: *const EVP_MD, imple: *const ENGINE) -> c_int;
+ #[cfg_attr(not(target_os = "nacl"), link_name = "HMAC_Final_shim")]
+ pub fn HMAC_Final(ctx: *mut HMAC_CTX, output: *mut u8, len: *mut c_uint) -> c_int;
+ #[cfg_attr(not(target_os = "nacl"), link_name = "HMAC_Update_shim")]
+ pub fn HMAC_Update(ctx: *mut HMAC_CTX, input: *const u8, len: c_uint) -> c_int;
+
+ /// Deprecated - use the non "_shim" version
#[cfg_attr(target_os = "nacl", link_name = "HMAC_Init_ex")]
pub fn HMAC_Init_ex_shim(ctx: *mut HMAC_CTX, key: *const u8, keylen: c_int, md: *const EVP_MD, imple: *const ENGINE) -> c_int;
+ /// Deprecated - use the non "_shim" version
#[cfg_attr(target_os = "nacl", link_name = "HMAC_Final")]
pub fn HMAC_Final_shim(ctx: *mut HMAC_CTX, output: *mut u8, len: *mut c_uint) -> c_int;
+ /// Deprecated - use the non "_shim" version
#[cfg_attr(target_os = "nacl", link_name = "HMAC_Update")]
pub fn HMAC_Update_shim(ctx: *mut HMAC_CTX, input: *const u8, len: c_uint) -> c_int;
diff --git a/openssl/src/crypto/hmac.rs b/openssl/src/crypto/hmac.rs
index a59cb929..5c9f7576 100644
--- a/openssl/src/crypto/hmac.rs
+++ b/openssl/src/crypto/hmac.rs
@@ -88,9 +88,9 @@ impl HMAC {
#[inline]
fn init_once(&mut self, md: *const ffi::EVP_MD, key: &[u8]) {
unsafe {
- let r = ffi::HMAC_Init_ex_shim(&mut self.ctx,
- key.as_ptr(), key.len() as c_int,
- md, 0 as *const _);
+ let r = ffi::HMAC_Init_ex(&mut self.ctx,
+ key.as_ptr(), key.len() as c_int,
+ md, 0 as *const _);
assert_eq!(r, 1);
}
self.state = Reset;
@@ -106,9 +106,9 @@ impl HMAC {
// If the key and/or md is not supplied it's reused from the last time
// avoiding redundant initializations
unsafe {
- let r = ffi::HMAC_Init_ex_shim(&mut self.ctx,
- 0 as *const _, 0,
- 0 as *const _, 0 as *const _);
+ let r = ffi::HMAC_Init_ex(&mut self.ctx,
+ 0 as *const _, 0,
+ 0 as *const _, 0 as *const _);
assert_eq!(r, 1);
}
self.state = Reset;
@@ -120,7 +120,7 @@ impl HMAC {
self.init();
}
unsafe {
- let r = ffi::HMAC_Update_shim(&mut self.ctx, data.as_ptr(), data.len() as c_uint);
+ let r = ffi::HMAC_Update(&mut self.ctx, data.as_ptr(), data.len() as c_uint);
assert_eq!(r, 1);
}
self.state = Updated;
@@ -135,7 +135,7 @@ impl HMAC {
let mut res: Vec<u8> = repeat(0).take(md_len).collect();
unsafe {
let mut len = 0;
- let r = ffi::HMAC_Final_shim(&mut self.ctx, res.as_mut_ptr(), &mut len);
+ let r = ffi::HMAC_Final(&mut self.ctx, res.as_mut_ptr(), &mut len);
self.state = Finalized;
assert_eq!(len as usize, md_len);
assert_eq!(r, 1);
@@ -181,7 +181,7 @@ impl Drop for HMAC {
if self.state != Finalized {
let mut buf: Vec<u8> = repeat(0).take(self.type_.md_len()).collect();
let mut len = 0;
- ffi::HMAC_Final_shim(&mut self.ctx, buf.as_mut_ptr(), &mut len);
+ ffi::HMAC_Final(&mut self.ctx, buf.as_mut_ptr(), &mut len);
}
ffi::HMAC_CTX_cleanup(&mut self.ctx);
}