aboutsummaryrefslogtreecommitdiff
path: root/openssl-sys/src
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2017-08-14 17:12:55 -0700
committerGitHub <[email protected]>2017-08-14 17:12:55 -0700
commitdfdf4e4d3867ef18c32e4c691023c3978537acd2 (patch)
tree4178ad5d4cea70a016f40d3dabbe66cadd37ab9c /openssl-sys/src
parentMerge pull request #679 from mcgoo/vcpkg (diff)
parentAdd a stateful SHA256 hasher (diff)
downloadrust-openssl-dfdf4e4d3867ef18c32e4c691023c3978537acd2.tar.xz
rust-openssl-dfdf4e4d3867ef18c32e4c691023c3978537acd2.zip
Merge pull request #680 from sfackler/sha256-state
Add a stateful SHA256 hasher
Diffstat (limited to 'openssl-sys/src')
-rw-r--r--openssl-sys/src/lib.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs
index fe50dcad..6f33678f 100644
--- a/openssl-sys/src/lib.rs
+++ b/openssl-sys/src/lib.rs
@@ -128,6 +128,16 @@ pub struct X509V3_CTX {
// Maybe more here
}
+#[repr(C)]
+pub struct SHA256_CTX {
+ pub h: [SHA_LONG; 8],
+ pub Nl: SHA_LONG,
+ pub Nh: SHA_LONG,
+ pub data: [SHA_LONG; SHA_LBLOCK as usize],
+ pub num: c_uint,
+ pub md_len: c_uint,
+}
+
#[cfg(target_pointer_width = "64")]
pub type BN_ULONG = libc::c_ulonglong;
#[cfg(target_pointer_width = "32")]
@@ -159,6 +169,8 @@ pub type PasswordCallback = unsafe extern "C" fn(buf: *mut c_char,
user_data: *mut c_void)
-> c_int;
+pub type SHA_LONG = c_uint;
+
pub const AES_ENCRYPT: c_int = 1;
pub const AES_DECRYPT: c_int = 0;
@@ -1169,6 +1181,8 @@ pub const RSA_NO_PADDING: c_int = 3;
pub const RSA_PKCS1_OAEP_PADDING: c_int = 4;
pub const RSA_X931_PADDING: c_int = 5;
+pub const SHA_LBLOCK: c_int = 16;
+
pub const SSL_CTRL_SET_TMP_DH: c_int = 3;
pub const SSL_CTRL_SET_TMP_ECDH: c_int = 4;
pub const SSL_CTRL_EXTRA_CHAIN_CERT: c_int = 14;
@@ -2221,6 +2235,10 @@ extern "C" {
pub fn SHA384(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar;
pub fn SHA512(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar;
+ pub fn SHA256_Init(c: *mut SHA256_CTX) -> c_int;
+ pub fn SHA256_Update(c: *mut SHA256_CTX, data: *const c_void, len: size_t) -> c_int;
+ pub fn SHA256_Final(md: *mut c_uchar, c: *mut SHA256_CTX) -> c_int;
+
pub fn SSL_new(ctx: *mut SSL_CTX) -> *mut SSL;
pub fn SSL_pending(ssl: *const SSL) -> c_int;
pub fn SSL_free(ssl: *mut SSL);