sigstore-models 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sigstore_models/__init__.py +0 -0
- sigstore_models/_core.py +85 -0
- sigstore_models/bundle/__init__.py +0 -0
- sigstore_models/bundle/v1/__init__.py +62 -0
- sigstore_models/common/__init__.py +0 -0
- sigstore_models/common/v1/__init__.py +186 -0
- sigstore_models/intoto.py +14 -0
- sigstore_models/py.typed +0 -0
- sigstore_models/rekor/__init__.py +0 -0
- sigstore_models/rekor/v1/__init__.py +48 -0
- sigstore_models/rekor/v2/__init__.py +8 -0
- sigstore_models/rekor/v2/dsse.py +14 -0
- sigstore_models/rekor/v2/entry.py +39 -0
- sigstore_models/rekor/v2/hashedrekord.py +13 -0
- sigstore_models/rekor/v2/verifier.py +30 -0
- sigstore_models/trustroot/__init__.py +0 -0
- sigstore_models/trustroot/v1/__init__.py +84 -0
- sigstore_models-0.0.1.dist-info/METADATA +34 -0
- sigstore_models-0.0.1.dist-info/RECORD +21 -0
- sigstore_models-0.0.1.dist-info/WHEEL +4 -0
- sigstore_models-0.0.1.dist-info/licenses/LICENSE +21 -0
|
File without changes
|
sigstore_models/_core.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import base64
|
|
4
|
+
import typing as t
|
|
5
|
+
|
|
6
|
+
import typing_extensions as te
|
|
7
|
+
from pydantic import BaseModel, BeforeValidator, ConfigDict, PlainSerializer
|
|
8
|
+
from pydantic.alias_generators import to_camel
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Base(BaseModel):
|
|
12
|
+
model_config = ConfigDict(
|
|
13
|
+
alias_generator=to_camel,
|
|
14
|
+
strict=True,
|
|
15
|
+
extra="forbid",
|
|
16
|
+
validate_by_name=True,
|
|
17
|
+
validate_by_alias=True,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def from_json(cls, json: str | bytes) -> te.Self:
|
|
22
|
+
return cls.model_validate_json(json)
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def from_dict(cls, data: dict) -> te.Self:
|
|
26
|
+
return cls.model_validate(data)
|
|
27
|
+
|
|
28
|
+
def to_json(self) -> str:
|
|
29
|
+
return self.model_dump_json(
|
|
30
|
+
exclude_none=True,
|
|
31
|
+
exclude_unset=True,
|
|
32
|
+
by_alias=True,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def to_dict(self) -> dict:
|
|
36
|
+
return self.model_dump(
|
|
37
|
+
mode="json", exclude_none=True, exclude_unset=True, by_alias=True
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _validate_proto_u64(value: object) -> int:
|
|
42
|
+
if not isinstance(value, str):
|
|
43
|
+
raise ValueError(
|
|
44
|
+
f"Expected protobuf uint64 as string, got {type(value).__name__}"
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
n = int(value)
|
|
48
|
+
if n < 0 or n > 2**64 - 1:
|
|
49
|
+
raise ValueError(f"Value exceeds uint64 domain: {value}")
|
|
50
|
+
|
|
51
|
+
return n
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _serialize_proto_u64(value: int) -> str:
|
|
55
|
+
if value < 0 or value > 2**64 - 1:
|
|
56
|
+
raise ValueError(f"Value exceeds uint64 domain: {value}")
|
|
57
|
+
|
|
58
|
+
return str(value)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
ProtoU64 = t.Annotated[
|
|
62
|
+
int,
|
|
63
|
+
BeforeValidator(_validate_proto_u64),
|
|
64
|
+
PlainSerializer(_serialize_proto_u64, return_type=str),
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _validate_proto_bytes(value: object) -> bytes:
|
|
69
|
+
if not isinstance(value, (bytes, str)):
|
|
70
|
+
raise ValueError(
|
|
71
|
+
f"Expected protobuf bytes as string or bytes, got {type(value).__name__}"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
return base64.b64decode(value)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _serialize_proto_bytes(value: bytes) -> bytes:
|
|
78
|
+
return base64.b64encode(value)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
ProtoBytes = t.Annotated[
|
|
82
|
+
bytes,
|
|
83
|
+
BeforeValidator(_validate_proto_bytes),
|
|
84
|
+
PlainSerializer(_serialize_proto_bytes, return_type=bytes),
|
|
85
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
import typing_extensions as te
|
|
4
|
+
from pydantic import model_validator
|
|
5
|
+
|
|
6
|
+
from sigstore_models._core import Base
|
|
7
|
+
from sigstore_models.common.v1 import (
|
|
8
|
+
MessageSignature,
|
|
9
|
+
PublicKeyIdentifier,
|
|
10
|
+
RFC3161SignedTimestamp,
|
|
11
|
+
X509Certificate,
|
|
12
|
+
X509CertificateChain,
|
|
13
|
+
)
|
|
14
|
+
from sigstore_models.intoto import Envelope
|
|
15
|
+
from sigstore_models.rekor.v1 import TransparencyLogEntry
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TimestampVerificationData(Base):
|
|
19
|
+
rfc3161_timestamps: t.Optional[list[RFC3161SignedTimestamp]] = None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class VerificationMaterial(Base):
|
|
23
|
+
public_key: t.Optional[PublicKeyIdentifier] = None
|
|
24
|
+
x509_certificate_chain: t.Optional[X509CertificateChain] = None
|
|
25
|
+
certificate: t.Optional[X509Certificate] = None
|
|
26
|
+
|
|
27
|
+
tlog_entries: list[TransparencyLogEntry] # TODO
|
|
28
|
+
timestamp_verification_data: t.Optional[TimestampVerificationData] = None
|
|
29
|
+
|
|
30
|
+
@model_validator(mode="after")
|
|
31
|
+
def check_content_oneof(self) -> te.Self:
|
|
32
|
+
fields = [self.public_key, self.x509_certificate_chain, self.certificate]
|
|
33
|
+
if sum(bool(f) for f in fields) != 1:
|
|
34
|
+
raise ValueError(
|
|
35
|
+
"Exactly one of publicKey, x509CertificateChain, or certificate must be set"
|
|
36
|
+
)
|
|
37
|
+
return self
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
BUNDLE_MEDIA_TYPES = t.Literal[
|
|
41
|
+
"application/vnd.dev.sigstore.bundle+json;version=0.1",
|
|
42
|
+
"application/vnd.dev.sigstore.bundle+json;version=0.2",
|
|
43
|
+
"application/vnd.dev.sigstore.bundle+json;version=0.3",
|
|
44
|
+
"application/vnd.dev.sigstore.bundle.v0.3+json",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Bundle(Base):
|
|
49
|
+
media_type: BUNDLE_MEDIA_TYPES
|
|
50
|
+
verification_material: VerificationMaterial
|
|
51
|
+
|
|
52
|
+
message_signature: t.Optional[MessageSignature] = None
|
|
53
|
+
dsse_envelope: t.Optional[Envelope] = None
|
|
54
|
+
|
|
55
|
+
@model_validator(mode="after")
|
|
56
|
+
def check_content_oneof(self) -> te.Self:
|
|
57
|
+
fields = [self.message_signature, self.dsse_envelope]
|
|
58
|
+
if sum(bool(f) for f in fields) != 1:
|
|
59
|
+
raise ValueError(
|
|
60
|
+
"Exactly one of messageSignature or dsseEnvelope must be set"
|
|
61
|
+
)
|
|
62
|
+
return self
|
|
File without changes
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
import typing as t
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from sigstore_models._core import Base, ProtoBytes
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class HashAlgorithm(str, enum.Enum):
|
|
9
|
+
# NOTE: We don't include HASH_ALGORITHM_UNSPECIFIED
|
|
10
|
+
# because it's a protobuf-level hack, and not a valid hash algorithm.
|
|
11
|
+
SHA2_256 = "SHA2_256"
|
|
12
|
+
SHA2_384 = "SHA2_384"
|
|
13
|
+
SHA2_512 = "SHA2_512"
|
|
14
|
+
SHA3_256 = "SHA3_256"
|
|
15
|
+
SHA3_384 = "SHA3_384"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class PublicKeyDetails(str, enum.Enum):
|
|
19
|
+
# TODO: Figure out a good way to encode deprecated variants.
|
|
20
|
+
# RSA
|
|
21
|
+
PKCS1_RSA_PKCS1V5 = "PKCS1_RSA_PKCS1V5" # deprecated
|
|
22
|
+
PKCS1_RSA_PSS = "PKCS1_RSA_PSS" # deprecated
|
|
23
|
+
PKIX_RSA_PKCS1V5 = "PKIX_RSA_PKCS1V5" # deprecated
|
|
24
|
+
PKIX_RSA_PSS = "PKIX_RSA_PSS" # deprecated
|
|
25
|
+
|
|
26
|
+
# RSA public key in PKIX format, PKCS#1v1.5 signature
|
|
27
|
+
PKIX_RSA_PKCS1V15_2048_SHA256 = "PKIX_RSA_PKCS1V15_2048_SHA256"
|
|
28
|
+
PKIX_RSA_PKCS1V15_3072_SHA256 = "PKIX_RSA_PKCS1V15_3072_SHA256"
|
|
29
|
+
PKIX_RSA_PKCS1V15_4096_SHA256 = "PKIX_RSA_PKCS1V15_4096_SHA256"
|
|
30
|
+
|
|
31
|
+
# RSA public key in PKIX format, RSASSA-PSS signature
|
|
32
|
+
PKIX_RSA_PSS_2048_SHA256 = "PKIX_RSA_PSS_2048_SHA256" # See RFC4055
|
|
33
|
+
PKIX_RSA_PSS_3072_SHA256 = "PKIX_RSA_PSS_3072_SHA256"
|
|
34
|
+
PKIX_RSA_PSS_4096_SHA256 = "PKIX_RSA_PSS_4096_SHA256"
|
|
35
|
+
|
|
36
|
+
# ECDSA
|
|
37
|
+
PKIX_ECDSA_P256_HMAC_SHA_256 = (
|
|
38
|
+
"PKIX_ECDSA_P256_HMAC_SHA_256" # deprecated - See RFC6979
|
|
39
|
+
)
|
|
40
|
+
PKIX_ECDSA_P256_SHA_256 = "PKIX_ECDSA_P256_SHA_256" # See NIST FIPS 186-4
|
|
41
|
+
PKIX_ECDSA_P384_SHA_384 = "PKIX_ECDSA_P384_SHA_384"
|
|
42
|
+
PKIX_ECDSA_P521_SHA_512 = "PKIX_ECDSA_P521_SHA_512"
|
|
43
|
+
|
|
44
|
+
# Ed 25519
|
|
45
|
+
PKIX_ED25519 = "PKIX_ED25519" # See RFC8032
|
|
46
|
+
PKIX_ED25519_PH = "PKIX_ED25519_PH"
|
|
47
|
+
|
|
48
|
+
# These algorithms are deprecated and should not be used, but they
|
|
49
|
+
# were/are being used by most Sigstore clients implementations.
|
|
50
|
+
PKIX_ECDSA_P384_SHA_256 = "PKIX_ECDSA_P384_SHA_256" # deprecated
|
|
51
|
+
PKIX_ECDSA_P521_SHA_256 = "PKIX_ECDSA_P521_SHA_256" # deprecated
|
|
52
|
+
|
|
53
|
+
# LMS and LM-OTS
|
|
54
|
+
#
|
|
55
|
+
# These algorithms are deprecated and should not be used.
|
|
56
|
+
# Keys and signatures MAY be used by private Sigstore
|
|
57
|
+
# deployments, but will not be supported by the public
|
|
58
|
+
# good instance.
|
|
59
|
+
#
|
|
60
|
+
# USER WARNING: LMS and LM-OTS are both stateful signature schemes.
|
|
61
|
+
# Using them correctly requires discretion and careful consideration
|
|
62
|
+
# to ensure that individual secret keys are not used more than once.
|
|
63
|
+
# In addition, LM-OTS is a single-use scheme, meaning that it
|
|
64
|
+
# MUST NOT be used for more than one signature per LM-OTS key.
|
|
65
|
+
# If you cannot maintain these invariants, you MUST NOT use these
|
|
66
|
+
# schemes.
|
|
67
|
+
LMS_SHA256 = "LMS_SHA256" # deprecated
|
|
68
|
+
LMOTS_SHA256 = "LMOTS_SHA256" # deprecated
|
|
69
|
+
|
|
70
|
+
# ML-DSA
|
|
71
|
+
#
|
|
72
|
+
# These ML_DSA_65 and ML-DSA_87 algorithms are the pure variants that
|
|
73
|
+
# take data to sign rather than the prehash variants (HashML-DSA), which
|
|
74
|
+
# take digests. While considered quantum-resistant, their usage
|
|
75
|
+
# involves tradeoffs in that signatures and keys are much larger, and
|
|
76
|
+
# this makes deployments more costly.
|
|
77
|
+
#
|
|
78
|
+
# USER WARNING: ML_DSA_65 and ML_DSA_87 are experimental algorithms.
|
|
79
|
+
# In the future they MAY be used by private Sigstore deployments, but
|
|
80
|
+
# they are not yet fully functional. This warning will be removed when
|
|
81
|
+
# these algorithms are widely supported by Sigstore clients and servers,
|
|
82
|
+
# but care should still be taken for production environments.
|
|
83
|
+
ML_DSA_65 = "ML_DSA_65" # See NIST FIPS 204
|
|
84
|
+
ML_DSA_87 = "ML_DSA_87"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class HashOutput(Base):
|
|
88
|
+
"""HashOutput captures a digest of a 'message' (generic octet sequence)
|
|
89
|
+
and the corresponding hash algorithm used."""
|
|
90
|
+
|
|
91
|
+
algorithm: HashAlgorithm
|
|
92
|
+
digest: ProtoBytes # Raw octets of the message digest
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class MessageSignature(Base):
|
|
96
|
+
"""MessageSignature stores the computed signature over a message."""
|
|
97
|
+
|
|
98
|
+
message_digest: t.Optional[HashOutput] = None # For artifact identification only
|
|
99
|
+
signature: ProtoBytes # Raw signature bytes (required)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class LogId(Base):
|
|
103
|
+
"""LogId captures the identity of a transparency log."""
|
|
104
|
+
|
|
105
|
+
key_id: ProtoBytes # Unique identity of the log (required)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class RFC3161SignedTimestamp(Base):
|
|
109
|
+
"""This message holds a RFC 3161 timestamp."""
|
|
110
|
+
|
|
111
|
+
signed_timestamp: ProtoBytes # DER encoded TimeStampResponse (required)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class PublicKey(Base):
|
|
115
|
+
"""Public key with encoding details and optional validity period."""
|
|
116
|
+
|
|
117
|
+
raw_bytes: t.Optional[ProtoBytes] = None # DER-encoded public key
|
|
118
|
+
key_details: PublicKeyDetails # Key encoding and signature algorithm
|
|
119
|
+
valid_for: t.Optional["TimeRange"] = None # Optional validity period
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class PublicKeyIdentifier(Base):
|
|
123
|
+
"""PublicKeyIdentifier can be used to identify an (out of band) delivered
|
|
124
|
+
key, to verify a signature."""
|
|
125
|
+
|
|
126
|
+
hint: t.Optional[str] # Optional unauthenticated hint on which key to use
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class ObjectIdentifier(Base):
|
|
130
|
+
"""An ASN.1 OBJECT IDENTIFIER"""
|
|
131
|
+
|
|
132
|
+
id: list[int] # Required list of integers
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class ObjectIdentifierValuePair(Base):
|
|
136
|
+
"""An OID and the corresponding (byte) value."""
|
|
137
|
+
|
|
138
|
+
oid: ObjectIdentifier
|
|
139
|
+
value: ProtoBytes
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class DistinguishedName(Base):
|
|
143
|
+
"""Distinguished name with organization and common name."""
|
|
144
|
+
|
|
145
|
+
organization: str
|
|
146
|
+
common_name: str
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class X509Certificate(Base):
|
|
150
|
+
"""X.509 certificate container."""
|
|
151
|
+
|
|
152
|
+
raw_bytes: ProtoBytes # DER-encoded X.509 certificate (required)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class SubjectAlternativeNameType(str, enum.Enum):
|
|
156
|
+
EMAIL = "EMAIL"
|
|
157
|
+
URI = "URI"
|
|
158
|
+
OTHER_NAME = "OTHER_NAME"
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class SubjectAlternativeName(Base):
|
|
162
|
+
"""Subject Alternative Name with type and identity."""
|
|
163
|
+
|
|
164
|
+
type: SubjectAlternativeNameType
|
|
165
|
+
# Using Union for the oneof identity field
|
|
166
|
+
regexp: t.Optional[str] = None # Regular expression for expected value
|
|
167
|
+
value: t.Optional[str] = None # Exact value to match against
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class X509CertificateChain(Base):
|
|
171
|
+
"""A collection of X.509 certificates.
|
|
172
|
+
|
|
173
|
+
This "chain" can be used in multiple contexts, such as providing a root CA
|
|
174
|
+
certificate within a TUF root of trust or multiple untrusted certificates for
|
|
175
|
+
the purpose of chain building."""
|
|
176
|
+
|
|
177
|
+
certificates: list[X509Certificate] # One or more DER-encoded certificates
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class TimeRange(Base):
|
|
181
|
+
"""The time range is closed and includes both the start and end times,
|
|
182
|
+
(i.e., [start, end]). End is optional to be able to capture a period
|
|
183
|
+
that has started but has no known end."""
|
|
184
|
+
|
|
185
|
+
start: datetime
|
|
186
|
+
end: t.Optional[datetime] = None
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
from sigstore_models._core import Base, ProtoBytes
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Envelope(Base):
|
|
7
|
+
payload: ProtoBytes
|
|
8
|
+
payload_type: str
|
|
9
|
+
signatures: list["Signature"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Signature(Base):
|
|
13
|
+
sig: ProtoBytes
|
|
14
|
+
keyid: t.Optional[str] = None
|
sigstore_models/py.typed
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
import typing_extensions as te
|
|
4
|
+
from pydantic import model_validator
|
|
5
|
+
|
|
6
|
+
from sigstore_models._core import Base, ProtoBytes, ProtoU64
|
|
7
|
+
from sigstore_models.common.v1 import LogId
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class KindVersion(Base):
|
|
11
|
+
kind: str
|
|
12
|
+
version: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Checkpoint(Base):
|
|
16
|
+
envelope: str
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class InclusionProof(Base):
|
|
20
|
+
log_index: ProtoU64
|
|
21
|
+
root_hash: ProtoBytes
|
|
22
|
+
tree_size: ProtoU64
|
|
23
|
+
hashes: list[ProtoBytes]
|
|
24
|
+
checkpoint: t.Optional[Checkpoint] = None
|
|
25
|
+
|
|
26
|
+
@model_validator(mode="after")
|
|
27
|
+
def validate_log_index_in_tree_size(self) -> te.Self:
|
|
28
|
+
if self.tree_size <= self.log_index:
|
|
29
|
+
raise ValueError(
|
|
30
|
+
f"logIndex {self.log_index} must be less than treeSize {self.tree_size}"
|
|
31
|
+
)
|
|
32
|
+
return self
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class InclusionPromise(Base):
|
|
36
|
+
signed_entry_timestamp: ProtoBytes
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class TransparencyLogEntry(Base):
|
|
40
|
+
log_index: ProtoU64
|
|
41
|
+
log_id: LogId
|
|
42
|
+
kind_version: KindVersion
|
|
43
|
+
# NOTE: protobuf-specs claims this is mandatory, but in practice
|
|
44
|
+
# it's optional.
|
|
45
|
+
integrated_time: t.Optional[ProtoU64] = None
|
|
46
|
+
inclusion_promise: t.Optional[InclusionPromise] = None
|
|
47
|
+
inclusion_proof: InclusionProof
|
|
48
|
+
canonicalized_body: t.Optional[ProtoBytes] = None
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from sigstore_models._core import Base
|
|
2
|
+
from sigstore_models.common.v1 import HashOutput
|
|
3
|
+
from sigstore_models.intoto import Envelope
|
|
4
|
+
from sigstore_models.rekor.v2 import verifier
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class DSSERequestV002(Base):
|
|
8
|
+
envelope: Envelope
|
|
9
|
+
verifiers: list[verifier.Verifier]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DSSELogEntryV002(Base):
|
|
13
|
+
payload_hash: HashOutput
|
|
14
|
+
signatures: list[verifier.Signature]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
import typing_extensions as te
|
|
4
|
+
from pydantic import model_validator
|
|
5
|
+
|
|
6
|
+
from sigstore_models._core import Base
|
|
7
|
+
from sigstore_models.rekor.v2 import dsse, hashedrekord
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Entry(Base):
|
|
11
|
+
kind: str
|
|
12
|
+
api_version: str
|
|
13
|
+
spec: "Spec"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Spec(Base):
|
|
17
|
+
hashed_rekord_v002: t.Optional[hashedrekord.HashedRekordLogEntryV002] = None
|
|
18
|
+
dsse_v002: t.Optional[dsse.DSSELogEntryV002] = None
|
|
19
|
+
|
|
20
|
+
@model_validator(mode="after")
|
|
21
|
+
def check_spec_oneof(self) -> te.Self:
|
|
22
|
+
fields = [self.hashed_rekord_v002, self.dsse_v002]
|
|
23
|
+
if sum(bool(f) for f in fields) != 1:
|
|
24
|
+
raise ValueError("Exactly one of hashedRekordV002 or dsseV002 must be set")
|
|
25
|
+
return self
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class CreateEntryRequest(Base):
|
|
29
|
+
hashed_rekord_request_v002: t.Optional[hashedrekord.HashedRekordRequestV002] = None
|
|
30
|
+
dsse_request_v002: t.Optional[dsse.DSSERequestV002] = None
|
|
31
|
+
|
|
32
|
+
@model_validator(mode="after")
|
|
33
|
+
def check_request_oneof(self) -> te.Self:
|
|
34
|
+
fields = [self.hashed_rekord_request_v002, self.dsse_request_v002]
|
|
35
|
+
if sum(bool(f) for f in fields) != 1:
|
|
36
|
+
raise ValueError(
|
|
37
|
+
"Exactly one of hashedRekordRequestV002 or dsseRequestV002 must be set"
|
|
38
|
+
)
|
|
39
|
+
return self
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from sigstore_models._core import Base, ProtoBytes
|
|
2
|
+
from sigstore_models.common.v1 import HashOutput
|
|
3
|
+
from sigstore_models.rekor.v2 import verifier
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class HashedRekordRequestV002(Base):
|
|
7
|
+
digest: ProtoBytes
|
|
8
|
+
signature: verifier.Signature
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class HashedRekordLogEntryV002(Base):
|
|
12
|
+
data: HashOutput
|
|
13
|
+
signature: verifier.Signature
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import typing as t
|
|
2
|
+
|
|
3
|
+
import typing_extensions as te
|
|
4
|
+
from pydantic import model_validator
|
|
5
|
+
|
|
6
|
+
from sigstore_models._core import Base, ProtoBytes
|
|
7
|
+
from sigstore_models.common.v1 import PublicKeyDetails, X509Certificate
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class PublicKey(Base):
|
|
11
|
+
raw_bytes: ProtoBytes
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Verifier(Base):
|
|
15
|
+
public_key: t.Optional[PublicKey] = None
|
|
16
|
+
x509_certificate: t.Optional[X509Certificate] = None
|
|
17
|
+
|
|
18
|
+
key_details: PublicKeyDetails
|
|
19
|
+
|
|
20
|
+
@model_validator(mode="after")
|
|
21
|
+
def check_verifier_oneof(self) -> te.Self:
|
|
22
|
+
fields = [self.public_key, self.x509_certificate]
|
|
23
|
+
if sum(bool(f) for f in fields) != 1:
|
|
24
|
+
raise ValueError("Exactly one of publicKey or x509Certificate must be set")
|
|
25
|
+
return self
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class Signature(Base):
|
|
29
|
+
content: ProtoBytes
|
|
30
|
+
verifier: Verifier
|
|
File without changes
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
import typing as t
|
|
3
|
+
|
|
4
|
+
from sigstore_models._core import Base
|
|
5
|
+
from sigstore_models.common.v1 import (
|
|
6
|
+
DistinguishedName,
|
|
7
|
+
HashAlgorithm,
|
|
8
|
+
LogId,
|
|
9
|
+
PublicKey,
|
|
10
|
+
TimeRange,
|
|
11
|
+
X509CertificateChain,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TransparencyLogInstance(Base):
|
|
16
|
+
base_url: str
|
|
17
|
+
hash_algorithm: HashAlgorithm
|
|
18
|
+
public_key: PublicKey
|
|
19
|
+
log_id: LogId
|
|
20
|
+
checkpoint_key_id: t.Optional[LogId] = None
|
|
21
|
+
operator: t.Optional[str] = None
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class CertificateAuthority(Base):
|
|
25
|
+
subject: DistinguishedName
|
|
26
|
+
uri: t.Optional[str] = None
|
|
27
|
+
cert_chain: X509CertificateChain
|
|
28
|
+
valid_for: TimeRange
|
|
29
|
+
operator: t.Optional[str] = None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
TRUSTED_ROOT_MEDIA_TYPES = t.Literal[
|
|
33
|
+
"application/vnd.dev.sigstore.trustedroot+json;version=0.1",
|
|
34
|
+
"application/vnd.dev.sigstore.trustedroot.v0.2+json",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class TrustedRoot(Base):
|
|
39
|
+
media_type: TRUSTED_ROOT_MEDIA_TYPES
|
|
40
|
+
tlogs: list[TransparencyLogInstance]
|
|
41
|
+
certificate_authorities: list[CertificateAuthority]
|
|
42
|
+
ctlogs: list[TransparencyLogInstance]
|
|
43
|
+
timestamp_authorities: list[CertificateAuthority]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
SIGNING_CONFIG_MEDIA_TYPES = t.Literal[
|
|
47
|
+
"application/vnd.dev.sigstore.signingconfig.v0.1+json",
|
|
48
|
+
"application/vnd.dev.sigstore.signingconfig.v0.2+json",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class SigningConfig(Base):
|
|
53
|
+
media_type: SIGNING_CONFIG_MEDIA_TYPES
|
|
54
|
+
ca_urls: list["Service"]
|
|
55
|
+
oidc_urls: list["Service"]
|
|
56
|
+
rekor_tlog_urls: list["Service"]
|
|
57
|
+
rekor_tlog_config: "ServiceConfiguration"
|
|
58
|
+
tsa_urls: list["Service"]
|
|
59
|
+
tsa_config: "ServiceConfiguration"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Service(Base):
|
|
63
|
+
url: str
|
|
64
|
+
major_api_version: int
|
|
65
|
+
valid_for: t.Optional[TimeRange] = None
|
|
66
|
+
operator: t.Optional[str] = None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ServiceSelector(str, enum.Enum):
|
|
70
|
+
ALL = "ALL"
|
|
71
|
+
ANY = "ANY"
|
|
72
|
+
EXACT = "EXACT"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ServiceConfiguration(Base):
|
|
76
|
+
selector: ServiceSelector
|
|
77
|
+
count: t.Optional[int] = None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class ClientTrustConfig(Base):
|
|
81
|
+
media_type: t.Literal["application/vnd.dev.sigstore.clienttrustconfig.v0.1+json"]
|
|
82
|
+
|
|
83
|
+
trusted_root: TrustedRoot
|
|
84
|
+
signing_config: SigningConfig
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sigstore-models
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Author: William Woodruff
|
|
6
|
+
Author-email: William Woodruff <william@astral.sh>
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: pydantic>=2.11.7
|
|
9
|
+
Requires-Dist: typing-extensions>=4.14.1
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Project-URL: Repository, https://github.com/astral-sh/sigstore-models
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# sigstore-models
|
|
15
|
+
|
|
16
|
+
Pydantic-based data models for Sigstore.
|
|
17
|
+
|
|
18
|
+
These models mirror the subset of the [protobuf-specs] that
|
|
19
|
+
are used by the [sigstore-python] library.
|
|
20
|
+
|
|
21
|
+
## Goals
|
|
22
|
+
|
|
23
|
+
* Providing high-quality, type-safe data models to [sigstore-python].
|
|
24
|
+
* Matching Sigstore's (mostly protobuf influenced) JSON serialization
|
|
25
|
+
format.
|
|
26
|
+
|
|
27
|
+
## Anti-goals
|
|
28
|
+
|
|
29
|
+
* Supporting protobuf serialization/deserialization.
|
|
30
|
+
* Doing anything besides mirroring a subset of the types in
|
|
31
|
+
[protobuf-specs].
|
|
32
|
+
|
|
33
|
+
[protobuf-specs]: https://github.com/sigstore/protobuf-specs
|
|
34
|
+
[sigstore-python]: https://github.com/sigstore/sigstore-python
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
sigstore_models/__init__.py,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
|
|
2
|
+
sigstore_models/_core.py,sha256=d18d67db13280cc610019611cde9c1a7fe89ec98eb23e3944e781369a8ecb90d,2106
|
|
3
|
+
sigstore_models/bundle/__init__.py,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
|
|
4
|
+
sigstore_models/bundle/v1/__init__.py,sha256=b8b889f837e956e96fafc05db4a7391e4a7a1c32ccb5d1af7d1c59d3f7e7bbb2,2030
|
|
5
|
+
sigstore_models/common/__init__.py,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
|
|
6
|
+
sigstore_models/common/v1/__init__.py,sha256=770096e93583e11ae6fa4d8bd94588a83784b9331301e3e0e1510570fcfb160a,6492
|
|
7
|
+
sigstore_models/intoto.py,sha256=a784e130d4909159db91cf820731d13440204038993aa05edfde7983176a3502,254
|
|
8
|
+
sigstore_models/py.typed,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
|
|
9
|
+
sigstore_models/rekor/__init__.py,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
|
|
10
|
+
sigstore_models/rekor/v1/__init__.py,sha256=16423379864d01a38a938cb0ba086a4b80ae6ca4c5ce24dc74b7c467f035965a,1234
|
|
11
|
+
sigstore_models/rekor/v2/__init__.py,sha256=bba38bf31b52d3f92d7ba5dda0cc18011f3fc5ada63d6ef92a4f39a0362a3ec8,126
|
|
12
|
+
sigstore_models/rekor/v2/dsse.py,sha256=a47fe1c9955c7c6b8d07a7e506392dae1996cdf5a1b9c42a38599e847ba4d441,373
|
|
13
|
+
sigstore_models/rekor/v2/entry.py,sha256=ddd0e1fb3b440262a7e35963765fa274a55f2975f057290b8bf88aedd9cc1a01,1246
|
|
14
|
+
sigstore_models/rekor/v2/hashedrekord.py,sha256=cec42677fac3c4f55fef7e3dcfddbcdb8e1bdd4ee67b0f4ef139cca1f140d44c,337
|
|
15
|
+
sigstore_models/rekor/v2/verifier.py,sha256=4ce38a6a9122d17b911003a51703a2105c94b16a465164dc9cb61d610c2d9194,791
|
|
16
|
+
sigstore_models/trustroot/__init__.py,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
|
|
17
|
+
sigstore_models/trustroot/v1/__init__.py,sha256=bb3a734b8c27e4edd807f84ede78c191553884927f4186bb9854bae4557249c4,2035
|
|
18
|
+
sigstore_models-0.0.1.dist-info/licenses/LICENSE,sha256=860e3d7a86b84e6a7012c7a635fc64df475cebc6cce34dfeb73a5982ec58176c,1077
|
|
19
|
+
sigstore_models-0.0.1.dist-info/WHEEL,sha256=d10358abd5c217094bd40da9e447bd3c8979f6f95a2ce6e2da850cf9abfe7943,78
|
|
20
|
+
sigstore_models-0.0.1.dist-info/METADATA,sha256=4ed349bafc7a8c6c34323558976dd5544c798640209bffef4dbdfa04eefcb4d2,998
|
|
21
|
+
sigstore_models-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Astral Software Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|