All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sha1.h
Go to the documentation of this file.
1 #ifndef _FR_SHA1_H
2 #define _FR_SHA1_H
3 /**
4  * $Id: 65ec96a0508624313fc62b9bfef65611fb97c34e $
5  *
6  * @file include/sha1.h
7  * @brief Local implementation of the SHA1 hashing scheme.
8  */
9 #ifdef WITH_OPENSSL_SHA1
10 # include <openssl/sha.h>
11 #endif
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 #ifndef SHA1_DIGEST_LENGTH
18 # define SHA1_DIGEST_LENGTH 20
19 #endif
20 
21 #ifndef WITH_OPENSSL_SHA1
22 typedef struct {
23  uint32_t state[5];
24  uint32_t count[2];
25  uint8_t buffer[64];
26 } fr_sha1_ctx;
27 
28 void fr_sha1_transform(uint32_t state[5], uint8_t const buffer[64]);
29 void fr_sha1_init(fr_sha1_ctx *context);
30 void fr_sha1_update(fr_sha1_ctx *context, uint8_t const *data, size_t len);
31 void fr_sha1_final(uint8_t digest[20], fr_sha1_ctx *context);
32 
33 /*
34  * this version implements a raw SHA1 transform, no length is appended,
35  * nor any 128s out to the block size.
36  */
37 void fr_sha1_final_no_len(uint8_t digest[20], fr_sha1_ctx* context);
38 
39 #else /* WITH_OPENSSL_SHA1 */
41 # define fr_sha1_ctx SHA_CTX
42 # define fr_sha1_init SHA1_Init
43 # define fr_sha1_update SHA1_Update
44 # define fr_sha1_final SHA1_Final
45 # define fr_sha1_transform SHA1_Transform
46 #endif
47 
48 /*
49  * FIPS 186-2 PRF based upon SHA1.
50  */
51 void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160]);
52 
53 /* hmacsha1.c */
54 
55 void fr_hmac_sha1(uint8_t digest[SHA1_DIGEST_LENGTH], uint8_t const *text, size_t text_len,
56  uint8_t const *key, size_t key_len);
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 #endif /* _FR_SHA1_H */
void fr_sha1_update(fr_sha1_ctx *context, uint8_t const *data, size_t len)
Definition: sha1.c:106
#define SHA1_DIGEST_LENGTH
Definition: sha1.h:18
void fr_sha1_init(fr_sha1_ctx *context)
Definition: sha1.c:94
void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160])
Definition: fips186prf.c:100
void fr_sha1_final(uint8_t digest[20], fr_sha1_ctx *context)
Definition: sha1.c:132
unsigned int state
Definition: proto_bfd.c:200
uint8_t data[]
Definition: eap_pwd.h:625
void fr_hmac_sha1(uint8_t digest[SHA1_DIGEST_LENGTH], uint8_t const *text, size_t text_len, uint8_t const *key, size_t key_len)
Calculate HMAC using SHA1.
Definition: hmacsha1.c:28
void fr_sha1_final_no_len(uint8_t digest[20], fr_sha1_ctx *context)
Definition: sha1.c:165
#define USES_APPLE_DEPRECATED_API
Definition: build.h:122
void fr_sha1_transform(uint32_t state[5], uint8_t const buffer[64])
Definition: sha1.c:36