-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathkeytriple.go
33 lines (26 loc) · 964 Bytes
/
keytriple.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
// Copyright 2021-2024 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0
package comid
import "fmt"
// KeyTriple stores a cryptographic key triple record (identity-triple-record
// or attest-key-triple-record) with CBOR and JSON serializations. Note that
// the CBOR serialization packs the structure into an array. Instead, when
// serializing to JSON, the structure is converted into an object.
type KeyTriple struct {
_ struct{} `cbor:",toarray"`
Environment Environment `json:"environment"`
VerifKeys CryptoKeys `json:"verification-keys"`
}
func (o KeyTriple) Valid() error {
if err := o.Environment.Valid(); err != nil {
return fmt.Errorf("environment validation failed: %w", err)
}
if err := o.VerifKeys.Valid(); err != nil {
return fmt.Errorf("verification keys validation failed: %w", err)
}
return nil
}
type KeyTriples []KeyTriple
func NewKeyTriples() *KeyTriples {
return &KeyTriples{}
}