Loading...
Searching...
No Matches
sha1.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Oliver Hahm <oliver.hahm@inria.fr>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
21
22/* This code is public-domain - it is based on libcrypt
23 * placed in the public domain by Wei Dai and other contributors. */
24
25#include <stdint.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
34#define SHA1_DIGEST_LENGTH (20)
35
39#define SHA1_BLOCK_LENGTH (64)
40
45typedef struct {
47 uint32_t buffer[SHA1_BLOCK_LENGTH / sizeof(uint32_t)];
49 uint32_t state[SHA1_DIGEST_LENGTH / sizeof(uint32_t)];
51 uint32_t byte_count;
60
67
75void sha1_update(sha1_context *ctx, const void *data, size_t len);
76
84void sha1_final(sha1_context *ctx, void *digest);
85
93void sha1(void *digest, const void *data, size_t len);
94
102void sha1_init_hmac(sha1_context *ctx, const void *key, size_t key_length);
103
112void sha1_final_hmac(sha1_context *ctx, void *digest);
113
114#ifdef __cplusplus
115}
116#endif
117
#define SHA1_BLOCK_LENGTH
Length of SHA-1 block in byte.
Definition sha1.h:39
#define SHA1_DIGEST_LENGTH
Length of SHA-1 digests in byte.
Definition sha1.h:34
void sha1_final_hmac(sha1_context *ctx, void *digest)
Finalizes the SHA-1 message digest with MAC.
void sha1_update(sha1_context *ctx, const void *data, size_t len)
Update the SHA-1 context with a portion of the message being hashed.
void sha1_init(sha1_context *ctx)
Initialize SHA-1 message digest context.
void sha1(void *digest, const void *data, size_t len)
Calculate a SHA1 hash from the given data.
void sha1_final(sha1_context *ctx, void *digest)
Finalizes the SHA-1 message digest.
void sha1_init_hmac(sha1_context *ctx, const void *key, size_t key_length)
Initialize SHA-1 message digest context with MAC.
SHA-1 algorithm context.
Definition sha1.h:45
uint8_t key_buffer[SHA1_BLOCK_LENGTH]
internal state of the key buffer
Definition sha1.h:56
uint32_t state[SHA1_DIGEST_LENGTH/sizeof(uint32_t)]
buffering current state of hashing
Definition sha1.h:49
uint32_t byte_count
already processed bytes
Definition sha1.h:51
uint32_t buffer[SHA1_BLOCK_LENGTH/sizeof(uint32_t)]
internal buffer
Definition sha1.h:47
uint8_t inner_hash[SHA1_DIGEST_LENGTH]
temporary buffer for the inner hashing
Definition sha1.h:58
uint8_t buffer_offset
internal state variable to keep track if the buffer is filled before proceeding to hash this block
Definition sha1.h:54