diff options
Diffstat (limited to 'src/lib/libcrypto/sha/sha.h')
| -rw-r--r-- | src/lib/libcrypto/sha/sha.h | 90 |
1 files changed, 81 insertions, 9 deletions
diff --git a/src/lib/libcrypto/sha/sha.h b/src/lib/libcrypto/sha/sha.h index 79c07b0fd1..eed44d7f94 100644 --- a/src/lib/libcrypto/sha/sha.h +++ b/src/lib/libcrypto/sha/sha.h | |||
| @@ -60,6 +60,7 @@ | |||
| 60 | #define HEADER_SHA_H | 60 | #define HEADER_SHA_H |
| 61 | 61 | ||
| 62 | #include <openssl/e_os2.h> | 62 | #include <openssl/e_os2.h> |
| 63 | #include <stddef.h> | ||
| 63 | 64 | ||
| 64 | #ifdef __cplusplus | 65 | #ifdef __cplusplus |
| 65 | extern "C" { | 66 | extern "C" { |
| @@ -70,7 +71,7 @@ extern "C" { | |||
| 70 | #endif | 71 | #endif |
| 71 | 72 | ||
| 72 | #if defined(OPENSSL_FIPS) | 73 | #if defined(OPENSSL_FIPS) |
| 73 | #define FIPS_SHA_SIZE_T unsigned long | 74 | #define FIPS_SHA_SIZE_T size_t |
| 74 | #endif | 75 | #endif |
| 75 | 76 | ||
| 76 | /* | 77 | /* |
| @@ -101,26 +102,97 @@ typedef struct SHAstate_st | |||
| 101 | SHA_LONG h0,h1,h2,h3,h4; | 102 | SHA_LONG h0,h1,h2,h3,h4; |
| 102 | SHA_LONG Nl,Nh; | 103 | SHA_LONG Nl,Nh; |
| 103 | SHA_LONG data[SHA_LBLOCK]; | 104 | SHA_LONG data[SHA_LBLOCK]; |
| 104 | int num; | 105 | unsigned int num; |
| 105 | } SHA_CTX; | 106 | } SHA_CTX; |
| 106 | 107 | ||
| 107 | #ifndef OPENSSL_NO_SHA0 | 108 | #ifndef OPENSSL_NO_SHA0 |
| 108 | #ifdef OPENSSL_FIPS | ||
| 109 | int private_SHA_Init(SHA_CTX *c); | ||
| 110 | #endif | ||
| 111 | int SHA_Init(SHA_CTX *c); | 109 | int SHA_Init(SHA_CTX *c); |
| 112 | int SHA_Update(SHA_CTX *c, const void *data, unsigned long len); | 110 | int SHA_Update(SHA_CTX *c, const void *data, size_t len); |
| 113 | int SHA_Final(unsigned char *md, SHA_CTX *c); | 111 | int SHA_Final(unsigned char *md, SHA_CTX *c); |
| 114 | unsigned char *SHA(const unsigned char *d, unsigned long n,unsigned char *md); | 112 | unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md); |
| 115 | void SHA_Transform(SHA_CTX *c, const unsigned char *data); | 113 | void SHA_Transform(SHA_CTX *c, const unsigned char *data); |
| 116 | #endif | 114 | #endif |
| 117 | #ifndef OPENSSL_NO_SHA1 | 115 | #ifndef OPENSSL_NO_SHA1 |
| 118 | int SHA1_Init(SHA_CTX *c); | 116 | int SHA1_Init(SHA_CTX *c); |
| 119 | int SHA1_Update(SHA_CTX *c, const void *data, unsigned long len); | 117 | int SHA1_Update(SHA_CTX *c, const void *data, size_t len); |
| 120 | int SHA1_Final(unsigned char *md, SHA_CTX *c); | 118 | int SHA1_Final(unsigned char *md, SHA_CTX *c); |
| 121 | unsigned char *SHA1(const unsigned char *d, unsigned long n,unsigned char *md); | 119 | unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); |
| 122 | void SHA1_Transform(SHA_CTX *c, const unsigned char *data); | 120 | void SHA1_Transform(SHA_CTX *c, const unsigned char *data); |
| 123 | #endif | 121 | #endif |
| 122 | |||
| 123 | #define SHA256_CBLOCK (SHA_LBLOCK*4) /* SHA-256 treats input data as a | ||
| 124 | * contiguous array of 32 bit | ||
| 125 | * wide big-endian values. */ | ||
| 126 | #define SHA224_DIGEST_LENGTH 28 | ||
| 127 | #define SHA256_DIGEST_LENGTH 32 | ||
| 128 | |||
| 129 | typedef struct SHA256state_st | ||
| 130 | { | ||
| 131 | SHA_LONG h[8]; | ||
| 132 | SHA_LONG Nl,Nh; | ||
| 133 | SHA_LONG data[SHA_LBLOCK]; | ||
| 134 | unsigned int num,md_len; | ||
| 135 | } SHA256_CTX; | ||
| 136 | |||
| 137 | #ifndef OPENSSL_NO_SHA256 | ||
| 138 | int SHA224_Init(SHA256_CTX *c); | ||
| 139 | int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); | ||
| 140 | int SHA224_Final(unsigned char *md, SHA256_CTX *c); | ||
| 141 | unsigned char *SHA224(const unsigned char *d, size_t n,unsigned char *md); | ||
| 142 | int SHA256_Init(SHA256_CTX *c); | ||
| 143 | int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); | ||
| 144 | int SHA256_Final(unsigned char *md, SHA256_CTX *c); | ||
| 145 | unsigned char *SHA256(const unsigned char *d, size_t n,unsigned char *md); | ||
| 146 | void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); | ||
| 147 | #endif | ||
| 148 | |||
| 149 | #define SHA384_DIGEST_LENGTH 48 | ||
| 150 | #define SHA512_DIGEST_LENGTH 64 | ||
| 151 | |||
| 152 | #ifndef OPENSSL_NO_SHA512 | ||
| 153 | /* | ||
| 154 | * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64 | ||
| 155 | * being exactly 64-bit wide. See Implementation Notes in sha512.c | ||
| 156 | * for further details. | ||
| 157 | */ | ||
| 158 | #define SHA512_CBLOCK (SHA_LBLOCK*8) /* SHA-512 treats input data as a | ||
| 159 | * contiguous array of 64 bit | ||
| 160 | * wide big-endian values. */ | ||
| 161 | #if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) | ||
| 162 | #define SHA_LONG64 unsigned __int64 | ||
| 163 | #define U64(C) C##UI64 | ||
| 164 | #elif defined(__arch64__) | ||
| 165 | #define SHA_LONG64 unsigned long | ||
| 166 | #define U64(C) C##UL | ||
| 167 | #else | ||
| 168 | #define SHA_LONG64 unsigned long long | ||
| 169 | #define U64(C) C##ULL | ||
| 170 | #endif | ||
| 171 | |||
| 172 | typedef struct SHA512state_st | ||
| 173 | { | ||
| 174 | SHA_LONG64 h[8]; | ||
| 175 | SHA_LONG64 Nl,Nh; | ||
| 176 | union { | ||
| 177 | SHA_LONG64 d[SHA_LBLOCK]; | ||
| 178 | unsigned char p[SHA512_CBLOCK]; | ||
| 179 | } u; | ||
| 180 | unsigned int num,md_len; | ||
| 181 | } SHA512_CTX; | ||
| 182 | #endif | ||
| 183 | |||
| 184 | #ifndef OPENSSL_NO_SHA512 | ||
| 185 | int SHA384_Init(SHA512_CTX *c); | ||
| 186 | int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); | ||
| 187 | int SHA384_Final(unsigned char *md, SHA512_CTX *c); | ||
| 188 | unsigned char *SHA384(const unsigned char *d, size_t n,unsigned char *md); | ||
| 189 | int SHA512_Init(SHA512_CTX *c); | ||
| 190 | int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); | ||
| 191 | int SHA512_Final(unsigned char *md, SHA512_CTX *c); | ||
| 192 | unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md); | ||
| 193 | void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); | ||
| 194 | #endif | ||
| 195 | |||
| 124 | #ifdef __cplusplus | 196 | #ifdef __cplusplus |
| 125 | } | 197 | } |
| 126 | #endif | 198 | #endif |
