aboutsummaryrefslogtreecommitdiff
path: root/hash.rs
diff options
context:
space:
mode:
Diffstat (limited to 'hash.rs')
-rw-r--r--hash.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/hash.rs b/hash.rs
index 2b964518..421cdc23 100644
--- a/hash.rs
+++ b/hash.rs
@@ -25,6 +25,7 @@ mod libcrypto {
#[link_args = "-lcrypto"]
extern {
fn EVP_MD_CTX_create() -> EVP_MD_CTX;
+ fn EVP_MD_CTX_destroy(ctx: EVP_MD_CTX);
fn EVP_md5() -> EVP_MD;
fn EVP_sha1() -> EVP_MD;
@@ -96,6 +97,14 @@ impl Hasher {
}
}
+impl Drop for Hasher {
+ fn drop(&self) {
+ unsafe {
+ libcrypto::EVP_MD_CTX_destroy(self.ctx);
+ }
+ }
+}
+
/**
* Hashes the supplied input data using hash t, returning the resulting hash
* value