diff options
Diffstat (limited to '3rd_party/libsrp6a-sha512/t_sha.h')
-rw-r--r-- | 3rd_party/libsrp6a-sha512/t_sha.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/3rd_party/libsrp6a-sha512/t_sha.h b/3rd_party/libsrp6a-sha512/t_sha.h new file mode 100644 index 0000000..18deec5 --- /dev/null +++ b/3rd_party/libsrp6a-sha512/t_sha.h | |||
@@ -0,0 +1,125 @@ | |||
1 | #ifndef T_SHA_H | ||
2 | #define T_SHA_H | ||
3 | |||
4 | #if !defined(P) | ||
5 | #ifdef __STDC__ | ||
6 | #define P(x) x | ||
7 | #else | ||
8 | #define P(x) () | ||
9 | #endif | ||
10 | #endif | ||
11 | |||
12 | #define SHA_DIGESTSIZE 20 | ||
13 | |||
14 | #ifdef OPENSSL | ||
15 | #define OPENSSL_SHA 1 | ||
16 | #endif | ||
17 | |||
18 | #ifdef TOMCRYPT | ||
19 | # include <tomcrypt.h> | ||
20 | # ifdef SHA1 | ||
21 | # define TOMCRYPT_SHA 1 | ||
22 | # endif | ||
23 | #endif | ||
24 | |||
25 | #ifdef CRYPTOLIB | ||
26 | /* The SHA (shs) implementation in CryptoLib 1.x breaks when Update | ||
27 | * is called multiple times, so we still use our own code. | ||
28 | * Uncomment below if you think your copy of CryptoLib is fixed. */ | ||
29 | /*#define CRYPTOLIB_SHA 1*/ | ||
30 | #endif | ||
31 | |||
32 | #ifdef GCRYPT | ||
33 | # define GCRYPT_SHA 1 | ||
34 | #endif | ||
35 | |||
36 | #ifdef MBEDTLS | ||
37 | # define MBEDTLS_SHA 1 | ||
38 | #endif | ||
39 | |||
40 | #ifdef OPENSSL_SHA | ||
41 | #include <openssl/sha.h> | ||
42 | |||
43 | typedef SHA_CTX SHA1_CTX; | ||
44 | #define SHA1Init SHA1_Init | ||
45 | #define SHA1Update SHA1_Update | ||
46 | #define SHA1Final SHA1_Final | ||
47 | |||
48 | #define SHA512Init SHA512_Init | ||
49 | #define SHA512Update SHA512_Update | ||
50 | #define SHA512Final SHA512_Final | ||
51 | |||
52 | #elif defined(TOMCRYPT_SHA) | ||
53 | /* mycrypt.h already included above */ | ||
54 | |||
55 | typedef hash_state SHA1_CTX; | ||
56 | #define SHA1Init sha1_init | ||
57 | #define SHA1Update sha1_process | ||
58 | #define SHA1Final(D,C) sha1_done(C,D) | ||
59 | |||
60 | #elif defined(GCRYPT_SHA) | ||
61 | #include "gcrypt.h" | ||
62 | |||
63 | typedef gcry_md_hd_t SHA1_CTX; | ||
64 | #define SHA1Init SHA1Init_gcry | ||
65 | #define SHA1Update SHA1Update_gcry | ||
66 | #define SHA1Final SHA1Final_gcry | ||
67 | typedef gcry_md_hd_t SHA512_CTX; | ||
68 | #define SHA512Init SHA512Init_gcry | ||
69 | #define SHA512Update SHA512Update_gcry | ||
70 | #define SHA512Final SHA512Final_gcry | ||
71 | |||
72 | void SHA1Init_gcry(SHA1_CTX * ctx); | ||
73 | void SHA1Update_gcry(SHA1_CTX * ctx, const void *data, unsigned int len); | ||
74 | void SHA1Final_gcry(unsigned char digest[20], SHA1_CTX * ctx); | ||
75 | |||
76 | void SHA512Init_gcry(SHA512_CTX * ctx); | ||
77 | void SHA512Update_gcry(SHA512_CTX * ctx, const void *data, unsigned int len); | ||
78 | void SHA512Final_gcry(unsigned char digest[64], SHA512_CTX * ctx); | ||
79 | |||
80 | #elif defined(MBEDTLS_SHA) | ||
81 | #include <mbedtls/md.h> | ||
82 | |||
83 | typedef mbedtls_md_context_t SHA1_CTX; | ||
84 | #define SHA1Init SHA1Init_mbed | ||
85 | #define SHA1Update SHA1Update_mbed | ||
86 | #define SHA1Final SHA1Final_mbed | ||
87 | |||
88 | typedef mbedtls_md_context_t SHA512_CTX; | ||
89 | #define SHA512Init SHA512Init_mbed | ||
90 | #define SHA512Update SHA512Update_mbed | ||
91 | #define SHA512Final SHA512Final_mbed | ||
92 | |||
93 | void SHA1Init_mbed(SHA1_CTX * ctx); | ||
94 | void SHA1Update_mbed(SHA1_CTX * ctx, const void *data, unsigned int len); | ||
95 | void SHA1Final_mbed(unsigned char digest[20], SHA1_CTX * ctx); | ||
96 | |||
97 | void SHA512Init_mbed(SHA512_CTX * ctx); | ||
98 | void SHA512Update_mbed(SHA512_CTX * ctx, const void *data, unsigned int len); | ||
99 | void SHA512Final_mbed(unsigned char digest[64], SHA512_CTX * ctx); | ||
100 | |||
101 | #elif defined(CRYPTOLIB_SHA) | ||
102 | #include "libcrypt.h" | ||
103 | |||
104 | typedef SHS_CTX SHA1_CTX; | ||
105 | #define SHA1Init shsInit | ||
106 | #define SHA1Update shsUpdate | ||
107 | #define SHA1Final shsFinalBytes | ||
108 | |||
109 | void shsFinalBytes P((unsigned char digest[20], SHS_CTX* context)); | ||
110 | |||
111 | #else | ||
112 | typedef unsigned int uint32; | ||
113 | |||
114 | typedef struct { | ||
115 | uint32 state[5]; | ||
116 | uint32 count[2]; | ||
117 | unsigned char buffer[64]; | ||
118 | } SHA1_CTX; | ||
119 | |||
120 | void SHA1Init P((SHA1_CTX* context)); | ||
121 | void SHA1Update P((SHA1_CTX* context, const unsigned char* data, unsigned int len)); | ||
122 | void SHA1Final P((unsigned char digest[20], SHA1_CTX* context)); | ||
123 | #endif /* !OPENSSL && !CRYPTOLIB */ | ||
124 | |||
125 | #endif /* T_SHA_H */ | ||