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
@@ -496,6 +496,11 @@ write_deb_package(const std::filesystem::path &output, const InstallOptions &opt
|
||||
return Platform::atomic_write_file(output, deb, true);
|
||||
}
|
||||
|
||||
// Canonical short message signed for installer archives (independent of archive size).
|
||||
std::string installer_signing_message(std::string_view archive_sha256) {
|
||||
return "vbs-installer-v1\n" + std::string{archive_sha256} + "\n";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Void::Result::Result<InstallReport, Void::Result::Error>
|
||||
@@ -904,13 +909,15 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
|
||||
}
|
||||
report.archive_path = *options.archive_path;
|
||||
|
||||
// Optional detached signature and checksums over the final archive bytes.
|
||||
// Optional detached signature and checksums over the final archive. The signed message
|
||||
// is a short canonical digest statement, not the archive bytes, so archives of any size
|
||||
// stay within the crypto one-shot limit.
|
||||
if (options.signing_seed_path) {
|
||||
auto bytes = Void::FileSystem::read_file(*options.archive_path);
|
||||
if (!bytes) {
|
||||
return std::unexpected{bytes.error()};
|
||||
auto digest = Util::sha256_file_hex(*options.archive_path);
|
||||
if (!digest) {
|
||||
return std::unexpected{digest.error()};
|
||||
}
|
||||
report.archive_sha256 = Util::sha256_hex(*bytes);
|
||||
report.archive_sha256 = *digest;
|
||||
report.checksum_path = options.archive_path->string() + ".sha256";
|
||||
if (auto written = Platform::atomic_write_file(
|
||||
*report.checksum_path,
|
||||
@@ -920,8 +927,10 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
|
||||
return std::unexpected{written.error()};
|
||||
}
|
||||
|
||||
const std::string canonical_message = installer_signing_message(report.archive_sha256);
|
||||
auto signature = Provenance::sign_message(
|
||||
std::as_bytes(std::span<const char>{bytes->data(), bytes->size()}),
|
||||
std::as_bytes(std::span<const char>{canonical_message.data(),
|
||||
canonical_message.size()}),
|
||||
*options.signing_seed_path);
|
||||
if (!signature) {
|
||||
return std::unexpected{signature.error()};
|
||||
@@ -942,6 +951,11 @@ install_project(const Graph::ProjectDescription &description, const Graph::Build
|
||||
!written) {
|
||||
return std::unexpected{written.error()};
|
||||
}
|
||||
if (auto written = Platform::atomic_write_file(
|
||||
options.archive_path->string() + ".msg", canonical_message, true);
|
||||
!written) {
|
||||
return std::unexpected{written.error()};
|
||||
}
|
||||
}
|
||||
}
|
||||
return report;
|
||||
|
||||
Reference in new issue
Block a user