feat(security): add SecureBuffer, VSEC envelopes, authorization, and SecurityAsync Authenticator
This commit is contained in:
1 parent
eb42228604
commit
713d2dc656
20 files changed
+4070
-43
No files matched your search
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/Functional/Result.hpp>
|
||||
#include <Void/Security/Types.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
@@ -23,6 +24,14 @@ namespace Void::Security
|
||||
inline constexpr std::size_t secret_authentication_bytes = 16;
|
||||
using SecretKey = std::array<unsigned char, secret_key_bytes>;
|
||||
|
||||
/// Wipe a mutable byte buffer with sodium_memzero.
|
||||
void wipe_bytes(std::span<unsigned char> buffer) noexcept;
|
||||
|
||||
/// Constant-time comparison using sodium_memcmp.
|
||||
[[nodiscard]] bool
|
||||
constant_time_equal(std::span<const unsigned char> lhs,
|
||||
std::span<const unsigned char> rhs) noexcept;
|
||||
|
||||
/// Generate a URL-safe, unpadded token containing `entropy_bytes` of
|
||||
/// cryptographically secure randomness.
|
||||
[[nodiscard]] Void::Result::Result<std::string>
|
||||
@@ -44,6 +53,18 @@ namespace Void::Security
|
||||
std::string_view password,
|
||||
PasswordHashStrength strength = PasswordHashStrength::Moderate);
|
||||
|
||||
/// Parse Argon2id cost parameters (`$argon2id$v=19$m=...,t=...,p=...$...`)
|
||||
/// without executing Argon2id or allocating memory.
|
||||
[[nodiscard]] Void::Result::Result<Argon2idCost>
|
||||
parse_argon2id_cost(std::string_view encoded_hash);
|
||||
|
||||
/// Verify a password against an encoded Argon2id hash after enforcing input
|
||||
/// caps and operator-approved memory/iteration/parallelism cost budgets.
|
||||
[[nodiscard]] Void::Result::Result<bool>
|
||||
verify_password_budgeted(std::string_view password,
|
||||
std::string_view encoded_hash,
|
||||
const PasswordVerifyBudget& budget = {});
|
||||
|
||||
/// Verify a password against a libsodium Argon2id encoded hash.
|
||||
/// Malformed hashes are treated as a non-match.
|
||||
[[nodiscard]] Void::Result::Result<bool>
|
||||
@@ -53,8 +74,8 @@ namespace Void::Security
|
||||
/// Generate a cryptographically random key for local secret encryption.
|
||||
[[nodiscard]] Void::Result::Result<SecretKey> random_secret_key();
|
||||
|
||||
/// Encrypt and authenticate bytes. The returned portable envelope is
|
||||
/// nonce || ciphertext || authentication tag.
|
||||
/// Encrypt and authenticate bytes using the legacy local secret format
|
||||
/// (24-byte nonce || crypto_secretbox_easy combined MAC + ciphertext).
|
||||
[[nodiscard]] Void::Result::Result<std::vector<unsigned char>>
|
||||
seal_secret(std::span<const unsigned char> plaintext,
|
||||
const SecretKey& key);
|
||||
|
||||
Reference in new issue
Block a user