Add "extern C {...} to header files for C++ builds.
[freeradius.git] / src / include / sha1.h
1 #ifndef _FR_SHA1_H
2 #define _FR_SHA1_H
3
4 #ifdef WITH_OPENSSL_SHA1
5 #include <openssl/sha.h>
6 #endif
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 #ifndef WITH_OPENSSL_SHA1
13 typedef struct {
14     uint32_t state[5];
15     uint32_t count[2];
16     uint8_t buffer[64];
17 } fr_SHA1_CTX;
18
19 void fr_SHA1Transform(uint32_t state[5], const uint8_t buffer[64]);
20 void fr_SHA1Init(fr_SHA1_CTX* context);
21 void fr_SHA1Update(fr_SHA1_CTX* context, const uint8_t* data, unsigned int len);
22 void fr_SHA1Final(uint8_t digest[20], fr_SHA1_CTX* context);
23
24 /*
25  * this version implements a raw SHA1 transform, no length is appended,
26  * nor any 128s out to the block size.
27  *
28  *      Hmm... this function doesn't appear to be used anywhere.
29  */
30 void fr_SHA1FinalNoLen(uint8_t digest[20], fr_SHA1_CTX* context);
31
32 #else  /* WITH_OPENSSL_SHA1 */
33
34 #define fr_SHA1_CTX     SHA_CTX
35 #define fr_SHA1Init     SHA1_Init
36 #define fr_SHA1Update   SHA1_Update
37 #define fr_SHA1Final    SHA1_Final
38 #define fr_SHA1Transform SHA1_Transform
39 #endif
40
41 /*
42  * FIPS 186-2 PRF based upon SHA1.
43  *
44  *      Hmm... this is only used in src/modules/rlm_eap/libeap/
45  *      why is the prototype here?
46  */
47 extern void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160]);
48
49 #ifdef __cplusplus
50 }
51 #endif
52
53 #endif /* _FR_SHA1_H */