| 1 |
use super::super::*; |
| 2 |
use libc::size_t; |
| 3 |
use std::ffi::{c_int, c_uchar, c_uint, c_void}; |
| 4 |
|
| 5 |
cfg_if! { |
| 6 |
if #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))] { |
| 7 |
#[repr(C)] |
| 8 |
#[derive(Clone)] |
| 9 |
pub struct SHA_CTX { |
| 10 |
pub h0: SHA_LONG, |
| 11 |
pub h1: SHA_LONG, |
| 12 |
pub h2: SHA_LONG, |
| 13 |
pub h3: SHA_LONG, |
| 14 |
pub h4: SHA_LONG, |
| 15 |
pub Nl: SHA_LONG, |
| 16 |
pub Nh: SHA_LONG, |
| 17 |
pub data: [SHA_LONG; SHA_LBLOCK as usize], |
| 18 |
pub num: c_uint, |
| 19 |
} |
| 20 |
|
| 21 |
extern "C" { |
| 22 |
pub fn SHA1_Init(c: *mut SHA_CTX) -> c_int; |
| 23 |
pub fn SHA1_Update(c: *mut SHA_CTX, data: *const c_void, len: size_t) -> c_int; |
| 24 |
pub fn SHA1_Final(md: *mut c_uchar, c: *mut SHA_CTX) -> c_int; |
| 25 |
} |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
cfg_if! { |
| 30 |
if #[cfg(not(ossl300))] { |
| 31 |
extern "C" { |
| 32 |
pub fn SHA1(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar; |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
cfg_if! { |
| 38 |
if #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))] { |
| 39 |
#[repr(C)] |
| 40 |
#[derive(Clone)] |
| 41 |
pub struct SHA256_CTX { |
| 42 |
pub h: [SHA_LONG; 8], |
| 43 |
pub Nl: SHA_LONG, |
| 44 |
pub Nh: SHA_LONG, |
| 45 |
pub data: [SHA_LONG; SHA_LBLOCK as usize], |
| 46 |
pub num: c_uint, |
| 47 |
pub md_len: c_uint, |
| 48 |
} |
| 49 |
|
| 50 |
extern "C" { |
| 51 |
pub fn SHA224_Init(c: *mut SHA256_CTX) -> c_int; |
| 52 |
pub fn SHA224_Update(c: *mut SHA256_CTX, data: *const c_void, len: size_t) -> c_int; |
| 53 |
pub fn SHA224_Final(md: *mut c_uchar, c: *mut SHA256_CTX) -> c_int; |
| 54 |
pub fn SHA256_Init(c: *mut SHA256_CTX) -> c_int; |
| 55 |
pub fn SHA256_Update(c: *mut SHA256_CTX, data: *const c_void, len: size_t) -> c_int; |
| 56 |
pub fn SHA256_Final(md: *mut c_uchar, c: *mut SHA256_CTX) -> c_int; |
| 57 |
} |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
cfg_if! { |
| 62 |
if #[cfg(not(ossl300))] { |
| 63 |
extern "C" { |
| 64 |
pub fn SHA224(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar; |
| 65 |
pub fn SHA256(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar; |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
cfg_if! { |
| 71 |
if #[cfg(not(osslconf = "OPENSSL_NO_DEPRECATED_3_0"))] { |
| 72 |
#[repr(C)] |
| 73 |
#[derive(Clone)] |
| 74 |
pub struct SHA512_CTX { |
| 75 |
pub h: [SHA_LONG64; 8], |
| 76 |
pub Nl: SHA_LONG64, |
| 77 |
pub Nh: SHA_LONG64, |
| 78 |
// this is a union but we don't want to require 1.19 |
| 79 |
u: [SHA_LONG64; SHA_LBLOCK as usize], |
| 80 |
pub num: c_uint, |
| 81 |
pub md_len: c_uint, |
| 82 |
} |
| 83 |
|
| 84 |
extern "C" { |
| 85 |
pub fn SHA384_Init(c: *mut SHA512_CTX) -> c_int; |
| 86 |
pub fn SHA384_Update(c: *mut SHA512_CTX, data: *const c_void, len: size_t) -> c_int; |
| 87 |
pub fn SHA384_Final(md: *mut c_uchar, c: *mut SHA512_CTX) -> c_int; |
| 88 |
pub fn SHA512_Init(c: *mut SHA512_CTX) -> c_int; |
| 89 |
pub fn SHA512_Update(c: *mut SHA512_CTX, data: *const c_void, len: size_t) -> c_int; |
| 90 |
pub fn SHA512_Final(md: *mut c_uchar, c: *mut SHA512_CTX) -> c_int; |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
cfg_if! { |
| 96 |
if #[cfg(not(ossl300))] { |
| 97 |
extern "C" { |
| 98 |
pub fn SHA384(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar; |
| 99 |
pub fn SHA512(d: *const c_uchar, n: size_t, md: *mut c_uchar) -> *mut c_uchar; |
| 100 |
} |
| 101 |
} |
| 102 |
} |