Add destructors to all the types that need destructing
This commit is contained in:
parent
e3fef0c40e
commit
5ba7c49a91
9
hash.rs
9
hash.rs
|
|
@ -25,6 +25,7 @@ mod libcrypto {
|
||||||
#[link_args = "-lcrypto"]
|
#[link_args = "-lcrypto"]
|
||||||
extern {
|
extern {
|
||||||
fn EVP_MD_CTX_create() -> EVP_MD_CTX;
|
fn EVP_MD_CTX_create() -> EVP_MD_CTX;
|
||||||
|
fn EVP_MD_CTX_destroy(ctx: EVP_MD_CTX);
|
||||||
|
|
||||||
fn EVP_md5() -> EVP_MD;
|
fn EVP_md5() -> EVP_MD;
|
||||||
fn EVP_sha1() -> 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
|
* Hashes the supplied input data using hash t, returning the resulting hash
|
||||||
* value
|
* value
|
||||||
|
|
|
||||||
8
pkey.rs
8
pkey.rs
|
|
@ -336,6 +336,14 @@ impl PKey {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for PKey {
|
||||||
|
fn drop(&self) {
|
||||||
|
unsafe {
|
||||||
|
libcrypto::EVP_PKEY_free(self.evp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
||||||
9
symm.rs
9
symm.rs
|
|
@ -16,6 +16,7 @@ pub mod libcrypto {
|
||||||
#[link_args = "-lcrypto"]
|
#[link_args = "-lcrypto"]
|
||||||
fn EVP_CIPHER_CTX_new() -> EVP_CIPHER_CTX;
|
fn EVP_CIPHER_CTX_new() -> EVP_CIPHER_CTX;
|
||||||
fn EVP_CIPHER_CTX_set_padding(ctx: EVP_CIPHER_CTX, padding: c_int);
|
fn EVP_CIPHER_CTX_set_padding(ctx: EVP_CIPHER_CTX, padding: c_int);
|
||||||
|
fn EVP_CIPHER_CTX_free(ctx: EVP_CIPHER_CTX);
|
||||||
|
|
||||||
fn EVP_aes_128_ecb() -> EVP_CIPHER;
|
fn EVP_aes_128_ecb() -> EVP_CIPHER;
|
||||||
fn EVP_aes_128_cbc() -> EVP_CIPHER;
|
fn EVP_aes_128_cbc() -> EVP_CIPHER;
|
||||||
|
|
@ -149,6 +150,14 @@ impl Crypter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for Crypter {
|
||||||
|
fn drop(&self) {
|
||||||
|
unsafe {
|
||||||
|
libcrypto::EVP_CIPHER_CTX_free(self.ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypts data, using the specified crypter type in encrypt mode with the
|
* Encrypts data, using the specified crypter type in encrypt mode with the
|
||||||
* specified key and iv; returns the resulting (encrypted) data.
|
* specified key and iv; returns the resulting (encrypted) data.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue