The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
sha1.h
Go to the documentation of this file.
1 #pragma once
2 /** Local implementation of the SHA1 hashing scheme
3  *
4  * SHA-1 in C 100% Public Domain
5  *
6  * @file src/lib/util/sha1.h
7  *
8  * @author Steve Reid (steve@edmweb.com)
9  */
10 RCSIDH(sha1_h, "$Id: f096d1077fff60350abe74624bb45b8e3dc6052d $")
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #include <freeradius-devel/build.h>
17 #include <freeradius-devel/missing.h>
18 
19 #ifdef WITH_OPENSSL_SHA1
20 # include <freeradius-devel/tls/openssl_user_macros.h>
21 # include <openssl/sha.h>
22 #endif
23 
24 #include <stddef.h>
25 #include <stdint.h>
26 #include <string.h>
27 
28 #ifndef SHA1_DIGEST_LENGTH
29 # define SHA1_DIGEST_LENGTH 20
30 #endif
31 
32 #ifndef WITH_OPENSSL_SHA1
33 typedef struct {
34  uint32_t state[5];
37 } fr_sha1_ctx;
38 
39 void fr_sha1_transform(uint32_t state[static 5], uint8_t const buffer[static 64]);
41 void fr_sha1_update(fr_sha1_ctx *context, uint8_t const *in, size_t len);
43 
44 /*
45  * this version implements a raw SHA1 transform, no length is appended,
46  * nor any 128s out to the block size.
47  */
49 
50 #else /* WITH_OPENSSL_SHA1 */
52 # define fr_sha1_ctx SHA_CTX
53 # define fr_sha1_init SHA1_Init
54 # define fr_sha1_update SHA1_Update
55 # define fr_sha1_final SHA1_Final
56 # define fr_sha1_transform SHA1_Transform
57 #endif
58 
59 /* hmacsha1.c */
60 
61 int fr_hmac_sha1(uint8_t digest[static SHA1_DIGEST_LENGTH], uint8_t const *in, size_t inlen,
62  uint8_t const *key, size_t key_len);
63 
64 #ifdef __cplusplus
65 }
66 #endif
static int const char char buffer[256]
Definition: acutest.h:574
static int context
Definition: radmin.c:71
#define USES_APPLE_DEPRECATED_API
Definition: build.h:431
#define RCSIDH(h, id)
Definition: build.h:445
static fr_slen_t in
Definition: dict.h:645
unsigned int uint32_t
Definition: merged_model.c:33
unsigned char uint8_t
Definition: merged_model.c:30
#define SHA1_DIGEST_LENGTH
Definition: sha1.h:29
void fr_sha1_init(fr_sha1_ctx *context)
Definition: sha1.c:93
int fr_hmac_sha1(uint8_t digest[static SHA1_DIGEST_LENGTH], uint8_t const *in, size_t inlen, uint8_t const *key, size_t key_len)
Calculate HMAC using internal SHA1 implementation.
Definition: hmac_sha1.c:124
void fr_sha1_final_no_len(uint8_t digest[static SHA1_DIGEST_LENGTH], fr_sha1_ctx *context)
Definition: sha1.c:174
void fr_sha1_final(uint8_t digest[static SHA1_DIGEST_LENGTH], fr_sha1_ctx *context)
Definition: sha1.c:141
void fr_sha1_update(fr_sha1_ctx *context, uint8_t const *in, size_t len)
Definition: sha1.c:105
void fr_sha1_transform(uint32_t state[static 5], uint8_t const buffer[static 64])
Definition: sha1.c:35
return count
Definition: module.c:175
static size_t char fr_sbuff_t size_t inlen
Definition: value.h:984