auth 0.0.1
Authenticated computation with C++26 modules
Loading...
Searching...
No Matches
hash.ccm
Go to the documentation of this file.
1// SPDX-FileType: Source
2// SPDX-FileCopyrightText: 2026 Edward Kmett <ekmett@gmail.com>
3// SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0
4
8module;
9#include <array>
10#include <cstdint>
11#include <span>
12#include <openssl/sha.h>
13
14export module auth.hash;
15export import auth.error;
16
17namespace auth {
18
20export using digest = std::array<std::uint8_t, 32>;
21
27export inline digest sha256(std::span<const std::uint8_t> data) {
28 digest result;
29 if (!SHA256(data.data(), data.size(), result.data()))
30 throw auth_error("SHA-256 failed");
31 return result;
32}
33
34} // namespace auth
std::array< std::uint8_t, 32 > digest
The 32 bytes of a SHA-256 digest in hash output order.
Definition hash.ccm:20
digest sha256(std::span< const std::uint8_t > data)
Hashes exactly the supplied bytes with OpenSSL's SHA-256 implementation.
Definition hash.ccm:27
Reports malformed input, invalid proofs, or hashing failures.
Definition error.ccm:16