ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
sha1.h
Go to the documentation of this file.
1// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file sha1.h
6 * @brief SHA-1 (FIPS 180-4) - one-shot digest.
7 *
8 * The shared SHA-1 primitive. On Arduino (ESP32) delegates to mbedtls_sha1() (hardware SHA
9 * accelerator); on native builds a portable software implementation is used. Used for the WebSocket
10 * opening handshake (RFC 6455 ยง4.2.2) and other legacy digest needs. Output is always 20 bytes.
11 *
12 * @author Douglas Quigg (dstroy0)
13 * @date 2026
14 */
15
16#ifndef PROTOCORE_SHA1_H
17#define PROTOCORE_SHA1_H
18
19#include <stddef.h>
20#include <stdint.h>
21
22/** @brief SHA-1 digest length in bytes. */
23#define PC_SHA1_DIGEST_LEN 20
24
25/**
26 * @brief Compute a SHA-1 digest over an arbitrary byte buffer.
27 *
28 * @param data Input bytes.
29 * @param len Number of input bytes.
30 * @param digest Output buffer; must be at least PC_SHA1_DIGEST_LEN bytes.
31 */
32void pc_sha1(const uint8_t *data, size_t len, uint8_t digest[PC_SHA1_DIGEST_LEN]);
33
34#endif // PROTOCORE_SHA1_H
void pc_sha1(const uint8_t *data, size_t len, uint8_t digest[PC_SHA1_DIGEST_LEN])
Compute a SHA-1 digest over an arbitrary byte buffer.
Definition sha1.cpp:26
#define PC_SHA1_DIGEST_LEN
SHA-1 digest length in bytes.
Definition sha1.h:23