Merge issue-41-hmac-pbkdf2: HMAC-SHA1 and PBKDF2-HMAC-SHA256 (closes #41)

This commit is contained in:
faumaray committed 2026-12-03 15:51:04 +03:00
commit 9b773a4553
6 files changed
+826 -46

No files matched your search

+33
View File
@@ -5,6 +5,7 @@
#include <Void/Functional/Result.hpp>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <memory>
#include <span>
@@ -195,6 +196,19 @@ namespace Void::Crypto
std::span<const std::byte> signature,
const ProviderOptions& provider = {});
/// Compute HMAC-SHA-1 (RFC 2104) into a caller-owned 20-byte buffer.
/// Wipes output on backend failure and rejects overlapping buffers.
[[nodiscard]] Void::Result::Result<void>
hmac_sha1_into(std::span<const std::byte> secret_key,
std::span<const std::byte> message,
std::span<std::byte> output,
const ProviderOptions& provider = {});
[[nodiscard]] Void::Result::Result<Digest>
hmac_sha1(std::span<const std::byte> secret_key,
std::span<const std::byte> message,
const ProviderOptions& provider = {});
/// Compute HMAC-SHA-256 into a caller-owned 32-byte buffer.
/// Wipes output on backend failure and rejects overlapping buffers.
[[nodiscard]] Void::Result::Result<void>
@@ -208,6 +222,25 @@ namespace Void::Crypto
std::span<const std::byte> message,
const ProviderOptions& provider = {});
/// Derive key material with RFC 8018 PBKDF2-HMAC-SHA-256 into a
/// caller-owned buffer. iterations must be 1..kMaxPbkdf2Iterations, salt
/// at most kMaxPbkdf2SaltBytes and output 1..kMaxPbkdf2OutputBytes.
/// Rejects overlapping buffers and wipes output on any failure after
/// validation.
[[nodiscard]] Void::Result::Result<void>
pbkdf2_hmac_sha256_into(std::span<const std::byte> password,
std::span<const std::byte> salt,
std::uint32_t iterations,
std::span<std::byte> output,
const ProviderOptions& provider = {});
[[nodiscard]] Void::Result::Result<Digest>
pbkdf2_hmac_sha256(std::span<const std::byte> password,
std::span<const std::byte> salt,
std::uint32_t iterations,
std::size_t output_length,
const ProviderOptions& provider = {});
/// Derive key material with RFC 5869 HKDF-SHA-256 into a caller-owned
/// buffer (1..CryptoLimits::kMaxHkdfOutputBytes). Rejects overlapping
/// buffers and wipes secret_output on any failure after validation.