aboutsummaryrefslogtreecommitdiff
path: root/pkcs5.rs
diff options
context:
space:
mode:
authorErick Tryzelaar <[email protected]>2013-12-18 07:30:16 -0800
committerErick Tryzelaar <[email protected]>2013-12-18 07:30:16 -0800
commit4e0257ab5991eaa6863d261f97dcf6ff8e6b7545 (patch)
treed58c184dae0040a0afbf9f4b8e8eb83e72cef314 /pkcs5.rs
parentIntegrate with Travis (diff)
parentUpdate for latest rustc (0.9-pre ca54ad8) (diff)
downloadrust-openssl-4e0257ab5991eaa6863d261f97dcf6ff8e6b7545.tar.xz
rust-openssl-4e0257ab5991eaa6863d261f97dcf6ff8e6b7545.zip
Merge branch 'master' of https://github.com/kballard/rustcrypto
Diffstat (limited to 'pkcs5.rs')
-rw-r--r--pkcs5.rs26
1 files changed, 12 insertions, 14 deletions
diff --git a/pkcs5.rs b/pkcs5.rs
index 400d3207..b7c83a3f 100644
--- a/pkcs5.rs
+++ b/pkcs5.rs
@@ -4,28 +4,26 @@ use std::vec;
mod libcrypto {
use std::libc::c_int;
- #[link_args = "-lcrypto"]
+ #[link(name = "crypto")]
extern {
- fn PKCS5_PBKDF2_HMAC_SHA1(pass: *u8, passlen: c_int,
- salt: *u8, saltlen: c_int,
- iter: c_int, keylen: c_int,
- out: *mut u8) -> c_int;
+ pub fn PKCS5_PBKDF2_HMAC_SHA1(pass: *u8, passlen: c_int,
+ salt: *u8, saltlen: c_int,
+ iter: c_int, keylen: c_int,
+ out: *mut u8) -> c_int;
}
}
-#[doc = "
-Derives a key from a password and salt using the PBKDF2-HMAC-SHA1 algorithm.
-"]
+/// Derives a key from a password and salt using the PBKDF2-HMAC-SHA1 algorithm.
pub fn pbkdf2_hmac_sha1(pass: &str, salt: &[u8], iter: uint,
keylen: uint) -> ~[u8] {
assert!(iter >= 1u);
assert!(keylen >= 1u);
- do pass.as_imm_buf |pass_buf, pass_len| {
- do salt.as_imm_buf |salt_buf, salt_len| {
+ pass.as_imm_buf(|pass_buf, pass_len| {
+ salt.as_imm_buf(|salt_buf, salt_len| {
let mut out = vec::with_capacity(keylen);
- do out.as_mut_buf |out_buf, _out_len| {
+ out.as_mut_buf(|out_buf, _out_len| {
let r = unsafe {
libcrypto::PKCS5_PBKDF2_HMAC_SHA1(
pass_buf, pass_len as c_int,
@@ -35,13 +33,13 @@ pub fn pbkdf2_hmac_sha1(pass: &str, salt: &[u8], iter: uint,
};
if r != 1 as c_int { fail!(); }
- }
+ });
unsafe { vec::raw::set_len(&mut out, keylen); }
out
- }
- }
+ })
+ })
}
#[cfg(test)]