feat(crypto,archive): implement VL-007 built-in hashes and VL-006 archive creation/gzip/tar fallback
This commit is contained in:
1 parent
b50131f52e
commit
22c8538754
19 files changed
+3326
-133
No files matched your search
@@ -123,6 +123,35 @@ Void::Testing::Test crypto_ed25519_signing_vectors_and_boundaries()
|
||||
{
|
||||
using namespace Void::Crypto;
|
||||
|
||||
if (!has_openssl_backend()) {
|
||||
auto gen_unavail = Ed25519PrivateKey::generate();
|
||||
Void::Testing::require(!gen_unavail.has_value());
|
||||
Void::Testing::expect_eq(
|
||||
gen_unavail.error().code().value,
|
||||
static_cast<std::int32_t>(CryptoErrorCode::unsupported_algorithm));
|
||||
|
||||
const std::array<std::byte, Ed25519PublicKeySize> dummy_pub{};
|
||||
const std::array<std::byte, Ed25519SignatureSize> dummy_sig{};
|
||||
for (const std::size_t bad_key_len : {0U, 1U, 31U, 33U, 64U}) {
|
||||
std::vector<std::byte> bad_key(bad_key_len, std::byte{0x11});
|
||||
auto r = verifyEd25519({}, dummy_sig, bad_key);
|
||||
Void::Testing::require(!r.has_value());
|
||||
Void::Testing::expect_eq(
|
||||
r.error().code().value,
|
||||
static_cast<std::int32_t>(CryptoErrorCode::invalid_key_size));
|
||||
}
|
||||
for (const std::size_t bad_sig_len : {0U, 1U, 63U, 65U}) {
|
||||
std::vector<std::byte> bad_sig(bad_sig_len, std::byte{0x22});
|
||||
auto r = verifyEd25519({}, bad_sig, dummy_pub);
|
||||
Void::Testing::require(!r.has_value());
|
||||
Void::Testing::expect_eq(
|
||||
r.error().code().value,
|
||||
static_cast<std::int32_t>(
|
||||
CryptoErrorCode::invalid_signature_size));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
struct Rfc8032Vector {
|
||||
std::string_view seed_hex;
|
||||
std::string_view pub_hex;
|
||||
@@ -357,6 +386,30 @@ Void::Testing::Test crypto_hmac_sha256_and_hkdf_sha256_vectors_and_guards()
|
||||
[](std::byte b) { return b == std::byte{0x00}; }));
|
||||
}
|
||||
|
||||
// Also verify built-in HMAC-SHA-256 and HKDF-SHA-256 produce identical
|
||||
// outputs without OpenSSL.
|
||||
{
|
||||
const ProviderOptions builtin_opts{.prefer_builtin = true};
|
||||
const std::vector<std::byte> key(20, std::byte{0x0b});
|
||||
auto mac = hmac_sha256(key, as_bytes("Hi There"), builtin_opts);
|
||||
Void::Testing::require(mac.has_value());
|
||||
Void::Testing::expect_eq(
|
||||
to_hex(*mac),
|
||||
std::string{"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e93"
|
||||
"76c2e32cff7"});
|
||||
|
||||
const std::vector<std::byte> ikm(22, std::byte{0x0b});
|
||||
const auto salt = from_hex("000102030405060708090a0b0c");
|
||||
const auto info = from_hex("f0f1f2f3f4f5f6f7f8f9");
|
||||
std::array<std::byte, 42> okm{};
|
||||
auto r = hkdf_sha256(ikm, salt, info, okm, builtin_opts);
|
||||
Void::Testing::require(r.has_value());
|
||||
Void::Testing::expect_eq(
|
||||
to_hex(okm),
|
||||
std::string{"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02"
|
||||
"d56ecc4c5bf34007208d5b887185865"});
|
||||
}
|
||||
|
||||
// constant_time_equal checks
|
||||
const auto a = from_hex("01020304");
|
||||
const auto b = from_hex("01020304");
|
||||
|
||||
Reference in new issue
Block a user