Skip to content

Commit 1885194

Browse files
committed
ASN.1: fix Hashes definition, add HashesOfSnapshot def
These will both hopefully not be necessary in the end, since they're used in only one way each and the definitions should just directly say things like meta: SetOf(componentType=HashOfSnapshot()) instead of having an extra level, but for now this is easier to debug. Separately, the Hashes definition was incorrectly Set() instead of SetOf() Hash Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
1 parent 1fda798 commit 1885194

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tuf/encoding/asn1_metadata_definitions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Hash(univ.Sequence):
7575
NamedType('digest', univ.OctetString()))
7676

7777
# TEMPORARY, FOR DEBUGGING ONLY; DO NOT MERGE
78-
class Hashes(univ.Set):
78+
class Hashes(univ.SetOf):
7979
componentType = Hash()
8080

8181

@@ -135,13 +135,16 @@ class HashOfSnapshot(univ.Sequence):
135135
NamedType('num-hashes', IntegerNatural()),
136136
NamedType('hashes', univ.SetOf(componentType=Hash()))) # unordered
137137

138+
class HashesOfSnapshot(univ.SetOf):
139+
componentType = HashOfSnapshot()
140+
138141
class TimestampMetadata(univ.Sequence):
139142
componentType = NamedTypes(
140143
NamedType('type', char.VisibleString()),
141144
NamedType('expires', IntegerNatural()),
142145
NamedType('version', IntegerNatural()),
143146
NamedType('num-meta', IntegerNatural()),
144-
NamedType('meta', univ.SetOf(componentType=HashOfSnapshot())) # unordered
147+
NamedType('meta', HashesOfSnapshot()) #univ.SetOf(componentType=HashOfSnapshot())) # unordered
145148
)
146149

147150

tuf/encoding/metadata_definitions.asn1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ TUFMetadataDefinitions DEFINITIONS AUTOMATIC TAGS ::= BEGIN
137137
digest OCTET STRING
138138
}
139139

140+
Hashes ::= SET OF Hash
141+
140142

141143
Signature ::= SEQUENCE {
142144
keyid OCTET STRING,

0 commit comments

Comments
 (0)