Debian Codegraph @

verifier/timestamp_test.go

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 // Copyright The Notary Project Authors.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 package verifier
15
16 import (
17 "context"
18 "crypto/x509"
19 "net/http"
20 "os"
21 "testing"
22 "time"
23
24 "github.com/notaryproject/notation-core-go/revocation"
25 "github.com/notaryproject/notation-core-go/revocation/purpose"
26 "github.com/notaryproject/notation-core-go/signature"
27 "github.com/notaryproject/notation-core-go/signature/cose"
28 "github.com/notaryproject/notation-core-go/signature/jws"
29 "github.com/notaryproject/notation-go"
30 "github.com/notaryproject/notation-go/dir"
31 "github.com/notaryproject/notation-go/verifier/trustpolicy"
32 "github.com/notaryproject/notation-go/verifier/truststore"
33 )
34
35 func TestAuthenticTimestamp(t *testing.T) {
36 dir.UserConfigDir = "testdata"
37 trustStore := truststore.NewX509TrustStore(dir.ConfigFS())
38 dummyTrustPolicy := &trustpolicy.TrustPolicy{
39 Name: "test-timestamp",
40 RegistryScopes: []string{"*"},
41 SignatureVerification: trustpolicy.SignatureVerification{
42 VerificationLevel: trustpolicy.LevelStrict.Name,
43 VerifyTimestamp: trustpolicy.OptionAlways,
44 },
45 TrustStores: []string{"ca:valid-trust-store", "tsa:test-timestamp"},
46 TrustedIdentities: []string{"*"},
47 }
48 revocationTimestampingValidator, err := revocation.NewWithOptions(revocation.Options{
49 OCSPHTTPClient: &http.Client{Timeout: 2 * time.Second},
50 CertChainPurpose: purpose.Timestamping,
51 })
52 if err != nil {
53 t.Fatalf("failed to get revocation timestamp client: %v", err)
54 }
55 // valid JWS signature envelope with timestamp countersignature
56 jwsEnvContent, err := parseEnvContent("testdata/timestamp/sigEnv/jwsWithTimestamp.sig", jws.MediaTypeEnvelope)
57 if err != nil {
58 t.Fatalf("failed to get signature envelope content: %v", err)
59 }
60
61 // valid COSE signature envelope with timestamp countersignature
62 coseEnvContent, err := parseEnvContent("testdata/timestamp/sigEnv/coseWithTimestamp.sig", cose.MediaTypeEnvelope)
63 if err != nil {
64 t.Fatalf("failed to get signature envelope content: %v", err)
65 }
66
67 t.Run("verify Authentic Timestamp with jws format", func(t *testing.T) {
68 outcome := &notation.VerificationOutcome{
69 EnvelopeContent: jwsEnvContent,
70 VerificationLevel: trustpolicy.LevelStrict,
71 }
72 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
73 if err := authenticTimestampResult.Error; err != nil {
74 t.Fatalf("expected nil error, but got %s", err)
75 }
76 })
77
78 t.Run("verify Authentic Timestamp with cose format", func(t *testing.T) {
79 outcome := &notation.VerificationOutcome{
80 EnvelopeContent: coseEnvContent,
81 VerificationLevel: trustpolicy.LevelStrict,
82 }
83 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
84 if err := authenticTimestampResult.Error; err != nil {
85 t.Fatalf("expected nil error, but got %s", err)
86 }
87 })
88
89 t.Run("verify Authentic Timestamp jws with expired codeSigning cert", func(t *testing.T) {
90 jwsEnvContent, err := parseEnvContent("testdata/timestamp/sigEnv/jwsExpiredWithTimestamp.sig", jws.MediaTypeEnvelope)
91 if err != nil {
92 t.Fatalf("failed to get signature envelope content: %v", err)
93 }
94 outcome := &notation.VerificationOutcome{
95 EnvelopeContent: jwsEnvContent,
96 VerificationLevel: trustpolicy.LevelStrict,
97 }
98 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
99 if err := authenticTimestampResult.Error; err != nil {
100 t.Fatalf("expected nil error, but got %s", err)
101 }
102 })
103
104 t.Run("verify Authentic Timestamp cose with expired codeSigning cert", func(t *testing.T) {
105 coseEnvContent, err := parseEnvContent("testdata/timestamp/sigEnv/coseExpiredWithTimestamp.sig", cose.MediaTypeEnvelope)
106 if err != nil {
107 t.Fatalf("failed to get signature envelope content: %v", err)
108 }
109 outcome := &notation.VerificationOutcome{
110 EnvelopeContent: coseEnvContent,
111 VerificationLevel: trustpolicy.LevelStrict,
112 }
113 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
114 if err := authenticTimestampResult.Error; err != nil {
115 t.Fatalf("expected nil error, but got %s", err)
116 }
117 })
118
119 t.Run("verify Authentic Timestamp with afterCertExpiry set", func(t *testing.T) {
120 dummyTrustPolicy := &trustpolicy.TrustPolicy{
121 Name: "test-timestamp",
122 RegistryScopes: []string{"*"},
123 SignatureVerification: trustpolicy.SignatureVerification{
124 VerificationLevel: trustpolicy.LevelStrict.Name,
125 VerifyTimestamp: trustpolicy.OptionAfterCertExpiry,
126 },
127 TrustStores: []string{"ca:valid-trust-store", "tsa:test-timestamp"},
128 TrustedIdentities: []string{"*"},
129 }
130 outcome := &notation.VerificationOutcome{
131 EnvelopeContent: coseEnvContent,
132 VerificationLevel: trustpolicy.LevelStrict,
133 }
134 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
135 if err := authenticTimestampResult.Error; err != nil {
136 t.Fatalf("expected nil error, but got %s", err)
137 }
138 })
139
140 t.Run("verify Authentic Timestamp failed due to invalid trust policy", func(t *testing.T) {
141 dummyTrustPolicy := &trustpolicy.TrustPolicy{
142 Name: "test-timestamp",
143 RegistryScopes: []string{"*"},
144 SignatureVerification: trustpolicy.SignatureVerification{
145 VerificationLevel: trustpolicy.LevelStrict.Name,
146 VerifyTimestamp: trustpolicy.OptionAlways,
147 },
148 TrustStores: []string{"ca:valid-trust-store", "tsa"},
149 TrustedIdentities: []string{"*"},
150 }
151 outcome := &notation.VerificationOutcome{
152 EnvelopeContent: jwsEnvContent,
153 VerificationLevel: trustpolicy.LevelStrict,
154 }
155 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
156 expectedErrMsg := "failed to check tsa trust store configuration in turst policy with error: invalid trust policy statement: \"test-timestamp\" is missing separator in trust store value \"tsa\". The required format is <TrustStoreType>:<TrustStoreName>"
157 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
158 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
159 }
160 })
161
162 t.Run("verify Authentic Timestamp failed due to missing tsa in trust policy and expired codeSigning cert", func(t *testing.T) {
163 dummyTrustPolicy := &trustpolicy.TrustPolicy{
164 Name: "test-timestamp",
165 RegistryScopes: []string{"*"},
166 SignatureVerification: trustpolicy.SignatureVerification{
167 VerificationLevel: trustpolicy.LevelStrict.Name,
168 VerifyTimestamp: trustpolicy.OptionAlways,
169 },
170 TrustStores: []string{"ca:valid-trust-store"},
171 TrustedIdentities: []string{"*"},
172 }
173 coseEnvContent, err := parseEnvContent("testdata/timestamp/sigEnv/coseExpiredWithTimestamp.sig", cose.MediaTypeEnvelope)
174 if err != nil {
175 t.Fatalf("failed to get signature envelope content: %v", err)
176 }
177 outcome := &notation.VerificationOutcome{
178 EnvelopeContent: coseEnvContent,
179 VerificationLevel: trustpolicy.LevelStrict,
180 }
181 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
182 expectedErrMsg := "verification time is after certificate \"CN=testTSA,O=Notary,L=Seattle,ST=WA,C=US\" validity period, it was expired at \"Tue, 18 Jun 2024 07:30:31 +0000\""
183 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
184 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
185 }
186 })
187
188 t.Run("verify Authentic Timestamp failed due to missing timestamp countersignature", func(t *testing.T) {
189 envContent, err := parseEnvContent("testdata/timestamp/sigEnv/withoutTimestamp.sig", jws.MediaTypeEnvelope)
190 if err != nil {
191 t.Fatalf("failed to get signature envelope content: %v", err)
192 }
193 outcome := &notation.VerificationOutcome{
194 EnvelopeContent: envContent,
195 VerificationLevel: trustpolicy.LevelStrict,
196 }
197 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
198 expectedErrMsg := "no timestamp countersignature was found in the signature envelope"
199 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
200 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
201 }
202 })
203
204 t.Run("verify Authentic Timestamp failed due to invalid timestamp countersignature content type", func(t *testing.T) {
205 signedToken, err := os.ReadFile("testdata/timestamp/countersignature/TimeStampTokenWithInvalideContentType.p7s")
206 if err != nil {
207 t.Fatalf("failed to get signedToken: %v", err)
208 }
209 envContent, err := parseEnvContent("testdata/timestamp/sigEnv/withoutTimestamp.sig", jws.MediaTypeEnvelope)
210 if err != nil {
211 t.Fatalf("failed to get signature envelope content: %v", err)
212 }
213 envContent.SignerInfo.UnsignedAttributes.TimestampSignature = signedToken
214 outcome := &notation.VerificationOutcome{
215 EnvelopeContent: envContent,
216 VerificationLevel: trustpolicy.LevelStrict,
217 }
218 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
219 expectedErrMsg := "failed to parse timestamp countersignature with error: unexpected content type: 1.2.840.113549.1.7.1. Expected to be id-ct-TSTInfo (1.2.840.113549.1.9.16.1.4)"
220 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
221 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
222 }
223 })
224
225 t.Run("verify Authentic Timestamp failed due to invalid TSTInfo", func(t *testing.T) {
226 signedToken, err := os.ReadFile("testdata/timestamp/countersignature/TimeStampTokenWithInvalidTSTInfo.p7s")
227 if err != nil {
228 t.Fatalf("failed to get signedToken: %v", err)
229 }
230 envContent, err := parseEnvContent("testdata/timestamp/sigEnv/withoutTimestamp.sig", jws.MediaTypeEnvelope)
231 if err != nil {
232 t.Fatalf("failed to get signature envelope content: %v", err)
233 }
234 envContent.SignerInfo.UnsignedAttributes.TimestampSignature = signedToken
235 outcome := &notation.VerificationOutcome{
236 EnvelopeContent: envContent,
237 VerificationLevel: trustpolicy.LevelStrict,
238 }
239 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
240 expectedErrMsg := "failed to get the timestamp TSTInfo with error: cannot unmarshal TSTInfo from timestamp token: asn1: structure error: tags don't match (23 vs {class:0 tag:16 length:3 isCompound:true}) {optional:false explicit:false application:false private:false defaultValue:<nil> tag:<nil> stringType:0 timeType:24 set:false omitEmpty:false} Time @89"
241 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
242 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
243 }
244 })
245
246 t.Run("verify Authentic Timestamp failed due to failed to validate TSTInfo", func(t *testing.T) {
247 signedToken, err := os.ReadFile("testdata/timestamp/countersignature/TimeStampToken.p7s")
248 if err != nil {
249 t.Fatalf("failed to get signedToken: %v", err)
250 }
251 envContent, err := parseEnvContent("testdata/timestamp/sigEnv/withoutTimestamp.sig", jws.MediaTypeEnvelope)
252 if err != nil {
253 t.Fatalf("failed to get signature envelope content: %v", err)
254 }
255 envContent.SignerInfo.UnsignedAttributes.TimestampSignature = signedToken
256 envContent.SignerInfo.Signature = []byte("mismatch")
257 outcome := &notation.VerificationOutcome{
258 EnvelopeContent: envContent,
259 VerificationLevel: trustpolicy.LevelStrict,
260 }
261 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
262 expectedErrMsg := "failed to get timestamp from timestamp countersignature with error: invalid TSTInfo: mismatched message"
263 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
264 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
265 }
266 })
267
268 t.Run("verify Authentic Timestamp failed due to failed to verify timestamp countersignature", func(t *testing.T) {
269 signedToken, err := os.ReadFile("testdata/timestamp/countersignature/TimeStampTokenWithoutCertificate.p7s")
270 if err != nil {
271 t.Fatalf("failed to get signedToken: %v", err)
272 }
273 envContent, err := parseEnvContent("testdata/timestamp/sigEnv/withoutTimestamp.sig", jws.MediaTypeEnvelope)
274 if err != nil {
275 t.Fatalf("failed to get signature envelope content: %v", err)
276 }
277 envContent.SignerInfo.UnsignedAttributes.TimestampSignature = signedToken
278 envContent.SignerInfo.Signature = []byte("notation")
279 outcome := &notation.VerificationOutcome{
280 EnvelopeContent: envContent,
281 VerificationLevel: trustpolicy.LevelStrict,
282 }
283 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
284 expectedErrMsg := "failed to verify the timestamp countersignature with error: failed to verify signed token: signing certificate not found in the timestamp token"
285 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
286 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
287 }
288 })
289
290 t.Run("verify Authentic Timestamp failed due to trust store does not exist", func(t *testing.T) {
291 dummyTrustPolicy := &trustpolicy.TrustPolicy{
292 Name: "test-timestamp",
293 RegistryScopes: []string{"*"},
294 SignatureVerification: trustpolicy.SignatureVerification{
295 VerificationLevel: trustpolicy.LevelStrict.Name,
296 VerifyTimestamp: trustpolicy.OptionAlways,
297 },
298 TrustStores: []string{"ca:valid-trust-store", "tsa:does-not-exist"},
299 TrustedIdentities: []string{"*"},
300 }
301 outcome := &notation.VerificationOutcome{
302 EnvelopeContent: coseEnvContent,
303 VerificationLevel: trustpolicy.LevelStrict,
304 }
305 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
306 expectedErrMsg := "failed to load tsa trust store with error: the trust store \"does-not-exist\" of type \"tsa\" does not exist"
307 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
308 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
309 }
310 })
311
312 t.Run("verify Authentic Timestamp failed due to empty trust store", func(t *testing.T) {
313 dummyTrustPolicy := &trustpolicy.TrustPolicy{
314 Name: "test-timestamp",
315 RegistryScopes: []string{"*"},
316 SignatureVerification: trustpolicy.SignatureVerification{
317 VerificationLevel: trustpolicy.LevelStrict.Name,
318 VerifyTimestamp: trustpolicy.OptionAlways,
319 },
320 TrustStores: []string{"ca:valid-trust-store", "tsa:test-empty"},
321 TrustedIdentities: []string{"*"},
322 }
323 outcome := &notation.VerificationOutcome{
324 EnvelopeContent: coseEnvContent,
325 VerificationLevel: trustpolicy.LevelStrict,
326 }
327 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, dummyTrustStore{}, revocationTimestampingValidator, outcome)
328 expectedErrMsg := "no trusted TSA certificate found in trust store"
329 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
330 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
331 }
332 })
333
334 t.Run("verify Authentic Timestamp failed due to tsa not trust", func(t *testing.T) {
335 dummyTrustPolicy := &trustpolicy.TrustPolicy{
336 Name: "test-timestamp",
337 RegistryScopes: []string{"*"},
338 SignatureVerification: trustpolicy.SignatureVerification{
339 VerificationLevel: trustpolicy.LevelStrict.Name,
340 VerifyTimestamp: trustpolicy.OptionAlways,
341 },
342 TrustStores: []string{"ca:valid-trust-store", "tsa:test-mismatch"},
343 TrustedIdentities: []string{"*"},
344 }
345 outcome := &notation.VerificationOutcome{
346 EnvelopeContent: coseEnvContent,
347 VerificationLevel: trustpolicy.LevelStrict,
348 }
349 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
350 expectedErrMsg := "failed to verify the timestamp countersignature with error: failed to verify signed token: cms verification failure: x509: certificate signed by unknown authority"
351 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
352 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
353 }
354 })
355
356 t.Run("verify Authentic Timestamp failed due to timestamp before signing cert not before", func(t *testing.T) {
357 dummyTrustPolicy := &trustpolicy.TrustPolicy{
358 Name: "test-timestamp",
359 RegistryScopes: []string{"*"},
360 SignatureVerification: trustpolicy.SignatureVerification{
361 VerificationLevel: trustpolicy.LevelStrict.Name,
362 VerifyTimestamp: trustpolicy.OptionAlways,
363 },
364 TrustStores: []string{"ca:valid-trust-store", "tsa:test-timestamp"},
365 TrustedIdentities: []string{"*"},
366 }
367 envContent, err := parseEnvContent("testdata/timestamp/sigEnv/timestampBeforeNotBefore.sig", jws.MediaTypeEnvelope)
368 if err != nil {
369 t.Fatalf("failed to get signature envelope content: %v", err)
370 }
371 outcome := &notation.VerificationOutcome{
372 EnvelopeContent: envContent,
373 VerificationLevel: trustpolicy.LevelStrict,
374 }
375 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
376 expectedErrMsg := "timestamp can be before certificate \"CN=testTSA,O=Notary,L=Seattle,ST=WA,C=US\" validity period, it will be valid from \"Fri, 18 Sep 2099 11:54:34 +0000\""
377 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
378 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
379 }
380 })
381
382 t.Run("verify Authentic Timestamp failed due to timestamp after signing cert not after", func(t *testing.T) {
383 dummyTrustPolicy := &trustpolicy.TrustPolicy{
384 Name: "test-timestamp",
385 RegistryScopes: []string{"*"},
386 SignatureVerification: trustpolicy.SignatureVerification{
387 VerificationLevel: trustpolicy.LevelStrict.Name,
388 VerifyTimestamp: trustpolicy.OptionAlways,
389 },
390 TrustStores: []string{"ca:valid-trust-store", "tsa:test-timestamp"},
391 TrustedIdentities: []string{"*"},
392 }
393 envContent, err := parseEnvContent("testdata/timestamp/sigEnv/timestampAfterNotAfter.sig", cose.MediaTypeEnvelope)
394 if err != nil {
395 t.Fatalf("failed to get signature envelope content: %v", err)
396 }
397 outcome := &notation.VerificationOutcome{
398 EnvelopeContent: envContent,
399 VerificationLevel: trustpolicy.LevelStrict,
400 }
401 authenticTimestampResult := verifyAuthenticTimestamp(context.Background(), dummyTrustPolicy.Name, dummyTrustPolicy.TrustStores, dummyTrustPolicy.SignatureVerification, trustStore, revocationTimestampingValidator, outcome)
402 expectedErrMsg := "timestamp can be after certificate \"CN=testTSA,O=Notary,L=Seattle,ST=WA,C=US\" validity period, it was expired at \"Tue, 18 Sep 2001 11:54:34 +0000\""
403 if err := authenticTimestampResult.Error; err == nil || err.Error() != expectedErrMsg {
404 t.Fatalf("expected %s, but got %s", expectedErrMsg, err)
405 }
406 })
407 }
408
409 func parseEnvContent(filepath, format string) (*signature.EnvelopeContent, error) {
410 sigEnvBytes, err := os.ReadFile(filepath)
411 if err != nil {
412 return nil, err
413 }
414 sigEnv, err := signature.ParseEnvelope(format, sigEnvBytes)
415 if err != nil {
416 return nil, err
417 }
418 return sigEnv.Content()
419 }
420
421 type dummyTrustStore struct{}
422
423 func (ts dummyTrustStore) GetCertificates(ctx context.Context, storeType truststore.Type, namedStore string) ([]*x509.Certificate, error) {
424 return nil, nil
425 }