aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/rand.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/rand.rs')
-rw-r--r--src/crypto/rand.rs31
1 files changed, 0 insertions, 31 deletions
diff --git a/src/crypto/rand.rs b/src/crypto/rand.rs
deleted file mode 100644
index 4e95046b..00000000
--- a/src/crypto/rand.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-use std::libc::c_int;
-use std::vec;
-
-#[link(name = "crypto")]
-extern {
- fn RAND_bytes(buf: *mut u8, num: c_int) -> c_int;
-}
-
-pub fn rand_bytes(len: uint) -> ~[u8] {
- unsafe {
- let mut out = vec::with_capacity(len);
-
- let r = RAND_bytes(out.as_mut_ptr(), len as c_int);
- if r != 1 as c_int { fail!() }
-
- out.set_len(len);
-
- out
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::rand_bytes;
-
- #[test]
- fn test_rand_bytes() {
- let bytes = rand_bytes(32u);
- println!("{:?}", bytes);
- }
-}