Skip to content

Commit c768756

Browse files
committed
ASN.1: make expiration data string, not int, to match TUF metadata
While int is preferable for efficiency, the initial goal here is total compatibility. The TUF-internal metadata format defined in the TUF specification uses strings for expiration dates, and so should the ASN.1 definitions used in the reference implementation for now. This also facilitates automated conversion between the formats. Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
1 parent 3bdc58d commit c768756

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

tuf/encoding/asn1_metadata_definitions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class TopLevelDelegation(ac.Sequence):
9797
class RootMetadata(ac.Sequence):
9898
_fields = [
9999
('type', ac.VisibleString),
100-
('expires', ac.Integer),
100+
('expires', ac.VisibleString),
101101
('version', ac.Integer),
102102
('consistent-snapshot', ac.Boolean),
103103
('keys', ac.SetOf, {'_child_spec': PublicKey}),
@@ -161,7 +161,7 @@ class HashesOfSnapshot(ac.SetOf):
161161
class TimestampMetadata(ac.Sequence):
162162
_fields = [
163163
('type', ac.VisibleString),
164-
('expires', ac.Integer),
164+
('expires', ac.VisibleString),
165165
('version', ac.Integer),
166166
('meta', ac.SetOf, {'_child_spec': HashOfSnapshot})]
167167

@@ -175,7 +175,7 @@ class RoleInfo(ac.Sequence):
175175
class SnapshotMetadata(ac.Sequence):
176176
_fields = [
177177
('type', ac.VisibleString),
178-
('expires', ac.Integer),
178+
('expires', ac.VisibleString),
179179
('version', ac.Integer),
180180
('meta', ac.SetOf, {'_child_spec': RoleInfo})]
181181

@@ -206,7 +206,7 @@ class Target(ac.Sequence):
206206
class TargetsMetadata(ac.Sequence):
207207
_fields = [
208208
('type', ac.VisibleString),
209-
('expires', ac.Integer),
209+
('expires', ac.VisibleString),
210210
('version', ac.Integer),
211211
('targets', ac.SetOf, {'_child_spec': Target}),
212212
('delegations', ac.Sequence, {'_fields': [

tuf/encoding/metadata_definitions.asn1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ TUFMetadataDefinitions DEFINITIONS AUTOMATIC TAGS ::= BEGIN
184184

185185
RootMetadata ::= SEQUENCE {
186186
type VisibleString, -- ("root"),
187-
expires IntegerNatural, --date&time, UTC, as a UNIX timestamp
187+
expires VisibleString, --date&time, UTC, as a UNIX timestamp
188188
version IntegerNatural,
189189
consistent-snapshot BOOLEAN,
190190
keys SET OF PublicKey, -- unordered set
@@ -200,7 +200,7 @@ TUFMetadataDefinitions DEFINITIONS AUTOMATIC TAGS ::= BEGIN
200200

201201
TimestampMetadata ::= SEQUENCE {
202202
type VisibleString, -- ("timestamp"),
203-
expires IntegerNatural, -- date&time, UTC, as a UNIX timestamp
203+
expires VisibleString, -- date&time, UTC, as a UNIX timestamp
204204
version IntegerNatural,
205205

206206
meta SET OF RoleInfoLong -- unordered set
@@ -222,7 +222,7 @@ TUFMetadataDefinitions DEFINITIONS AUTOMATIC TAGS ::= BEGIN
222222

223223
SnapshotMetadata ::= SEQUENCE {
224224
type VisibleString, -- ("snapshot"),
225-
expires IntegerNatural, -- date&time, UTC, as a UNIX timestamp
225+
expires VisibleString, -- date&time, UTC, as a UNIX timestamp
226226
version IntegerNatural,
227227

228228
meta SET OF RoleInfo -- unordered set
@@ -248,7 +248,7 @@ TUFMetadataDefinitions DEFINITIONS AUTOMATIC TAGS ::= BEGIN
248248

249249
TargetsMetadata ::= SEQUENCE {
250250
type VisibleString, -- allow delegated role names, too
251-
expires IntegerNatural, -- date&time, UTC, as a UNIX timestamp
251+
expires VisibleString, -- date&time, UTC, as a UNIX timestamp
252252
version IntegerNatural,
253253

254254
targets SET OF Target, -- unordered set

0 commit comments

Comments
 (0)