feat(install): sign installer archives with Ed25519 and checksums
This commit is contained in:
1 parent
9509c0691e
commit
b55aca328a
8 files changed
+122
-10
No files matched your search
@@ -14,9 +14,11 @@
|
||||
#include <Void/Build/Platform/FileOps.hpp>
|
||||
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||
#include <Void/Build/Provenance/Sbom.hpp>
|
||||
#include <Void/Build/Provenance/Signing.hpp>
|
||||
#include <Void/Build/Provider/Provider.hpp>
|
||||
#include <Void/Build/Provider/Translator.hpp>
|
||||
#include <Void/Build/Snapshot/Snapshot.hpp>
|
||||
#include <Void/Build/Util/Sha256.hpp>
|
||||
#include <Void/Build/State/StateStore.hpp>
|
||||
#include <Void/Build/Toolchain/Driver.hpp>
|
||||
#include <Void/Build/Watch/Watcher.hpp>
|
||||
@@ -32,6 +34,7 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <span>
|
||||
#include <thread>
|
||||
|
||||
using namespace Void::Build;
|
||||
@@ -1009,6 +1012,49 @@ void build(Void::Build::Project &p) {
|
||||
Void::Testing::expect(std::filesystem::exists(data_out / "bin" / "cli_hi"));
|
||||
}
|
||||
|
||||
// Signed installer archive: Ed25519 detached signature plus checksums.
|
||||
const auto signed_archive = tmp / "cli_hi-signed.tar";
|
||||
const auto signing_seed = tmp / "install.seed";
|
||||
auto sign_req = inst_req;
|
||||
for (auto &arg : sign_req.arguments) {
|
||||
if (arg == installer_archive.string()) {
|
||||
arg = signed_archive.string();
|
||||
}
|
||||
}
|
||||
sign_req.arguments.push_back("--signing-key");
|
||||
sign_req.arguments.push_back(signing_seed.string());
|
||||
const bool signing_ready = Provenance::signing_available();
|
||||
if (signing_ready) {
|
||||
Void::Testing::require(
|
||||
Provenance::generate_signing_seed(signing_seed).has_value());
|
||||
}
|
||||
auto sign_res = Platform::run_supervised(sign_req);
|
||||
if (signing_ready) {
|
||||
Void::Testing::expect(sign_res.has_value() && sign_res->succeeded());
|
||||
Void::Testing::expect(std::filesystem::exists(signed_archive.string() + ".sha256"));
|
||||
Void::Testing::expect(std::filesystem::exists(signed_archive.string() + ".sig"));
|
||||
Void::Testing::expect(std::filesystem::exists(signed_archive.string() + ".pub"));
|
||||
auto archive_bytes = Void::FileSystem::read_file(signed_archive);
|
||||
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");
|
||||
Void::Testing::require(archive_bytes.has_value() && signature_text.has_value() &&
|
||||
public_key_text.has_value() && checksum_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)));
|
||||
auto verified = Provenance::verify_message(
|
||||
std::as_bytes(
|
||||
std::span<const char>{archive_bytes->data(), archive_bytes->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);
|
||||
} else {
|
||||
// Without an Ed25519 backend signing must fail closed, never silently skip.
|
||||
Void::Testing::expect(sign_res.has_value() && !sign_res->succeeded());
|
||||
}
|
||||
|
||||
Platform::ProcessRequest uninst_req;
|
||||
uninst_req.executable = vbs_bin;
|
||||
uninst_req.arguments = {"uninstall", "--prefix", cli_prefix.string()};
|
||||
|
||||
Reference in new issue
Block a user