Skip to content

Commit

Permalink
pb-rust: serialization sketches
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Leightcap <jack.leightcap@trailofbits.com>
  • Loading branch information
jleightcap committed Jul 27, 2023
1 parent b7d905d commit 284ed4f
Show file tree
Hide file tree
Showing 19 changed files with 206 additions and 530 deletions.
420 changes: 4 additions & 416 deletions gen/pb-rust/Cargo.lock

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions gen/pb-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ keywords = ["sigstore"]
categories = ["encoding", "parser-implementations"]

[dependencies]
pbjson-types = "0.5.1"
prost-types = "0.11.9"
prost = "0.11.9"
serde = {version = "1.0", features = ["derive"]}

[dev-dependencies]
serde_json = "1.0.79"
serde_json = "1.0"
13 changes: 0 additions & 13 deletions gen/pb-rust/codegen/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion gen/pb-rust/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ license-file = "../LICENSE"
[dependencies]
anyhow = "1.0.72"
glob = "0.3"
pbjson-build = "0.5.1"
prost-build = "0.11.9"
12 changes: 6 additions & 6 deletions gen/pb-rust/codegen/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
fn main() -> anyhow::Result<()> {
prost_build::Config::new()
.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
.type_attribute(".", r#"#[serde(rename_all = "camelCase")]"#)
// .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
// .type_attribute(".", r#"#[serde(rename_all = "camelCase")]"#)
.compile_well_known_types()
.extern_path(".google.protobuf", "::pbjson_types")
.extern_path(".google.protobuf", "::prost_types")
.out_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/../src/codegen"))
.compile_protos(
&glob::glob(concat!(
Expand All @@ -19,9 +19,9 @@ fn main() -> anyhow::Result<()> {
],
)?;

pbjson_build::Builder::new()
.out_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/../src/codegen"))
.build(&[""])?;
// pbjson_build::Builder::new()
// .out_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/../src/codegen"))
// .build(&[""])?;

Ok(())
}
10 changes: 0 additions & 10 deletions gen/pb-rust/src/codegen/dev.sigstore.bundle.v1.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/// Various timestamped counter signatures over the artifacts signature.
/// Currently only RFC3161 signatures are provided. More formats may be added
/// in the future.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TimestampVerificationData {
Expand All @@ -18,8 +16,6 @@ pub struct TimestampVerificationData {
}
/// VerificationMaterial captures details on the materials used to verify
/// signatures.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct VerificationMaterial {
Expand All @@ -43,8 +39,6 @@ pub struct VerificationMaterial {
}
/// Nested message and enum types in `VerificationMaterial`.
pub mod verification_material {
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Content {
Expand All @@ -54,8 +48,6 @@ pub mod verification_material {
X509CertificateChain(super::super::super::common::v1::X509CertificateChain),
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Bundle {
Expand All @@ -76,8 +68,6 @@ pub struct Bundle {
}
/// Nested message and enum types in `Bundle`.
pub mod bundle {
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Content {
Expand Down
38 changes: 2 additions & 36 deletions gen/pb-rust/src/codegen/dev.sigstore.common.v1.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/// HashOutput captures a digest of a 'message' (generic octet sequence)
/// and the corresponding hash algorithm used.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HashOutput {
Expand All @@ -13,8 +11,6 @@ pub struct HashOutput {
pub digest: ::prost::alloc::vec::Vec<u8>,
}
/// MessageSignature stores the computed signature over a message.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MessageSignature {
Expand All @@ -33,8 +29,6 @@ pub struct MessageSignature {
pub signature: ::prost::alloc::vec::Vec<u8>,
}
/// LogId captures the identity of a transparency log.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogId {
Expand All @@ -46,8 +40,6 @@ pub struct LogId {
pub key_id: ::prost::alloc::vec::Vec<u8>,
}
/// This message holds a RFC 3161 timestamp.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Rfc3161SignedTimestamp {
Expand All @@ -56,8 +48,6 @@ pub struct Rfc3161SignedTimestamp {
#[prost(bytes = "vec", tag = "1")]
pub signed_timestamp: ::prost::alloc::vec::Vec<u8>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublicKey {
Expand All @@ -74,8 +64,6 @@ pub struct PublicKey {
}
/// PublicKeyIdentifier can be used to identify an (out of band) delivered
/// key, to verify a signature.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PublicKeyIdentifier {
Expand All @@ -92,17 +80,13 @@ pub struct PublicKeyIdentifier {
pub hint: ::prost::alloc::string::String,
}
/// An ASN.1 OBJECT IDENTIFIER
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ObjectIdentifier {
#[prost(int32, repeated, packed = "false", tag = "1")]
pub id: ::prost::alloc::vec::Vec<i32>,
}
/// An OID and the corresponding (byte) value.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ObjectIdentifierValuePair {
Expand All @@ -111,8 +95,6 @@ pub struct ObjectIdentifierValuePair {
#[prost(bytes = "vec", tag = "2")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DistinguishedName {
Expand All @@ -121,17 +103,13 @@ pub struct DistinguishedName {
#[prost(string, tag = "2")]
pub common_name: ::prost::alloc::string::String,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct X509Certificate {
/// DER-encoded X.509 certificate.
#[prost(bytes = "vec", tag = "1")]
pub raw_bytes: ::prost::alloc::vec::Vec<u8>,
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SubjectAlternativeName {
Expand All @@ -142,8 +120,6 @@ pub struct SubjectAlternativeName {
}
/// Nested message and enum types in `SubjectAlternativeName`.
pub mod subject_alternative_name {
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Identity {
Expand All @@ -157,8 +133,6 @@ pub mod subject_alternative_name {
}
}
/// A chain of X.509 certificates.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct X509CertificateChain {
Expand Down Expand Up @@ -186,15 +160,13 @@ pub struct X509CertificateChain {
/// (i.e., [start, end]).
/// End is optional to be able to capture a period that has started but
/// has no known end.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TimeRange {
#[prost(message, optional, tag = "1")]
pub start: ::core::option::Option<::pbjson_types::Timestamp>,
pub start: ::core::option::Option<::prost_types::Timestamp>,
#[prost(message, optional, tag = "2")]
pub end: ::core::option::Option<::pbjson_types::Timestamp>,
pub end: ::core::option::Option<::prost_types::Timestamp>,
}
/// Only a subset of the secure hash standard algorithms are supported.
/// See <<https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf>> for more
Expand All @@ -203,8 +175,6 @@ pub struct TimeRange {
/// any proto JSON serialization to emit the used hash algorithm, as default
/// option is to *omit* the default value of an enum (which is the first
/// value, represented by '0'.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum HashAlgorithm {
Expand Down Expand Up @@ -237,8 +207,6 @@ impl HashAlgorithm {
/// ED25519 the valid permutations are listed as a linear set instead of a
/// cartesian set (i.e one combined variable instead of two, one for encoding
/// and one for the signature algorithm).
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum PublicKeyDetails {
Expand Down Expand Up @@ -294,8 +262,6 @@ impl PublicKeyDetails {
}
}
}
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SubjectAlternativeNameType {
Expand Down
10 changes: 0 additions & 10 deletions gen/pb-rust/src/codegen/dev.sigstore.rekor.v1.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/// KindVersion contains the entry's kind and api version.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KindVersion {
Expand All @@ -20,8 +18,6 @@ pub struct KindVersion {
/// The details are here <https://github.com/sigstore/rekor/blob/a6e58f72b6b18cc06cefe61808efd562b9726330/pkg/util/signed_note.go#L114>
/// The signature has the same format as
/// InclusionPromise.signed_entry_timestamp. See below for more details.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Checkpoint {
Expand All @@ -30,8 +26,6 @@ pub struct Checkpoint {
}
/// InclusionProof is the proof returned from the transparency log. Can
/// be used for offline or online verification against the log.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InclusionProof {
Expand Down Expand Up @@ -67,8 +61,6 @@ pub struct InclusionProof {
/// operators, together with the public key.
/// This is used to verify the integration timestamp's value and that the log
/// has promised to include the entry.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InclusionPromise {
Expand All @@ -83,8 +75,6 @@ pub struct InclusionPromise {
/// inclusion promise. The inclusion promise (called SignedEntryTimestamp in
/// the response from Rekor) is similar to a Signed Certificate Timestamp
/// as described here <https://www.rfc-editor.org/rfc/rfc6962.html#section-3.2.>
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransparencyLogEntry {
Expand Down
6 changes: 0 additions & 6 deletions gen/pb-rust/src/codegen/dev.sigstore.trustroot.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
/// for more details.
/// The included parameters are the minimal set required to identify a log,
/// and verify an inclusion proof/promise.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TransparencyLogInstance {
Expand All @@ -25,8 +23,6 @@ pub struct TransparencyLogInstance {
}
/// CertificateAuthority enlists the information required to identify which
/// CA to use and perform signature verification.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CertificateAuthority {
Expand Down Expand Up @@ -71,8 +67,6 @@ pub struct CertificateAuthority {
/// their 'valid_for' attribute for easy identification.
/// All the listed instances SHOULD be sorted by the 'valid_for' in ascending
/// order, that is, the oldest instance first and the current instance last.
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrustedRoot {
Expand Down
Loading

0 comments on commit 284ed4f

Please sign in to comment.