feat(provenance): sign and verify prebuilt binary variants with trusted keys
This commit is contained in:
1 parent
ff59f6ff5c
commit
e97f3905e5
12 files changed
+250
-14
No files matched your search
@@ -59,6 +59,14 @@ make_binary_compatibility_key(const ProfileContext &profile,
|
||||
select_compatible_binary(const BinaryCompatibilityKey &key,
|
||||
const std::vector<BinaryVariantMeta> &available);
|
||||
|
||||
// Selects the first ABI-compatible binary variant and, when trusted keys are supplied, requires
|
||||
// a valid Ed25519 signature over the canonical binary message (fail closed on unsigned, untrusted,
|
||||
// or invalid variants). With no trusted keys this matches select_compatible_binary.
|
||||
[[nodiscard]] Void::Result::Result<BinaryVariantMeta, Void::Result::Error>
|
||||
select_compatible_signed_binary(const BinaryCompatibilityKey &key,
|
||||
const std::vector<BinaryVariantMeta> &available,
|
||||
const std::vector<std::string> &trusted_public_keys_hex);
|
||||
|
||||
// Acquires and verifies a source dependency (local path, exact pinned Git SHA, or
|
||||
// SHA-256 verified archive) into managed storage without ever modifying external checkouts.
|
||||
[[nodiscard]] Void::Result::Result<MaterializedSource, Void::Result::Error>
|
||||
|
||||
@@ -44,6 +44,8 @@ struct BinaryVariantMeta {
|
||||
std::string dependency_closure_hash;
|
||||
std::string sha256;
|
||||
std::string download_url;
|
||||
std::optional<std::string> signature; // Ed25519 detached signature hex (optional)
|
||||
std::optional<std::string> public_key; // Signer public key hex (optional)
|
||||
};
|
||||
|
||||
struct ReleaseRecord {
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#include <Void/Functional/Error.hpp>
|
||||
#include <Void/Functional/Result.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <filesystem>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
@@ -24,6 +26,15 @@ generate_signing_seed(const std::filesystem::path &seed_path);
|
||||
[[nodiscard]] Void::Result::Result<std::string, Void::Result::Error>
|
||||
public_key_from_seed(const std::filesystem::path &seed_path);
|
||||
|
||||
// Signs arbitrary exact message bytes and returns 128 lowercase hex characters.
|
||||
[[nodiscard]] Void::Result::Result<std::string, Void::Result::Error>
|
||||
sign_message(std::span<const std::byte> message, const std::filesystem::path &seed_path);
|
||||
|
||||
// Verifies a detached signature over arbitrary exact message bytes.
|
||||
[[nodiscard]] Void::Result::Result<bool, Void::Result::Error>
|
||||
verify_message(std::span<const std::byte> message, std::string_view signature_hex,
|
||||
std::string_view public_key_hex);
|
||||
|
||||
// Canonical package message signed by vbs:
|
||||
// "vbs-package-v1\n<name>@<version>\nsha256:<digest-hex>\n"
|
||||
[[nodiscard]] std::string canonical_package_message(std::string_view name, std::string_view version,
|
||||
|
||||
@@ -20,6 +20,23 @@ enum class TrustDecision { Verified, Unsigned, UntrustedKey, InvalidSignature };
|
||||
|
||||
[[nodiscard]] std::string_view trust_decision_name(TrustDecision decision) noexcept;
|
||||
|
||||
// Detached signature metadata attached to a prebuilt binary variant.
|
||||
struct BinarySignature {
|
||||
std::string variant_id;
|
||||
std::string sha256; // Binary artifact digest hex.
|
||||
std::string signature; // Ed25519 detached signature hex (may be empty).
|
||||
std::string public_key; // Ed25519 signer public key hex (may be empty).
|
||||
};
|
||||
|
||||
// Canonical binary-variant message: "vbs-binary-v1\n<variant_id>\nsha256:<digest-hex>\n".
|
||||
[[nodiscard]] std::string canonical_binary_message(std::string_view variant_id,
|
||||
std::string_view sha256_hex);
|
||||
|
||||
// Trust policy for binary-variant signatures (same decision semantics as package signatures).
|
||||
[[nodiscard]] Void::Result::Result<TrustDecision, Void::Result::Error>
|
||||
verify_trusted_binary_signature(const BinarySignature &signature,
|
||||
const std::vector<std::string> &trusted_public_keys_hex);
|
||||
|
||||
// Trust policy for package signatures:
|
||||
// - No trusted keys => Unsigned (the caller keeps legacy unsigned behavior).
|
||||
// - Missing signature or public key => Unsigned (the caller decides whether that is an error).
|
||||
|
||||
Reference in new issue
Block a user