/
verify.go
731 lines (628 loc) · 21.2 KB
/
verify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
// Copyright (c) 2020-2021, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the LICENSE.md file
// distributed with the sources of this project regarding your rights to use or distribute this
// software.
package integrity
import (
"bytes"
"errors"
"fmt"
"io"
"sort"
"strings"
"github.com/sylabs/sif/pkg/sif" //nolint:staticcheck // In use until v2 API
"golang.org/x/crypto/openpgp"
)
var (
errFingerprintMismatch = errors.New("fingerprint in descriptor does not correspond to signing entity")
errNonGroupedObject = errors.New("non-signature object not associated with object group")
)
// SignatureNotValidError records an error when an invalid signature is encountered.
type SignatureNotValidError struct {
ID uint32 // Signature object ID.
Err error // Wrapped error.
}
func (e *SignatureNotValidError) Error() string {
b := &strings.Builder{}
if e.ID == 0 {
fmt.Fprintf(b, "signature not valid")
} else {
fmt.Fprintf(b, "signature object %v not valid", e.ID)
}
if e.Err != nil {
fmt.Fprintf(b, ": %v", e.Err)
}
return b.String()
}
func (e *SignatureNotValidError) Unwrap() error {
return e.Err
}
// Is compares e against target. If target is a SignatureNotValidError and matches e or target has
// a zero value ID, true is returned.
func (e *SignatureNotValidError) Is(target error) bool {
t, ok := target.(*SignatureNotValidError)
if !ok {
return false
}
return e.ID == t.ID || t.ID == 0
}
// VerifyResult is the interface that each verification result implements.
type VerifyResult interface {
// Signature returns the ID of the signature object associated with the result.
Signature() uint32
// Signed returns the IDs of data objects that were signed.
Signed() []uint32
// Verified returns the IDs of data objects that were verified.
Verified() []uint32
// Entity returns the signing entity, or nil if the signing entity could not be determined.
Entity() *openpgp.Entity
// Error returns an error describing the reason verification failed, or nil if verification was
// successful.
Error() error
}
// VerifyCallback is called immediately after a signature is verified. If r contains a non-nil
// error, and the callback returns true, the error is ignored, and verification proceeds as if no
// error occurred.
type VerifyCallback func(r VerifyResult) (ignoreError bool)
type groupVerifier struct {
f *sif.FileImage // SIF image to verify.
cb VerifyCallback // Verification callback.
groupID uint32 // Object group ID.
ods []*sif.Descriptor // Object descriptors.
subsetOK bool // If true, permit ods to be a subset of the objects in signatures.
}
// newGroupVerifier constructs a new group verifier, optionally limited to objects described by
// ods. If no descriptors are supplied, verify all objects in group.
func newGroupVerifier(f *sif.FileImage, cb VerifyCallback, groupID uint32, ods ...*sif.Descriptor) (*groupVerifier, error) { // nolint:lll
v := groupVerifier{f: f, cb: cb, groupID: groupID, ods: ods}
if len(ods) == 0 {
ods, err := getGroupObjects(f, groupID)
if err != nil {
return nil, err
}
v.ods = ods
} else {
v.subsetOK = true
}
return &v, nil
}
// fingerprints returns a sorted list of unique fingerprints of entities that have signed the
// objects specified by v.
func (v *groupVerifier) fingerprints() ([][20]byte, error) {
sigs, err := getGroupSignatures(v.f, v.groupID, false)
if errors.Is(err, &SignatureNotFoundError{}) {
return nil, nil
} else if err != nil {
return nil, err
}
return getFingerprints(sigs)
}
// verifySignature verifies the objects specified by v against signature sig using keyring kr.
//
// If an invalid signature is encountered, a SignatureNotValidError is returned.
//
// If verification of the SIF global header fails, ErrHeaderIntegrity is returned. If verification
// of a data object descriptor fails, a DescriptorIntegrityError is returned. If verification of a
// data object fails, a ObjectIntegrityError is returned.
func (v *groupVerifier) verifySignature(sig *sif.Descriptor, kr openpgp.KeyRing) (imageMetadata, []uint32, *openpgp.Entity, error) { // nolint:lll
b := make([]byte, sig.Filelen)
if _, err := io.ReadFull(sig.GetReader(v.f), b); err != nil {
return imageMetadata{}, nil, nil, err
}
// Verify signature and decode image metadata.
var im imageMetadata
e, _, err := verifyAndDecodeJSON(b, &im, kr)
if err != nil {
return im, nil, e, &SignatureNotValidError{ID: sig.ID, Err: err}
}
// Get minimum object ID in group, and use this to populate absolute object IDs in im.
minID, err := getGroupMinObjectID(v.f, v.groupID)
if err != nil {
return im, nil, e, err
}
im.populateAbsoluteObjectIDs(minID)
// Ensure signing entity matches fingerprint in descriptor.
fp, err := sig.GetEntity()
if err != nil {
return im, nil, e, err
}
if !bytes.Equal(e.PrimaryKey.Fingerprint[:], fp[:20]) {
return im, nil, e, errFingerprintMismatch
}
// If an object subset is not permitted, verify our set of IDs match exactly what is in the
// image metadata.
if !v.subsetOK {
if err := im.objectIDsMatch(v.ods); err != nil {
return im, nil, e, err
}
}
// Verify header and object integrity.
verified, err := im.matches(v.f, v.ods)
if err != nil {
return im, verified, e, err
}
return im, verified, e, nil
}
// verifyWithKeyRing performs verification of the objects specified by v using keyring kr.
//
// If no signatures are found for the object group specified by v, a SignatureNotFoundError is
// returned. If an invalid signature is encountered, a SignatureNotValidError is returned.
//
// If verification of the SIF global header fails, ErrHeaderIntegrity is returned. If verification
// of a data object descriptor fails, a DescriptorIntegrityError is returned. If verification of a
// data object fails, a ObjectIntegrityError is returned.
func (v *groupVerifier) verifyWithKeyRing(kr openpgp.KeyRing) error {
// Obtain all signatures related to group.
sigs, err := getGroupSignatures(v.f, v.groupID, false)
if err != nil {
return err
}
for _, sig := range sigs {
im, verified, e, err := v.verifySignature(sig, kr)
// Call verify callback, if applicable.
if v.cb != nil {
r := result{signature: sig.ID, im: im, verified: verified, e: e, err: err}
if ignoreError := v.cb(r); ignoreError {
err = nil
}
}
if err != nil {
return err
}
}
return nil
}
type legacyGroupVerifier struct {
f *sif.FileImage // SIF image to verify.
cb VerifyCallback // Verification callback.
groupID uint32 // Object group ID.
ods []*sif.Descriptor // Object descriptors.
}
// newLegacyGroupVerifier constructs a new legacy group verifier.
func newLegacyGroupVerifier(f *sif.FileImage, cb VerifyCallback, groupID uint32) (*legacyGroupVerifier, error) {
ods, err := getGroupObjects(f, groupID)
if err != nil {
return nil, err
}
return &legacyGroupVerifier{f: f, cb: cb, groupID: groupID, ods: ods}, nil
}
// fingerprints returns a sorted list of unique fingerprints of entities that have signed the
// objects specified by v.
func (v *legacyGroupVerifier) fingerprints() ([][20]byte, error) {
sigs, err := getGroupSignatures(v.f, v.groupID, true)
if errors.Is(err, &SignatureNotFoundError{}) {
return nil, nil
} else if err != nil {
return nil, err
}
return getFingerprints(sigs)
}
// verifySignature verifies the objects specified by v against signature sig using keyring kr.
//
// If an invalid signature is encountered, a SignatureNotValidError is returned.
//
// If verification of a data object fails, a ObjectIntegrityError is returned.
func (v *legacyGroupVerifier) verifySignature(sig *sif.Descriptor, kr openpgp.KeyRing) (*openpgp.Entity, error) {
b := make([]byte, sig.Filelen)
if _, err := io.ReadFull(sig.GetReader(v.f), b); err != nil {
return nil, err
}
// Verify signature and decode plaintext.
e, b, _, err := verifyAndDecode(b, kr)
if err != nil {
return e, &SignatureNotValidError{ID: sig.ID, Err: err}
}
// Ensure signing entity matches fingerprint in descriptor.
fp, err := sig.GetEntity()
if err != nil {
return e, err
}
if !bytes.Equal(e.PrimaryKey.Fingerprint[:], fp[:20]) {
return e, errFingerprintMismatch
}
// Determine hash type.
ht, err := sig.GetHashType()
if err != nil {
return e, err
}
// Obtain digest from plaintext.
d, err := newLegacyDigest(ht, b)
if err != nil {
return e, err
}
// Get reader covering all non-signature objects.
rs := make([]io.Reader, 0, len(v.ods))
for _, od := range v.ods {
rs = append(rs, od.GetReader(v.f))
}
r := io.MultiReader(rs...)
// Verify integrity of objects.
if ok, err := d.matches(r); err != nil {
return e, err
} else if !ok {
return e, &ObjectIntegrityError{}
}
return e, nil
}
// verifyWithKeyRing performs verification of the objects specified by v using keyring kr.
//
// If no signatures are found for the object group specified by v, a SignatureNotFoundError is
// returned. If an invalid signature is encountered, a SignatureNotValidError is returned.
//
// If verification of the data object group fails, a ObjectIntegrityError is returned.
func (v *legacyGroupVerifier) verifyWithKeyRing(kr openpgp.KeyRing) error {
// Obtain all signatures related to object.
sigs, err := getGroupSignatures(v.f, v.groupID, true)
if err != nil {
return err
}
for _, sig := range sigs {
e, err := v.verifySignature(sig, kr)
// Call verify callback, if applicable.
if v.cb != nil {
r := legacyResult{signature: sig.ID, ods: v.ods, e: e, err: err}
if ignoreError := v.cb(r); ignoreError {
err = nil
}
}
if err != nil {
return err
}
}
return nil
}
type legacyObjectVerifier struct {
f *sif.FileImage // SIF image to verify.
cb VerifyCallback // Verification callback.
od *sif.Descriptor // Object descriptor.
}
// newLegacyObjectVerifier constructs a new legacy object verifier.
func newLegacyObjectVerifier(f *sif.FileImage, cb VerifyCallback, id uint32) (*legacyObjectVerifier, error) {
od, err := getObject(f, id)
if err != nil {
return nil, err
}
return &legacyObjectVerifier{f: f, cb: cb, od: od}, nil
}
// fingerprints returns a sorted list of unique fingerprints of entities that have signed the
// objects specified by v.
func (v *legacyObjectVerifier) fingerprints() ([][20]byte, error) {
sigs, err := getObjectSignatures(v.f, v.od.ID)
if errors.Is(err, &SignatureNotFoundError{}) {
return nil, nil
} else if err != nil {
return nil, err
}
return getFingerprints(sigs)
}
// verifySignature verifies the objects specified by v against signature sig using keyring kr.
//
// If an invalid signature is encountered, a SignatureNotValidError is returned.
//
// If verification of a data object fails, a ObjectIntegrityError is returned.
func (v *legacyObjectVerifier) verifySignature(sig *sif.Descriptor, kr openpgp.KeyRing) (*openpgp.Entity, error) {
b := make([]byte, sig.Filelen)
if _, err := io.ReadFull(sig.GetReader(v.f), b); err != nil {
return nil, err
}
// Verify signature and decode plaintext.
e, b, _, err := verifyAndDecode(b, kr)
if err != nil {
return e, &SignatureNotValidError{ID: sig.ID, Err: err}
}
// Ensure signing entity matches fingerprint in descriptor.
fp, err := sig.GetEntity()
if err != nil {
return e, err
}
if !bytes.Equal(e.PrimaryKey.Fingerprint[:], fp[:20]) {
return e, errFingerprintMismatch
}
// Determine hash type.
ht, err := sig.GetHashType()
if err != nil {
return e, err
}
// Obtain digest from plaintext.
d, err := newLegacyDigest(ht, b)
if err != nil {
return e, err
}
// Verify object integrity.
if ok, err := d.matches(v.od.GetReader(v.f)); err != nil {
return e, err
} else if !ok {
return e, &ObjectIntegrityError{ID: v.od.ID}
}
return e, nil
}
// verifyWithKeyRing performs verification of the objects specified by v using keyring kr.
//
// If no signatures are found for the object specified by v, a SignatureNotFoundError is returned.
// If an invalid signature is encountered, a SignatureNotValidError is returned.
//
// If verification of the data object fails, a ObjectIntegrityError is returned.
func (v *legacyObjectVerifier) verifyWithKeyRing(kr openpgp.KeyRing) error {
// Obtain all signatures related to object.
sigs, err := getObjectSignatures(v.f, v.od.ID)
if err != nil {
return err
}
for _, sig := range sigs {
e, err := v.verifySignature(sig, kr)
// Call verify callback, if applicable.
if v.cb != nil {
r := legacyResult{signature: sig.ID, ods: []*sif.Descriptor{v.od}, e: e, err: err}
if ignoreError := v.cb(r); ignoreError {
err = nil
}
}
if err != nil {
return err
}
}
return nil
}
type verifyTask interface {
fingerprints() ([][20]byte, error)
verifyWithKeyRing(kr openpgp.KeyRing) error
}
// Verifier describes a SIF image verifier.
type Verifier struct {
f *sif.FileImage // SIF image to verify.
keyRing openpgp.KeyRing // Keyring to use for verification.
groups []uint32 // Data object group(s) selected for verification.
objects []uint32 // Individual data object(s) selected for verification.
isLegacy bool // Enable verification of legacy signature(s).
isLegacyAll bool // Verify legacy sigs of all of non-signature objects in a group.
cb VerifyCallback // Verification callback.
tasks []verifyTask // Slice of verification tasks.
}
// VerifierOpt are used to configure v.
type VerifierOpt func(v *Verifier) error
// OptVerifyWithKeyRing sets the keyring to use for verification to kr.
func OptVerifyWithKeyRing(kr openpgp.KeyRing) VerifierOpt {
return func(v *Verifier) error {
v.keyRing = kr
return nil
}
}
// OptVerifyGroup adds a verification task for the group with the specified groupID. This may be
// called multliple times to request verification of more than one group.
func OptVerifyGroup(groupID uint32) VerifierOpt {
return func(v *Verifier) error {
if groupID == 0 {
return errInvalidGroupID
}
v.groups = insertSorted(v.groups, groupID)
return nil
}
}
// OptVerifyObject adds a verification task for the object with the specified id. This may be
// called multliple times to request verification of more than one object.
func OptVerifyObject(id uint32) VerifierOpt {
return func(v *Verifier) error {
if id == 0 {
return errInvalidObjectID
}
v.objects = insertSorted(v.objects, id)
return nil
}
}
// OptVerifyLegacy enables verification of legacy signatures. Non-legacy signatures will not be
// considered.
//
// Note that legacy signatures do not provide integrity protection of metadata contained in the
// global header or object descriptors. For the best security, use of non-legacy signatures is
// required.
func OptVerifyLegacy() VerifierOpt {
return func(v *Verifier) error {
v.isLegacy = true
return nil
}
}
// OptVerifyLegacyAll enables verification of legacy signatures, and adds verification tasks for
// all non-signature objects that are part of a group. Non-legacy signatures will not be
// considered.
//
// Note that legacy signatures do not provide integrity protection of metadata contained in the
// global header or object descriptors. For the best security, use of non-legacy signatures is
// required.
func OptVerifyLegacyAll() VerifierOpt {
return func(v *Verifier) error {
v.isLegacy = true
v.isLegacyAll = true
return nil
}
}
// OptVerifyCallback registers cb as the verification callback, which is called after each
// signature is verified.
func OptVerifyCallback(cb VerifyCallback) VerifierOpt {
return func(v *Verifier) error {
v.cb = cb
return nil
}
}
// getTasks returns verification tasks corresponding to groupIDs and objectIDs.
func getTasks(f *sif.FileImage, cb VerifyCallback, groupIDs, objectIDs []uint32) ([]verifyTask, error) {
t := make([]verifyTask, 0, len(groupIDs)+len(objectIDs))
for _, groupID := range groupIDs {
v, err := newGroupVerifier(f, cb, groupID)
if err != nil {
return nil, err
}
t = append(t, v)
}
for _, id := range objectIDs {
od, err := getObject(f, id)
if err != nil {
return nil, err
}
v, err := newGroupVerifier(f, cb, od.Groupid&^sif.DescrGroupMask, od)
if err != nil {
return nil, err
}
t = append(t, v)
}
return t, nil
}
// getLegacyTasks returns legacy verification tasks corresponding to groupIDs and objectIDs.
func getLegacyTasks(f *sif.FileImage, cb VerifyCallback, groupIDs, objectIDs []uint32) ([]verifyTask, error) {
t := make([]verifyTask, 0, len(groupIDs)+len(objectIDs))
for _, groupID := range groupIDs {
v, err := newLegacyGroupVerifier(f, cb, groupID)
if err != nil {
return nil, err
}
t = append(t, v)
}
for _, id := range objectIDs {
v, err := newLegacyObjectVerifier(f, cb, id)
if err != nil {
return nil, err
}
t = append(t, v)
}
return t, nil
}
// NewVerifier returns a Verifier to examine and/or verify digital signatures(s) in f according to
// opts.
//
// Verify requires key material be provided. OptVerifyWithKeyRing can be used for this purpose. Key
// material is not required for routines that do not perform cryptographic verification, such as
// AnySignedBy or AllSignedBy.
//
// By default, the returned Verifier will consider non-legacy signatures for all object groups. To
// override this behavior, consider using OptVerifyGroup, OptVerifyObject, OptVerifyLegacy, and/or
// OptVerifyLegacyAll.
func NewVerifier(f *sif.FileImage, opts ...VerifierOpt) (*Verifier, error) {
if f == nil {
return nil, fmt.Errorf("integrity: %w", errNilFileImage)
}
v := &Verifier{f: f}
// Apply options.
for _, o := range opts {
if err := o(v); err != nil {
return nil, fmt.Errorf("integrity: %w", err)
}
}
// If "legacy all" mode selected, add all non-signature objects that are in a group.
if v.isLegacyAll {
for _, od := range f.DescrArr {
if !od.Used {
continue
}
if od.Datatype == sif.DataSignature {
continue
}
if od.Groupid == sif.DescrUnusedGroup {
continue
}
v.objects = insertSorted(v.objects, od.ID)
}
}
// If no verification tasks specified, add one per object group
if len(v.groups) == 0 && len(v.objects) == 0 {
ids, err := getGroupIDs(f)
if err != nil {
return nil, fmt.Errorf("integrity: %w", err)
}
v.groups = ids
}
// Get tasks.
getTasksFunc := getTasks
if v.isLegacy {
getTasksFunc = getLegacyTasks
}
t, err := getTasksFunc(f, v.cb, v.groups, v.objects)
if err != nil {
return nil, fmt.Errorf("integrity: %w", err)
}
v.tasks = t
return v, nil
}
// fingerprints returns a sorted list of unique fingerprints of entities participating in the
// verification tasks in v. If any is true, entities involved in at least one task are included.
// Otherwise, only entities participatinging in all tasks are included.
func (v *Verifier) fingerprints(any bool) ([][20]byte, error) {
m := make(map[[20]byte]int)
// Build up a map containing fingerprints, and the number of tasks they are participating in.
for _, t := range v.tasks {
fps, err := t.fingerprints()
if err != nil {
return nil, err
}
for _, fp := range fps {
m[fp]++
}
}
// Build up list of fingerprints.
var fps [][20]byte
for fp, n := range m {
if any || len(v.tasks) == n {
fps = append(fps, fp)
}
}
sort.Slice(fps, func(i, j int) bool {
return bytes.Compare(fps[i][:], fps[j][:]) < 0
})
return fps, nil
}
// AnySignedBy returns fingerprints for entities that have signed any of the objects specified by
// verification tasks in v.
//
// Note that this routine does not perform cryptograhic validation. To ensure the image contains
// cryptographically valid signatures, use Verify.
func (v *Verifier) AnySignedBy() ([][20]byte, error) {
fps, err := v.fingerprints(true)
if err != nil {
return nil, fmt.Errorf("integrity: %w", err)
}
return fps, nil
}
// AllSignedBy returns fingerprints for entities that have signed all of the objects specified by
// verification tasks in v.
//
// Note that this routine does not perform cryptograhic validation. To ensure the image contains
// cryptographically valid signatures, use Verify.
func (v *Verifier) AllSignedBy() ([][20]byte, error) {
fps, err := v.fingerprints(false)
if err != nil {
return nil, fmt.Errorf("integrity: %w", err)
}
return fps, nil
}
// Verify performs all cryptographic verification tasks specified by v.
//
// If key material was not provided when v was created, Verify returns an error wrapping
// ErrNoKeyMaterial.
//
// If no signatures are found for a task specified by v, an error wrapping a SignatureNotFoundError
// is returned. If an invalid signature is encountered, an error wrapping a SignatureNotValidError
// is returned.
//
// If verification of the SIF global header fails, an error wrapping ErrHeaderIntegrity is
// returned. If verification of a data object descriptor fails, an error wrapping a
// DescriptorIntegrityError is returned. If verification of a data object fails, an error wrapping
// a ObjectIntegrityError is returned.
func (v *Verifier) Verify() error {
if v.keyRing == nil {
return fmt.Errorf("integrity: %w", ErrNoKeyMaterial)
}
// All non-signature objects must be contained in an object group.
ods, err := getNonGroupObjects(v.f)
if err != nil {
return fmt.Errorf("integrity: %w", err)
}
for _, od := range ods {
if od.Datatype != sif.DataSignature {
return fmt.Errorf("integrity: %w", errNonGroupedObject)
}
}
for _, t := range v.tasks {
if err := t.verifyWithKeyRing(v.keyRing); err != nil {
return fmt.Errorf("integrity: %w", err)
}
}
return nil
}