@@ -45,7 +45,9 @@ const (
45
45
defaultRekorAddr = "https://rekor.sigstore.dev"
46
46
)
47
47
48
- func verifyRootHash (ctx context.Context , rekorClient * client.Rekor , eproof * models.InclusionProof , pub * ecdsa.PublicKey ) error {
48
+ func verifyRootHash (ctx context.Context , rekorClient * client.Rekor ,
49
+ treeID int64 , eproof * models.InclusionProof , pub * ecdsa.PublicKey ) error {
50
+ treeIDString := fmt .Sprintf ("%d" , treeID )
49
51
infoParams := tlog .NewGetLogInfoParamsWithContext (ctx )
50
52
result , err := rekorClient .Tlog .GetLogInfo (infoParams )
51
53
if err != nil {
@@ -58,6 +60,13 @@ func verifyRootHash(ctx context.Context, rekorClient *client.Rekor, eproof *mode
58
60
if err := sth .UnmarshalText ([]byte (* logInfo .SignedTreeHead )); err != nil {
59
61
return err
60
62
}
63
+ for _ , inactiveShard := range logInfo .InactiveShards {
64
+ if * inactiveShard .TreeID == treeIDString {
65
+ if err := sth .UnmarshalText ([]byte (* inactiveShard .SignedTreeHead )); err != nil {
66
+ return err
67
+ }
68
+ }
69
+ }
61
70
62
71
verifier , err := signature .LoadVerifier (pub , crypto .SHA256 )
63
72
if err != nil {
@@ -122,22 +131,36 @@ func verifyTlogEntryByUUID(ctx context.Context, rekorClient *client.Rekor, entry
122
131
return nil , err
123
132
}
124
133
125
- var e models.LogEntryAnon
126
134
for k , entry := range lep .Payload {
127
- if k != uuid {
135
+ returnUUID , err := sharding .GetUUIDFromIDString (k )
136
+ if err != nil {
137
+ return nil , err
138
+ }
139
+ // Validate that the request matches the response
140
+ if returnUUID != uuid {
128
141
return nil , errors .New ("expected matching UUID" )
129
142
}
130
- e = entry
143
+ return verifyTlogEntry ( ctx , rekorClient , k , entry )
131
144
}
132
145
133
- return verifyTlogEntry ( ctx , rekorClient , uuid , e )
146
+ return nil , serrors . ErrorRekorSearch
134
147
}
135
148
136
- func verifyTlogEntry (ctx context.Context , rekorClient * client.Rekor , uuid string , e models.LogEntryAnon ) (* models.LogEntryAnon , error ) {
149
+ func verifyTlogEntry (ctx context.Context , rekorClient * client.Rekor ,
150
+ entryUUID string , e models.LogEntryAnon ) (* models.LogEntryAnon , error ) {
137
151
if e .Verification == nil || e .Verification .InclusionProof == nil {
138
152
return nil , errors .New ("inclusion proof not provided" )
139
153
}
140
154
155
+ uuid , err := sharding .GetUUIDFromIDString (entryUUID )
156
+ if err != nil {
157
+ return nil , fmt .Errorf ("%w: retrieving uuid from entry uuid" , err )
158
+ }
159
+ treeID , err := sharding .TreeID (entryUUID )
160
+ if err != nil {
161
+ return nil , fmt .Errorf ("%w: retrieving tree ID" , err )
162
+ }
163
+
141
164
var hashes [][]byte
142
165
for _ , h := range e .Verification .InclusionProof .Hashes {
143
166
hb , err := hex .DecodeString (h )
@@ -165,7 +188,8 @@ func verifyTlogEntry(ctx context.Context, rekorClient *client.Rekor, uuid string
165
188
var entryVerError error
166
189
for _ , pubKey := range pubs {
167
190
// Verify inclusion against the signed tree head
168
- entryVerError = verifyRootHash (ctx , rekorClient , e .Verification .InclusionProof , pubKey .PubKey )
191
+ entryVerError = verifyRootHash (ctx , rekorClient , treeID ,
192
+ e .Verification .InclusionProof , pubKey .PubKey )
169
193
if entryVerError == nil {
170
194
break
171
195
}
0 commit comments