Documentation ¶
Overview ¶
Copyright 2023 Contributors to the Veraison project. SPDX-License-Identifier: Apache-2.0
Copyright 2024 Contributors to the Veraison project. SPDX-License-Identifier: Apache-2.0
Example (Cca_realm_refval) ¶
package main import ( "fmt" "strings" ) func main() { comid := Comid{} if err := comid.FromJSON([]byte(CCARealmRefValJSONTemplate)); err != nil { panic(err) } if err := comid.Valid(); err != nil { panic(err) } if err := extractRealmRefVals(&comid); err != nil { panic(err) } } func extractRealmRefVals(c *Comid) error { if c.Triples.ReferenceValues == nil { return fmt.Errorf("no reference values triples") } for i, rv := range *c.Triples.ReferenceValues { if err := extractRealmRefVal(rv); err != nil { return fmt.Errorf("bad Realm reference value at index %d: %w", i, err) } } return nil } func extractRealmRefVal(rv ReferenceValue) error { class := rv.Environment.Class instance := rv.Environment.Instance if err := extractRealmClass(class); err != nil { return fmt.Errorf("extracting class: %w", err) } if err := extractRealmInstanceID(instance); err != nil { return fmt.Errorf("extracting realm instanceID: %w", err) } measurements := rv.Measurements if err := extractMeasurements(measurements); err != nil { return fmt.Errorf("extracting measurements: %w", err) } return nil } func extractMeasurements(m Measurements) error { if len(m) == 0 { return fmt.Errorf("no measurements") } for i, m := range m { if err := extractMeasurement(m); err != nil { return fmt.Errorf("extracting measurement at index %d: %w", i, err) } } return nil } func extractMeasurement(m Measurement) error { if err := extractIntegrityRegisters(m.Val.IntegrityRegisters); err != nil { return fmt.Errorf("extracting digest: %w", err) } return nil } func extractRealmClass(c *Class) error { if c == nil { fmt.Println("class not present") return nil } if c.Vendor != nil { fmt.Printf("Vendor: %s\n", c.GetVendor()) } classID := c.ClassID if classID == nil { fmt.Println("class-id not present") return nil } if classID.Type() != "uuid" { return fmt.Errorf("class id is not a uuid") } if err := classID.Valid(); err != nil { return fmt.Errorf("invalid uuid: %v", err) } fmt.Printf("ClassID: %x\n", classID.Bytes()) return nil } func extractRealmInstanceID(i *Instance) error { if i == nil { return fmt.Errorf("no instance") } if i.Type() != "bytes" { return fmt.Errorf("instance id is not bytes") } fmt.Printf("InstanceID: %x\n", i.Bytes()) return nil } func extractIntegrityRegisters(r *IntegrityRegisters) error { if r == nil { return fmt.Errorf("no integrity registers") } keys, err := extractRegisterIndexes(r) if err != nil { return fmt.Errorf("unable to extract register index: %v", err) } for _, k := range keys { d, ok := r.m[k] if !ok { return fmt.Errorf("unable to locate register index for: %s", k) } fmt.Printf("Index: %s\n", k) if err := extractRealmDigests(d); err != nil { return fmt.Errorf("invalid Digests for key: %s, %v", k, err) } } return nil } func extractRealmDigests(digests Digests) error { if err := digests.Valid(); err != nil { return fmt.Errorf("invalid digest: %v", err) } for _, d := range digests { fmt.Printf("Alg: %s\n", d.AlgIDToString()) fmt.Printf("Digest: %x\n", d.HashValue) } return nil } func extractRegisterIndexes(r *IntegrityRegisters) ([]string, error) { var keys [5]string for k := range r.m { switch t := k.(type) { case string: key := strings.ToLower(t) switch key { case "rim": keys[0] = key case "rem0": keys[1] = key case "rem1": keys[2] = key case "rem2": keys[3] = key case "rem3": keys[4] = key default: return nil, fmt.Errorf("unexpected register index: %s", key) } default: return nil, fmt.Errorf("unexpected type for index: %T", t) } } return keys[:], nil }
Output: Vendor: Workload Client Ltd ClassID: cd1f0e5526f9460db9d8f7fde171787c InstanceID: 4284b5694ca6c0d2cf4789a0b95ac8025c818de52304364be7cd2981b2d2edc685b322277ec25819962413d8c9b2c1f5 Index: rim Alg: sha-384 Digest: 4284b5694ca6c0d2cf4789a0b95ac8025c818de52304364be7cd2981b2d2edc685b322277ec25819962413d8c9b2c1f5 Index: rem0 Alg: sha-384 Digest: 2107bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a78 Index: rem1 Alg: sha-384 Digest: 2507bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a78 Index: rem2 Alg: sha-384 Digest: 3107bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a78 Index: rem3 Alg: sha-384 Digest: 3507bbe761fca52d95136a1354db7a4dd57b1b26be0d3da71d9eb23986b34ba615abf6514cf35e5a9ea55a032d068a78
Example (Cca_refval) ¶
package main import "fmt" func main() { comid := Comid{} if err := comid.FromJSON([]byte(CCARefValJSONTemplate)); err != nil { panic(err) } if err := comid.Valid(); err != nil { panic(err) } if err := extractCcaRefVals(&comid); err != nil { panic(err) } } func extractCcaRefVals(c *Comid) error { if c.Triples.ReferenceValues == nil { return fmt.Errorf("no reference values triples") } for i, rv := range *c.Triples.ReferenceValues { if err := extractCCARefVal(rv); err != nil { return fmt.Errorf("bad PSA reference value at index %d: %w", i, err) } } return nil } func extractCCARefVal(rv ReferenceValue) error { class := rv.Environment.Class if err := extractImplementationID(class); err != nil { return fmt.Errorf("extracting impl-id: %w", err) } for i, m := range rv.Measurements { if m.Key == nil { return fmt.Errorf("missing mKey at index %d", i) } if !m.Key.IsSet() { return fmt.Errorf("mKey not set at index %d", i) } switch t := m.Key.Value.(type) { case *TaggedPSARefValID: if err := extractSwMeasurement(m); err != nil { return fmt.Errorf("extracting measurement at index %d: %w", i, err) } case *TaggedCCAPlatformConfigID: if err := extractCCARefValID(m.Key); err != nil { return fmt.Errorf("extracting cca-refval-id: %w", err) } if err := extractRawValue(m.Val.RawValue); err != nil { return fmt.Errorf("extracting raw vlue: %w", err) } default: return fmt.Errorf("unexpected Mkey type: %T", t) } } return nil } func extractRawValue(r *RawValue) error { if r == nil { return fmt.Errorf("no raw value") } b, err := r.GetBytes() if err != nil { return fmt.Errorf("failed to extract raw value bytes") } fmt.Printf("Raw value: %x\n", b) return nil } func extractCCARefValID(k *Mkey) error { if k == nil { return fmt.Errorf("no measurement key") } id, ok := k.Value.(*TaggedCCAPlatformConfigID) if !ok { return fmt.Errorf("expected CCA platform config id, found: %T", k.Value) } fmt.Printf("Label: %s\n", id) return nil }
Output: ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b Label: BL Version: 2.1.0 Digest: 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7 SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b Label: PRoT Version: 1.3.5 Digest: 0263829989b6fd954f72baaf2fc64bc2e2f01d692d4de72986ea808f6e99813f SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b Label: ARoT Version: 0.1.4 Digest: a3a5e715f0cc574a73c3f9bebb6bc24f32ffd5b67b387244c2c909da779a1478 Label: a non-empty (unique) label Raw value: 72617776616c75650a72617776616c75650a
Example (Decode_CBOR_1) ¶
// https://github.com/ietf-rats/ietf-corim-cddl/blob/main/examples/comid-1.diag in := []byte{ 0xa3, 0x01, 0xa1, 0x00, 0x50, 0x3f, 0x06, 0xaf, 0x63, 0xa9, 0x3c, 0x11, 0xe4, 0x97, 0x97, 0x00, 0x50, 0x56, 0x90, 0x77, 0x3f, 0x02, 0x81, 0xa3, 0x00, 0x69, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x01, 0xd8, 0x20, 0x74, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x61, 0x63, 0x6d, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x02, 0x81, 0x00, 0x04, 0xa1, 0x00, 0x81, 0x82, 0xa1, 0x00, 0xa4, 0x00, 0xd8, 0x25, 0x50, 0x67, 0xb2, 0x8b, 0x6c, 0x34, 0xcc, 0x40, 0xa1, 0x91, 0x17, 0xab, 0x5b, 0x05, 0x91, 0x1e, 0x37, 0x01, 0x69, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x02, 0x6f, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x52, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x03, 0x01, 0x81, 0xa1, 0x01, 0xa2, 0x00, 0xa2, 0x00, 0x65, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x01, 0x19, 0x40, 0x00, 0x02, 0x81, 0x82, 0x01, 0x58, 0x20, 0x44, 0xaa, 0x33, 0x6a, 0xf4, 0xcb, 0x14, 0xa8, 0x79, 0x43, 0x2e, 0x53, 0xdd, 0x65, 0x71, 0xc7, 0xfa, 0x9b, 0xcc, 0xaf, 0xb7, 0x5f, 0x48, 0x82, 0x59, 0x26, 0x2d, 0x6e, 0xa3, 0xa4, 0xd9, 0x1b, } comid := Comid{} err := comid.FromCBOR(in) if err != nil { fmt.Printf("FAIL: %v", err) } else { fmt.Println("OK") }
Output: OK
Example (Decode_CBOR_2) ¶
// https://github.com/ietf-rats/ietf-corim-cddl/blob/main/examples/comid-2.diag in := []byte{ 0xa3, 0x01, 0xa1, 0x00, 0x50, 0x3f, 0x06, 0xaf, 0x63, 0xa9, 0x3c, 0x11, 0xe4, 0x97, 0x97, 0x00, 0x50, 0x56, 0x90, 0x77, 0x3f, 0x02, 0x81, 0xa3, 0x00, 0x69, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x01, 0xd8, 0x20, 0x74, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x61, 0x63, 0x6d, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x02, 0x81, 0x00, 0x04, 0xa2, 0x00, 0x83, 0x82, 0xa1, 0x00, 0xa4, 0x00, 0xd8, 0x25, 0x50, 0x67, 0xb2, 0x8b, 0x6c, 0x34, 0xcc, 0x40, 0xa1, 0x91, 0x17, 0xab, 0x5b, 0x05, 0x91, 0x1e, 0x37, 0x01, 0x69, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x02, 0x78, 0x18, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x52, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x20, 0x46, 0x69, 0x72, 0x6d, 0x77, 0x61, 0x72, 0x65, 0x03, 0x01, 0x81, 0xa1, 0x01, 0xa1, 0x02, 0x81, 0x82, 0x01, 0x58, 0x20, 0x44, 0xaa, 0x33, 0x6a, 0xf4, 0xcb, 0x14, 0xa8, 0x79, 0x43, 0x2e, 0x53, 0xdd, 0x65, 0x71, 0xc7, 0xfa, 0x9b, 0xcc, 0xaf, 0xb7, 0x5f, 0x48, 0x82, 0x59, 0x26, 0x2d, 0x6e, 0xa3, 0xa4, 0xd9, 0x1b, 0x82, 0xa1, 0x00, 0xa5, 0x00, 0xd8, 0x25, 0x50, 0xa7, 0x1b, 0x3e, 0x38, 0x8d, 0x45, 0x4a, 0x05, 0x81, 0xf3, 0x52, 0xe5, 0x8c, 0x83, 0x2c, 0x5c, 0x01, 0x6a, 0x57, 0x59, 0x4c, 0x49, 0x45, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x02, 0x77, 0x57, 0x59, 0x4c, 0x49, 0x45, 0x20, 0x43, 0x6f, 0x79, 0x6f, 0x74, 0x65, 0x20, 0x54, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x20, 0x4f, 0x53, 0x03, 0x02, 0x04, 0x00, 0x81, 0xa1, 0x01, 0xa1, 0x02, 0x81, 0x82, 0x01, 0x58, 0x20, 0xbb, 0x71, 0x19, 0x8e, 0xd6, 0x0a, 0x95, 0xdc, 0x3c, 0x61, 0x9e, 0x55, 0x5c, 0x2c, 0x0b, 0x8d, 0x75, 0x64, 0xa3, 0x80, 0x31, 0xb0, 0x34, 0xa1, 0x95, 0x89, 0x25, 0x91, 0xc6, 0x53, 0x65, 0xb0, 0x82, 0xa1, 0x00, 0xa5, 0x00, 0xd8, 0x25, 0x50, 0xa7, 0x1b, 0x3e, 0x38, 0x8d, 0x45, 0x4a, 0x05, 0x81, 0xf3, 0x52, 0xe5, 0x8c, 0x83, 0x2c, 0x5c, 0x01, 0x6a, 0x57, 0x59, 0x4c, 0x49, 0x45, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x02, 0x77, 0x57, 0x59, 0x4c, 0x49, 0x45, 0x20, 0x43, 0x6f, 0x79, 0x6f, 0x74, 0x65, 0x20, 0x54, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x20, 0x4f, 0x53, 0x03, 0x02, 0x04, 0x01, 0x81, 0xa1, 0x01, 0xa1, 0x02, 0x81, 0x82, 0x01, 0x58, 0x20, 0xbb, 0x71, 0x19, 0x8e, 0xd6, 0x0a, 0x95, 0xdc, 0x3c, 0x61, 0x9e, 0x55, 0x5c, 0x2c, 0x0b, 0x8d, 0x75, 0x64, 0xa3, 0x80, 0x31, 0xb0, 0x34, 0xa1, 0x95, 0x89, 0x25, 0x91, 0xc6, 0x53, 0x65, 0xb0, 0x01, 0x81, 0x82, 0xa1, 0x00, 0xa4, 0x00, 0xd8, 0x25, 0x50, 0x67, 0xb2, 0x8b, 0x6c, 0x34, 0xcc, 0x40, 0xa1, 0x91, 0x17, 0xab, 0x5b, 0x05, 0x91, 0x1e, 0x37, 0x01, 0x69, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x02, 0x72, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x54, 0x72, 0x75, 0x73, 0x74, 0x03, 0x00, 0x81, 0xa1, 0x01, 0xa1, 0x01, 0xd9, 0x02, 0x28, 0x01, } comid := Comid{} err := comid.FromCBOR(in) if err != nil { fmt.Printf("FAIL: %v", err) } else { fmt.Println("OK") }
Output: OK
Example (Decode_CBOR_3) ¶
// https://github.com/ietf-rats/ietf-corim-cddl/blob/main/examples/comid-design-cd.diag in := []byte{ 0xa4, 0x01, 0xa1, 0x00, 0x50, 0x1e, 0xac, 0xd5, 0x96, 0xf4, 0xa3, 0x4f, 0xb6, 0x99, 0xbf, 0xae, 0xb5, 0x8e, 0x0a, 0x4e, 0x47, 0x02, 0x81, 0xa3, 0x00, 0x71, 0x46, 0x50, 0x47, 0x41, 0x20, 0x44, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x73, 0x2d, 0x52, 0x2d, 0x55, 0x73, 0x01, 0xd8, 0x20, 0x78, 0x1e, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x66, 0x70, 0x67, 0x61, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x73, 0x72, 0x75, 0x73, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x02, 0x81, 0x00, 0x03, 0x81, 0xa2, 0x00, 0x50, 0x97, 0xf5, 0xa7, 0x07, 0x1c, 0x6f, 0x43, 0x8f, 0x87, 0x7a, 0x4a, 0x02, 0x07, 0x80, 0xeb, 0xe9, 0x01, 0x00, 0x04, 0xa2, 0x00, 0x84, 0x82, 0xa1, 0x00, 0xa3, 0x00, 0xd8, 0x6f, 0x4b, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x4d, 0x01, 0x0f, 0x04, 0x01, 0x01, 0x76, 0x66, 0x70, 0x67, 0x61, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x73, 0x72, 0x75, 0x73, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x02, 0x81, 0xa1, 0x01, 0xa2, 0x04, 0xd9, 0x02, 0x30, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x48, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x82, 0xa1, 0x00, 0xa3, 0x00, 0xd8, 0x6f, 0x4b, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x4d, 0x01, 0x0f, 0x04, 0x02, 0x01, 0x76, 0x66, 0x70, 0x67, 0x61, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x73, 0x72, 0x75, 0x73, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x02, 0x81, 0xa1, 0x01, 0xa1, 0x02, 0x81, 0x82, 0x07, 0x58, 0x30, 0x3f, 0xe1, 0x8e, 0xca, 0x40, 0x53, 0x87, 0x9e, 0x01, 0x7e, 0xf5, 0xeb, 0x7a, 0x3e, 0x51, 0x57, 0x65, 0x9c, 0x5f, 0x9b, 0xb1, 0x5b, 0x7d, 0x09, 0x95, 0x9b, 0x8b, 0x86, 0x47, 0x82, 0x2a, 0x4c, 0xc2, 0x1c, 0x3a, 0xa6, 0x72, 0x1c, 0xef, 0x87, 0xf5, 0xbf, 0xa5, 0x34, 0x95, 0xdb, 0x08, 0x33, 0x82, 0xa1, 0x00, 0xa3, 0x00, 0xd8, 0x6f, 0x4b, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x4d, 0x01, 0x0f, 0x04, 0x03, 0x01, 0x76, 0x66, 0x70, 0x67, 0x61, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x73, 0x72, 0x75, 0x73, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03, 0x02, 0x81, 0xa1, 0x01, 0xa1, 0x02, 0x81, 0x82, 0x07, 0x58, 0x30, 0x20, 0xff, 0x68, 0x1a, 0x08, 0x82, 0xe2, 0x9b, 0x48, 0x19, 0x53, 0x88, 0x89, 0x36, 0x20, 0x9c, 0xb5, 0x3d, 0xf9, 0xc5, 0xaa, 0xec, 0x60, 0x6a, 0x2c, 0x24, 0xa0, 0xfb, 0x13, 0x85, 0x95, 0x12, 0x4b, 0x8e, 0x3f, 0x24, 0xa1, 0x27, 0x71, 0xbc, 0x38, 0x54, 0xcc, 0x68, 0xb4, 0x03, 0x61, 0xad, 0x82, 0xa1, 0x00, 0xa2, 0x00, 0xd8, 0x6f, 0x4c, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x4d, 0x01, 0x0f, 0x04, 0x63, 0x01, 0x01, 0x76, 0x66, 0x70, 0x67, 0x61, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x73, 0x72, 0x75, 0x73, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x81, 0xa1, 0x01, 0xa2, 0x04, 0xd9, 0x02, 0x30, 0x58, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x58, 0x30, 0x46, 0x62, 0x24, 0x34, 0x3d, 0x68, 0x18, 0x02, 0xc1, 0x50, 0x6b, 0xbe, 0xd7, 0xd7, 0xf0, 0x0b, 0x96, 0x9b, 0xad, 0xdd, 0x63, 0x46, 0xe4, 0xf2, 0xe7, 0xce, 0x14, 0x66, 0x92, 0x99, 0x6f, 0x22, 0xa4, 0x58, 0x14, 0xde, 0x81, 0xd2, 0x48, 0xf5, 0x83, 0xb6, 0x5f, 0x81, 0x7b, 0x5f, 0xce, 0xab, 0x01, 0x81, 0x82, 0xa1, 0x00, 0xa2, 0x00, 0xd8, 0x6f, 0x4c, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x4d, 0x01, 0x0f, 0x04, 0x63, 0x02, 0x01, 0x76, 0x66, 0x70, 0x67, 0x61, 0x64, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x73, 0x72, 0x75, 0x73, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x81, 0xa1, 0x01, 0xa2, 0x04, 0xd9, 0x02, 0x30, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x48, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, } comid := Comid{} err := comid.FromCBOR(in) if err != nil { fmt.Printf("FAIL: %v", err) } else { fmt.Println("OK") }
Output: OK
Example (Decode_CBOR_4) ¶
// https://github.com/ietf-rats/ietf-corim-cddl/blob/main/examples/comid-firmware-cd.diag in := []byte{ 0xa3, 0x01, 0xa1, 0x00, 0x50, 0xaf, 0x1c, 0xd8, 0x95, 0xbe, 0x78, 0x4a, 0xdb, 0xb7, 0xe9, 0xad, 0xd4, 0x4a, 0x65, 0xab, 0xf3, 0x02, 0x81, 0xa3, 0x00, 0x71, 0x46, 0x69, 0x72, 0x6d, 0x77, 0x61, 0x72, 0x65, 0x20, 0x4d, 0x46, 0x47, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x01, 0xd8, 0x20, 0x78, 0x18, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x66, 0x77, 0x6d, 0x66, 0x67, 0x69, 0x6e, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x02, 0x81, 0x00, 0x04, 0xa2, 0x00, 0x82, 0x82, 0xa1, 0x00, 0xa4, 0x01, 0x70, 0x66, 0x77, 0x6d, 0x66, 0x67, 0x69, 0x6e, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x02, 0x67, 0x66, 0x77, 0x59, 0x5f, 0x6e, 0x35, 0x78, 0x03, 0x00, 0x04, 0x00, 0x81, 0xa1, 0x01, 0xa2, 0x01, 0xd9, 0x02, 0x28, 0x01, 0x02, 0x81, 0x82, 0x07, 0x58, 0x30, 0x15, 0xe7, 0x7d, 0x6f, 0x13, 0x32, 0x52, 0xf1, 0xdb, 0x70, 0x44, 0x90, 0x13, 0x13, 0x88, 0x4f, 0x29, 0x77, 0xd2, 0x10, 0x9b, 0x33, 0xc7, 0x9f, 0x33, 0xe0, 0x79, 0xbf, 0xc7, 0x88, 0x65, 0x25, 0x5c, 0x0f, 0xb7, 0x33, 0xc2, 0x40, 0xfd, 0xda, 0x54, 0x4b, 0x82, 0x15, 0xd7, 0xb8, 0xf8, 0x15, 0x82, 0xa1, 0x00, 0xa4, 0x01, 0x70, 0x66, 0x77, 0x6d, 0x66, 0x67, 0x69, 0x6e, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x02, 0x67, 0x66, 0x77, 0x58, 0x5f, 0x6e, 0x35, 0x78, 0x03, 0x01, 0x04, 0x00, 0x81, 0xa1, 0x01, 0xa2, 0x01, 0xd9, 0x02, 0x28, 0x01, 0x02, 0x81, 0x82, 0x07, 0x58, 0x30, 0x3d, 0x90, 0xb6, 0xbf, 0x00, 0x3d, 0xa2, 0xd9, 0x4e, 0xa5, 0x46, 0x3f, 0x97, 0xfb, 0x3c, 0x53, 0xdd, 0xc5, 0x1c, 0xfb, 0xa1, 0xe3, 0xe3, 0x8e, 0xef, 0x7a, 0xf0, 0x71, 0xa6, 0x79, 0x86, 0x59, 0x5d, 0x22, 0x72, 0x91, 0x31, 0xdf, 0x9f, 0xe8, 0x0f, 0x54, 0x51, 0xee, 0xf1, 0x54, 0xf8, 0x5e, 0x01, 0x81, 0x82, 0xa1, 0x00, 0xa2, 0x00, 0xd8, 0x6f, 0x4c, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x4d, 0x01, 0x0f, 0x04, 0x63, 0x01, 0x01, 0x70, 0x66, 0x77, 0x6d, 0x66, 0x67, 0x69, 0x6e, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x81, 0xa1, 0x01, 0xa2, 0x04, 0xd9, 0x02, 0x30, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x48, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, } comid := Comid{} err := comid.FromCBOR(in) if err != nil { fmt.Printf("FAIL: %v", err) } else { fmt.Println("OK") }
Output: OK
Example (Decode_CBOR_5) ¶
// Taken from https://github.com/ietf-corim-cddl/blob/main/examples/comid-3.diag in := []byte{ 0xa3, 0x01, 0xa1, 0x00, 0x78, 0x20, 0x6d, 0x79, 0x2d, 0x6e, 0x73, 0x3a, 0x61, 0x63, 0x6d, 0x65, 0x2d, 0x72, 0x6f, 0x61, 0x64, 0x72, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x2d, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x02, 0x81, 0xa3, 0x00, 0x69, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x01, 0xd8, 0x20, 0x74, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x61, 0x63, 0x6d, 0x65, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x02, 0x83, 0x01, 0x00, 0x02, 0x04, 0xa1, 0x00, 0x81, 0x82, 0xa1, 0x00, 0xa3, 0x00, 0xd8, 0x6f, 0x44, 0x55, 0x02, 0xc0, 0x00, 0x01, 0x69, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x02, 0x78, 0x18, 0x41, 0x43, 0x4d, 0x45, 0x20, 0x52, 0x6f, 0x61, 0x64, 0x52, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x20, 0x46, 0x69, 0x72, 0x6d, 0x77, 0x61, 0x72, 0x65, 0x81, 0xa2, 0x00, 0x19, 0x02, 0xbc, 0x01, 0xa1, 0x02, 0x81, 0x82, 0x06, 0x44, 0xab, 0xcd, 0xef, 0x00, } comid := Comid{} err := comid.FromCBOR(in) if err != nil { fmt.Printf("FAIL: %v", err) } else { fmt.Println("OK") }
Output: OK
Example (Decode_JSON) ¶
j := ` { "lang": "en-GB", "tag-identity": { "id": "43BBE37F-2E61-4B33-AED3-53CFF1428B16", "version": 1 }, "entities": [ { "name": "ACME Ltd.", "regid": "https://acme.example", "roles": [ "tagCreator" ] }, { "name": "EMCA Ltd.", "regid": "https://emca.example", "roles": [ "maintainer", "creator" ] } ], "linked-tags": [ { "target": "6F7D8D2F-EAEC-4A15-BB46-1E4DCB85DDFF", "rel": "replaces" } ], "triples": { "reference-values": [ { "environment": { "class": { "id": { "type": "uuid", "value": "83294297-97EB-42EF-8A72-AE9FEA002750" }, "vendor": "ACME", "model": "RoadRunner Boot ROM", "layer": 0, "index": 0 }, "instance": { "type": "ueid", "value": "Ad6tvu/erb7v3q2+796tvu8=" } }, "measurements": [ { "value": { "digests": [ "sha-256:3q2+7w==" ] } } ] }, { "environment": { "class": { "id": { "type": "psa.impl-id", "value": "YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=" }, "vendor": "PSA-X", "model": "Turbo PRoT" } }, "measurements": [ { "key": { "type": "psa.refval-id", "value": { "label": "PRoT", "version": "1.3.5", "signer-id": "rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs=" } }, "value": { "digests": [ "sha-256:3q2+7w==" ], "svn": { "type": "exact-value", "value": 1 }, "mac-addr": "00:00:5e:00:53:01" } } ] } ], "endorsed-values": [ { "environment": { "class": { "id": { "type": "oid", "value": "2.16.840.1.101.3.4.2.1" } }, "instance": { "type": "uuid", "value": "9090B8D3-3B17-474C-A0B9-6F54731CAB72" } }, "measurements": [ { "value": { "mac-addr": "00:00:5e:00:53:01", "ip-addr": "2001:4860:0:2001::68", "serial-number": "C02X70VHJHD5", "ueid": "Ad6tvu/erb7v3q2+796tvu8=", "uuid": "9090B8D3-3B17-474C-A0B9-6F54731CAB72", "raw-value": { "type": "bytes", "value": "cmF3dmFsdWUKcmF3dmFsdWUK" }, "raw-value-mask": "qg==", "op-flags": [ "notSecure" ], "digests": [ "sha-256;5Fty9cDAtXLbTY06t+l/No/3TmI0eoJN7LZ6hOUiTXU=", "sha-384;S1bPoH+usqtX3pIeSpfWVRRLVGRw66qrb3HA21GN31tKX7KPsq0bSTQmRCTrHlqG" ], "version": { "scheme": "semaver", "value": "1.2.3beta4" }, "svn": { "type": "min-value", "value": 10 } } } ] } ], "attester-verification-keys": [ { "environment": { "group": { "type": "uuid", "value": "83294297-97EB-42EF-8A72-AE9FEA002750" } }, "verification-keys": [ { "type": "pkix-base64-key", "value": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----" } ] } ], "dev-identity-keys": [ { "environment": { "instance": { "type": "uuid", "value": "4ECCE47C-85F2-4FD9-9EC6-00DEB72DA707" } }, "verification-keys": [ { "type": "pkix-base64-key", "value": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----" }, { "type": "pkix-base64-key", "value": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----" } ] } ] } } ` comid := Comid{} err := comid.FromJSON([]byte(j)) if err != nil { fmt.Printf("FAIL: %v", err) } else { fmt.Println("OK") }
Output: OK
Example (Encode) ¶
comid := NewComid(). SetLanguage("en-GB"). SetTagIdentity("my-ns:acme-roadrunner-supplement", 0). AddEntity("ACME Ltd.", &TestRegID, RoleCreator, RoleTagCreator). AddEntity("EMCA Ltd.", nil, RoleMaintainer). AddLinkedTag("my-ns:acme-roadrunner-base", RelSupplements). AddLinkedTag("my-ns:acme-roadrunner-old", RelReplaces). AddReferenceValue( ReferenceValue{ Environment: Environment{ Class: NewClassOID(TestOID). SetVendor("ACME Ltd."). SetModel("RoadRunner"). SetLayer(0). SetIndex(1), Instance: MustNewUEIDInstance(TestUEID), Group: MustNewUUIDGroup(TestUUID), }, Measurements: *NewMeasurements(). AddMeasurement( MustNewUUIDMeasurement(TestUUID). SetRawValueBytes([]byte{0x01, 0x02, 0x03, 0x04}, []byte{0xff, 0xff, 0xff, 0xff}). SetSVN(2). AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}). AddDigest(swid.Sha256_32, []byte{0xff, 0xff, 0xff, 0xff}). SetFlagsTrue(FlagIsDebug). SetFlagsFalse(FlagIsSecure). SetSerialNumber("C02X70VHJHD5"). SetUEID(TestUEID). SetUUID(TestUUID). SetMACaddr(MACaddr(TestMACaddr)). SetIPaddr(TestIPaddr), ), }, ). AddEndorsedValue( EndorsedValue{ Environment: Environment{ Class: NewClassUUID(TestUUID). SetVendor("ACME Ltd."). SetModel("RoadRunner"). SetLayer(0). SetIndex(1), Instance: MustNewUEIDInstance(TestUEID), Group: MustNewUUIDGroup(TestUUID), }, Measurements: *NewMeasurements(). AddMeasurement( MustNewUUIDMeasurement(TestUUID). SetRawValueBytes([]byte{0x01, 0x02, 0x03, 0x04}, []byte{0xff, 0xff, 0xff, 0xff}). SetMinSVN(2). AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}). AddDigest(swid.Sha256_32, []byte{0xff, 0xff, 0xff, 0xff}). SetFlagsTrue(FlagIsDebug). SetFlagsFalse(FlagIsSecure, FlagIsConfigured). SetSerialNumber("C02X70VHJHD5"). SetUEID(TestUEID). SetUUID(TestUUID). SetMACaddr(MACaddr(TestMACaddr)). SetIPaddr(TestIPaddr), ), }, ). AddAttestVerifKey( AttestVerifKey{ Environment: Environment{ Instance: MustNewUUIDInstance(uuid.UUID(TestUUID)), }, VerifKeys: *NewCryptoKeys(). Add( MustNewPKIXBase64Key(TestECPubKey), ), }, ).AddDevIdentityKey( DevIdentityKey{ Environment: Environment{ Instance: MustNewUEIDInstance(TestUEID), }, VerifKeys: *NewCryptoKeys(). Add( MustNewPKIXBase64Key(TestECPubKey), ), }, ) cbor, err := comid.ToCBOR() if err == nil { fmt.Printf("%x\n", cbor) } json, err := comid.ToJSON() if err == nil { fmt.Printf("%s\n", string(json)) }
Output: a50065656e2d474201a10078206d792d6e733a61636d652d726f616472756e6e65722d737570706c656d656e740282a3006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c6502820100a20069454d4341204c74642e0281020382a200781a6d792d6e733a61636d652d726f616472756e6e65722d626173650100a20078196d792d6e733a61636d652d726f616472756e6e65722d6f6c64010104a4008182a300a500d86f445502c000016941434d45204c74642e026a526f616452756e6e65720300040101d902264702deadbeefdead02d8255031fb5abf023e4992aa4e95f9c1503bfa81a200d8255031fb5abf023e4992aa4e95f9c1503bfa01aa01d90228020282820644abcdef00820644ffffffff03a201f403f504d9023044010203040544ffffffff064802005e1000000001075020010db8000000000000000000000068086c43303258373056484a484435094702deadbeefdead0a5031fb5abf023e4992aa4e95f9c1503bfa018182a300a500d8255031fb5abf023e4992aa4e95f9c1503bfa016941434d45204c74642e026a526f616452756e6e65720300040101d902264702deadbeefdead02d8255031fb5abf023e4992aa4e95f9c1503bfa81a200d8255031fb5abf023e4992aa4e95f9c1503bfa01aa01d90229020282820644abcdef00820644ffffffff03a300f401f403f504d9023044010203040544ffffffff064802005e1000000001075020010db8000000000000000000000068086c43303258373056484a484435094702deadbeefdead0a5031fb5abf023e4992aa4e95f9c1503bfa028182a101d8255031fb5abf023e4992aa4e95f9c1503bfa81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d038182a101d902264702deadbeefdead81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d {"lang":"en-GB","tag-identity":{"id":"my-ns:acme-roadrunner-supplement"},"entities":[{"name":"ACME Ltd.","regid":"https://acme.example","roles":["creator","tagCreator"]},{"name":"EMCA Ltd.","roles":["maintainer"]}],"linked-tags":[{"target":"my-ns:acme-roadrunner-base","rel":"supplements"},{"target":"my-ns:acme-roadrunner-old","rel":"replaces"}],"triples":{"reference-values":[{"environment":{"class":{"id":{"type":"oid","value":"2.5.2.8192"},"vendor":"ACME Ltd.","model":"RoadRunner","layer":0,"index":1},"instance":{"type":"ueid","value":"At6tvu/erQ=="},"group":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}},"measurements":[{"key":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"},"value":{"svn":{"type":"exact-value","value":2},"digests":["sha-256-32;q83vAA==","sha-256-32;/////w=="],"flags":{"is-secure":false,"is-debug":true},"raw-value":{"type":"bytes","value":"AQIDBA=="},"raw-value-mask":"/////w==","mac-addr":"02:00:5e:10:00:00:00:01","ip-addr":"2001:db8::68","serial-number":"C02X70VHJHD5","ueid":"At6tvu/erQ==","uuid":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}}]}],"endorsed-values":[{"environment":{"class":{"id":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"},"vendor":"ACME Ltd.","model":"RoadRunner","layer":0,"index":1},"instance":{"type":"ueid","value":"At6tvu/erQ=="},"group":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}},"measurements":[{"key":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"},"value":{"svn":{"type":"min-value","value":2},"digests":["sha-256-32;q83vAA==","sha-256-32;/////w=="],"flags":{"is-configured":false,"is-secure":false,"is-debug":true},"raw-value":{"type":"bytes","value":"AQIDBA=="},"raw-value-mask":"/////w==","mac-addr":"02:00:5e:10:00:00:00:01","ip-addr":"2001:db8::68","serial-number":"C02X70VHJHD5","ueid":"At6tvu/erQ==","uuid":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}}]}],"attester-verification-keys":[{"environment":{"instance":{"type":"uuid","value":"31fb5abf-023e-4992-aa4e-95f9c1503bfa"}},"verification-keys":[{"type":"pkix-base64-key","value":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----"}]}],"dev-identity-keys":[{"environment":{"instance":{"type":"ueid","value":"At6tvu/erQ=="}},"verification-keys":[{"type":"pkix-base64-key","value":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----"}]}]}}
Example (Encode_PSA) ¶
comid := NewComid(). SetTagIdentity("my-ns:acme-roadrunner-supplement", 0). AddEntity("ACME Ltd.", &TestRegID, RoleCreator, RoleTagCreator, RoleMaintainer). AddReferenceValue( ReferenceValue{ Environment: Environment{ Class: NewClassImplID(TestImplID). SetVendor("ACME Ltd."). SetModel("RoadRunner 2.0"), }, Measurements: *NewMeasurements(). AddMeasurement( MustNewPSAMeasurement( MustCreatePSARefValID( TestSignerID, "BL", "5.0.5", )).AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}), ). AddMeasurement( MustNewPSAMeasurement( MustCreatePSARefValID( TestSignerID, "PRoT", "1.3.5", )).AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}), ), }, ). AddAttestVerifKey( AttestVerifKey{ Environment: Environment{ Instance: MustNewUEIDInstance(TestUEID), }, VerifKeys: *NewCryptoKeys(). Add( MustNewPKIXBase64Key(TestECPubKey), ), }, ) cbor, err := comid.ToCBOR() if err == nil { fmt.Printf("%x\n", cbor) } json, err := comid.ToJSON() if err == nil { fmt.Printf("%s\n", string(json)) }
Output: a301a10078206d792d6e733a61636d652d726f616472756e6e65722d737570706c656d656e740281a3006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c65028301000204a2008182a100a300d90258582061636d652d696d706c656d656e746174696f6e2d69642d303030303030303031016941434d45204c74642e026e526f616452756e6e657220322e3082a200d90259a30162424c0465352e302e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00a200d90259a3016450526f540465312e332e35055820acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b01a10281820644abcdef00028182a101d902264702deadbeefdead81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d {"tag-identity":{"id":"my-ns:acme-roadrunner-supplement"},"entities":[{"name":"ACME Ltd.","regid":"https://acme.example","roles":["creator","tagCreator","maintainer"]}],"triples":{"reference-values":[{"environment":{"class":{"id":{"type":"psa.impl-id","value":"YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE="},"vendor":"ACME Ltd.","model":"RoadRunner 2.0"}},"measurements":[{"key":{"type":"psa.refval-id","value":{"label":"BL","version":"5.0.5","signer-id":"rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs="}},"value":{"digests":["sha-256-32;q83vAA=="]}},{"key":{"type":"psa.refval-id","value":{"label":"PRoT","version":"1.3.5","signer-id":"rLsRx+TaIXIFUjzkzhokWuGiOa48a/2eeHH35di66Gs="}},"value":{"digests":["sha-256-32;q83vAA=="]}}]}],"attester-verification-keys":[{"environment":{"instance":{"type":"ueid","value":"At6tvu/erQ=="}},"verification-keys":[{"type":"pkix-base64-key","value":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----"}]}]}}
Example (Encode_PSA_attestation_verification) ¶
comid := NewComid(). SetTagIdentity("my-ns:acme-roadrunner-supplement", 0). AddEntity("ACME Ltd.", &TestRegID, RoleCreator, RoleTagCreator, RoleMaintainer). AddAttestVerifKey( AttestVerifKey{ Environment: Environment{ Instance: MustNewUEIDInstance(TestUEID), }, VerifKeys: *NewCryptoKeys(). Add( MustNewPKIXBase64Key(TestECPubKey), ), }, ) cbor, err := comid.ToCBOR() if err == nil { fmt.Printf("%x\n", cbor) } json, err := comid.ToJSON() if err == nil { fmt.Printf("%s", string(json)) }
Output: a301a10078206d792d6e733a61636d652d726f616472756e6e65722d737570706c656d656e740281a3006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c65028301000204a1028182a101d902264702deadbeefdead81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d {"tag-identity":{"id":"my-ns:acme-roadrunner-supplement"},"entities":[{"name":"ACME Ltd.","regid":"https://acme.example","roles":["creator","tagCreator","maintainer"]}],"triples":{"attester-verification-keys":[{"environment":{"instance":{"type":"ueid","value":"At6tvu/erQ=="}},"verification-keys":[{"type":"pkix-base64-key","value":"-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEW1BvqF+/ry8BWa7ZEMU1xYYHEQ8B\nlLT4MFHOaO+ICTtIvrEeEpr/sfTAP66H2hCHdb5HEXKtRKod6QLcOLPA1Q==\n-----END PUBLIC KEY-----"}]}]}}
Example (Psa_keys) ¶
package main import "fmt" func main() { comid := Comid{} if err := comid.FromJSON([]byte(PSAKeysJSONTemplate)); err != nil { panic(err) } if err := comid.Valid(); err != nil { panic(err) } if err := extractKeys(&comid); err != nil { panic(err) } } func extractKeys(c *Comid) error { if c.Triples.AttestVerifKeys == nil { return fmt.Errorf("no reference values triples") } for i, k := range *c.Triples.AttestVerifKeys { if err := extractPSAKey(k); err != nil { return fmt.Errorf("bad PSA verification key value at index %d: %w", i, err) } } return nil } func extractPSAKey(k AttestVerifKey) error { class := k.Environment.Class if err := extractImplementationID(class); err != nil { return fmt.Errorf("extracting impl-id: %w", err) } instance := k.Environment.Instance if err := extractInstanceID(instance); err != nil { return fmt.Errorf("extracting inst-id: %w", err) } if len(k.VerifKeys) != 1 { return fmt.Errorf("more than one key") } fmt.Printf("IAK public key: %x\n", k.VerifKeys[0]) return nil } func extractInstanceID(i *Instance) error { if i == nil { return fmt.Errorf("no instance") } fmt.Printf("InstanceID: %x\n", i.Bytes()) return nil }
Output: ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 InstanceID: 01ceebae7b8927a3227e5303cf5e0f1f7b34bb542ad7250ac03fbcde36ec2f1508 IAK public key: 2d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 InstanceID: 014ca3e4f50bf248c39787020d68ffd05c88767751bf2645ca923f57a98becd296 IAK public key: 2d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d
Example (Psa_refval) ¶
package main import "fmt" func main() { comid := Comid{} if err := comid.FromJSON([]byte(PSARefValJSONTemplate)); err != nil { panic(err) } if err := comid.Valid(); err != nil { panic(err) } if err := extractRefVals(&comid); err != nil { panic(err) } } func extractRefVals(c *Comid) error { if c.Triples.ReferenceValues == nil { return fmt.Errorf("no reference values triples") } for i, rv := range *c.Triples.ReferenceValues { if err := extractPSARefVal(rv); err != nil { return fmt.Errorf("bad PSA reference value at index %d: %w", i, err) } } return nil } func extractPSARefVal(rv ReferenceValue) error { class := rv.Environment.Class if err := extractImplementationID(class); err != nil { return fmt.Errorf("extracting impl-id: %w", err) } measurements := rv.Measurements if err := extractSwMeasurements(measurements); err != nil { return fmt.Errorf("extracting measurements: %w", err) } return nil } func extractSwMeasurements(m Measurements) error { if len(m) == 0 { return fmt.Errorf("no measurements") } for i, m := range m { if err := extractSwMeasurement(m); err != nil { return fmt.Errorf("extracting measurement at index %d: %w", i, err) } } return nil } func extractSwMeasurement(m Measurement) error { if err := extractPSARefValID(m.Key); err != nil { return fmt.Errorf("extracting PSA refval id: %w", err) } if err := extractDigest(m.Val.Digests); err != nil { return fmt.Errorf("extracting digest: %w", err) } return nil } func extractDigest(d *Digests) error { if d == nil { return fmt.Errorf("no digest") } if len(*d) != 1 { return fmt.Errorf("more than one digest") } fmt.Printf("Digest: %x\n", (*d)[0].HashValue) return nil } func extractPSARefValID(k *Mkey) error { if k == nil { return fmt.Errorf("no measurement key") } id, ok := k.Value.(*TaggedPSARefValID) if !ok { return fmt.Errorf("expected PSA refval id, found: %T", k.Value) } fmt.Printf("SignerID: %x\n", id.SignerID) if id.Label != nil { fmt.Printf("Label: %s\n", *id.Label) } if id.Version != nil { fmt.Printf("Version: %s\n", *id.Version) } // ignore alg-id return nil } func extractImplementationID(c *Class) error { if c == nil { return fmt.Errorf("no class") } classID := c.ClassID if classID == nil { return fmt.Errorf("no class-id") } if classID.Type() != ImplIDType { return fmt.Errorf("class id is not a psa.impl-id") } fmt.Printf("ImplementationID: %x\n", classID.Bytes()) return nil }
Output: ImplementationID: 61636d652d696d706c656d656e746174696f6e2d69642d303030303030303031 SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b Label: BL Version: 2.1.0 Digest: 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7 SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b Label: PRoT Version: 1.3.5 Digest: 0263829989b6fd954f72baaf2fc64bc2e2f01d692d4de72986ea808f6e99813f SignerID: acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b Label: ARoT Version: 0.1.4 Digest: a3a5e715f0cc574a73c3f9bebb6bc24f32ffd5b67b387244c2c909da779a1478
Index ¶
- Constants
- Variables
- func IsAbsoluteURI(s string) error
- func MustHexDecode(t *testing.T, s string) []byte
- func NewHashEntry(algID uint64, value []byte) *swid.HashEntry
- func RegisterClassIDType(tag uint64, factory IClassIDFactory) error
- func RegisterCryptoKeyType(tag uint64, factory ICryptoKeyFactory) error
- func RegisterEntityNameType(tag uint64, factory IEntityNameFactory) error
- func RegisterGroupType(tag uint64, factory IGroupFactory) error
- func RegisterInstanceType(tag uint64, factory IInstanceFactory) error
- func RegisterMkeyType(tag uint64, factory IMkeyFactory) error
- func RegisterRel(val int64, name string) error
- func RegisterRole(val int64, name string) error
- func RegisterSVNType(tag uint64, factory ISVNFactory) error
- type AttestVerifKey
- type CCAPlatformConfigID
- type Class
- func (o *Class) FromCBOR(data []byte) error
- func (o *Class) FromJSON(data []byte) error
- func (o Class) GetIndex() uint64
- func (o Class) GetLayer() uint64
- func (o Class) GetModel() string
- func (o Class) GetVendor() string
- func (o *Class) SetIndex(index uint64) *Class
- func (o *Class) SetLayer(layer uint64) *Class
- func (o *Class) SetModel(model string) *Class
- func (o *Class) SetVendor(vendor string) *Class
- func (o Class) ToCBOR() ([]byte, error)
- func (o Class) ToJSON() ([]byte, error)
- func (o Class) Valid() error
- type ClassID
- func MustNewImplIDClassID(val any) *ClassID
- func MustNewOIDClassID(val any) *ClassID
- func MustNewUUIDClassID(val any) *ClassID
- func NewBytesClassID(val any) (*ClassID, error)
- func NewClassID(val any, typ string) (*ClassID, error)
- func NewImplIDClassID(val any) (*ClassID, error)
- func NewIntClassID(val any) (*ClassID, error)
- func NewOIDClassID(val any) (*ClassID, error)
- func NewUUIDClassID(val any) (*ClassID, error)
- func (o ClassID) Bytes() []byte
- func (o ClassID) GetImplID() (ImplID, error)
- func (o ClassID) IsSet() bool
- func (o ClassID) MarshalCBOR() ([]byte, error)
- func (o ClassID) MarshalJSON() ([]byte, error)
- func (o *ClassID) SetImplID(implID ImplID) *ClassID
- func (o *ClassID) SetOID(s string) *ClassID
- func (o *ClassID) SetUUID(uuid UUID) *ClassID
- func (o ClassID) String() string
- func (o ClassID) Type() string
- func (o *ClassID) UnmarshalCBOR(data []byte) error
- func (o *ClassID) UnmarshalJSON(data []byte) error
- func (o ClassID) Valid() error
- type Comid
- func (o *Comid) AddAttestVerifKey(val AttestVerifKey) *Comid
- func (o *Comid) AddDevIdentityKey(val DevIdentityKey) *Comid
- func (o *Comid) AddEndorsedValue(val EndorsedValue) *Comid
- func (o *Comid) AddEntity(name string, regID *string, roles ...Role) *Comid
- func (o *Comid) AddLinkedTag(tagID interface{}, rel Rel) *Comid
- func (o *Comid) AddReferenceValue(val ReferenceValue) *Comid
- func (o *Comid) FromCBOR(data []byte) error
- func (o *Comid) FromJSON(data []byte) error
- func (o *Comid) GetExtensions() extensions.IExtensionsValue
- func (o *Comid) RegisterExtensions(exts extensions.IExtensionsValue)
- func (o *Comid) SetLanguage(language string) *Comid
- func (o *Comid) SetTagIdentity(tagID interface{}, tagIDVersion uint) *Comid
- func (o Comid) ToCBOR() ([]byte, error)
- func (o Comid) ToJSON() ([]byte, error)
- func (o Comid) ToJSONPretty(indent string) ([]byte, error)
- func (o Comid) Valid() error
- type CryptoKey
- func MustNewCOSEKey(k any) *CryptoKey
- func MustNewCertPathThumbprint(k any) *CryptoKey
- func MustNewCertThumbprint(k any) *CryptoKey
- func MustNewCryptoKey(k any, typ string) *CryptoKey
- func MustNewPKIXBase64Cert(k any) *CryptoKey
- func MustNewPKIXBase64CertPath(k any) *CryptoKey
- func MustNewPKIXBase64Key(k any) *CryptoKey
- func MustNewThumbprint(k any) *CryptoKey
- func NewCOSEKey(k any) (*CryptoKey, error)
- func NewCertPathThumbprint(k any) (*CryptoKey, error)
- func NewCertThumbprint(k any) (*CryptoKey, error)
- func NewCryptoKey(k any, typ string) (*CryptoKey, error)
- func NewPKIXBase64Cert(k any) (*CryptoKey, error)
- func NewPKIXBase64CertPath(k any) (*CryptoKey, error)
- func NewPKIXBase64Key(k any) (*CryptoKey, error)
- func NewThumbprint(k any) (*CryptoKey, error)
- func (o CryptoKey) MarshalCBOR() ([]byte, error)
- func (o CryptoKey) MarshalJSON() ([]byte, error)
- func (o CryptoKey) PublicKey() (crypto.PublicKey, error)
- func (o CryptoKey) String() string
- func (o CryptoKey) Type() string
- func (o *CryptoKey) UnmarshalCBOR(b []byte) error
- func (o *CryptoKey) UnmarshalJSON(b []byte) error
- func (o CryptoKey) Valid() error
- type CryptoKeys
- type DevIdentityKey
- type Digests
- type EndorsedValue
- type Entities
- type Entity
- func (o *Entity) GetExtensions() extensions.IExtensionsValue
- func (o *Entity) MarshalCBOR() ([]byte, error)
- func (o *Entity) MarshalJSON() ([]byte, error)
- func (o *Entity) RegisterExtensions(exts extensions.IExtensionsValue)
- func (o *Entity) SetEntityName(name string) *Entity
- func (o *Entity) SetRegID(uri string) *Entity
- func (o *Entity) SetRoles(roles ...Role) *Entity
- func (o *Entity) UnmarshalCBOR(data []byte) error
- func (o *Entity) UnmarshalJSON(data []byte) error
- func (o Entity) Valid() error
- type EntityName
- type Environment
- type Extensions
- type Flag
- type FlagsMap
- func (o *FlagsMap) AnySet() bool
- func (o *FlagsMap) Clear(flags ...Flag)
- func (o *FlagsMap) Get(flag Flag) *bool
- func (o *FlagsMap) GetExtensions() extensions.IExtensionsValue
- func (o *FlagsMap) MarshalCBOR() ([]byte, error)
- func (o *FlagsMap) MarshalJSON() ([]byte, error)
- func (o *FlagsMap) RegisterExtensions(exts extensions.IExtensionsValue)
- func (o *FlagsMap) SetFalse(flags ...Flag)
- func (o *FlagsMap) SetTrue(flags ...Flag)
- func (o *FlagsMap) UnmarshalCBOR(data []byte) error
- func (o *FlagsMap) UnmarshalJSON(data []byte) error
- func (o FlagsMap) Valid() error
- type Group
- func (o Group) Bytes() []byte
- func (o Group) MarshalCBOR() ([]byte, error)
- func (o Group) MarshalJSON() ([]byte, error)
- func (o Group) String() string
- func (o Group) Type() string
- func (o *Group) UnmarshalCBOR(data []byte) error
- func (o *Group) UnmarshalJSON(data []byte) error
- func (o Group) Valid() error
- type IClassIDFactory
- type IClassIDValue
- type IComidConstrainer
- type ICryptoKeyFactory
- type ICryptoKeyValue
- type IEntityConstrainer
- type IEntityNameFactory
- type IEntityNameValue
- type IFlagSetter
- type IFlagsMapConstrainer
- type IGroupFactory
- type IGroupValue
- type IInstanceFactory
- type IInstanceValue
- type IMKeyValue
- type IMkeyFactory
- type IMvalConstrainer
- type IRegisterIndex
- type ISVNFactory
- type ISVNValue
- type ITriplesConstrainer
- type ImplID
- type Instance
- func (o Instance) Bytes() []byte
- func (o Instance) GetUEID() (eat.UEID, error)
- func (o Instance) GetUUID() (UUID, error)
- func (o Instance) MarshalCBOR() ([]byte, error)
- func (o Instance) MarshalJSON() ([]byte, error)
- func (o *Instance) SetUEID(val eat.UEID) *Instance
- func (o *Instance) SetUUID(val uuid.UUID) *Instance
- func (o Instance) String() string
- func (o Instance) Type() string
- func (o *Instance) UnmarshalCBOR(data []byte) error
- func (o *Instance) UnmarshalJSON(data []byte) error
- func (o Instance) Valid() error
- type IntegrityRegisters
- func (i *IntegrityRegisters) AddDigest(index IRegisterIndex, digest swid.HashEntry) error
- func (i *IntegrityRegisters) AddDigests(index IRegisterIndex, digests Digests) error
- func (i IntegrityRegisters) MarshalCBOR() ([]byte, error)
- func (i IntegrityRegisters) MarshalJSON() ([]byte, error)
- func (i *IntegrityRegisters) UnmarshalCBOR(data []byte) error
- func (i *IntegrityRegisters) UnmarshalJSON(data []byte) error
- type LinkedTag
- type LinkedTags
- type MACaddr
- type Measurement
- func MustNewCCAPlatCfgMeasurement(key any) *Measurement
- func MustNewMeasurement(val any, typ string) *Measurement
- func MustNewPSAMeasurement(key any) *Measurement
- func MustNewUUIDMeasurement(key any) *Measurement
- func MustNewUintMeasurement(key any) *Measurement
- func NewCCAPlatCfgMeasurement(key any) (*Measurement, error)
- func NewMeasurement(val any, typ string) (*Measurement, error)
- func NewOIDMeasurement(key any) (*Measurement, error)
- func NewPSAMeasurement(key any) (*Measurement, error)
- func NewUUIDMeasurement(key any) (*Measurement, error)
- func NewUintMeasurement(key any) (*Measurement, error)
- func (o *Measurement) AddDigest(algID uint64, digest []byte) *Measurement
- func (o *Measurement) ClearFlags(flags ...Flag) *Measurement
- func (o *Measurement) SetFlagsFalse(flags ...Flag) *Measurement
- func (o *Measurement) SetFlagsTrue(flags ...Flag) *Measurement
- func (o *Measurement) SetIPaddr(a net.IP) *Measurement
- func (o *Measurement) SetMACaddr(a MACaddr) *Measurement
- func (o *Measurement) SetMinSVN(svn uint64) *Measurement
- func (o *Measurement) SetRawValueBytes(rawValue, rawValueMask []byte) *Measurement
- func (o *Measurement) SetSVN(svn uint64) *Measurement
- func (o *Measurement) SetSerialNumber(sn string) *Measurement
- func (o *Measurement) SetUEID(ueid eat.UEID) *Measurement
- func (o *Measurement) SetUUID(u UUID) *Measurement
- func (o *Measurement) SetVersion(ver string, scheme int64) *Measurement
- func (o Measurement) Valid() error
- type Measurements
- type Mkey
- func MustNewMkey(val any, typ string) *Mkey
- func NewMkey(val any, typ string) (*Mkey, error)
- func NewMkeyCCAPlatformConfigID(val any) (*Mkey, error)
- func NewMkeyOID(val any) (*Mkey, error)
- func NewMkeyPSARefvalID(val any) (*Mkey, error)
- func NewMkeyUUID(val any) (*Mkey, error)
- func NewMkeyUint(val any) (*Mkey, error)
- func (o Mkey) GetCCAPlatformConfigID() (CCAPlatformConfigID, error)
- func (o Mkey) GetKeyUint() (uint64, error)
- func (o Mkey) GetPSARefValID() (PSARefValID, error)
- func (o Mkey) IsSet() bool
- func (o Mkey) MarshalCBOR() ([]byte, error)
- func (o Mkey) MarshalJSON() ([]byte, error)
- func (o Mkey) Type() string
- func (o *Mkey) UnmarshalCBOR(data []byte) error
- func (o *Mkey) UnmarshalJSON(data []byte) error
- func (o Mkey) Valid() error
- type Mval
- func (o *Mval) GetExtensions() extensions.IExtensionsValue
- func (o *Mval) MarshalCBOR() ([]byte, error)
- func (o *Mval) MarshalJSON() ([]byte, error)
- func (o *Mval) RegisterExtensions(exts extensions.IExtensionsValue)
- func (o *Mval) UnmarshalCBOR(data []byte) error
- func (o *Mval) UnmarshalJSON(data []byte) error
- func (o Mval) Valid() error
- type OID
- type PSARefValID
- type RawValue
- type ReferenceValue
- type Rel
- type Role
- type Roles
- type SVN
- type StringEntityName
- type TagIdentity
- type TaggedBytes
- type TaggedCCAPlatformConfigID
- type TaggedCOSEKey
- type TaggedCertPathThumbprint
- type TaggedCertThumbprint
- type TaggedImplID
- type TaggedInt
- type TaggedMinSVN
- type TaggedOID
- type TaggedPKIXBase64Cert
- type TaggedPKIXBase64CertPath
- type TaggedPKIXBase64Key
- type TaggedPSARefValID
- type TaggedSVN
- type TaggedThumbprint
- type TaggedUEID
- type TaggedURI
- type TaggedUUID
- type Triples
- func (o *Triples) AddAttestVerifKey(val AttestVerifKey) *Triples
- func (o *Triples) AddDevIdentityKey(val DevIdentityKey) *Triples
- func (o *Triples) AddEndorsedValue(val EndorsedValue) *Triples
- func (o *Triples) AddReferenceValue(val ReferenceValue) *Triples
- func (o *Triples) GetExtensions() extensions.IExtensionsValue
- func (o *Triples) MarshalCBOR() ([]byte, error)
- func (o *Triples) MarshalJSON() ([]byte, error)
- func (o *Triples) RegisterExtensions(exts extensions.IExtensionsValue)
- func (o *Triples) UnmarshalCBOR(data []byte) error
- func (o *Triples) UnmarshalJSON(data []byte) error
- func (o Triples) Valid() error
- type UEID
- type UUID
- type UintMkey
- type Version
Examples ¶
- Package (Cca_realm_refval)
- Package (Cca_refval)
- Package (Decode_CBOR_1)
- Package (Decode_CBOR_2)
- Package (Decode_CBOR_3)
- Package (Decode_CBOR_4)
- Package (Decode_CBOR_5)
- Package (Decode_JSON)
- Package (Encode)
- Package (Encode_PSA)
- Package (Encode_PSA_attestation_verification)
- Package (Psa_keys)
- Package (Psa_refval)
Constants ¶
const ( // PKIXBase64KeyType indicates a PEM-encoded SubjectPublicKeyInfo. See // https://www.rfc-editor.org/rfc/rfc7468#section-13 PKIXBase64KeyType = "pkix-base64-key" // PKIXBase64CertType indicates a PEM-encoded X.509 public key // certificate. See https://www.rfc-editor.org/rfc/rfc7468#section-5 PKIXBase64CertType = "pkix-base64-cert" // PKIXBase64CertPathType indicates a X.509 certificate chain created // by the concatenation of as many PEM encoded X.509 certificates as // needed. The certificates MUST be concatenated in order so that each // directly certifies the one preceding. PKIXBase64CertPathType = "pkix-base64-cert-path" // COSEKeyType represents a CBOR encoded COSE_Key or COSE_KeySet. See // https://www.rfc-editor.org/rfc/rfc9052#section-7 COSEKeyType = "cose-key" // ThumbprintType represents a digest of a raw public key. The digest // value may be used to find the public key if contained in a lookup // table. ThumbprintType = "thumbprint" // CertThumbprintType represents a digest of a certificate. The digest // value may be used to find the certificate if contained in a lookup // table. CertThumbprintType = "cert-thumbprint" // CertPathThumbprintType represents a digest of a certification path. // The digest value may be used to find the certificate path if // contained in a lookup table. CertPathThumbprintType = "cert-path-thumbprint" )
const ( // MaxASN1OIDLen is the maximum OID length accepted by the implementation MaxASN1OIDLen = 255 // MinNumOIDArcs represents the minimum required arcs for a valid OID MinNumOIDArcs = 3 )
const ( ExactValueType = "exact-value" MinValueType = "min-value" )
const BytesType = "bytes"
const ImplIDType = "psa.impl-id"
const IntType = "int"
const MaxUint64 = ^uint64(0)
const OIDType = "oid"
const TextType = "text"
const UEIDType = "ueid"
const UUIDType = "uuid"
const UintType = "uint"
Variables ¶
var ( TestUUIDString = "31fb5abf-023e-4992-aa4e-95f9c1503bfa" TestUUID = UUID(uuid.Must(uuid.Parse(TestUUIDString))) TestImplID = ImplID([32]byte{ 0x61, 0x63, 0x6d, 0x65, 0x2d, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2d, 0x69, 0x64, 0x2d, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, }) TestOID = "2.5.2.8192" TestRegID = "https://acme.example" TestMACaddr, _ = net.ParseMAC("02:00:5e:10:00:00:00:01") TestIPaddr = net.ParseIP("2001:db8::68") TestBytes = []byte{0x89, 0x99, 0x78, 0x65, 0x56} TestUEIDString = "02deadbeefdead" TestUEID = eat.UEID(MustHexDecode(nil, TestUEIDString)) TestSignerID = MustHexDecode(nil, "acbb11c7e4da217205523ce4ce1a245ae1a239ae3c6bfd9e7871f7e5d8bae86b") TestTagID = "urn:example:veraison" TestMKey uint64 = 700 TestCCALabel = "cca-platform-config" TestECPrivKey = `` /* 226-byte string literal not displayed */ TestECPubKey = `` /* 177-byte string literal not displayed */ TestCert = `` /* 712-byte string literal not displayed */ TestCertPath = `` /* 6439-byte string literal not displayed */ TestCOSEKey = MustHexDecode(nil, `a501020258246d65726961646f632e6272616e64796275636b406275636b6c616e642e6578616d706c65200121582065eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c08551d2258201e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd0084d19c`) TestCOSEKeySetOne = MustHexDecode(nil, `81a501020258246d65726961646f632e6272616e64796275636b406275636b6c616e642e6578616d706c65200121582065eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c08551d2258201e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd0084d19c`) TestCOSEKeySetMulti = MustHexDecode(nil, `82a501020258246d65726961646f632e6272616e64796275636b406275636b6c616e642e6578616d706c65200121582065eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c08551d2258201e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd0084d19ca601010327048202647369676e0543030201200621582015522ef15729ccf39509ea5c15a26be949e38807a5c26ef9281487ef4ae67b46`) TestThumbprint = swid.HashEntry{ HashAlgID: 1, HashValue: MustHexDecode(nil, `68e656b251e67e8358bef8483ab0d51c6619f3e7a1a9f0e75838d41ff368f728`), } )
var ( PSARefValJSONTemplate = `` /* 1556-byte string literal not displayed */ PSAKeysJSONTemplate = `` /* 1541-byte string literal not displayed */ CCARefValJSONTemplate = `` /* 1806-byte string literal not displayed */ CCARealmRefValJSONTemplate = `` /* 1566-byte string literal not displayed */ )
var CCAPlatformConfigIDType = "cca.platform-config-id"
var False = false
var PSARefValIDType = "psa.refval-id"
var True = true
Functions ¶
func IsAbsoluteURI ¶
func RegisterClassIDType ¶ added in v1.1.2
func RegisterClassIDType(tag uint64, factory IClassIDFactory) error
RegisterClassIDType registers a new IClassIDValue implementation (created by the provided IClassIDFactory) under the specified CBOR tag.
func RegisterCryptoKeyType ¶ added in v1.1.2
func RegisterCryptoKeyType(tag uint64, factory ICryptoKeyFactory) error
RegisterCryptoKeyType registers a new ICryptoKeyValue implementation (created by the provided ICryptoKeyFactory) under the specified type name and CBOR tag.
func RegisterEntityNameType ¶ added in v1.1.2
func RegisterEntityNameType(tag uint64, factory IEntityNameFactory) error
RegisterEntityNameType registers a new IEntityNameValue implementation (created by the provided IEntityNameFactory) under the specified type name and CBOR tag.
func RegisterGroupType ¶ added in v1.1.2
func RegisterGroupType(tag uint64, factory IGroupFactory) error
RegisterGroupType registers a new IGroupValue implementation (created by the provided IGroupFactory) under the specified type name and CBOR tag.
func RegisterInstanceType ¶ added in v1.1.2
func RegisterInstanceType(tag uint64, factory IInstanceFactory) error
RegisterInstanceType registers a new IInstanceValue implementation (created by the provided IInstanceFactory) under the specified CBOR tag.
func RegisterMkeyType ¶ added in v1.1.2
func RegisterMkeyType(tag uint64, factory IMkeyFactory) error
RegisterMkeyType registers a new IMKeyValue implementation (created by the provided IMKeyFactory) under the specified CBOR tag.
func RegisterRel ¶ added in v1.1.2
RegisterRel creates a new Rel association between the provided value and name. An error is returned if either clashes with any of the existing roles.
func RegisterRole ¶ added in v1.1.2
RegisterRole creates a new Role association between the provided value and name. An error is returned if either clashes with any of the existing roles.
func RegisterSVNType ¶ added in v1.1.2
func RegisterSVNType(tag uint64, factory ISVNFactory) error
RegisterSVNType registers a new ISVNValue implementation (created by the provided ISVNFactory) under the specified CBOR tag.
Types ¶
type AttestVerifKey ¶
type AttestVerifKey struct { Environment Environment `json:"environment"` VerifKeys CryptoKeys `json:"verification-keys"` // contains filtered or unexported fields }
AttestVerifKey stores an 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.
func (AttestVerifKey) Valid ¶
func (o AttestVerifKey) Valid() error
type CCAPlatformConfigID ¶
type CCAPlatformConfigID string
func (CCAPlatformConfigID) Empty ¶
func (o CCAPlatformConfigID) Empty() bool
func (CCAPlatformConfigID) Get ¶
func (o CCAPlatformConfigID) Get() (CCAPlatformConfigID, error)
func (*CCAPlatformConfigID) Set ¶
func (o *CCAPlatformConfigID) Set(v string) error
type Class ¶
type Class struct { ClassID *ClassID `cbor:"0,keyasint,omitempty" json:"id,omitempty"` Vendor *string `cbor:"1,keyasint,omitempty" json:"vendor,omitempty"` Model *string `cbor:"2,keyasint,omitempty" json:"model,omitempty"` Layer *uint64 `cbor:"3,keyasint,omitempty" json:"layer,omitempty"` Index *uint64 `cbor:"4,keyasint,omitempty" json:"index,omitempty"` }
Class represents the class of the (target / attesting) environment. The only required field is the class unique identifier (see ClassID). Optionally, information about the specific brand & product as well as its topological coordinates within the wider device can be recorded.
func NewClassImplID ¶
NewClassImplID instantiates a new Class object that identifies the specified PSA Implementation ID
func NewClassOID ¶
NewClassOID instantiates a new Class object that identifies the OID
func NewClassUUID ¶
NewClassUUID instantiates a new Class object with the specified UUID as identifier
func (Class) GetIndex ¶
GetIndex returns the index number if it set in the target Class. Otherwise, uint64_max is returned.
func (Class) GetLayer ¶
GetLayer returns the layer number if it set in the target Class. Otherwise, uint64_max is returned.
func (Class) GetModel ¶
GetModel returns the model string if it set in the target Class. Otherwise, an empty string is returned.
func (Class) GetVendor ¶
GetVendor returns the vendor string if it set in the target Class. Otherwise, an empty string is returned.
func (*Class) SetIndex ¶
SetIndex sets the "index" (i.e., the identifier of the environment instance in a specific layer) as indicated
func (*Class) SetLayer ¶
SetLayer sets the "layer" (i.e., the logical/topological location of the environment in the device) as indicated
type ClassID ¶
type ClassID struct {
Value IClassIDValue
}
ClassID identifies the environment via a well-known identifier. This can be an OID, a UUID, variable-length opaque bytes or a profile-defined extension type.
func MustNewImplIDClassID ¶ added in v1.1.2
func MustNewOIDClassID ¶ added in v1.1.2
func MustNewUUIDClassID ¶ added in v1.1.2
func NewBytesClassID ¶ added in v1.1.2
NewBytesClassID creates a New ClassID of type bytes The supplied interface parameter could be a byte slice, a pointer to a byte slice or a string
func NewClassID ¶ added in v1.1.2
NewClassID creates a new ClassID of the specified type using the specified value.
func NewImplIDClassID ¶ added in v1.1.2
func NewIntClassID ¶ added in v1.1.2
func NewOIDClassID ¶ added in v1.1.2
func NewUUIDClassID ¶ added in v1.1.2
func (ClassID) Bytes ¶ added in v1.1.2
Bytes returns a []byte containing the raw bytes of the class id value
func (ClassID) GetImplID ¶
GetImplID retrieves the value of the PSA Implementation ID (see Section 3.2.2 of draft-tschofenig-rats-psa-token) from ClassID
func (ClassID) IsSet ¶ added in v1.1.2
IsSet returns true iff the underlying class id value has been set (is not nil)
func (ClassID) MarshalCBOR ¶
MarshalCBOR serializes the target ClassID to CBOR
func (ClassID) MarshalJSON ¶
MarshalJSON serializes the target ClassID to JSON
func (*ClassID) SetImplID ¶
SetImplID sets the value of the target ClassID to the supplied PSA Implementation ID (see Section 3.2.2 of draft-tschofenig-rats-psa-token)
func (*ClassID) SetOID ¶
SetOID sets the value of the targed ClassID to the supplied OID. The OID is a string in dotted-decimal notation
func (ClassID) String ¶
String returns a printable string of the ClassID value. UUIDs use the canonical 8-4-4-4-12 format, PSA Implementation IDs are base64 encoded. OIDs are output in dotted-decimal notation.
func (*ClassID) UnmarshalCBOR ¶
UnmarshalCBOR deserializes the supplied CBOR buffer into the target ClassID. It is undefined behavior to try and inspect the target ClassID in case this method returns an error.
func (*ClassID) UnmarshalJSON ¶
UnmarshalJSON deserializes the supplied JSON object into the target ClassID The class id object must have the following shape:
{ "type": "<CLASS_ID_TYPE>", "value": <CLASS_ID_VALUE> }
where <CLASS_ID_TYPE> must be one of the known IClassIDValue implementation type names (available in this implementation: "uuid", "oid", "psa.impl-id", "int", "bytes"), and <CLASS_ID_VALUE> is the JSON encoding of the underlying class id value. The exact encoding is <CLASS_ID_TYPE> dependent. For the base implementation types it is
oid: dot-separated integers, e.g. "1.2.3.4" psa.impl-id: base64-encoded bytes, e.g. "YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=" uuid: standard UUID string representation, e.g. "550e8400-e29b-41d4-a716-446655440000" int: an integer value, e.g. 7 bytes: a variable length opaque bytes, example {0x07, 0x12, 0x34}
type Comid ¶
type Comid struct { Language *string `cbor:"0,keyasint,omitempty" json:"lang,omitempty"` TagIdentity TagIdentity `cbor:"1,keyasint" json:"tag-identity"` Entities *Entities `cbor:"2,keyasint,omitempty" json:"entities,omitempty"` LinkedTags *LinkedTags `cbor:"3,keyasint,omitempty" json:"linked-tags,omitempty"` Triples Triples `cbor:"4,keyasint" json:"triples"` Extensions }
Comid is the top-level representation of a Concise Module IDentifier with CBOR and JSON serialization.
func (*Comid) AddAttestVerifKey ¶
func (o *Comid) AddAttestVerifKey(val AttestVerifKey) *Comid
AddAttestVerifKey adds the supplied endorsed value to the attest-key-triples list of the target Comid.
func (*Comid) AddDevIdentityKey ¶
func (o *Comid) AddDevIdentityKey(val DevIdentityKey) *Comid
AddDevIdentityKey adds the supplied identity key to the identity-triples list of the target Comid.
func (*Comid) AddEndorsedValue ¶
func (o *Comid) AddEndorsedValue(val EndorsedValue) *Comid
AddEndorsedValue adds the supplied endorsed value to the endorsed-triples list of the target Comid.
func (*Comid) AddEntity ¶
AddEntity adds an organizational entity, together with the roles this entity claims with regards to the CoMID, to the target Comid. name is the entity name, regID is a URI that uniquely identifies the entity, and roles are one or more claimed roles chosen from the following: RoleTagCreator, RoleCreator and RoleMaintainer.
func (*Comid) AddLinkedTag ¶
AddLinkedTag adds a link relationship of type rel between the target Comid and another CoMID identified by its tagID. The rel parameter can be one of RelSupplements or RelReplaces.
func (*Comid) AddReferenceValue ¶
func (o *Comid) AddReferenceValue(val ReferenceValue) *Comid
AddReferenceValue adds the supplied reference value to the reference-triples list of the target Comid.
func (*Comid) GetExtensions ¶ added in v1.1.2
func (o *Comid) GetExtensions() extensions.IExtensionsValue
GetExtensions returns pervisouosly registered extension
func (*Comid) RegisterExtensions ¶ added in v1.1.2
func (o *Comid) RegisterExtensions(exts extensions.IExtensionsValue)
RegisterExtensions registers a struct as a collections of extensions
func (*Comid) SetLanguage ¶
SetLanguage sets the language used in the target Comid to the supplied language tag. See also: BCP 47 and the IANA Language subtag registry.
func (*Comid) SetTagIdentity ¶
SetTagIdentity sets the identifier of the target Comid to the supplied tagID, which MUST be of type string or [16]byte. A tagIDVersion must also be supplied to disambiguate between different revisions of the same tag identity. If the tagID is newly minted, use 0. If the tagID has already been associated with a CoMID, pick a tagIDVersion greater than any other existing tagIDVersion's associated with that tagID.
type CryptoKey ¶ added in v1.1.2
type CryptoKey struct {
Value ICryptoKeyValue
}
CryptoKey is the struct implementing CoRIM crypto-key-type-choice. See https://www.ietf.org/archive/id/draft-ietf-rats-corim-02.html#name-crypto-keys
func MustNewCOSEKey ¶ added in v1.1.2
func MustNewCertPathThumbprint ¶ added in v1.1.2
func MustNewCertThumbprint ¶ added in v1.1.2
func MustNewCryptoKey ¶ added in v1.1.2
MustNewCryptoKey is the same as NewCryptoKey, but does not return an error, and panics if there is a problem.
func MustNewPKIXBase64Cert ¶ added in v1.1.2
func MustNewPKIXBase64CertPath ¶ added in v1.1.2
func MustNewPKIXBase64Key ¶ added in v1.1.2
func MustNewThumbprint ¶ added in v1.1.2
func NewCOSEKey ¶ added in v1.1.2
func NewCertPathThumbprint ¶ added in v1.1.2
func NewCertThumbprint ¶ added in v1.1.2
func NewCryptoKey ¶ added in v1.1.2
NewCryptoKey returns the pointer to a new CryptoKey of the specified type, constructed using the provided value k. The type of k depends on the specified crypto key type. For PKIX types, k must be a string. For COSE_Key, k must be a []byte. For thumbprint types, k must be a swid.HashEntry.
func NewPKIXBase64Cert ¶ added in v1.1.2
func NewPKIXBase64CertPath ¶ added in v1.1.2
func NewPKIXBase64Key ¶ added in v1.1.2
func NewThumbprint ¶ added in v1.1.2
func (CryptoKey) MarshalCBOR ¶ added in v1.1.2
MarshalCBOR returns a []byte containing the CBOR representation of the CryptoKey.
func (CryptoKey) MarshalJSON ¶ added in v1.1.2
MarshalJSON returns a []byte containing the JSON representation of the CryptoKey.
func (CryptoKey) PublicKey ¶ added in v1.1.2
PublicKey returns a crypto.PublicKey constructed from the CryptoKey's underlying value. This returns an error if the CryptoKey is one of the thumbprint types.
func (CryptoKey) String ¶ added in v1.1.2
String returns the string representation of the CryptoKey.
func (*CryptoKey) UnmarshalCBOR ¶ added in v1.1.2
UnmarshalCBOR populates the CryptoKey from the CBOR representation inside the provided []byte.
func (*CryptoKey) UnmarshalJSON ¶ added in v1.1.2
UnmarshalJSON populates the CryptoKey from the JSON representation inside the provided []byte.
type CryptoKeys ¶ added in v1.1.2
type CryptoKeys []*CryptoKey
CryptoKeys is an array of *CryptoKey
func NewCryptoKeys ¶ added in v1.1.2
func NewCryptoKeys() *CryptoKeys
NewCryptoKeys instantiates an empty CryptoKeys
func (*CryptoKeys) Add ¶ added in v1.1.2
func (o *CryptoKeys) Add(v *CryptoKey) *CryptoKeys
Add the supplied *CryptoKey to the CryptoKeys
func (CryptoKeys) Valid ¶ added in v1.1.2
func (o CryptoKeys) Valid() error
Valid returns an error if any of the contained keys fail to validate, or if CryptoKeys is empty
type DevIdentityKey ¶
type DevIdentityKey struct { Environment Environment `json:"environment"` VerifKeys CryptoKeys `json:"verification-keys"` // contains filtered or unexported fields }
DevIdentityKey stores an identity-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.
func (DevIdentityKey) Valid ¶
func (o DevIdentityKey) Valid() error
type Digests ¶
Digests is an alias for an array of SWID HashEntry
type EndorsedValue ¶
type EndorsedValue struct { Environment Environment `json:"environment"` Measurements Measurements `json:"measurements"` // contains filtered or unexported fields }
EndorsedValue stores an endorsed-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.
func (EndorsedValue) Valid ¶
func (o EndorsedValue) Valid() error
type Entities ¶
type Entities []Entity
Entities is an array of entity-map's
type Entity ¶
type Entity struct { EntityName *EntityName `cbor:"0,keyasint" json:"name"` RegID *TaggedURI `cbor:"1,keyasint,omitempty" json:"regid,omitempty"` Roles Roles `cbor:"2,keyasint" json:"roles"` Extensions }
Entity stores an entity-map capable of CBOR and JSON serializations.
func (*Entity) GetExtensions ¶ added in v1.1.2
func (o *Entity) GetExtensions() extensions.IExtensionsValue
GetExtensions returns pervisouosly registered extension
func (*Entity) MarshalCBOR ¶ added in v1.1.2
MarshalCBOR serializes to CBOR
func (*Entity) MarshalJSON ¶ added in v1.1.2
MarshalJSON serializes to JSON
func (*Entity) RegisterExtensions ¶ added in v1.1.2
func (o *Entity) RegisterExtensions(exts extensions.IExtensionsValue)
RegisterExtensions registers a struct as a collections of extensions
func (*Entity) SetEntityName ¶
SetEntityName is used to set the EntityName field of Entity using supplied name
func (*Entity) UnmarshalCBOR ¶ added in v1.1.2
UnmarshalCBOR deserializes from CBOR
func (*Entity) UnmarshalJSON ¶ added in v1.1.2
UnmarshalJSON deserializes from JSON
type EntityName ¶ added in v1.1.2
type EntityName struct {
Value IEntityNameValue
}
EntityName encapsulates the name of the associated Entity. The CoRIM specification only allows for text (string) name, but this may be extended by other specifications.
func MustNewEntityName ¶ added in v1.1.2
func MustNewEntityName(val any, typ string) *EntityName
MustNewEntityName is like NewEntityName, except it doesn't return an error, assuming that the provided value is valid. It panics if that isn't the case.
func MustNewStringEntityName ¶ added in v1.1.2
func MustNewStringEntityName(val any) *EntityName
func NewEntityName ¶ added in v1.1.2
func NewEntityName(val any, typ string) (*EntityName, error)
NewEntityName creates a new EntityName of the specified type using the provided value.
func NewStringEntityName ¶ added in v1.1.2
func NewStringEntityName(val any) (*EntityName, error)
func (EntityName) MarshalCBOR ¶ added in v1.1.2
func (o EntityName) MarshalCBOR() ([]byte, error)
func (EntityName) MarshalJSON ¶ added in v1.1.2
func (o EntityName) MarshalJSON() ([]byte, error)
func (EntityName) String ¶ added in v1.1.2
func (o EntityName) String() string
func (*EntityName) UnmarshalCBOR ¶ added in v1.1.2
func (o *EntityName) UnmarshalCBOR(data []byte) error
func (*EntityName) UnmarshalJSON ¶ added in v1.1.2
func (o *EntityName) UnmarshalJSON(data []byte) error
func (EntityName) Valid ¶ added in v1.1.2
func (o EntityName) Valid() error
type Environment ¶
type Environment struct { Class *Class `cbor:"0,keyasint,omitempty" json:"class,omitempty"` Instance *Instance `cbor:"1,keyasint,omitempty" json:"instance,omitempty"` Group *Group `cbor:"2,keyasint,omitempty" json:"group,omitempty"` }
Environment stores the identifying information about a target or attesting environment at the class, instance and group scope. The Environment type has JSON and CBOR serializations.
func (*Environment) FromCBOR ¶
func (o *Environment) FromCBOR(data []byte) error
FromCBOR deserializes the supplied CBOR data into the target Environment
func (*Environment) FromJSON ¶
func (o *Environment) FromJSON(data []byte) error
FromJSON deserializes the supplied JSON string into the target Environment
func (Environment) ToCBOR ¶
func (o Environment) ToCBOR() ([]byte, error)
ToCBOR serializes the target Environment to CBOR (if the Environment is "valid")
func (Environment) ToJSON ¶
func (o Environment) ToJSON() ([]byte, error)
ToJSON serializes the target Environment to JSON (if the Environment is "valid")
func (Environment) Valid ¶
func (o Environment) Valid() error
Valid checks the validity (according to the spec) of the target Environment
type Extensions ¶ added in v1.1.2
type Extensions struct {
extensions.Extensions
}
type Flag ¶ added in v1.1.2
type Flag int
Flag indicates whether a particular operational mode is active within the measured environment.
type FlagsMap ¶ added in v1.1.2
type FlagsMap struct { // IsConfigured indicates whether the measured environment is fully // configured for normal operation. IsConfigured *bool `cbor:"0,keyasint,omitempty" json:"is-configured,omitempty"` // IsSecure indicates whether the measured environment's configurable // security settings are fully enabled. IsSecure *bool `cbor:"1,keyasint,omitempty" json:"is-secure,omitempty"` // IsRecovery indicates whether the measured environment is in recovery // mode. IsRecovery *bool `cbor:"2,keyasint,omitempty" json:"is-recovery,omitempty"` // IsDebug indicates whether the measured environment is in a debug // enabled mode. IsDebug *bool `cbor:"3,keyasint,omitempty" json:"is-debug,omitempty"` // IsReplayProtected indicates whether the measured environment is // protected from replay by a previous image that differs from the // current image. IsReplayProtected *bool `cbor:"4,keyasint,omitempty" json:"is-replay-protected,omitempty"` // IsIntegrityProtected indicates whether the measured environment is // protected from unauthorized update. IsIntegrityProtected *bool `cbor:"5,keyasint,omitempty" json:"is-integrity-protected,omitempty"` // IsRuntimeMeasured indicates whether the measured environment is // measured after being loaded into memory. IsRuntimeMeasured *bool `cbor:"6,keyasint,omitempty" json:"is-runtime-meas,omitempty"` // IsImmutable indicates whether the measured environment is immutable. IsImmutable *bool `cbor:"7,keyasint,omitempty" json:"is-immutable,omitempty"` // IsTcb indicates whether the measured environment is a trusted // computing base. IsTcb *bool `cbor:"8,keyasint,omitempty" json:"is-tcb,omitempty"` Extensions }
FlagsMap describes a number of boolean operational modes. If a value is nil, then the operational mode is unknown.
func NewFlagsMap ¶ added in v1.1.2
func NewFlagsMap() *FlagsMap
func (*FlagsMap) GetExtensions ¶ added in v1.1.2
func (o *FlagsMap) GetExtensions() extensions.IExtensionsValue
GetExtensions returns pervisouosly registered extension
func (*FlagsMap) MarshalCBOR ¶ added in v1.1.2
MarshalCBOR serializes to CBOR
func (*FlagsMap) MarshalJSON ¶ added in v1.1.2
MarshalJSON serializes to JSON
func (*FlagsMap) RegisterExtensions ¶ added in v1.1.2
func (o *FlagsMap) RegisterExtensions(exts extensions.IExtensionsValue)
RegisterExtensions registers a struct as a collections of extensions
func (*FlagsMap) UnmarshalCBOR ¶ added in v1.1.2
UnmarshalCBOR deserializes from CBOR
func (*FlagsMap) UnmarshalJSON ¶ added in v1.1.2
UnmarshalJSON deserializes from JSON
type Group ¶
type Group struct {
Value IGroupValue
}
Group stores a group identity. The supported formats are UUID and variable-length opaque bytes.
func MustNewUUIDGroup ¶ added in v1.1.2
func NewBytesGroup ¶ added in v1.1.2
NewBytesGroup creates a New Group of type bytes The supplied interface parameter could be a byte slice, a pointer to a byte slice or a string
func NewUUIDGroup ¶ added in v1.1.2
func (Group) Bytes ¶ added in v1.1.2
Bytes returns a []byte containing the raw bytes of the group value
func (Group) MarshalCBOR ¶
MarshalCBOR serializes the target group to CBOR
func (Group) MarshalJSON ¶
func (Group) String ¶
String returns a printable string of the Group value. UUIDs use the canonical 8-4-4-4-12 format, UEIDs are hex encoded.
func (*Group) UnmarshalCBOR ¶
UnmarshalCBOR deserializes the supplied CBOR into the target group
func (*Group) UnmarshalJSON ¶
UnmarshalJSON deserializes the supplied JSON type/value object into the Group target. The following formats are supported:
(a) UUID, e.g.: { "type": "uuid", "value": "69E027B2-7157-4758-BCB4-D9F167FE49EA" }
(b) Tagged bytes, e.g. :
{ "type": "bytes", "value": "MTIzNDU2Nzg5" }
type IClassIDFactory ¶ added in v1.1.2
IClassIDFactory defines the signature for the factory functions that may be registred using RegisterClassIDType to provide a new implementation of the corresponding type choice. The factory function should create a new *ClassID with the underlying value created based on the provided input. The range of valid inputs is up to the specific type choice implementation, however it _must_ accept nil as one of the inputs, and return the Zero value for implemented type. See also https://go.dev/ref/spec#The_zero_value
type IClassIDValue ¶ added in v1.1.2
type IClassIDValue interface { extensions.ITypeChoiceValue Bytes() []byte }
type IComidConstrainer ¶ added in v1.1.2
type ICryptoKeyFactory ¶ added in v1.1.2
ICryptoKeyFactory defines the signature for the factory functions that may be registred using RegisterCryptoKeyType to provide a new implementation of the corresponding type choice. The factory function should create a new *CryptoKey with the underlying value created based on the provided input. The range of valid inputs is up to the specific type choice implementation, however it _must_ accept nil as one of the inputs, and return the Zero value for implemented type. See also https://go.dev/ref/spec#The_zero_value
type ICryptoKeyValue ¶ added in v1.1.2
type ICryptoKeyValue interface { extensions.ITypeChoiceValue // PublicKey returns a crypto.PublicKey constructed from the // ICryptoKeyValue's underlying value. This returns an error if the // ICryptoKeyValue is one of the thumbprint types. PublicKey() (crypto.PublicKey, error) }
ICryptoKeyValue is the interface implemented by the concrete CryptoKey value types.
type IEntityConstrainer ¶ added in v1.1.2
type IEntityNameFactory ¶ added in v1.1.2
type IEntityNameFactory func(any) (*EntityName, error)
IEntityNameFactory defines the signature for the factory functions that may be registred using RegisterEntityNameType to provide a new implementation of the corresponding type choice. The factory function should create a new *EntityName with the underlying value created based on the provided input. The range of valid inputs is up to the specific type choice implementation, however it _must_ accept nil as one of the inputs, and return the Zero value for implemented type. See also https://go.dev/ref/spec#The_zero_value
type IEntityNameValue ¶ added in v1.1.2
type IEntityNameValue interface { extensions.ITypeChoiceValue }
type IFlagSetter ¶ added in v1.1.2
type IFlagsMapConstrainer ¶ added in v1.1.2
type IGroupFactory ¶ added in v1.1.2
IGroupFactory defines the signature for the factory functions that may be registered using RegisterGroupType to provide a new implementation of the corresponding type choice. The factory function should create a new *Group with the underlying value created based on the provided input. The range of valid inputs is up to the specific type choice implementation, however it _must_ accept nil as one of the inputs, and return the Zero value for implemented type. See also https://go.dev/ref/spec#The_zero_value
type IGroupValue ¶ added in v1.1.2
type IGroupValue interface { extensions.ITypeChoiceValue Bytes() []byte }
type IInstanceFactory ¶ added in v1.1.2
IInstanceFactory defines the signature for the factory functions that may be registered using RegisterInstanceType to provide a new implementation of the corresponding type choice. The factory function should create a new *Instance with the underlying value created based on the provided input. The range of valid inputs is up to the specific type choice implementation, however it _must_ accept nil as one of the inputs, and return the Zero value for implemented type. See also https://go.dev/ref/spec#The_zero_value
type IInstanceValue ¶ added in v1.1.2
type IInstanceValue interface { extensions.ITypeChoiceValue Bytes() []byte }
IInstanceValue is the interface implemented by all Instance value implementations.
type IMKeyValue ¶ added in v1.1.2
type IMKeyValue interface { extensions.ITypeChoiceValue }
IMKeyValue is the interface implemented by all Mkey value implementations.
type IMkeyFactory ¶ added in v1.1.2
IMkeyFactory defines the signature for the factory functions that may be registred using RegisterMkeyType to provide a new implementation of the corresponding type choice. The factory function should create a new *Mkey with the underlying value created based on the provided input. The range of valid inputs is up to the specific type choice implementation, however it _must_ accept nil as one of the inputs, and return the Zero value for implemented type. See also https://go.dev/ref/spec#The_zero_value
type IMvalConstrainer ¶ added in v1.1.2
type IRegisterIndex ¶ added in v1.1.2
type IRegisterIndex interface{}
IRegisterIndex is the interface to hold register index Supported index types are uint and text
type ISVNFactory ¶ added in v1.1.2
ISVNFactory defines the signature for the factory functions that may be registred using RegisterSVNType to provide a new implementation of the corresponding type choice. The factory function should create a new *SVN with the underlying value created based on the provided input. The range of valid inputs is up to the specific type choice implementation, however it _must_ accept nil as one of the inputs, and return the Zero value for implemented type. See also https://go.dev/ref/spec#The_zero_value
type ISVNValue ¶ added in v1.1.2
type ISVNValue interface { extensions.ITypeChoiceValue }
ISVNValue is the interface that must be implemented by all SVN values.
type ITriplesConstrainer ¶ added in v1.1.2
type Instance ¶
type Instance struct {
Value IInstanceValue
}
Instance stores an instance identity. The supported formats are UUID, UEID and variable-length opaque bytes.
func MustNewUEIDInstance ¶ added in v1.1.2
MustNewUEIDInstance is like NewUEIDInstance execept it does not return an error, assuming that the provided value is valid. It panics if that isn't the case.
func MustNewUUIDInstance ¶ added in v1.1.2
MustNewUUIDInstance is like NewUUIDInstance execept it does not return an error, assuming that the provided value is valid. It panics if that isn't the case.
func NewBytesInstance ¶ added in v1.1.2
NewBytesInstance creates a new instance of type bytes The supplied interface parameter could be a byte slice, a pointer to a byte slice or a string
func NewInstance ¶
NewInstance creates a new instance with the value of the specified type populated using the provided value.
func NewUEIDInstance ¶ added in v1.1.2
NewUEIDInstance instantiates a new instance with the supplied UEID identity.
func NewUUIDInstance ¶ added in v1.1.2
NewUUIDInstance instantiates a new instance with the supplied UUID identity
func (Instance) Bytes ¶ added in v1.1.2
Bytes returns a []byte containing the bytes of the underlying Instance value.
func (Instance) MarshalCBOR ¶
MarshalCBOR serializes the target instance to CBOR
func (Instance) MarshalJSON ¶
MarshalJSON serializes the Instance into a JSON object.
func (Instance) String ¶
String returns a printable string of the Instance value. UUIDs use the canonical 8-4-4-4-12 format, UEIDs are hex encoded.
func (Instance) Type ¶ added in v1.1.2
Type returns a string naming the type of the underlying Instance value.
func (*Instance) UnmarshalCBOR ¶
func (*Instance) UnmarshalJSON ¶
UnmarshalJSON deserializes the supplied JSON object into the target Instance The instance object must have the following shape:
{ "type": "<INSTANCE_TYPE>", "value": <INSTANCE_VALUE> }
where <INSTANCE_TYPE> must be one of the known IInstanceValue implementation type names (available in the base implementation: "ueid" and "uuid"), and <INSTANCE_VALUE> is the JSON encoding of the instance value. The exact encoding is <INSTANCE_TYPE> dependent. For the base implmentation types it is
ueid: base64-encoded bytes, e.g. "YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE=" uuid: standard UUID string representation, e.g. "550e8400-e29b-41d4-a716-446655440000" bytes: a variable-length opaque byte string, example {0x07, 0x12, 0x34}
type IntegrityRegisters ¶ added in v1.1.2
type IntegrityRegisters struct {
// contains filtered or unexported fields
}
IntegrityRegisters holds the Integrity Registers
func NewIntegrityRegisters ¶ added in v1.1.2
func NewIntegrityRegisters() *IntegrityRegisters
func (*IntegrityRegisters) AddDigest ¶ added in v1.1.2
func (i *IntegrityRegisters) AddDigest(index IRegisterIndex, digest swid.HashEntry) error
AddDigest allows inserting a digest at a specific index Supported index types are uint and text
func (*IntegrityRegisters) AddDigests ¶ added in v1.1.2
func (i *IntegrityRegisters) AddDigests(index IRegisterIndex, digests Digests) error
AddDigests allows inserting an array of digests at a specific index Supported index types are uint and text
func (IntegrityRegisters) MarshalCBOR ¶ added in v1.1.2
func (i IntegrityRegisters) MarshalCBOR() ([]byte, error)
func (IntegrityRegisters) MarshalJSON ¶ added in v1.1.2
func (i IntegrityRegisters) MarshalJSON() ([]byte, error)
func (*IntegrityRegisters) UnmarshalCBOR ¶ added in v1.1.2
func (i *IntegrityRegisters) UnmarshalCBOR(data []byte) error
func (*IntegrityRegisters) UnmarshalJSON ¶ added in v1.1.2
func (i *IntegrityRegisters) UnmarshalJSON(data []byte) error
type LinkedTag ¶
type LinkedTag struct { LinkedTagID swid.TagID `cbor:"0,keyasint" json:"target"` Rel Rel `cbor:"1,keyasint" json:"rel"` }
LinkedTag stores one link relation of type Rel between the embedding CoMID (the link context) and the referenced CoMID (the link target). The link can be viewed as a statement of the form: "$link_context $link_relation_type $link_target".
func NewLinkedTag ¶
func NewLinkedTag() *LinkedTag
type LinkedTags ¶
type LinkedTags []LinkedTag
LinkedTags is an array of LinkedTag
func NewLinkedTags ¶
func NewLinkedTags() *LinkedTags
func (*LinkedTags) AddLinkedTag ¶
func (o *LinkedTags) AddLinkedTag(lt LinkedTag) *LinkedTags
AddLinkedTag adds the supplied linked Tag-map to the target Entities
func (LinkedTags) Valid ¶
func (o LinkedTags) Valid() error
type MACaddr ¶
type MACaddr net.HardwareAddr
MACaddr is an HW address (e.g., IEEE 802 MAC-48, EUI-48, EUI-64)
Note: Since TextUnmarshal is not defined on net.HardwareAddr (see: https://github.com/golang/go/issues/29678) we need to create an alias type with a custom decoder.
func (MACaddr) MarshalJSON ¶
func (*MACaddr) UnmarshalJSON ¶
UnmarshalJSON deserialize a MAC address in textual form into the MACaddr target, e.g.:
"mac-addr": "00:00:5e:00:53:01"
or
"mac-addr": "02:00:5e:10:00:00:00:01"
Supported formats are IEEE 802 MAC-48, EUI-48, EUI-64, e.g.:
00:00:5e:00:53:01 00-00-5e-00-53-01 02:00:5e:10:00:00:00:01 02-00-5e-10-00-00-00-01
type Measurement ¶
type Measurement struct { Key *Mkey `cbor:"0,keyasint,omitempty" json:"key,omitempty"` Val Mval `cbor:"1,keyasint" json:"value"` AuthorizedBy *CryptoKey `cbor:"2,keyasint,omitempty" json:"authorized-by,omitempty"` }
Measurement stores a measurement-map with CBOR and JSON serializations.
func MustNewCCAPlatCfgMeasurement ¶ added in v1.1.2
func MustNewCCAPlatCfgMeasurement(key any) *Measurement
func MustNewMeasurement ¶ added in v1.1.2
func MustNewMeasurement(val any, typ string) *Measurement
func MustNewPSAMeasurement ¶ added in v1.1.2
func MustNewPSAMeasurement(key any) *Measurement
func MustNewUUIDMeasurement ¶ added in v1.1.2
func MustNewUUIDMeasurement(key any) *Measurement
func MustNewUintMeasurement ¶ added in v1.1.2
func MustNewUintMeasurement(key any) *Measurement
func NewCCAPlatCfgMeasurement ¶
func NewCCAPlatCfgMeasurement(key any) (*Measurement, error)
NewCCAPlatCfgMeasurement instantiates a new measurement-map with the key set to the supplied CCA platform-config-id
func NewMeasurement ¶
func NewMeasurement(val any, typ string) (*Measurement, error)
func NewOIDMeasurement ¶ added in v1.1.2
func NewOIDMeasurement(key any) (*Measurement, error)
NewOIDMeasurement instantiates a new measurement-map with the key set to the supplied OID
func NewPSAMeasurement ¶
func NewPSAMeasurement(key any) (*Measurement, error)
NewPSAMeasurement instantiates a new measurement-map with the key set to the supplied PSA refval-id
func NewUUIDMeasurement ¶
func NewUUIDMeasurement(key any) (*Measurement, error)
NewUUIDMeasurement instantiates a new measurement-map with the key set to the supplied UUID
func NewUintMeasurement ¶
func NewUintMeasurement(key any) (*Measurement, error)
NewUintMeasurement instantiates a new measurement-map with the key set to the supplied Uint
func (*Measurement) AddDigest ¶
func (o *Measurement) AddDigest(algID uint64, digest []byte) *Measurement
AddDigest add the supplied digest - comprising the digest itself together with the hash algorithm used to obtain it - to the measurement-values-map of the target measurement
func (*Measurement) ClearFlags ¶ added in v1.1.2
func (o *Measurement) ClearFlags(flags ...Flag) *Measurement
ClearFlags clears the supplied operational flags in the measurement-values-map of the target measurement
func (*Measurement) SetFlagsFalse ¶ added in v1.1.2
func (o *Measurement) SetFlagsFalse(flags ...Flag) *Measurement
SetFlagsFalse sets the supplied operational flags to true in the measurement-values-map of the target measurement
func (*Measurement) SetFlagsTrue ¶ added in v1.1.2
func (o *Measurement) SetFlagsTrue(flags ...Flag) *Measurement
SetFlagsTrue sets the supplied operational flags to true in the measurement-values-map of the target measurement
func (*Measurement) SetIPaddr ¶
func (o *Measurement) SetIPaddr(a net.IP) *Measurement
SetIPaddr sets the supplied IP (v4 or v6) address in the measurement-values-map of the target measurement
func (*Measurement) SetMACaddr ¶
func (o *Measurement) SetMACaddr(a MACaddr) *Measurement
SetMACaddr sets the supplied MAC address in the measurement-values-map of the target measurement
func (*Measurement) SetMinSVN ¶
func (o *Measurement) SetMinSVN(svn uint64) *Measurement
SetMinSVN sets the supplied min-svn in the measurement-values-map of the target measurement
func (*Measurement) SetRawValueBytes ¶
func (o *Measurement) SetRawValueBytes(rawValue, rawValueMask []byte) *Measurement
SetRawValueBytes sets the supplied raw-value and its mask in the measurement-values-map of the target measurement
func (*Measurement) SetSVN ¶
func (o *Measurement) SetSVN(svn uint64) *Measurement
SetSVN sets the supplied svn in the measurement-values-map of the target measurement
func (*Measurement) SetSerialNumber ¶
func (o *Measurement) SetSerialNumber(sn string) *Measurement
SetSerialNumber sets the supplied serial number in the measurement-values-map of the target measurement
func (*Measurement) SetUEID ¶
func (o *Measurement) SetUEID(ueid eat.UEID) *Measurement
SetUEID sets the supplied ueid in the measurement-values-map of the target measurement
func (*Measurement) SetUUID ¶
func (o *Measurement) SetUUID(u UUID) *Measurement
SetUUID sets the supplied uuid in the measurement-values-map of the target measurement
func (*Measurement) SetVersion ¶
func (o *Measurement) SetVersion(ver string, scheme int64) *Measurement
func (Measurement) Valid ¶
func (o Measurement) Valid() error
type Measurements ¶
type Measurements []Measurement
Measurements is an array of Measurement
func NewMeasurements ¶
func NewMeasurements() *Measurements
NewMeasurements instantiates an empty Measurements array
func (*Measurements) AddMeasurement ¶
func (o *Measurements) AddMeasurement(m *Measurement) *Measurements
AddMeasurements adds the supplied Measurement to the target Measurement
func (Measurements) Valid ¶
func (o Measurements) Valid() error
type Mkey ¶
type Mkey struct {
Value IMKeyValue
}
Mkey stores a $measured-element-type-choice. The supported types are UUID, PSA refval-id, CCA platform-config-id and unsigned integer TO DO Add tagged OID: see https://github.com/veraison/corim/issues/35
func MustNewMkey ¶ added in v1.1.2
MustNewMkey is like NewMkey, execept it does not return an error, assuming that the provided value is valid. It panics if that is not the case.
func NewMkey ¶ added in v1.1.2
NewMkey creates a new Mkey of the specfied type using the provided value.
func NewMkeyCCAPlatformConfigID ¶ added in v1.1.2
func NewMkeyOID ¶ added in v1.1.2
func NewMkeyPSARefvalID ¶ added in v1.1.2
func NewMkeyUUID ¶ added in v1.1.2
func NewMkeyUint ¶ added in v1.1.2
func (Mkey) GetCCAPlatformConfigID ¶
func (o Mkey) GetCCAPlatformConfigID() (CCAPlatformConfigID, error)
func (Mkey) GetKeyUint ¶
func (Mkey) GetPSARefValID ¶
func (o Mkey) GetPSARefValID() (PSARefValID, error)
func (Mkey) MarshalCBOR ¶
MarshalCBOR serializes the taret mkey into CBOR-encoded bytes.
func (Mkey) MarshalJSON ¶
MarshalJSON serializes the target Mkey into the type'n'value JSON object
func (*Mkey) UnmarshalCBOR ¶
UnmarshalCBOR deserializes the Mkey from the provided CBOR bytes.
func (*Mkey) UnmarshalJSON ¶
UnmarshalJSON deserializes the supplied JSON object into the target MKey The key object must have the following shape:
{ "type": "<MKEY_TYPE>", "value": <MKEY_JSON_VALUE> }
where <MKEY_TYPE> must be one of the known IMKeyValue implementation type names (available in the base implementation: "uuid", "oid", "psa.impl-id"), and <MKEY_JSON_VALUE> is the class id value serialized to JSON. The exact serialization is <CLASS_ID_TYPE> depenent. For the base implementation types it is
oid: dot-seprated integers, e.g. "1.2.3.4" uuid: standard UUID string representation, e.g. "550e8400-e29b-41d4-a716-446655440000" psa.refval-id: JSON representation of the PSA refval-id
type Mval ¶
type Mval struct { Ver *Version `cbor:"0,keyasint,omitempty" json:"version,omitempty"` SVN *SVN `cbor:"1,keyasint,omitempty" json:"svn,omitempty"` Digests *Digests `cbor:"2,keyasint,omitempty" json:"digests,omitempty"` Flags *FlagsMap `cbor:"3,keyasint,omitempty" json:"flags,omitempty"` RawValue *RawValue `cbor:"4,keyasint,omitempty" json:"raw-value,omitempty"` RawValueMask *[]byte `cbor:"5,keyasint,omitempty" json:"raw-value-mask,omitempty"` MACAddr *MACaddr `cbor:"6,keyasint,omitempty" json:"mac-addr,omitempty"` IPAddr *net.IP `cbor:"7,keyasint,omitempty" json:"ip-addr,omitempty"` SerialNumber *string `cbor:"8,keyasint,omitempty" json:"serial-number,omitempty"` UEID *eat.UEID `cbor:"9,keyasint,omitempty" json:"ueid,omitempty"` UUID *UUID `cbor:"10,keyasint,omitempty" json:"uuid,omitempty"` IntegrityRegisters *IntegrityRegisters `cbor:"14,keyasint,omitempty" json:"integrity-registers,omitempty"` Extensions }
Mval stores a measurement-values-map with JSON and CBOR serializations.
func (*Mval) GetExtensions ¶ added in v1.1.2
func (o *Mval) GetExtensions() extensions.IExtensionsValue
GetExtensions returns pervisouosly registered extension
func (*Mval) MarshalCBOR ¶ added in v1.1.2
MarshalCBOR serializes to CBOR
func (*Mval) MarshalJSON ¶ added in v1.1.2
MarshalJSON serializes to JSON
func (*Mval) RegisterExtensions ¶ added in v1.1.2
func (o *Mval) RegisterExtensions(exts extensions.IExtensionsValue)
RegisterExtensions registers a struct as a collections of extensions
func (*Mval) UnmarshalCBOR ¶ added in v1.1.2
UnmarshalCBOR deserializes from CBOR
func (*Mval) UnmarshalJSON ¶ added in v1.1.2
UnmarshalJSON deserializes from JSON
type OID ¶
type OID []byte
BER-encoded absolute OID
func (*OID) FromString ¶
func (OID) MarshalJSON ¶
func (*OID) UnmarshalJSON ¶
type PSARefValID ¶
type PSARefValID struct { Label *string `cbor:"1,keyasint,omitempty" json:"label,omitempty"` Version *string `cbor:"4,keyasint,omitempty" json:"version,omitempty"` SignerID []byte `cbor:"5,keyasint" json:"signer-id"` // 32, 48 or 64 }
PSARefValID stores a PSA refval-id with CBOR and JSON serializations (See https://datatracker.ietf.org/doc/html/draft-xyz-rats-psa-endorsements)
func CreatePSARefValID ¶ added in v1.1.2
func CreatePSARefValID(signerID []byte, label, version string) (*PSARefValID, error)
func MustCreatePSARefValID ¶ added in v1.1.2
func MustCreatePSARefValID(signerID []byte, label, version string) *PSARefValID
func NewPSARefValID ¶
func NewPSARefValID(val any) (*PSARefValID, error)
func (*PSARefValID) SetLabel ¶
func (o *PSARefValID) SetLabel(label string) *PSARefValID
func (*PSARefValID) SetVersion ¶
func (o *PSARefValID) SetVersion(version string) *PSARefValID
func (PSARefValID) Valid ¶
func (o PSARefValID) Valid() error
Valid checks the validity (according to the spec) of the target PSARefValID
type RawValue ¶
type RawValue struct {
// contains filtered or unexported fields
}
RawValue models a $raw-value-type-choice. For now, the only available type is bytes.
func NewRawValue ¶
func NewRawValue() *RawValue
func (RawValue) MarshalCBOR ¶
func (RawValue) MarshalJSON ¶
func (*RawValue) UnmarshalCBOR ¶
func (*RawValue) UnmarshalJSON ¶
UnmarshalJSON deserializes the type'n'value JSON object into the target RawValue. The only supported type is BytesType with value
type ReferenceValue ¶
type ReferenceValue struct { Environment Environment `json:"environment"` Measurements Measurements `json:"measurements"` // contains filtered or unexported fields }
func (ReferenceValue) Valid ¶
func (o ReferenceValue) Valid() error
type SVN ¶
type SVN struct {
Value ISVNValue
}
SVN is the Security Version Number. This typically changes only when a security relevant change is needed to the measured environment.
func MustNewSVN ¶ added in v1.1.2
MustNewSVN is like NewSVN but does not return an error, assuming that the provided value is valid. It panics if this is not the case.
func MustNewTaggedMinSVN ¶ added in v1.1.2
func MustNewTaggedSVN ¶ added in v1.1.2
func NewSVN ¶ added in v1.1.2
NewSVN creates a new SVN of the specified and value. The type must be one of the strings defined by the spec ("exact-value", "min-value"), or has been registered with RegisterSVNType().
func NewTaggedMinSVN ¶ added in v1.1.2
func NewTaggedSVN ¶ added in v1.1.2
func (SVN) MarshalCBOR ¶
MarshalCBOR returns the CBOR encoding of the SVN.
func (SVN) MarshalJSON ¶
MarshalJSON serializes the SVN int a JSON object
func (*SVN) UnmarshalCBOR ¶
UnmarshalCBOR populates the SVN form the provided CBOR bytes.
func (*SVN) UnmarshalJSON ¶
UnmarshalJSON deserializes the supplied JSON object into the target SVN The SVN object must have the following shape:
{ "type": "<SVN_TYPE>", "value": <SVN_VALUE> }
where <SVN_TYPE> must be one of the known ISVNValue implementation type names (available in the base implementation: "exact-value", "min-value"), and <SVN_VALUE> is the JSON encoding of the underlying class id value. The exact encoding is <SVN_TYPE> dependent. For both base types, it is an integer (JSON number).
type StringEntityName ¶ added in v1.1.2
type StringEntityName string
func (StringEntityName) String ¶ added in v1.1.2
func (o StringEntityName) String() string
func (StringEntityName) Type ¶ added in v1.1.2
func (o StringEntityName) Type() string
func (StringEntityName) Valid ¶ added in v1.1.2
func (o StringEntityName) Valid() error
type TagIdentity ¶
type TagIdentity struct { TagID swid.TagID `cbor:"0,keyasint" json:"id"` TagVersion uint `cbor:"1,keyasint,omitempty" json:"version,omitempty"` }
func (TagIdentity) Valid ¶
func (o TagIdentity) Valid() error
type TaggedBytes ¶ added in v1.1.2
type TaggedBytes []byte
func NewBytes ¶ added in v1.1.2
func NewBytes(val any) (*TaggedBytes, error)
func (TaggedBytes) Bytes ¶ added in v1.1.2
func (o TaggedBytes) Bytes() []byte
func (TaggedBytes) String ¶ added in v1.1.2
func (o TaggedBytes) String() string
func (TaggedBytes) Type ¶ added in v1.1.2
func (o TaggedBytes) Type() string
func (TaggedBytes) Valid ¶ added in v1.1.2
func (o TaggedBytes) Valid() error
type TaggedCCAPlatformConfigID ¶
type TaggedCCAPlatformConfigID CCAPlatformConfigID
func NewTaggedCCAPlatformConfigID ¶ added in v1.1.2
func NewTaggedCCAPlatformConfigID(val any) (*TaggedCCAPlatformConfigID, error)
func (TaggedCCAPlatformConfigID) IsZero ¶ added in v1.1.2
func (o TaggedCCAPlatformConfigID) IsZero() bool
func (TaggedCCAPlatformConfigID) String ¶ added in v1.1.2
func (o TaggedCCAPlatformConfigID) String() string
func (TaggedCCAPlatformConfigID) Type ¶ added in v1.1.2
func (o TaggedCCAPlatformConfigID) Type() string
func (*TaggedCCAPlatformConfigID) UnmarshalJSON ¶ added in v1.1.2
func (o *TaggedCCAPlatformConfigID) UnmarshalJSON(data []byte) error
func (TaggedCCAPlatformConfigID) Valid ¶ added in v1.1.2
func (o TaggedCCAPlatformConfigID) Valid() error
type TaggedCOSEKey ¶ added in v1.1.2
type TaggedCOSEKey []byte
TaggedCOSEKey is a CBOR encoded COSE_Key or COSE_KeySet. See https://www.rfc-editor.org/rfc/rfc9052#section-7
func (TaggedCOSEKey) MarshalCBOR ¶ added in v1.1.2
func (o TaggedCOSEKey) MarshalCBOR() ([]byte, error)
func (TaggedCOSEKey) PublicKey ¶ added in v1.1.2
func (o TaggedCOSEKey) PublicKey() (crypto.PublicKey, error)
func (TaggedCOSEKey) String ¶ added in v1.1.2
func (o TaggedCOSEKey) String() string
func (TaggedCOSEKey) Type ¶ added in v1.1.2
func (o TaggedCOSEKey) Type() string
func (*TaggedCOSEKey) UnmarshalCBOR ¶ added in v1.1.2
func (o *TaggedCOSEKey) UnmarshalCBOR(b []byte) error
func (TaggedCOSEKey) Valid ¶ added in v1.1.2
func (o TaggedCOSEKey) Valid() error
type TaggedCertPathThumbprint ¶ added in v1.1.2
type TaggedCertPathThumbprint struct {
// contains filtered or unexported fields
}
TaggedCertPathThumbprint represents a digest of a certification path. The digest value may be used to find the certificate path if contained in a lookup table.
func (TaggedCertPathThumbprint) String ¶ added in v1.1.2
func (o TaggedCertPathThumbprint) String() string
func (TaggedCertPathThumbprint) Type ¶ added in v1.1.2
func (o TaggedCertPathThumbprint) Type() string
type TaggedCertThumbprint ¶ added in v1.1.2
type TaggedCertThumbprint struct {
// contains filtered or unexported fields
}
TaggedCertThumbprint represents a digest of a certificate. The digest value may be used to find the certificate if contained in a lookup table.
func (TaggedCertThumbprint) Type ¶ added in v1.1.2
func (o TaggedCertThumbprint) Type() string
type TaggedImplID ¶
type TaggedImplID ImplID
func (TaggedImplID) Bytes ¶ added in v1.1.2
func (o TaggedImplID) Bytes() []byte
func (*TaggedImplID) MarshalJSON ¶ added in v1.1.2
func (o *TaggedImplID) MarshalJSON() ([]byte, error)
func (TaggedImplID) String ¶ added in v1.1.2
func (o TaggedImplID) String() string
func (TaggedImplID) Type ¶ added in v1.1.2
func (o TaggedImplID) Type() string
func (*TaggedImplID) UnmarshalJSON ¶ added in v1.1.2
func (o *TaggedImplID) UnmarshalJSON(data []byte) error
func (TaggedImplID) Valid ¶ added in v1.1.2
func (o TaggedImplID) Valid() error
type TaggedMinSVN ¶
type TaggedMinSVN uint64
func (TaggedMinSVN) String ¶ added in v1.1.2
func (o TaggedMinSVN) String() string
func (TaggedMinSVN) Type ¶ added in v1.1.2
func (o TaggedMinSVN) Type() string
func (TaggedMinSVN) Valid ¶ added in v1.1.2
func (o TaggedMinSVN) Valid() error
type TaggedOID ¶
type TaggedOID OID
func NewTaggedOID ¶ added in v1.1.2
func (*TaggedOID) FromString ¶ added in v1.1.2
func (TaggedOID) MarshalJSON ¶ added in v1.1.2
func (*TaggedOID) UnmarshalJSON ¶ added in v1.1.2
type TaggedPKIXBase64Cert ¶ added in v1.1.2
type TaggedPKIXBase64Cert string
TaggedPKIXBase64Cert is a PEM-encoded X.509 public key certificate. See https://www.rfc-editor.org/rfc/rfc7468#section-5
func (TaggedPKIXBase64Cert) PublicKey ¶ added in v1.1.2
func (o TaggedPKIXBase64Cert) PublicKey() (crypto.PublicKey, error)
func (TaggedPKIXBase64Cert) String ¶ added in v1.1.2
func (o TaggedPKIXBase64Cert) String() string
func (TaggedPKIXBase64Cert) Type ¶ added in v1.1.2
func (o TaggedPKIXBase64Cert) Type() string
func (TaggedPKIXBase64Cert) Valid ¶ added in v1.1.2
func (o TaggedPKIXBase64Cert) Valid() error
type TaggedPKIXBase64CertPath ¶ added in v1.1.2
type TaggedPKIXBase64CertPath string
TaggedPKIXBase64CertPath is a X.509 certificate chain created by the concatenation of as many PEM encoded X.509 certificates as needed. The certificates MUST be concatenated in order so that each directly certifies the one preceding.
func (TaggedPKIXBase64CertPath) PublicKey ¶ added in v1.1.2
func (o TaggedPKIXBase64CertPath) PublicKey() (crypto.PublicKey, error)
func (TaggedPKIXBase64CertPath) String ¶ added in v1.1.2
func (o TaggedPKIXBase64CertPath) String() string
func (TaggedPKIXBase64CertPath) Type ¶ added in v1.1.2
func (o TaggedPKIXBase64CertPath) Type() string
func (TaggedPKIXBase64CertPath) Valid ¶ added in v1.1.2
func (o TaggedPKIXBase64CertPath) Valid() error
type TaggedPKIXBase64Key ¶ added in v1.1.2
type TaggedPKIXBase64Key string
TaggedPKIXBase64Key is a PEM-encoded SubjectPublicKeyInfo. See https://www.rfc-editor.org/rfc/rfc7468#section-13
func (TaggedPKIXBase64Key) PublicKey ¶ added in v1.1.2
func (o TaggedPKIXBase64Key) PublicKey() (crypto.PublicKey, error)
func (TaggedPKIXBase64Key) String ¶ added in v1.1.2
func (o TaggedPKIXBase64Key) String() string
func (TaggedPKIXBase64Key) Type ¶ added in v1.1.2
func (o TaggedPKIXBase64Key) Type() string
func (TaggedPKIXBase64Key) Valid ¶ added in v1.1.2
func (o TaggedPKIXBase64Key) Valid() error
type TaggedPSARefValID ¶
type TaggedPSARefValID PSARefValID
func NewTaggedPSARefValID ¶ added in v1.1.2
func NewTaggedPSARefValID(val any) (*TaggedPSARefValID, error)
func (TaggedPSARefValID) IsZero ¶ added in v1.1.2
func (o TaggedPSARefValID) IsZero() bool
func (TaggedPSARefValID) String ¶ added in v1.1.2
func (o TaggedPSARefValID) String() string
func (TaggedPSARefValID) Type ¶ added in v1.1.2
func (o TaggedPSARefValID) Type() string
func (TaggedPSARefValID) Valid ¶ added in v1.1.2
func (o TaggedPSARefValID) Valid() error
type TaggedThumbprint ¶ added in v1.1.2
type TaggedThumbprint struct {
// contains filtered or unexported fields
}
ThumbprintTypeTaggedThumbprint represents a digest of a raw public key. The digest value may be used to find the public key if contained in a lookup table.
func (TaggedThumbprint) Type ¶ added in v1.1.2
func (o TaggedThumbprint) Type() string
type TaggedUEID ¶
type TaggedUEID UEID
TaggedUEID is an alias to allow automatic tagging of an UEID type
func NewTaggedUEID ¶ added in v1.1.2
func NewTaggedUEID(val any) (*TaggedUEID, error)
func (TaggedUEID) Bytes ¶ added in v1.1.2
func (o TaggedUEID) Bytes() []byte
func (TaggedUEID) String ¶ added in v1.1.2
func (o TaggedUEID) String() string
func (TaggedUEID) Type ¶ added in v1.1.2
func (o TaggedUEID) Type() string
func (TaggedUEID) Valid ¶ added in v1.1.2
func (o TaggedUEID) Valid() error
type TaggedUUID ¶
type TaggedUUID UUID
TaggedUUID is an alias to allow automatic tagging of a UUID type
func NewTaggedUUID ¶ added in v1.1.2
func NewTaggedUUID(val any) (*TaggedUUID, error)
func (TaggedUUID) Bytes ¶ added in v1.1.2
func (o TaggedUUID) Bytes() []byte
Bytes returns a []byte containing the raw UUID bytes
func (TaggedUUID) MarshalJSON ¶ added in v1.1.2
func (o TaggedUUID) MarshalJSON() ([]byte, error)
func (TaggedUUID) String ¶ added in v1.1.2
func (o TaggedUUID) String() string
String returns a string representation of the binary UUID
func (TaggedUUID) Type ¶ added in v1.1.2
func (o TaggedUUID) Type() string
Type returns a string containing type name. This is part of the ITypeChoiceValue implementation.
func (*TaggedUUID) UnmarshalJSON ¶ added in v1.1.2
func (o *TaggedUUID) UnmarshalJSON(data []byte) error
func (TaggedUUID) Valid ¶ added in v1.1.2
func (o TaggedUUID) Valid() error
type Triples ¶
type Triples struct { ReferenceValues *[]ReferenceValue `cbor:"0,keyasint,omitempty" json:"reference-values,omitempty"` EndorsedValues *[]EndorsedValue `cbor:"1,keyasint,omitempty" json:"endorsed-values,omitempty"` AttestVerifKeys *[]AttestVerifKey `cbor:"2,keyasint,omitempty" json:"attester-verification-keys,omitempty"` DevIdentityKeys *[]DevIdentityKey `cbor:"3,keyasint,omitempty" json:"dev-identity-keys,omitempty"` Extensions }
func (*Triples) AddAttestVerifKey ¶
func (o *Triples) AddAttestVerifKey(val AttestVerifKey) *Triples
func (*Triples) AddDevIdentityKey ¶
func (o *Triples) AddDevIdentityKey(val DevIdentityKey) *Triples
func (*Triples) AddEndorsedValue ¶
func (o *Triples) AddEndorsedValue(val EndorsedValue) *Triples
func (*Triples) AddReferenceValue ¶
func (o *Triples) AddReferenceValue(val ReferenceValue) *Triples
func (*Triples) GetExtensions ¶ added in v1.1.2
func (o *Triples) GetExtensions() extensions.IExtensionsValue
GetExtensions returns pervisouosly registered extension
func (*Triples) MarshalCBOR ¶ added in v1.1.2
MarshalCBOR serializes to CBOR
func (*Triples) MarshalJSON ¶ added in v1.1.2
MarshalJSON serializes to JSON
func (*Triples) RegisterExtensions ¶ added in v1.1.2
func (o *Triples) RegisterExtensions(exts extensions.IExtensionsValue)
RegisterExtensions registers a struct as a collections of extensions
func (*Triples) UnmarshalCBOR ¶ added in v1.1.2
UnmarshalCBOR deserializes from CBOR
func (*Triples) UnmarshalJSON ¶ added in v1.1.2
UnmarshalJSON deserializes from JSON
type UUID ¶
UUID represents an Universally Unique Identifier (UUID, see RFC4122)
func (UUID) MarshalJSON ¶
MarshalJSON serialize the target UUID to a JSON string in canonical 8-4-4-4-12 format
func (*UUID) UnmarshalJSON ¶
UnmarshalJSON deserializes the supplied string into the UUID target The UUID string in expected to be in canonical 8-4-4-4-12 format
type UintMkey ¶ added in v1.1.2
type UintMkey uint64
func NewUintMkey ¶ added in v1.1.2
func (*UintMkey) UnmarshalJSON ¶ added in v1.1.2
type Version ¶
type Version struct { Version string `cbor:"0,keyasint" json:"value"` Scheme swid.VersionScheme `cbor:"1,keyasint" json:"scheme"` }
Version stores a version-map with JSON and CBOR serializations.
func NewVersion ¶
func NewVersion() *Version
func (*Version) SetVersion ¶
Source Files ¶
- attestverifkey.go
- bytes.go
- cbor.go
- ccaplatformconfigid.go
- class.go
- classid.go
- comid.go
- cryptokey.go
- cryptokeys.go
- devidentitykey.go
- digests.go
- endorsedvalue.go
- entity.go
- environment.go
- extensions.go
- flagsmap.go
- group.go
- instance.go
- integrityregisters.go
- linkedtag.go
- macaddr.go
- measurement.go
- measurements.go
- oid.go
- psareferencevalue.go
- rawvalue.go
- referencevalue.go
- rel.go
- role.go
- svn.go
- tagidentity.go
- test_vars.go
- triples.go
- typeandvalue.go
- ueid.go
- uuid.go