Update for latest incoming (4a52ff0)
This commit is contained in:
parent
47693a5dc3
commit
c393b2bc33
8
hex.rs
8
hex.rs
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::{str,uint,vec};
|
use std::{uint,vec};
|
||||||
use std::iterator::*;
|
use std::iterator::*;
|
||||||
|
|
||||||
pub trait ToHex {
|
pub trait ToHex {
|
||||||
|
|
@ -24,7 +24,7 @@ pub trait ToHex {
|
||||||
impl<'self> ToHex for &'self [u8] {
|
impl<'self> ToHex for &'self [u8] {
|
||||||
fn to_hex(&self) -> ~str {
|
fn to_hex(&self) -> ~str {
|
||||||
|
|
||||||
let chars = str::to_chars("0123456789ABCDEF");
|
let chars = "0123456789ABCDEF".iter().collect::<~[char]>();
|
||||||
|
|
||||||
let mut s = ~"";
|
let mut s = ~"";
|
||||||
|
|
||||||
|
|
@ -35,8 +35,8 @@ impl<'self> ToHex for &'self [u8] {
|
||||||
let xhi = (x >> 4) & 0x0F;
|
let xhi = (x >> 4) & 0x0F;
|
||||||
let xlo = (x ) & 0x0F;
|
let xlo = (x ) & 0x0F;
|
||||||
|
|
||||||
str::push_char(&mut s, chars[xhi]);
|
s.push_char(chars[xhi]);
|
||||||
str::push_char(&mut s, chars[xlo]);
|
s.push_char(chars[xlo]);
|
||||||
}
|
}
|
||||||
|
|
||||||
s
|
s
|
||||||
|
|
|
||||||
13
pkcs5.rs
13
pkcs5.rs
|
|
@ -44,7 +44,6 @@ pub fn pbkdf2_hmac_sha1(pass: &str, salt: &[u8], iter: uint,
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::str;
|
|
||||||
|
|
||||||
// Test vectors from
|
// Test vectors from
|
||||||
// http://tools.ietf.org/html/draft-josefsson-pbkdf2-test-vectors-06
|
// http://tools.ietf.org/html/draft-josefsson-pbkdf2-test-vectors-06
|
||||||
|
|
@ -52,7 +51,7 @@ mod tests {
|
||||||
fn test_pbkdf2_hmac_sha1() {
|
fn test_pbkdf2_hmac_sha1() {
|
||||||
assert!(pbkdf2_hmac_sha1(
|
assert!(pbkdf2_hmac_sha1(
|
||||||
"password",
|
"password",
|
||||||
str::to_bytes("salt"),
|
"salt".as_bytes(),
|
||||||
1u,
|
1u,
|
||||||
20u
|
20u
|
||||||
) == ~[
|
) == ~[
|
||||||
|
|
@ -63,7 +62,7 @@ mod tests {
|
||||||
|
|
||||||
assert!(pbkdf2_hmac_sha1(
|
assert!(pbkdf2_hmac_sha1(
|
||||||
"password",
|
"password",
|
||||||
str::to_bytes("salt"),
|
"salt".as_bytes(),
|
||||||
2u,
|
2u,
|
||||||
20u
|
20u
|
||||||
) == ~[
|
) == ~[
|
||||||
|
|
@ -74,7 +73,7 @@ mod tests {
|
||||||
|
|
||||||
assert!(pbkdf2_hmac_sha1(
|
assert!(pbkdf2_hmac_sha1(
|
||||||
"password",
|
"password",
|
||||||
str::to_bytes("salt"),
|
"salt".as_bytes(),
|
||||||
4096u,
|
4096u,
|
||||||
20u
|
20u
|
||||||
) == ~[
|
) == ~[
|
||||||
|
|
@ -85,7 +84,7 @@ mod tests {
|
||||||
|
|
||||||
assert!(pbkdf2_hmac_sha1(
|
assert!(pbkdf2_hmac_sha1(
|
||||||
"password",
|
"password",
|
||||||
str::to_bytes("salt"),
|
"salt".as_bytes(),
|
||||||
16777216u,
|
16777216u,
|
||||||
20u
|
20u
|
||||||
) == ~[
|
) == ~[
|
||||||
|
|
@ -96,7 +95,7 @@ mod tests {
|
||||||
|
|
||||||
assert!(pbkdf2_hmac_sha1(
|
assert!(pbkdf2_hmac_sha1(
|
||||||
"passwordPASSWORDpassword",
|
"passwordPASSWORDpassword",
|
||||||
str::to_bytes("saltSALTsaltSALTsaltSALTsaltSALTsalt"),
|
"saltSALTsaltSALTsaltSALTsaltSALTsalt".as_bytes(),
|
||||||
4096u,
|
4096u,
|
||||||
25u
|
25u
|
||||||
) == ~[
|
) == ~[
|
||||||
|
|
@ -108,7 +107,7 @@ mod tests {
|
||||||
|
|
||||||
assert!(pbkdf2_hmac_sha1(
|
assert!(pbkdf2_hmac_sha1(
|
||||||
"pass\x00word",
|
"pass\x00word",
|
||||||
str::to_bytes("sa\x00lt"),
|
"sa\x00lt".as_bytes(),
|
||||||
4096u,
|
4096u,
|
||||||
16u
|
16u
|
||||||
) == ~[
|
) == ~[
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue