feat(install): sign installer archives with Ed25519 and checksums
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 3s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 9s

This commit is contained in:
faumaray committed 2026-12-05 05:36:11 +03:00
1 parent 9509c0691e
commit b55aca328a
8 files changed
+122 -10

No files matched your search

+44 -8
View File
@@ -2,6 +2,7 @@
#include <Void/Build/Package/Archive.hpp>
#include <Void/Build/Platform/FileOps.hpp>
#include <Void/Build/Provenance/Signing.hpp>
#include <Void/Build/Util/Json.hpp>
#include <Void/Build/Util/Sha256.hpp>
#include <Void/Core/Scope.hpp>
@@ -591,19 +592,13 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
if (auto zipped = write_stored_zip(*options.archive_path, archive_entries); !zipped) {
return std::unexpected{zipped.error()};
}
report.archive_path = *options.archive_path;
return report;
}
if (options.archive_format == "deb") {
} else if (options.archive_format == "deb") {
if (auto packed = write_deb_package(*options.archive_path, options, graph,
archive_entries);
!packed) {
return std::unexpected{packed.error()};
}
report.archive_path = *options.archive_path;
return report;
}
} else {
const bool archive_as_script = options.archive_format == "sh";
const auto archive_target = archive_as_script
? stage_root / "installer-payload.tar"
@@ -659,7 +654,48 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
return std::unexpected{written.error()};
}
}
}
report.archive_path = *options.archive_path;
// Optional detached signature and checksums over the final archive bytes.
if (options.signing_seed_path) {
auto bytes = Void::FileSystem::read_file(*options.archive_path);
if (!bytes) {
return std::unexpected{bytes.error()};
}
report.archive_sha256 = Util::sha256_hex(*bytes);
report.checksum_path = options.archive_path->string() + ".sha256";
if (auto written = Platform::atomic_write_file(
*report.checksum_path,
report.archive_sha256 + " " + options.archive_path->filename().string() + "\n",
true);
!written) {
return std::unexpected{written.error()};
}
auto signature = Provenance::sign_message(
std::as_bytes(std::span<const char>{bytes->data(), bytes->size()}),
*options.signing_seed_path);
if (!signature) {
return std::unexpected{signature.error()};
}
auto public_key = Provenance::public_key_from_seed(*options.signing_seed_path);
if (!public_key) {
return std::unexpected{public_key.error()};
}
report.signature_path = options.archive_path->string() + ".sig";
if (auto written = Platform::atomic_write_file(*report.signature_path,
*signature + "\n", true);
!written) {
return std::unexpected{written.error()};
}
report.public_key_path = options.archive_path->string() + ".pub";
if (auto written = Platform::atomic_write_file(*report.public_key_path,
*public_key + "\n", true);
!written) {
return std::unexpected{written.error()};
}
}
}
return report;
}
+11 -1
View File
@@ -1691,6 +1691,7 @@ struct InstallCmdOptions {
std::optional<std::string> component_arg;
std::optional<std::string> archive_arg;
std::string archive_format_arg{"tar"};
std::optional<std::string> signing_key_arg;
bool no_cmake_export{false};
bool no_native_export{false};
bool bundle_dependencies{false};
@@ -1732,6 +1733,12 @@ int execute_install_command(const InstallCmdOptions &opts) {
if (opts.archive_arg && !opts.archive_arg->empty()) {
iopts.archive_path = std::filesystem::path{*opts.archive_arg};
iopts.archive_format = opts.archive_format_arg;
if (opts.signing_key_arg) {
iopts.signing_seed_path = std::filesystem::path{*opts.signing_key_arg};
}
} else if (opts.signing_key_arg) {
std::cerr << "vbs install: --signing-key requires --archive\n";
return 2;
}
std::error_code ec;
@@ -2874,7 +2881,10 @@ int main(int argc, char **argv) {
install_opts.archive_arg)
.option_default("--archive-format", "",
"Installer archive format: tar (default), sh, zip or deb",
install_opts.archive_format_arg, "tar");
install_opts.archive_format_arg, "tar")
.option("--signing-key", "",
"Ed25519 seed file; signs the archive and writes .sha256/.sig/.pub",
install_opts.signing_key_arg);
add_log_flags(install_cmd);
auto &uninstall_cmd =