feat(provenance): enforce trusted Ed25519 package signatures in publish, lockfile, and locked builds
This commit is contained in:
1 parent
21babb8c31
commit
85f2ae274f
21 files changed
+519
-15
No files matched your search
@@ -29,6 +29,8 @@ struct LockedSourceEntry {
|
||||
std::string builder;
|
||||
std::vector<std::string> features;
|
||||
bool build_dependency{false};
|
||||
std::optional<std::string> signature; // Ed25519 detached signature hex (package entries)
|
||||
std::optional<std::string> public_key; // Signer public key hex (package entries)
|
||||
};
|
||||
|
||||
struct LockContextRecord {
|
||||
|
||||
@@ -24,6 +24,9 @@ struct PublishOptions {
|
||||
std::string description;
|
||||
bool is_private{false};
|
||||
RegistryAuth auth;
|
||||
// Optional Ed25519 signing seed (64 hex chars). When set, the published release carries
|
||||
// X-Package-Signature / X-Package-Public-Key over the canonical package message.
|
||||
std::optional<std::filesystem::path> signing_seed_path;
|
||||
};
|
||||
|
||||
struct PublishReceipt {
|
||||
|
||||
@@ -54,6 +54,8 @@ struct ReleaseRecord {
|
||||
std::string source_url;
|
||||
std::vector<DependencyConstraint> dependencies;
|
||||
std::vector<BinaryVariantMeta> binaries;
|
||||
std::optional<std::string> signature; // Ed25519 detached signature hex (optional)
|
||||
std::optional<std::string> public_key; // Signer public key hex (optional)
|
||||
};
|
||||
|
||||
class PackageIndex {
|
||||
@@ -73,6 +75,8 @@ struct SolvedPackage {
|
||||
std::set<std::string> enabled_features;
|
||||
std::vector<PackageId> dependencies;
|
||||
std::vector<BinaryVariantMeta> binaries;
|
||||
std::optional<std::string> signature; // Copied from the selected release (optional)
|
||||
std::optional<std::string> public_key; // Copied from the selected release (optional)
|
||||
};
|
||||
|
||||
struct SolveResult {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <Void/Functional/Error.hpp>
|
||||
#include <Void/Functional/Result.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace Void::Build::Provenance {
|
||||
|
||||
// Detached signature metadata attached to a registry package release or lockfile entry.
|
||||
struct PackageSignature {
|
||||
std::string sha256; // Archive digest hex.
|
||||
std::string signature; // Ed25519 detached signature hex (may be empty).
|
||||
std::string public_key; // Ed25519 signer public key hex (may be empty).
|
||||
};
|
||||
|
||||
enum class TrustDecision { Verified, Unsigned, UntrustedKey, InvalidSignature };
|
||||
|
||||
[[nodiscard]] std::string_view trust_decision_name(TrustDecision decision) noexcept;
|
||||
|
||||
// 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).
|
||||
// - Public key not in the trusted set => UntrustedKey (no cryptography is invoked).
|
||||
// - Trusted key with a valid signature => Verified; with an invalid signature => InvalidSignature.
|
||||
// Malformed hex or an unavailable crypto backend returns an explicit error.
|
||||
[[nodiscard]] Void::Result::Result<TrustDecision, Void::Result::Error>
|
||||
verify_trusted_package_signature(std::string_view name, std::string_view version,
|
||||
const PackageSignature &signature,
|
||||
const std::vector<std::string> &trusted_public_keys_hex);
|
||||
|
||||
} // namespace Void::Build::Provenance
|
||||
Reference in new issue
Block a user