Documentation
¶
Overview ¶
auto-generated (see utils/README.md)
Example (Decode_CBOR_record) ¶
var o CMW
b := mustHexDecode(`83781d6170706c69636174696f6e2f7369676e65642d636f72696d2b63626f724dd901f6d28440a044d901f5a04003`)
if err := o.UnmarshalCBOR(b); err != nil {
log.Fatalf("unmarshal CBOR record failed: %v", err)
}
fmt.Printf("CMW format: %s\n", o.GetFormat())
actualType, _ := o.GetMonadType()
fmt.Printf("type: %s\n", actualType)
actualValue, _ := o.GetMonadValue()
fmt.Printf("value (hex): %x\n", actualValue)
actualIndicator, _ := o.GetMonadIndicator()
fmt.Printf("indicator: %s\n", actualIndicator)
Output: CMW format: CBOR record type: application/signed-corim+cbor value (hex): d901f6d28440a044d901f5a040 indicator: endorsements, reference values
Example (Decode_JSON_record) ¶
var o CMW
err := o.UnmarshalJSON([]byte(`[ "application/vnd.example.rats-conceptual-msg", "I0faVQ", 3 ]`))
if err != nil {
log.Fatalf("unmarshal JSON record failed: %v", err)
}
fmt.Printf("CMW format: %s\n", o.GetFormat())
actualType, _ := o.GetMonadType()
fmt.Printf("type: %s\n", actualType)
actualValue, _ := o.GetMonadValue()
fmt.Printf("value (hex): %x\n", actualValue)
actualIndicator, _ := o.GetMonadIndicator()
fmt.Printf("indicator: %s\n", actualIndicator)
Output: CMW format: JSON record type: application/vnd.example.rats-conceptual-msg value (hex): 2347da55 indicator: endorsements, reference values
Example (Encode_CBOR_collection) ¶
root := makeCMWCollection()
b, err := root.MarshalCBOR()
if err != nil {
log.Fatalf("marshal to CBOR failed: %v", err)
}
edn, _ := cbor.Diagnose(b)
fmt.Println(edn)
Output: {"__cmwc_t": "tag:ietf.org,2024:X", "murmurless": {"__cmwc_t": "tag:ietf.org,2024:Y", "polyscopic": ["application/eat-ucs+json", h'7b226561745f6e6f6e6365223a202e2e2e7d', 8]}, "bretwaldadom": ["application/eat-ucs+cbor", h'a10a'], "photoelectrograph": ["application/eat-ucs+cbor", h'827818', 3]}
Example (Encode_JSON_collection) ¶
root := makeCMWCollection()
b, err := root.MarshalJSON()
if err != nil {
log.Fatalf("marshal to JSON failed: %v", err)
}
fmt.Println(string(b))
Output: {"__cmwc_t":"tag:ietf.org,2024:X","bretwaldadom":["application/eat-ucs+cbor","oQo"],"murmurless":{"__cmwc_t":"tag:ietf.org,2024:Y","polyscopic":["application/eat-ucs+json","eyJlYXRfbm9uY2UiOiAuLi59",8]},"photoelectrograph":["application/eat-ucs+cbor","gngY",3]}
Example (Get_meta) ¶
root := makeCMWCollection()
meta, _ := root.GetCollectionMeta()
for _, m := range meta {
fmt.Printf("%s: %s\n", m.Key, m.Kind)
}
Output: bretwaldadom: monad murmurless: collection photoelectrograph: monad
Example (Roundtrip_JSON_collection) ¶
var o CMW
ex := []byte(`{
"bretwaldadom": [
"application/eat-ucs+cbor",
"oQo"
],
"__cmwc_t": "tag:ietf.org,2024:X",
"json-raw": [
"application/vnd.my.ref-val",
"e30K"
],
"murmurless": {
"__cmwc_t": "tag:ietf.org,2024:Y",
"polyscopic": [
"application/eat-ucs+json",
"eyJlYXRfbm9uY2UiOiAuLi59",
8
]
},
"photoelectrograph": [
"application/eat-ucs+cbor",
"gngY",
3
]
}`)
err := o.Deserialize(ex)
if err != nil {
log.Fatalf("unmarshal JSON collection failed: %v", err)
}
b, err := o.MarshalJSON()
if err != nil {
log.Fatalf("marshal collection to JSON failed: %v", err)
}
fmt.Println(string(b))
Output: {"__cmwc_t":"tag:ietf.org,2024:X","bretwaldadom":["application/eat-ucs+cbor","oQo"],"json-raw":["application/vnd.my.ref-val","e30K"],"murmurless":{"__cmwc_t":"tag:ietf.org,2024:Y","polyscopic":["application/eat-ucs+json","eyJlYXRfbm9uY2UiOiAuLi59",8]},"photoelectrograph":["application/eat-ucs+cbor","gngY",3]}
Index ¶
- Constants
- Variables
- func CF(tn uint64) (uint16, error)
- func TN(cf uint16) (uint64, error)
- type CMW
- func (o *CMW) AddCollectionItem(key any, node *CMW) error
- func (o *CMW) Deserialize(b []byte) error
- func (o CMW) EncodeX509Extension(choice Choice, critical bool) (*pkix.Extension, error)
- func (o CMW) GetCollectionItem(key any) (*CMW, error)
- func (o *CMW) GetCollectionMeta() ([]Meta, error)
- func (o CMW) GetCollectionType() (string, error)
- func (o CMW) GetFormat() Format
- func (o CMW) GetKind() Kind
- func (o CMW) GetMonadIndicator() (Indicator, error)
- func (o CMW) GetMonadType() (string, error)
- func (o CMW) GetMonadValue() ([]byte, error)
- func (o CMW) MarshalCBOR() ([]byte, error)
- func (o CMW) MarshalJSON() ([]byte, error)
- func (o *CMW) UnmarshalCBOR(b []byte) error
- func (o *CMW) UnmarshalJSON(b []byte) error
- func (o *CMW) UseCBORTagFormat()
- func (o CMW) ValidateCollection() error
- type Choice
- type Format
- type Indicator
- type Kind
- type Meta
- type Type
- func (o Type) IsSet() bool
- func (o Type) MarshalCBOR() ([]byte, error)
- func (o Type) MarshalJSON() ([]byte, error)
- func (o *Type) Set(v any) error
- func (o Type) String() string
- func (o Type) TagNumber() (uint64, error)
- func (o *Type) UnmarshalCBOR(b []byte) error
- func (o *Type) UnmarshalJSON(b []byte) error
- type Value
Examples ¶
Constants ¶
const ( KindUnknown = Kind(iota) KindMonad KindCollection )
const ( FormatUnknown = Format(iota) // JSON formats FormatJSONRecord FormatJSONCollection // CBOR formats FormatCBORRecord FormatCBORCollection FormatCBORTag )
const ( ReferenceValues = 1 << iota Endorsements Evidence AttestationResults TrustAnchors )
const ( CfMin = uint16(0) CfMax = uint16(65024) )
const ( TnMin = uint64(1668546817) TnMax = uint64(1668612095) )
const ( ChoiceJson = Choice(iota) ChoiceCbor )
const CmwCType string = "__cmwc_t"
const IndicatorNone = 0
Variables ¶
var OidExtCmw = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 35}
Functions ¶
Types ¶
type CMW ¶
type CMW struct {
// contains filtered or unexported fields
}
CMW holds the internal representation of a RATS conceptual message wrapper
func DecodeX509Extension ¶ added in v0.2.0
DecodeX509Extension extracts and decodes the CMW from the supplied id-pe-cmw extension.
func NewCollection ¶ added in v0.2.0
NewCollection instantiate a new Collection CMW with the supplied __cmwc_t Pass an empty string to avoid setting __cmwc_t
func (*CMW) AddCollectionItem ¶ added in v0.2.0
func (*CMW) Deserialize ¶
func (CMW) EncodeX509Extension ¶ added in v0.2.0
EncodeX509Extension encodes the target CMW as either JSON or CBOR (according to the specified choice), and wraps it in a X509 extension that can be used in Certificates, CSRs, or other PKIX data items. Unless you really know what you are doing, critical SHOULD be set to false.
func (CMW) GetCollectionItem ¶ added in v0.2.0
func (*CMW) GetCollectionMeta ¶ added in v0.2.0
GetCollectionMeta retrieves a (sorted) list of keys and associated types in a collection
func (CMW) GetCollectionType ¶ added in v0.2.0
GetCollectionType returns the Collection CMW's __cmwc_t If __cmwc_t is not set, an empty string is returned
func (CMW) GetMonadIndicator ¶ added in v0.2.0
func (CMW) GetMonadType ¶ added in v0.2.0
func (CMW) GetMonadValue ¶ added in v0.2.0
func (CMW) MarshalCBOR ¶
func (CMW) MarshalJSON ¶
func (*CMW) UnmarshalCBOR ¶
func (*CMW) UnmarshalJSON ¶
func (*CMW) UseCBORTagFormat ¶ added in v0.2.0
func (o *CMW) UseCBORTagFormat()
func (CMW) ValidateCollection ¶ added in v0.2.0
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
func (Type) MarshalCBOR ¶
func (Type) MarshalJSON ¶
func (*Type) UnmarshalCBOR ¶
func (*Type) UnmarshalJSON ¶
type Value ¶
type Value []byte