OLD | NEW |
1 /* crypto/sha/sha.h */ | 1 /* crypto/sha/sha.h */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #ifndef HEADER_SHA_H | 59 #ifndef HEADER_SHA_H |
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 #include <stddef.h> |
64 | 64 |
65 #ifdef __cplusplus | 65 #ifdef __cplusplus |
66 extern "C" { | 66 extern "C" { |
67 #endif | 67 #endif |
68 | 68 |
69 #include <stddef.h> | |
70 | |
71 #if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_S
HA1)) | 69 #if defined(OPENSSL_NO_SHA) || (defined(OPENSSL_NO_SHA0) && defined(OPENSSL_NO_S
HA1)) |
72 #error SHA is disabled. | 70 #error SHA is disabled. |
73 #endif | 71 #endif |
74 | 72 |
75 #if defined(OPENSSL_FIPS) | 73 #if defined(OPENSSL_FIPS) |
76 #define FIPS_SHA_SIZE_T size_t | 74 #define FIPS_SHA_SIZE_T size_t |
77 #endif | 75 #endif |
78 | 76 |
79 /* | 77 /* |
80 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 78 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
81 * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then ! | 79 * ! SHA_LONG has to be at least 32 bits wide. If it's wider, then ! |
82 * ! SHA_LONG_LOG2 has to be defined along. ! | 80 * ! SHA_LONG_LOG2 has to be defined along. ! |
83 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 81 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
84 */ | 82 */ |
85 | 83 |
86 #if defined(OPENSSL_SYS_WIN16) || defined(__LP32__) | 84 #if defined(__LP32__) |
87 #define SHA_LONG unsigned long | 85 #define SHA_LONG unsigned long |
88 #elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) | 86 #elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) |
89 #define SHA_LONG unsigned long | 87 #define SHA_LONG unsigned long |
90 #define SHA_LONG_LOG2 3 | 88 #define SHA_LONG_LOG2 3 |
91 #else | 89 #else |
92 #define SHA_LONG unsigned int | 90 #define SHA_LONG unsigned int |
93 #endif | 91 #endif |
94 | 92 |
95 #define SHA_LBLOCK 16 | 93 #define SHA_LBLOCK 16 |
96 #define SHA_CBLOCK (SHA_LBLOCK*4) /* SHA treats input data as a | 94 #define SHA_CBLOCK (SHA_LBLOCK*4) /* SHA treats input data as a |
97 * contiguous array of 32 bit | 95 * contiguous array of 32 bit |
98 * wide big-endian values. */ | 96 * wide big-endian values. */ |
99 #define SHA_LAST_BLOCK (SHA_CBLOCK-8) | 97 #define SHA_LAST_BLOCK (SHA_CBLOCK-8) |
100 #define SHA_DIGEST_LENGTH 20 | 98 #define SHA_DIGEST_LENGTH 20 |
101 | 99 |
102 typedef struct SHAstate_st | 100 typedef struct SHAstate_st |
103 { | 101 { |
104 SHA_LONG h0,h1,h2,h3,h4; | 102 SHA_LONG h0,h1,h2,h3,h4; |
105 SHA_LONG Nl,Nh; | 103 SHA_LONG Nl,Nh; |
106 SHA_LONG data[SHA_LBLOCK]; | 104 SHA_LONG data[SHA_LBLOCK]; |
107 unsigned int num; | 105 unsigned int num; |
108 } SHA_CTX; | 106 } SHA_CTX; |
109 | 107 |
110 #ifndef OPENSSL_NO_SHA0 | 108 #ifndef OPENSSL_NO_SHA0 |
111 #ifdef OPENSSL_FIPS | |
112 int private_SHA_Init(SHA_CTX *c); | |
113 #endif | |
114 int SHA_Init(SHA_CTX *c); | 109 int SHA_Init(SHA_CTX *c); |
115 int SHA_Update(SHA_CTX *c, const void *data, size_t len); | 110 int SHA_Update(SHA_CTX *c, const void *data, size_t len); |
116 int SHA_Final(unsigned char *md, SHA_CTX *c); | 111 int SHA_Final(unsigned char *md, SHA_CTX *c); |
117 unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md); | 112 unsigned char *SHA(const unsigned char *d, size_t n, unsigned char *md); |
118 void SHA_Transform(SHA_CTX *c, const unsigned char *data); | 113 void SHA_Transform(SHA_CTX *c, const unsigned char *data); |
119 #endif | 114 #endif |
120 #ifndef OPENSSL_NO_SHA1 | 115 #ifndef OPENSSL_NO_SHA1 |
121 int SHA1_Init(SHA_CTX *c); | 116 int SHA1_Init(SHA_CTX *c); |
122 int SHA1_Update(SHA_CTX *c, const void *data, size_t len); | 117 int SHA1_Update(SHA_CTX *c, const void *data, size_t len); |
123 int SHA1_Final(unsigned char *md, SHA_CTX *c); | 118 int SHA1_Final(unsigned char *md, SHA_CTX *c); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 int SHA512_Final(unsigned char *md, SHA512_CTX *c); | 191 int SHA512_Final(unsigned char *md, SHA512_CTX *c); |
197 unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md); | 192 unsigned char *SHA512(const unsigned char *d, size_t n,unsigned char *md); |
198 void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); | 193 void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); |
199 #endif | 194 #endif |
200 | 195 |
201 #ifdef __cplusplus | 196 #ifdef __cplusplus |
202 } | 197 } |
203 #endif | 198 #endif |
204 | 199 |
205 #endif | 200 #endif |
OLD | NEW |