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