From cd4e72dc98a19cda905c8c40c97b6491e4747b49 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Fri, 20 Apr 2012 09:47:46 -0700 Subject: Modernize crypto with new rust style and rustdoc support --- hash.rs | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'hash.rs') diff --git a/hash.rs b/hash.rs index 4ba64e0b..a68347c7 100644 --- a/hash.rs +++ b/hash.rs @@ -1,40 +1,23 @@ -use std; - -import core::ptr; -import core::str; -import core::vec; - import libc::c_uint; export hasher; export hashtype; -export mk_hasher; export hash; export _native; export md5, sha1, sha224, sha256, sha384, sha512; iface hasher { - /* - Method: init - - Initializes this hasher - */ + #[doc = "Initializes this hasher"] fn init(); - /* - Method: update - - Update this hasher with more input bytes - */ + #[doc = "Update this hasher with more input bytes"] fn update([u8]); - /* - Method: final - + #[doc = " Return the digest of all bytes added to this hasher since its last initialization - */ + "] fn final() -> [u8]; } @@ -78,7 +61,7 @@ fn evpmd(t: hashtype) -> (EVP_MD, uint) { } } -fn mk_hasher(ht: hashtype) -> hasher { +fn hasher(ht: hashtype) -> hasher { type hasherstate = { evp: EVP_MD, ctx: EVP_MD_CTX, @@ -111,13 +94,11 @@ fn mk_hasher(ht: hashtype) -> hasher { ret h; } -/* -Function: hash - +#[doc = " Hashes the supplied input data using hash t, returning the resulting hash value -*/ +"] fn hash(t: hashtype, data: [u8]) -> [u8] unsafe { - let h = mk_hasher(t); + let h = hasher(t); h.init(); h.update(data); ret h.final(); -- cgit v1.2.3