diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:49:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:49:46 +0000 |
commit | 50b37d4a27d3295a29afca2286f1a5a086142cec (patch) | |
tree | 9212f763934ee090ef72d823f559f52ce387f268 /src/include/sha1.h | |
parent | Initial commit. (diff) | |
download | freeradius-50b37d4a27d3295a29afca2286f1a5a086142cec.tar.xz freeradius-50b37d4a27d3295a29afca2286f1a5a086142cec.zip |
Adding upstream version 3.2.1+dfsg.upstream/3.2.1+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/include/sha1.h')
-rw-r--r-- | src/include/sha1.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/include/sha1.h b/src/include/sha1.h new file mode 100644 index 0000000..86c3d9f --- /dev/null +++ b/src/include/sha1.h @@ -0,0 +1,57 @@ +#ifndef _FR_SHA1_H +#define _FR_SHA1_H + +#ifdef WITH_OPENSSL_SHA1 +#include <openssl/sha.h> +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SHA1_DIGEST_LENGTH +# define SHA1_DIGEST_LENGTH 20 +#endif + +#ifndef WITH_OPENSSL_SHA1 +typedef struct { + uint32_t state[5]; + uint32_t count[2]; + uint8_t buffer[64]; +} fr_sha1_ctx; + +void fr_sha1_transform(uint32_t state[5], uint8_t const buffer[64]); +void fr_sha1_init(fr_sha1_ctx *context); +void fr_sha1_update(fr_sha1_ctx *context, uint8_t const *data, size_t len); +void fr_sha1_final(uint8_t digest[20], fr_sha1_ctx *context); + +/* + * this version implements a raw SHA1 transform, no length is appended, + * nor any 128s out to the block size. + */ +void fr_sha1_final_no_len(uint8_t digest[20], fr_sha1_ctx* context); + +#else /* WITH_OPENSSL_SHA1 */ +USES_APPLE_DEPRECATED_API +#define fr_sha1_ctx SHA_CTX +#define fr_sha1_init SHA1_Init +#define fr_sha1_update SHA1_Update +#define fr_sha1_final SHA1_Final +#define fr_sha1_transform SHA1_Transform +#endif + +/* + * FIPS 186-2 PRF based upon SHA1. + */ +void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160]); + +/* hmacsha1.c */ + +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); + +#ifdef __cplusplus +} +#endif + +#endif /* _FR_SHA1_H */ |