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