comid

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

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)
		}
		if m.Key.IsPSARefValID() {
			if err := extractSwMeasurement(m); err != nil {
				return fmt.Errorf("extracting measurement at index %d: %w", i, err)
			}
		}
		if m.Key.IsCCAPlatformConfigID() {
			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)
			}

			return nil
		}
	}

	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, err := k.GetCCAPlatformConfigID()
	if err != nil {
		return fmt.Errorf("getting CCA platform config id: %w", err)
	}
	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: NewInstanceUEID(TestUEID),
				Group:    NewGroupUUID(TestUUID),
			},
			Measurements: *NewMeasurements().
				AddMeasurement(
					NewMeasurement().
						SetKeyUUID(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}).
						SetOpFlags(OpFlagNotSecure, OpFlagDebug).
						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: NewInstanceUEID(TestUEID),
				Group:    NewGroupUUID(TestUUID),
			},
			Measurements: *NewMeasurements().
				AddMeasurement(
					NewMeasurement().
						SetKeyUUID(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}).
						SetOpFlags(OpFlagNotSecure, OpFlagDebug, OpFlagNotConfigured).
						SetSerialNumber("C02X70VHJHD5").
						SetUEID(TestUEID).
						SetUUID(TestUUID).
						SetMACaddr(MACaddr(TestMACaddr)).
						SetIPaddr(TestIPaddr),
				),
		},
	).
	AddAttestVerifKey(
		AttestVerifKey{
			Environment: Environment{
				Instance: NewInstanceUUID(uuid.UUID(TestUUID)),
			},
			VerifKeys: *NewCryptoKeys().
				Add(
					MustNewPKIXBase64Key(TestECPubKey),
				),
		},
	).AddDevIdentityKey(
	DevIdentityKey{
		Environment: Environment{
			Instance: NewInstanceUEID(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:

a50065656e2d474201a10078206d792d6e733a61636d652d726f616472756e6e65722d737570706c656d656e740282a3006941434d45204c74642e01d8207468747470733a2f2f61636d652e6578616d706c6502820100a20069454d4341204c74642e0281020382a200781a6d792d6e733a61636d652d726f616472756e6e65722d626173650100a20078196d792d6e733a61636d652d726f616472756e6e65722d6f6c64010104a4008182a300a500d86f445502c000016941434d45204c74642e026a526f616452756e6e65720300040101d902264702deadbeefdead02d8255031fb5abf023e4992aa4e95f9c1503bfa81a200d8255031fb5abf023e4992aa4e95f9c1503bfa01aa01d90228020282820644abcdef00820644ffffffff030a04d9023044010203040544ffffffff064802005e1000000001075020010db8000000000000000000000068086c43303258373056484a484435094702deadbeefdead0a5031fb5abf023e4992aa4e95f9c1503bfa018182a300a500d8255031fb5abf023e4992aa4e95f9c1503bfa016941434d45204c74642e026a526f616452756e6e65720300040101d902264702deadbeefdead02d8255031fb5abf023e4992aa4e95f9c1503bfa81a200d8255031fb5abf023e4992aa4e95f9c1503bfa01aa01d90229020282820644abcdef00820644ffffffff030b04d9023044010203040544ffffffff064802005e1000000001075020010db8000000000000000000000068086c43303258373056484a484435094702deadbeefdead0a5031fb5abf023e4992aa4e95f9c1503bfa028182a101d8255031fb5abf023e4992aa4e95f9c1503bfa81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d038182a101d902264702deadbeefdead81d9022a78b12d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b77457759484b6f5a497a6a3043415159494b6f5a497a6a304441516344516741455731427671462b2f727938425761375a454d553178595948455138420a6c4c54344d46484f614f2b4943547449767245654570722f7366544150363648326843486462354845584b74524b6f6436514c634f4c504131513d3d0a2d2d2d2d2d454e44205055424c4943204b45592d2d2d2d2d
{"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":"ueid","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=="],"op-flags":["notSecure","debug"],"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":"ueid","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=="],"op-flags":["notConfigured","notSecure","debug"],"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(
					NewPSAMeasurement(
						*NewPSARefValID(TestSignerID).
							SetLabel("BL").
							SetVersion("5.0.5"),
					).AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}),
				).
				AddMeasurement(
					NewPSAMeasurement(
						*NewPSARefValID(TestSignerID).
							SetLabel("PRoT").
							SetVersion("1.3.5"),
					).AddDigest(swid.Sha256_32, []byte{0xab, 0xcd, 0xef, 0x00}),
				),
		},
	).
	AddAttestVerifKey(
		AttestVerifKey{
			Environment: Environment{
				Instance: NewInstanceUEID(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: NewInstanceUEID(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")
	}

	instID, err := i.GetUEID()
	if err != nil {
		return fmt.Errorf("extracting implemenetation-id: %w", err)
	}

	fmt.Printf("InstanceID: %x\n", instID)

	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, err := k.GetPSARefValID()
	if err != nil {
		return fmt.Errorf("getting PSA refval id: %w", err)
	}

	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")
	}

	implID, err := classID.GetImplID()
	if err != nil {
		return fmt.Errorf("extracting implemenetation-id: %w", err)
	}

	fmt.Printf("ImplementationID: %x\n", implID)

	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

Examples

Constants

View Source
const (
	ClassIDTypeUUID = ClassIDType(iota)
	ClassIDTypeImplID
	ClassIDTypeOID

	ClassIDTypeUnknown = ^ClassIDType(0)
)
View Source
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"
	// CertAmdArkAskType represents the Certificate format used by AMD for either
	// AMD Root Key (ARK) or AMD Signing Key (ASK)
	CertAmdArkAskType = "cert-amd-ark-ask"
)
View Source
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
)
View Source
const MaxUint64 = ^uint64(0)

Variables

View Source
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")
	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`),
	}
)
View Source
var (
	PSARefValJSONTemplate = `` /* 1556-byte string literal not displayed */

	PSAKeysJSONTemplate = `` /* 1541-byte string literal not displayed */

	CCARefValJSONTemplate = `` /* 1806-byte string literal not displayed */

)

Functions

func IsAbsoluteURI

func IsAbsoluteURI(s string) error

func MustHexDecode

func MustHexDecode(t *testing.T, s string) []byte

func NewHashEntry

func NewHashEntry(algID uint64, value []byte) *swid.HashEntry

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 (*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

func NewClassImplID(implID ImplID) *Class

NewClassImplID instantiates a new Class object that identifies the specified PSA Implementation ID

func NewClassOID

func NewClassOID(oid string) *Class

NewClassOID instantiates a new Class object that identifies the OID

func NewClassUUID

func NewClassUUID(uuid UUID) *Class

NewClassUUID instantiates a new Class object with the specified UUID as identifier

func (*Class) FromCBOR

func (o *Class) FromCBOR(data []byte) error

FromCBOR deserializes the supplied CBOR data into the target Class

func (*Class) FromJSON

func (o *Class) FromJSON(data []byte) error

FromJSON deserializes the supplied JSON string into the target Class

func (Class) GetIndex

func (o Class) GetIndex() uint64

GetIndex returns the index number if it set in the target Class. Otherwise, uint64_max is returned.

func (Class) GetLayer

func (o Class) GetLayer() uint64

GetLayer returns the layer number if it set in the target Class. Otherwise, uint64_max is returned.

func (Class) GetModel

func (o Class) GetModel() string

GetModel returns the model string if it set in the target Class. Otherwise, an empty string is returned.

func (Class) GetVendor

func (o Class) GetVendor() string

GetVendor returns the vendor string if it set in the target Class. Otherwise, an empty string is returned.

func (*Class) SetIndex

func (o *Class) SetIndex(index uint64) *Class

SetIndex sets the "index" (i.e., the identifier of the environment instance in a specific layer) as indicated

func (*Class) SetLayer

func (o *Class) SetLayer(layer uint64) *Class

SetLayer sets the "layer" (i.e., the logical/topological location of the environment in the device) as indicated

func (*Class) SetModel

func (o *Class) SetModel(model string) *Class

SetModel sets the model metadata to the supplied string

func (*Class) SetVendor

func (o *Class) SetVendor(vendor string) *Class

SetVendor sets the vendor metadata to the supplied string

func (Class) ToCBOR

func (o Class) ToCBOR() ([]byte, error)

ToCBOR serializes the target Class to CBOR (if the Class is "valid")

func (Class) ToJSON

func (o Class) ToJSON() ([]byte, error)

ToJSON serializes the target Class to JSON (if the Class is "valid")

func (Class) Valid

func (o Class) Valid() error

Valid checks the non-empty<> constraint on the map

type ClassID

type ClassID struct {
	// contains filtered or unexported fields
}

ClassID represents a $class-id-type-choice, which can be one of TaggedUUID, TaggedOID, or TaggedImplID (PSA-specific extension)

func (ClassID) GetImplID added in v1.3.0

func (o ClassID) GetImplID() (ImplID, error)

func (ClassID) MarshalCBOR

func (o ClassID) MarshalCBOR() ([]byte, error)

MarshalCBOR serializes the target ClassID to CBOR

func (ClassID) MarshalJSON

func (o ClassID) MarshalJSON() ([]byte, error)

MarshalJSON serializes the target ClassID to JSON

func (*ClassID) SetImplID added in v1.3.0

func (o *ClassID) SetImplID(implID ImplID) *ClassID

SetImplID sets the value of the targed ClassID to the supplied PSA Implementation ID (see Section 3.2.2 of draft-tschofenig-rats-psa-token)

func (*ClassID) SetOID added in v1.3.0

func (o *ClassID) SetOID(s string) *ClassID

SetOID sets the value of the targed ClassID to the supplied OID. The OID is a string in dotted-decimal notation

func (*ClassID) SetUUID added in v1.3.0

func (o *ClassID) SetUUID(uuid UUID) *ClassID

SetUUID sets the value of the targed ClassID to the supplied UUID

func (ClassID) String

func (o ClassID) String() 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) Type

func (o ClassID) Type() ClassIDType

Type returns the type of the target ClassID, i.e., one of UUID, OID or PSA Implementation ID

func (*ClassID) UnmarshalCBOR

func (o *ClassID) UnmarshalCBOR(data []byte) error

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

func (o *ClassID) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the supplied JSON object into the target ClassID The class id object must have one of the following shapes:

UUID:

{
  "type": "uuid",
  "value": "69E027B2-7157-4758-BCB4-D9F167FE49EA"
}

OID:

{
  "type": "oid",
  "value": "2.16.840.1.113741.1.15.4.2"
}

PSA Implementation ID:

{
  "type": "psa.impl-id",
  "value": "YWNtZS1pbXBsZW1lbnRhdGlvbi1pZC0wMDAwMDAwMDE="
}

func (ClassID) Unset added in v1.3.0

func (o ClassID) Unset() bool

Unset tests whether the target ClassID has been initialized

type ClassIDType added in v1.3.0

type ClassIDType uint16

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"`
}

Comid is the top-level representation of a Concise Module IDentifier with CBOR and JSON serialization.

func NewComid

func NewComid() *Comid

NewComid instantiates an empty Comid

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

func (o *Comid) AddEntity(name string, regID *string, roles ...Role) *Comid

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

func (o *Comid) AddLinkedTag(tagID interface{}, rel Rel) *Comid

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) FromCBOR

func (o *Comid) FromCBOR(data []byte) error

FromCBOR deserializes a CBOR-encoded CoMID into the target Comid

func (*Comid) FromJSON

func (o *Comid) FromJSON(data []byte) error

FromJSON deserializes a JSON-encoded CoMID into the target Comid

func (*Comid) SetLanguage

func (o *Comid) SetLanguage(language string) *Comid

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

func (o *Comid) SetTagIdentity(tagID interface{}, tagIDVersion uint) *Comid

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.

func (Comid) ToCBOR

func (o Comid) ToCBOR() ([]byte, error)

ToCBOR serializes the target Comid to CBOR

func (Comid) ToJSON

func (o Comid) ToJSON() ([]byte, error)

ToJSON serializes the target Comid to JSON

func (Comid) ToJSONPretty

func (o Comid) ToJSONPretty(indent string) ([]byte, error)

func (Comid) Valid

func (o Comid) Valid() error

type CryptoKey

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

func MustNewCOSEKey(b []byte) *CryptoKey

func MustNewCertAmdArkAsk

func MustNewCertAmdArkAsk(k any) *CryptoKey

func MustNewCertPathThumbprint

func MustNewCertPathThumbprint(he swid.HashEntry) *CryptoKey

func MustNewCertThumbprint

func MustNewCertThumbprint(he swid.HashEntry) *CryptoKey

func MustNewCryptoKey

func MustNewCryptoKey(k any, typ string) *CryptoKey

MustNewCryptoKey is the same as NewCryptoKey, but does not return an error, and panics if there is a problem.

func MustNewPKIXBase64Cert

func MustNewPKIXBase64Cert(s string) *CryptoKey

func MustNewPKIXBase64CertPath

func MustNewPKIXBase64CertPath(s string) *CryptoKey

func MustNewPKIXBase64Key

func MustNewPKIXBase64Key(s string) *CryptoKey

func MustNewThumbprint

func MustNewThumbprint(he swid.HashEntry) *CryptoKey

func NewCOSEKey

func NewCOSEKey(b []byte) (*CryptoKey, error)

func NewCertAmdArkAsk

func NewCertAmdArkAsk(k any) (*CryptoKey, error)

func NewCertPathThumbprint

func NewCertPathThumbprint(he swid.HashEntry) (*CryptoKey, error)

func NewCertThumbprint

func NewCertThumbprint(he swid.HashEntry) (*CryptoKey, error)

func NewCryptoKey

func NewCryptoKey(k any, typ string) (*CryptoKey, error)

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

func NewPKIXBase64Cert(s string) (*CryptoKey, error)

func NewPKIXBase64CertPath

func NewPKIXBase64CertPath(s string) (*CryptoKey, error)

func NewPKIXBase64Key

func NewPKIXBase64Key(s string) (*CryptoKey, error)

func NewThumbprint

func NewThumbprint(he swid.HashEntry) (*CryptoKey, error)

func (CryptoKey) MarshalCBOR

func (o CryptoKey) MarshalCBOR() ([]byte, error)

MarshalCBOR returns a []byte containing the CBOR representation of the CryptoKey.

func (CryptoKey) MarshalJSON

func (o CryptoKey) MarshalJSON() ([]byte, error)

MarshalJSON returns a []byte containing the JSON representation of the CryptoKey.

func (CryptoKey) PublicKey

func (o CryptoKey) PublicKey() (crypto.PublicKey, error)

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

func (o CryptoKey) String() string

String returns the string representation of the CryptoKey.

func (*CryptoKey) UnmarshalCBOR

func (o *CryptoKey) UnmarshalCBOR(b []byte) error

UnmarshalCBOR populates the CryptoKey from the CBOR representation inside the provided []byte.

func (*CryptoKey) UnmarshalJSON

func (o *CryptoKey) UnmarshalJSON(b []byte) error

UnmarshalJSON populates the CryptoKey from the JSON representation inside the provided []byte.

func (CryptoKey) Valid

func (o CryptoKey) Valid() error

Valid returns an error if validation of the CryptoKey fails, or nil if it succeeds.

type CryptoKeys

type CryptoKeys []*CryptoKey

CryptoKeys is an array of *CryptoKey

func NewCryptoKeys

func NewCryptoKeys() *CryptoKeys

NewCryptoKeys instantiates an empty CryptoKeys

func (*CryptoKeys) Add

func (o *CryptoKeys) Add(v *CryptoKey) *CryptoKeys

Add the supplied *CryptoKey to the CryptoKeys

func (CryptoKeys) Valid

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

type Digests []swid.HashEntry

Digests is an alias for an array of SWID HashEntry

func NewDigests

func NewDigests() *Digests

NewDigests instantiates an empty array of Digests

func (*Digests) AddDigest

func (o *Digests) AddDigest(algID uint64, value []byte) *Digests

AddDigest create a new digest from the supplied arguments and appends it to the (already instantiated) Digests target. The method is a no-op if it is invoked on a nil target and will refuse to add inconsistent algo/value combinations.

func (Digests) Valid

func (o Digests) Valid() error

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

func NewEntities

func NewEntities() *Entities

NewEntities instantiates an empty entity-map array

func (*Entities) AddEntity

func (o *Entities) AddEntity(e Entity) *Entities

AddEntity adds the supplied entity-map to the target Entities

func (Entities) Valid

func (o Entities) Valid() error

type Entity

type Entity struct {
	EntityName string     `cbor:"0,keyasint" json:"name"`
	RegID      *TaggedURI `cbor:"1,keyasint,omitempty" json:"regid,omitempty"`
	Roles      Roles      `cbor:"2,keyasint" json:"roles"`
}

Entity stores an entity-map capable of CBOR and JSON serializations.

func (*Entity) SetEntityName

func (o *Entity) SetEntityName(name string) *Entity

func (*Entity) SetRegID

func (o *Entity) SetRegID(uri string) *Entity

func (*Entity) SetRoles

func (o *Entity) SetRoles(roles ...Role) *Entity

func (Entity) Valid

func (o Entity) 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 Group

type Group struct {
	// contains filtered or unexported fields
}

Group stores a group identity. The supported format is UUID.

func NewGroup

func NewGroup() *Group

NewGroup instantiates an empty group

func NewGroupUUID added in v1.3.0

func NewGroupUUID(val UUID) *Group

NewGroupUUID instantiates a new group with the supplied UUID identity

func (Group) MarshalCBOR

func (o Group) MarshalCBOR() ([]byte, error)

MarshalCBOR serializes the target group to CBOR

func (Group) MarshalJSON

func (o Group) MarshalJSON() ([]byte, error)

func (*Group) SetUUID added in v1.3.0

func (o *Group) SetUUID(val UUID) *Group

SetUUID sets the identity of the target group to the supplied UUID

func (Group) String

func (o Group) String() 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

func (o *Group) UnmarshalCBOR(data []byte) error

UnmarshalCBOR deserializes the supplied CBOR into the target group

func (*Group) UnmarshalJSON

func (o *Group) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the supplied JSON type/value object into the Group target. The only supported format is UUID, e.g.:

{
  "type": "uuid",
  "value": "69E027B2-7157-4758-BCB4-D9F167FE49EA"
}

func (Group) Valid

func (o Group) Valid() error

Valid checks for the validity of given group

type ICryptoKeyValue

type ICryptoKeyValue interface {
	// String returns the string representation of the ICryptoKeyValue.
	String() string
	// Valid returns an error if validation of the ICryptoKeyValue fails,
	// or nil if it succeeds.
	Valid() error
	// 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 ImplID

type ImplID [32]byte

func (ImplID) MarshalJSON added in v1.3.0

func (o ImplID) MarshalJSON() ([]byte, error)

func (*ImplID) UnmarshalJSON added in v1.3.0

func (o *ImplID) UnmarshalJSON(data []byte) error

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance stores an instance identity. The supported formats are UUID and UEID.

func NewInstance

func NewInstance() *Instance

NewInstance instantiates an empty instance

func NewInstanceUEID added in v1.3.0

func NewInstanceUEID(val eat.UEID) *Instance

NewInstanceUEID instantiates a new instance with the supplied UEID identity

func NewInstanceUUID added in v1.3.0

func NewInstanceUUID(val uuid.UUID) *Instance

NewInstanceUUID instantiates a new instance with the supplied UUID identity

func (Instance) GetUEID added in v1.3.0

func (o Instance) GetUEID() (eat.UEID, error)

func (Instance) GetUUID added in v1.3.0

func (o Instance) GetUUID() (UUID, error)

func (Instance) MarshalCBOR

func (o Instance) MarshalCBOR() ([]byte, error)

MarshalCBOR serializes the target instance to CBOR

func (Instance) MarshalJSON

func (o Instance) MarshalJSON() ([]byte, error)

func (*Instance) SetUEID added in v1.3.0

func (o *Instance) SetUEID(val eat.UEID) *Instance

SetUEID sets the identity of the target instance to the supplied UEID

func (*Instance) SetUUID added in v1.3.0

func (o *Instance) SetUUID(val uuid.UUID) *Instance

SetUUID sets the identity of the target instance to the supplied UUID

func (Instance) String

func (o Instance) String() 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) UnmarshalCBOR

func (o *Instance) UnmarshalCBOR(data []byte) error

func (*Instance) UnmarshalJSON

func (o *Instance) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the supplied JSON type/value object into the Group target. The supported formats are UUID, e.g.:

{
  "type": "uuid",
  "value": "69E027B2-7157-4758-BCB4-D9F167FE49EA"
}

and UEID:

{
  "type": "ueid",
  "value": "Ad6tvu/erb7v3q2+796tvu8="
}

func (Instance) Valid

func (o Instance) Valid() error

Valid checks for the validity of given instance

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

func (*LinkedTag) SetLinkedTag

func (o *LinkedTag) SetLinkedTag(t swid.TagID) *LinkedTag

func (*LinkedTag) SetRel

func (o *LinkedTag) SetRel(r Rel) *LinkedTag

func (LinkedTag) Valid

func (o LinkedTag) Valid() error

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 (o MACaddr) MarshalJSON() ([]byte, error)

func (*MACaddr) UnmarshalJSON

func (o *MACaddr) UnmarshalJSON(data []byte) error

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"`
}

Measurement stores a measurement-map with CBOR and JSON serializations.

func NewCCAPlatCfgMeasurement

func NewCCAPlatCfgMeasurement(ccaPlatformConfigID CCAPlatformConfigID) *Measurement

NewCCAPlatCfgMeasurement instantiates a new measurement-map with the key set to the supplied CCA platform-config-id

func NewMeasurement

func NewMeasurement() *Measurement

NewMeasurement instantiates an empty measurement

func NewPSAMeasurement

func NewPSAMeasurement(psaRefValID PSARefValID) *Measurement

NewPSAMeasurement instantiates a new measurement-map with the key set to the supplied PSA refval-id

func NewUUIDMeasurement

func NewUUIDMeasurement(uuid UUID) *Measurement

NewUUIDMeasurement instantiates a new measurement-map with the key set to the supplied UUID

func NewUintMeasurement

func NewUintMeasurement(mkey uint64) *Measurement

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) 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) SetKeyCCAPlatformConfigID added in v1.3.0

func (o *Measurement) SetKeyCCAPlatformConfigID(ccaPlatformConfigID CCAPlatformConfigID) *Measurement

SetKeyCCAPlatformConfigID sets the key of the target measurement-map to the supplied CCA platform-config-id

func (*Measurement) SetKeyPSARefValID added in v1.3.0

func (o *Measurement) SetKeyPSARefValID(psaRefValID PSARefValID) *Measurement

SetKeyPSARefValID sets the key of the target measurement-map to the supplied PSA refval-id

func (*Measurement) SetKeyUUID added in v1.3.0

func (o *Measurement) SetKeyUUID(u UUID) *Measurement

SetKeyKeyUUID sets the key of the target measurement-map to the supplied UUID

func (*Measurement) SetKeyUint added in v1.3.0

func (o *Measurement) SetKeyUint(u uint64) *Measurement

SetKeyUint sets the key of the target measurement-map to the supplied unsigned integer

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) SetOpFlags added in v1.3.0

func (o *Measurement) SetOpFlags(flags ...OpFlags) *Measurement

SetOpFlags sets the supplied operational flags 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 {
	// contains filtered or unexported fields
}

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/jraman567/corim/issues/35

func (Mkey) GetCCAPlatformConfigID added in v1.3.0

func (o Mkey) GetCCAPlatformConfigID() (CCAPlatformConfigID, error)

func (Mkey) GetKeyUint added in v1.3.0

func (o Mkey) GetKeyUint() (uint64, error)

func (Mkey) GetPSARefValID added in v1.3.0

func (o Mkey) GetPSARefValID() (PSARefValID, error)

func (Mkey) IsCCAPlatformConfigID added in v1.3.0

func (o Mkey) IsCCAPlatformConfigID() bool

func (Mkey) IsPSARefValID added in v1.3.0

func (o Mkey) IsPSARefValID() bool

func (Mkey) IsSet

func (o Mkey) IsSet() bool

func (Mkey) MarshalCBOR

func (o Mkey) MarshalCBOR() ([]byte, error)

func (Mkey) MarshalJSON

func (o Mkey) MarshalJSON() ([]byte, error)

MarshalJSON serializes the target Mkey into the type'n'value JSON object Supported types are: uuid, psa.refval-id and unsigned integer

func (*Mkey) UnmarshalCBOR

func (o *Mkey) UnmarshalCBOR(data []byte) error

func (*Mkey) UnmarshalJSON

func (o *Mkey) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the type'n'value JSON object into the target Mkey

func (Mkey) Valid

func (o Mkey) Valid() error

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"`
	OpFlags      *OpFlags  `cbor:"3,keyasint,omitempty" json:"op-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"`
}

Mval stores a measurement-values-map with JSON and CBOR serializations.

func (Mval) Valid

func (o Mval) Valid() error

type OID

type OID []byte

BER-encoded absolute OID

func (*OID) FromString

func (o *OID) FromString(s string) error

func (OID) MarshalJSON

func (o OID) MarshalJSON() ([]byte, error)

func (OID) String

func (o OID) String() string

func (*OID) UnmarshalJSON

func (o *OID) UnmarshalJSON(data []byte) error

type OpFlags added in v1.3.0

type OpFlags uint8

OpFlags implements the flags-type, mapping to DiceTcbInfo.flags via the operational flags not-configured, not-secure, recovery and debug. If the flags field is omitted, all flags are assumed to be 0.

const (
	OpFlagNotConfigured OpFlags = 1 << iota
	OpFlagNotSecure
	OpFlagRecovery
	OpFlagDebug
)

func NewOpFlags added in v1.3.0

func NewOpFlags() *OpFlags

func (OpFlags) IsSet added in v1.3.0

func (o OpFlags) IsSet(flag OpFlags) bool

func (OpFlags) MarshalJSON added in v1.3.0

func (o OpFlags) MarshalJSON() ([]byte, error)

func (*OpFlags) SetOpFlags added in v1.3.0

func (o *OpFlags) SetOpFlags(flags ...OpFlags) *OpFlags

SetFlags sets the target object as specified. As many flags as necessary can be specified in one call.

func (OpFlags) Strings added in v1.3.0

func (o OpFlags) Strings() []string

func (*OpFlags) UnmarshalJSON added in v1.3.0

func (o *OpFlags) UnmarshalJSON(data []byte) error

UnmarshalJSON provides a custom deserializer for the OpFlags type that uses an array of identifiers rather than a bit set, e.g.:

"op-flags": [
  "notSecure",
  "debug"
]

func (OpFlags) Valid added in v1.3.0

func (o OpFlags) Valid() error

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 NewPSARefValID

func NewPSARefValID(signerID []byte) *PSARefValID

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) GetBytes

func (o RawValue) GetBytes() ([]byte, error)

func (RawValue) MarshalCBOR

func (o RawValue) MarshalCBOR() ([]byte, error)

func (RawValue) MarshalJSON

func (o RawValue) MarshalJSON() ([]byte, error)

func (*RawValue) SetBytes

func (o *RawValue) SetBytes(val []byte) *RawValue

func (*RawValue) UnmarshalCBOR

func (o *RawValue) UnmarshalCBOR(data []byte) error

func (*RawValue) UnmarshalJSON

func (o *RawValue) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the type'n'value JSON object into the target RawValue. The only supported type is "bytes" 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 Rel

type Rel int64
const (
	RelSupplements Rel = iota
	RelReplaces

	RelUnset = ^Rel(0)
)

func NewRel

func NewRel() *Rel

func (*Rel) FromCBOR

func (o *Rel) FromCBOR(data []byte) error

func (Rel) Get

func (o Rel) Get() Rel

func (Rel) MarshalJSON

func (o Rel) MarshalJSON() ([]byte, error)

func (*Rel) Set

func (o *Rel) Set(r Rel) *Rel

func (Rel) String

func (o Rel) String() string

func (Rel) ToCBOR

func (o Rel) ToCBOR() ([]byte, error)

func (*Rel) UnmarshalJSON

func (o *Rel) UnmarshalJSON(data []byte) error

func (Rel) Valid

func (o Rel) Valid() error

type Role

type Role int64
const (
	RoleTagCreator Role = iota
	RoleCreator
	RoleMaintainer
)

type Roles

type Roles []Role

func NewRoles

func NewRoles() *Roles

func (*Roles) Add

func (o *Roles) Add(roles ...Role) *Roles

func (*Roles) FromCBOR

func (o *Roles) FromCBOR(data []byte) error

func (Roles) MarshalJSON

func (o Roles) MarshalJSON() ([]byte, error)

func (Roles) ToCBOR

func (o Roles) ToCBOR() ([]byte, error)

func (*Roles) UnmarshalJSON

func (o *Roles) UnmarshalJSON(data []byte) error

func (Roles) Valid

func (o Roles) Valid() error

type SVN

type SVN struct {
	// contains filtered or unexported fields
}

func (SVN) MarshalCBOR

func (o SVN) MarshalCBOR() ([]byte, error)

func (SVN) MarshalJSON

func (o SVN) MarshalJSON() ([]byte, error)

func (*SVN) SetMinSVN added in v1.3.0

func (o *SVN) SetMinSVN(val uint64) *SVN

func (*SVN) SetSVN added in v1.3.0

func (o *SVN) SetSVN(val uint64) *SVN

func (*SVN) UnmarshalCBOR

func (o *SVN) UnmarshalCBOR(data []byte) error

func (*SVN) UnmarshalJSON

func (o *SVN) UnmarshalJSON(data []byte) error

Supported formats: { "type": "exact-value", "value": 123 } -> SVN { "type": "min-value", "value": 123 } -> MinSVN

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 TaggedCCAPlatformConfigID

type TaggedCCAPlatformConfigID CCAPlatformConfigID

type TaggedCOSEKey

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

func (o TaggedCOSEKey) MarshalCBOR() ([]byte, error)

func (TaggedCOSEKey) PublicKey

func (o TaggedCOSEKey) PublicKey() (crypto.PublicKey, error)

func (TaggedCOSEKey) String

func (o TaggedCOSEKey) String() string

func (*TaggedCOSEKey) UnmarshalCBOR

func (o *TaggedCOSEKey) UnmarshalCBOR(b []byte) error

func (TaggedCOSEKey) Valid

func (o TaggedCOSEKey) Valid() error

type TaggedCertAmdArkAsk

type TaggedCertAmdArkAsk struct {
	Value string `cbor:"79499,keyasint" json:"askark"`
}

func (TaggedCertAmdArkAsk) PublicKey

func (o TaggedCertAmdArkAsk) PublicKey() (crypto.PublicKey, error)

ToDo: extract Public Key from ARK/ASK

ARK/ASK is in proprietary format. We need to extract the
Modulus and Exponent and then construct the Public Key

func (TaggedCertAmdArkAsk) String

func (o TaggedCertAmdArkAsk) String() string

func (TaggedCertAmdArkAsk) Type

func (o TaggedCertAmdArkAsk) Type() string

func (TaggedCertAmdArkAsk) Valid

func (o TaggedCertAmdArkAsk) Valid() error

ToDo: Add checks to validate ARK/ASK

type TaggedCertPathThumbprint

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) PublicKey

func (o TaggedCertPathThumbprint) PublicKey() (crypto.PublicKey, error)

func (TaggedCertPathThumbprint) String

func (o TaggedCertPathThumbprint) String() string

func (TaggedCertPathThumbprint) Valid

func (o TaggedCertPathThumbprint) Valid() error

type TaggedCertThumbprint

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) PublicKey

func (o TaggedCertThumbprint) PublicKey() (crypto.PublicKey, error)

func (TaggedCertThumbprint) String

func (o TaggedCertThumbprint) String() string

func (TaggedCertThumbprint) Valid

func (o TaggedCertThumbprint) Valid() error

type TaggedImplID

type TaggedImplID ImplID

type TaggedMinSVN

type TaggedMinSVN uint64

type TaggedOID

type TaggedOID OID

type TaggedPKIXBase64Cert

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

func (o TaggedPKIXBase64Cert) PublicKey() (crypto.PublicKey, error)

func (TaggedPKIXBase64Cert) String

func (o TaggedPKIXBase64Cert) String() string

func (TaggedPKIXBase64Cert) Valid

func (o TaggedPKIXBase64Cert) Valid() error

type TaggedPKIXBase64CertPath

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

func (TaggedPKIXBase64CertPath) String

func (o TaggedPKIXBase64CertPath) String() string

func (TaggedPKIXBase64CertPath) Valid

func (o TaggedPKIXBase64CertPath) Valid() error

type TaggedPKIXBase64Key

type TaggedPKIXBase64Key string

TaggedPKIXBase64Key is a PEM-encoded SubjectPublicKeyInfo. See https://www.rfc-editor.org/rfc/rfc7468#section-13

func (TaggedPKIXBase64Key) PublicKey

func (o TaggedPKIXBase64Key) PublicKey() (crypto.PublicKey, error)

func (TaggedPKIXBase64Key) String

func (o TaggedPKIXBase64Key) String() string

func (TaggedPKIXBase64Key) Valid

func (o TaggedPKIXBase64Key) Valid() error

type TaggedPSARefValID

type TaggedPSARefValID PSARefValID

type TaggedRawValueBytes added in v1.3.0

type TaggedRawValueBytes []byte

TaggedRawValueBytes is an alias for []byte to allow its automatic tagging

type TaggedSVN

type TaggedSVN uint64

type TaggedThumbprint

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) PublicKey

func (o TaggedThumbprint) PublicKey() (crypto.PublicKey, error)

func (TaggedThumbprint) String

func (o TaggedThumbprint) String() string

func (TaggedThumbprint) Valid

func (o TaggedThumbprint) Valid() error

type TaggedUEID

type TaggedUEID UEID

TaggedUEID is an alias to allow automatic tagging of an UEID type

type TaggedURI

type TaggedURI string

func String2URI

func String2URI(s *string) (*TaggedURI, error)

func (TaggedURI) Empty

func (o TaggedURI) Empty() bool

type TaggedUUID

type TaggedUUID UUID

TaggedUUID is an alias to allow automatic tagging of a UUID type

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"`
}

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) Valid

func (o Triples) Valid() error

Valid checks that the Triples is valid as per the specification

type UEID

type UEID eat.UEID

UEID is an Unique Entity Identifier

func (UEID) Empty

func (o UEID) Empty() bool

func (UEID) MarshalJSON added in v1.3.0

func (o UEID) MarshalJSON() ([]byte, error)

func (*UEID) UnmarshalJSON added in v1.3.0

func (o *UEID) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the supplied string into the UEID target

func (UEID) Valid

func (o UEID) Valid() error

Valid checks that the target UEID is in one of the defined formats: IMEI, EUI or RAND

type UUID

type UUID uuid.UUID

UUID represents an Universally Unique Identifier (UUID, see RFC4122)

func ParseUUID

func ParseUUID(s string) (UUID, error)

ParseUUID parses the supplied string into a UUID

func (UUID) Empty

func (o UUID) Empty() bool

func (UUID) MarshalJSON

func (o UUID) MarshalJSON() ([]byte, error)

MarshalJSON serialize the target UUID to a JSON string in canonical 8-4-4-4-12 format

func (UUID) String

func (o UUID) String() string

String returns a string representation of the binary UUID

func (*UUID) UnmarshalJSON

func (o *UUID) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the supplied string into the UUID target The UUID string in expected to be in canonical 8-4-4-4-12 format

func (UUID) Valid

func (o UUID) Valid() error

Valid checks that the target UUID is formatted as per RFC4122

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) SetScheme

func (o *Version) SetScheme(v int64) *Version

func (*Version) SetVersion

func (o *Version) SetVersion(v string) *Version

func (Version) Valid

func (o Version) Valid() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL