Update to latest rust master (0.9-pre 69e46f3)
This commit is contained in:
parent
76a3b83d27
commit
25e18fab13
|
|
@ -20,6 +20,8 @@
|
||||||
uuid = "38297409-b4c2-4499-8131-a99a7e44dad3")];
|
uuid = "38297409-b4c2-4499-8131-a99a7e44dad3")];
|
||||||
#[crate_type = "lib"];
|
#[crate_type = "lib"];
|
||||||
|
|
||||||
|
#[feature(globs)];
|
||||||
|
|
||||||
pub mod hash;
|
pub mod hash;
|
||||||
pub mod hex;
|
pub mod hex;
|
||||||
pub mod hmac;
|
pub mod hmac;
|
||||||
|
|
|
||||||
24
hash.rs
24
hash.rs
|
|
@ -24,19 +24,19 @@ mod libcrypto {
|
||||||
|
|
||||||
#[link_args = "-lcrypto"]
|
#[link_args = "-lcrypto"]
|
||||||
extern {
|
extern {
|
||||||
fn EVP_MD_CTX_create() -> EVP_MD_CTX;
|
pub fn EVP_MD_CTX_create() -> EVP_MD_CTX;
|
||||||
fn EVP_MD_CTX_destroy(ctx: EVP_MD_CTX);
|
pub fn EVP_MD_CTX_destroy(ctx: EVP_MD_CTX);
|
||||||
|
|
||||||
fn EVP_md5() -> EVP_MD;
|
pub fn EVP_md5() -> EVP_MD;
|
||||||
fn EVP_sha1() -> EVP_MD;
|
pub fn EVP_sha1() -> EVP_MD;
|
||||||
fn EVP_sha224() -> EVP_MD;
|
pub fn EVP_sha224() -> EVP_MD;
|
||||||
fn EVP_sha256() -> EVP_MD;
|
pub fn EVP_sha256() -> EVP_MD;
|
||||||
fn EVP_sha384() -> EVP_MD;
|
pub fn EVP_sha384() -> EVP_MD;
|
||||||
fn EVP_sha512() -> EVP_MD;
|
pub fn EVP_sha512() -> EVP_MD;
|
||||||
|
|
||||||
fn EVP_DigestInit(ctx: EVP_MD_CTX, typ: EVP_MD);
|
pub fn EVP_DigestInit(ctx: EVP_MD_CTX, typ: EVP_MD);
|
||||||
fn EVP_DigestUpdate(ctx: EVP_MD_CTX, data: *u8, n: c_uint);
|
pub fn EVP_DigestUpdate(ctx: EVP_MD_CTX, data: *u8, n: c_uint);
|
||||||
fn EVP_DigestFinal(ctx: EVP_MD_CTX, res: *mut u8, n: *u32);
|
pub fn EVP_DigestFinal(ctx: EVP_MD_CTX, res: *mut u8, n: *u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,7 +139,7 @@ mod tests {
|
||||||
let calced = calced_raw.to_hex();
|
let calced = calced_raw.to_hex();
|
||||||
|
|
||||||
if calced != hashtest.expected_output {
|
if calced != hashtest.expected_output {
|
||||||
println(fmt!("Test failed - %s != %s", calced, hashtest.expected_output));
|
println!("Test failed - {} != {}", calced, hashtest.expected_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert!(calced == hashtest.expected_output);
|
assert!(calced == hashtest.expected_output);
|
||||||
|
|
|
||||||
2
hmac.rs
2
hmac.rs
|
|
@ -95,5 +95,5 @@ fn main() {
|
||||||
|
|
||||||
h.update([00u8]);
|
h.update([00u8]);
|
||||||
|
|
||||||
println(fmt!("%?", h.final()))
|
println!("{:?}", h.final())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
pkcs5.rs
2
pkcs5.rs
|
|
@ -6,7 +6,7 @@ mod libcrypto {
|
||||||
|
|
||||||
#[link_args = "-lcrypto"]
|
#[link_args = "-lcrypto"]
|
||||||
extern {
|
extern {
|
||||||
fn PKCS5_PBKDF2_HMAC_SHA1(pass: *u8, passlen: c_int,
|
pub fn PKCS5_PBKDF2_HMAC_SHA1(pass: *u8, passlen: c_int,
|
||||||
salt: *u8, saltlen: c_int,
|
salt: *u8, saltlen: c_int,
|
||||||
iter: c_int, keylen: c_int,
|
iter: c_int, keylen: c_int,
|
||||||
out: *mut u8) -> c_int;
|
out: *mut u8) -> c_int;
|
||||||
|
|
|
||||||
28
pkey.rs
28
pkey.rs
|
|
@ -17,26 +17,26 @@ mod libcrypto {
|
||||||
|
|
||||||
#[link_args = "-lcrypto"]
|
#[link_args = "-lcrypto"]
|
||||||
extern {
|
extern {
|
||||||
fn EVP_PKEY_new() -> *EVP_PKEY;
|
pub fn EVP_PKEY_new() -> *EVP_PKEY;
|
||||||
fn EVP_PKEY_free(k: *EVP_PKEY);
|
pub fn EVP_PKEY_free(k: *EVP_PKEY);
|
||||||
fn EVP_PKEY_assign(pkey: *EVP_PKEY, typ: c_int, key: *c_char) -> c_int;
|
pub fn EVP_PKEY_assign(pkey: *EVP_PKEY, typ: c_int, key: *c_char) -> c_int;
|
||||||
fn EVP_PKEY_get1_RSA(k: *EVP_PKEY) -> *RSA;
|
pub fn EVP_PKEY_get1_RSA(k: *EVP_PKEY) -> *RSA;
|
||||||
|
|
||||||
fn i2d_PublicKey(k: *EVP_PKEY, buf: **mut u8) -> c_int;
|
pub fn i2d_PublicKey(k: *EVP_PKEY, buf: **mut u8) -> c_int;
|
||||||
fn d2i_PublicKey(t: c_int, k: **EVP_PKEY, buf: **u8, len: c_uint) -> *EVP_PKEY;
|
pub fn d2i_PublicKey(t: c_int, k: **EVP_PKEY, buf: **u8, len: c_uint) -> *EVP_PKEY;
|
||||||
fn i2d_PrivateKey(k: *EVP_PKEY, buf: **mut u8) -> c_int;
|
pub fn i2d_PrivateKey(k: *EVP_PKEY, buf: **mut u8) -> c_int;
|
||||||
fn d2i_PrivateKey(t: c_int, k: **EVP_PKEY, buf: **u8, len: c_uint) -> *EVP_PKEY;
|
pub fn d2i_PrivateKey(t: c_int, k: **EVP_PKEY, buf: **u8, len: c_uint) -> *EVP_PKEY;
|
||||||
|
|
||||||
fn RSA_generate_key(modsz: c_uint, e: c_uint, cb: *u8, cbarg: *u8) -> *RSA;
|
pub fn RSA_generate_key(modsz: c_uint, e: c_uint, cb: *u8, cbarg: *u8) -> *RSA;
|
||||||
fn RSA_size(k: *RSA) -> c_uint;
|
pub fn RSA_size(k: *RSA) -> c_uint;
|
||||||
|
|
||||||
fn RSA_public_encrypt(flen: c_uint, from: *u8, to: *mut u8, k: *RSA,
|
pub fn RSA_public_encrypt(flen: c_uint, from: *u8, to: *mut u8, k: *RSA,
|
||||||
pad: c_int) -> c_int;
|
pad: c_int) -> c_int;
|
||||||
fn RSA_private_decrypt(flen: c_uint, from: *u8, to: *mut u8, k: *RSA,
|
pub fn RSA_private_decrypt(flen: c_uint, from: *u8, to: *mut u8, k: *RSA,
|
||||||
pad: c_int) -> c_int;
|
pad: c_int) -> c_int;
|
||||||
fn RSA_sign(t: c_int, m: *u8, mlen: c_uint, sig: *mut u8, siglen: *mut c_uint,
|
pub fn RSA_sign(t: c_int, m: *u8, mlen: c_uint, sig: *mut u8, siglen: *mut c_uint,
|
||||||
k: *RSA) -> c_int;
|
k: *RSA) -> c_int;
|
||||||
fn RSA_verify(t: c_int, m: *u8, mlen: c_uint, sig: *u8, siglen: c_uint,
|
pub fn RSA_verify(t: c_int, m: *u8, mlen: c_uint, sig: *u8, siglen: c_uint,
|
||||||
k: *RSA) -> c_int;
|
k: *RSA) -> c_int;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
rand.rs
4
rand.rs
|
|
@ -6,7 +6,7 @@ mod libcrypto {
|
||||||
|
|
||||||
#[link_args = "-lcrypto"]
|
#[link_args = "-lcrypto"]
|
||||||
extern {
|
extern {
|
||||||
fn RAND_bytes(buf: *mut u8, num: c_int) -> c_int;
|
pub fn RAND_bytes(buf: *mut u8, num: c_int) -> c_int;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,6 +31,6 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rand_bytes() {
|
fn test_rand_bytes() {
|
||||||
let bytes = rand_bytes(32u);
|
let bytes = rand_bytes(32u);
|
||||||
println(fmt!("%?", bytes));
|
println!("{:?}", bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
40
symm.rs
40
symm.rs
|
|
@ -14,27 +14,27 @@ mod libcrypto {
|
||||||
|
|
||||||
extern {
|
extern {
|
||||||
#[link_args = "-lcrypto"]
|
#[link_args = "-lcrypto"]
|
||||||
fn EVP_CIPHER_CTX_new() -> EVP_CIPHER_CTX;
|
pub fn EVP_CIPHER_CTX_new() -> EVP_CIPHER_CTX;
|
||||||
fn EVP_CIPHER_CTX_set_padding(ctx: EVP_CIPHER_CTX, padding: c_int);
|
pub fn EVP_CIPHER_CTX_set_padding(ctx: EVP_CIPHER_CTX, padding: c_int);
|
||||||
fn EVP_CIPHER_CTX_free(ctx: EVP_CIPHER_CTX);
|
pub fn EVP_CIPHER_CTX_free(ctx: EVP_CIPHER_CTX);
|
||||||
|
|
||||||
fn EVP_aes_128_ecb() -> EVP_CIPHER;
|
pub fn EVP_aes_128_ecb() -> EVP_CIPHER;
|
||||||
fn EVP_aes_128_cbc() -> EVP_CIPHER;
|
pub fn EVP_aes_128_cbc() -> EVP_CIPHER;
|
||||||
// fn EVP_aes_128_ctr() -> EVP_CIPHER;
|
// pub fn EVP_aes_128_ctr() -> EVP_CIPHER;
|
||||||
// fn EVP_aes_128_gcm() -> EVP_CIPHER;
|
// pub fn EVP_aes_128_gcm() -> EVP_CIPHER;
|
||||||
|
|
||||||
fn EVP_aes_256_ecb() -> EVP_CIPHER;
|
pub fn EVP_aes_256_ecb() -> EVP_CIPHER;
|
||||||
fn EVP_aes_256_cbc() -> EVP_CIPHER;
|
pub fn EVP_aes_256_cbc() -> EVP_CIPHER;
|
||||||
// fn EVP_aes_256_ctr() -> EVP_CIPHER;
|
// pub fn EVP_aes_256_ctr() -> EVP_CIPHER;
|
||||||
// fn EVP_aes_256_gcm() -> EVP_CIPHER;
|
// pub fn EVP_aes_256_gcm() -> EVP_CIPHER;
|
||||||
|
|
||||||
fn EVP_rc4() -> EVP_CIPHER;
|
pub fn EVP_rc4() -> EVP_CIPHER;
|
||||||
|
|
||||||
fn EVP_CipherInit(ctx: EVP_CIPHER_CTX, evp: EVP_CIPHER,
|
pub fn EVP_CipherInit(ctx: EVP_CIPHER_CTX, evp: EVP_CIPHER,
|
||||||
key: *u8, iv: *u8, mode: c_int);
|
key: *u8, iv: *u8, mode: c_int);
|
||||||
fn EVP_CipherUpdate(ctx: EVP_CIPHER_CTX, outbuf: *mut u8,
|
pub fn EVP_CipherUpdate(ctx: EVP_CIPHER_CTX, outbuf: *mut u8,
|
||||||
outlen: &mut c_uint, inbuf: *u8, inlen: c_int);
|
outlen: &mut c_uint, inbuf: *u8, inlen: c_int);
|
||||||
fn EVP_CipherFinal(ctx: EVP_CIPHER_CTX, res: *mut u8, len: &mut c_int);
|
pub fn EVP_CipherFinal(ctx: EVP_CIPHER_CTX, res: *mut u8, len: &mut c_int);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -258,13 +258,13 @@ mod tests {
|
||||||
let computed = cipher.update(pt.from_hex()) + cipher.final();
|
let computed = cipher.update(pt.from_hex()) + cipher.final();
|
||||||
|
|
||||||
if computed != expected {
|
if computed != expected {
|
||||||
println(fmt!("Computed: %s", computed.to_hex()));
|
println!("Computed: {}", computed.to_hex());
|
||||||
println(fmt!("Expected: %s", expected.to_hex()));
|
println!("Expected: {}", expected.to_hex());
|
||||||
if computed.len() != expected.len() {
|
if computed.len() != expected.len() {
|
||||||
println(fmt!("Lengths differ: %u in computed vs %u expected",
|
println!("Lengths differ: {} in computed vs {} expected",
|
||||||
computed.len(), expected.len()));
|
computed.len(), expected.len());
|
||||||
}
|
}
|
||||||
fail!(~"test failure");
|
fail!("test failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue