fix: close the VBS-side gaps noted on Void/Library#61
This commit is contained in:
1 parent
4f581d1b51
commit
4d51331777
13 files changed
+158
-14
No files matched your search
+24
-3
@@ -1038,17 +1038,31 @@ void build(Void::Build::Project &p) {
|
||||
auto signature_text = Void::FileSystem::read_file(signed_archive.string() + ".sig");
|
||||
auto public_key_text = Void::FileSystem::read_file(signed_archive.string() + ".pub");
|
||||
auto checksum_text = Void::FileSystem::read_file(signed_archive.string() + ".sha256");
|
||||
auto message_text = Void::FileSystem::read_file(signed_archive.string() + ".msg");
|
||||
Void::Testing::require(archive_bytes.has_value() && signature_text.has_value() &&
|
||||
public_key_text.has_value() && checksum_text.has_value());
|
||||
public_key_text.has_value() && checksum_text.has_value() &&
|
||||
message_text.has_value());
|
||||
Void::Testing::expect_eq(signature_text->size(), std::size_t{129});
|
||||
Void::Testing::expect_eq(public_key_text->size(), std::size_t{65});
|
||||
Void::Testing::expect(checksum_text->starts_with(Util::sha256_hex(*archive_bytes)));
|
||||
// The signed message is the short canonical digest statement, not the archive bytes.
|
||||
Void::Testing::expect(message_text->starts_with("vbs-installer-v1\n"));
|
||||
Void::Testing::expect(message_text->size() < 128);
|
||||
auto verified = Provenance::verify_message(
|
||||
std::as_bytes(std::span<const char>{archive_bytes->data(), archive_bytes->size()}),
|
||||
std::as_bytes(std::span<const char>{message_text->data(), message_text->size()}),
|
||||
std::string_view{*signature_text}.substr(0, 128),
|
||||
std::string_view{*public_key_text}.substr(0, 64));
|
||||
Void::Testing::require(verified.has_value());
|
||||
Void::Testing::expect(*verified);
|
||||
// A tampered digest must not verify.
|
||||
std::string tampered = *message_text;
|
||||
tampered[tampered.size() - 2] = tampered[tampered.size() - 2] == '0' ? '1' : '0';
|
||||
auto tampered_result = Provenance::verify_message(
|
||||
std::as_bytes(std::span<const char>{tampered.data(), tampered.size()}),
|
||||
std::string_view{*signature_text}.substr(0, 128),
|
||||
std::string_view{*public_key_text}.substr(0, 64));
|
||||
Void::Testing::require(tampered_result.has_value());
|
||||
Void::Testing::expect(!*tampered_result);
|
||||
} else {
|
||||
// Without an Ed25519 backend signing must fail closed, never silently skip.
|
||||
Void::Testing::expect(sign_res.has_value() && !sign_res->succeeded());
|
||||
@@ -2095,7 +2109,14 @@ VOID_TEST(FullV1Tests, native_vbs_subproject_dependency_builds_without_cmake) {
|
||||
// Pure `build.cpp` library dependency (NO CMakeLists.txt!).
|
||||
const auto dep_dir = tmp / "sub_math_dep";
|
||||
write_file(dep_dir / "build.cpp", R"cpp(#include <Void/Build.hpp>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
void build(Void::Build::Project &p) {
|
||||
// The consumer's .native_builder({...}) options reach this description.
|
||||
const std::string enabled = Void::Build::dependency_option("SUB_MATH_ENABLED");
|
||||
if (enabled != "yes") {
|
||||
throw std::runtime_error("SUB_MATH_ENABLED must be yes, got '" + enabled + "'");
|
||||
}
|
||||
auto lib = p.static_library("sub_math");
|
||||
lib.cxx_standard(Void::Build::CxxStandard::Cxx26)
|
||||
.sources({"src/math.cpp"})
|
||||
@@ -2113,7 +2134,7 @@ void build(Void::Build::Project &p) {
|
||||
"void build(Void::Build::Project &p) {\n"
|
||||
" auto dep = p.dependency(\"math\").path(\"" +
|
||||
dep_dir.string() +
|
||||
"\").native_builder();\n"
|
||||
"\").native_builder({{\"SUB_MATH_ENABLED\", \"yes\"}});\n"
|
||||
" p.test(\"consumer_test\")\n"
|
||||
" .cxx_standard(Void::Build::CxxStandard::Cxx26)\n"
|
||||
" .sources({\"tests/main.cpp\"})\n"
|
||||
|
||||
Reference in new issue
Block a user