Documentation
¶
Overview ¶
Package eat provides an API for creating and interacting with Entity Attestation Tokens defined by draft-ietf-rats-eat.
Index ¶
- Constants
- type Audience
- type COSEKey
- type CWTClaims
- type ComponentID
- type Debug
- type Eat
- type KeyConfirmation
- type Location
- type Manifest
- type MeasuredComponent
- type Measurement
- type Nonce
- func (ns *Nonce) Add(v []byte) error
- func (ns *Nonce) AddHex(text string) error
- func (ns Nonce) GetI(index int) []byte
- func (ns Nonce) Len() int
- func (ns Nonce) MarshalCBOR() ([]byte, error)
- func (ns Nonce) MarshalJSON() ([]byte, error)
- func (ns *Nonce) UnmarshalCBOR(data []byte) error
- func (ns *Nonce) UnmarshalJSON(data []byte) error
- func (ns Nonce) Validate() error
- type Number
- type NumericDate
- type Profile
- func (s Profile) Get() (string, error)
- func (s Profile) IsOID() bool
- func (s Profile) IsURI() bool
- func (s Profile) MarshalCBOR() ([]byte, error)
- func (s Profile) MarshalJSON() ([]byte, error)
- func (s *Profile) Set(urlOrOID string) error
- func (s *Profile) UnmarshalCBOR(data []byte) error
- func (s *Profile) UnmarshalJSON(data []byte) error
- type SecurityLevel
- type StringOrURI
- func (s *StringOrURI) FromString(value string) error
- func (s *StringOrURI) FromURL(value *url.URL)
- func (s StringOrURI) IsURI() bool
- func (s StringOrURI) MarshalCBOR() ([]byte, error)
- func (s StringOrURI) MarshalJSON() ([]byte, error)
- func (s StringOrURI) String() string
- func (s StringOrURI) ToURL() (*url.URL, error)
- func (s *StringOrURI) UnmarshalCBOR(data []byte) error
- func (s *StringOrURI) UnmarshalJSON(data []byte) error
- type Submod
- type Submods
- type UEID
- type Version
Examples ¶
Constants ¶
const ( // DebugNotDisabled is asserted if any debug facility, even manufacturer // hardware diagnostics, is currently enabled DebugNotDisabled = iota // DebugDisabled indicates all debug facilities are currently disabled. It // may be possible to enable them in the future, and it may also be possible // that they were enabled in the past after the target device/sub-system // booted/started, but they are currently disabled. DebugDisabled // DebugDisabledSinceBoot indicates all debug facilities are currently // disabled and have been so since the target device/sub-system // booted/started. DebugDisabledSinceBoot // DebugPermanentDisable indicates all non-manufacturer facilities are // permanently disabled such that no end user or developer cannot enable // them. Only the manufacturer indicated in the OEMID claim can enable them. // This also indicates that all debug facilities are currently disabled and // have been so since boot/start. DebugPermanentDisable // DebugFullPermanentDisable indicates that all debug capabilities for the // target device/sub-module are permanently disabled. DebugFullPermanentDisable )
const ( MinNonceSize = 8 MaxNonceSize = 64 )
nonce-type = bstr .size (8..64)
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 ( // There is some expectation that implementer will protect the // attestation signing keys at this level. Otherwise, the EAT // provides no meaningful security assurance. SecLevelUnrestricted = iota // Enties at this level should not be general-purpose operating // environments that host features such as app download systems, web // browsers, and complex productivity applications. It is akin to the // Secure Restricted level (see below) without the security orientation. // E.g. a Wi-Fi subsystem, an IoT camera, or a sensor device. SecLevelRestricted // Entities at this level must meet the criteria defined by FIDO // Allowed Restricted Operating Environments [1]. Examples include TEE's // and schemes using virtualization-based security. Like the FIDO // security goal, security at this level is aimed defending well // against large-scale network / remote attacks against the device. // // [1] https://fidoalliance.org/specs/fido-security-requirements-v1.0-fd-20170524/ // fido-authenticator-allowed-restricted-operating-environments-list_20170524.pdf SecLevelSecureRestricted // Entities at this level must include substantial defense against // physical or electrical attacks against the device itself. It is // assumed any potential attacker has captured the device and can // disassemble it. Examples include TPMs and Secure Elements. SecLevelHardware )
security-level-type = &(
unrestricted: 1, restricted: 2, secure-restricted: 3, hardware: 4
)
const ( UEIDTypeInvalid = iota // This is a 128, 192 or 256 bit random number generated once and // stored in the device. This may be constructed by concatenating // enough identifiers to make up an equivalent number of random bits // and then feeding the concatenation through a cryptographic hash // function. It may also be a cryptographic quality random number // generated once at the beginning of the life of the device and // stored. It may not be smaller than 128 bits. UEIDTypeRAND // This makes use of the IEEE company identification registry. An EUI // is either an EUI-48, EUI-60 or EUI-64 and made up of an OUI, OUI-36 // or a CID, different registered company identifiers, and some unique // per-device identifier. EUIs are often the same as or similar to MAC // addresses. This type includes MAC-48, an obsolete name for EUI-48. // (Note that while devices with multiple network interfaces may have // multiple MAC addresses, there is only one UEID for a device) UEIDTypeEUI // This is a 14-digit identifier consisting of an 8-digit Type // Allocation Code and a 6-digit serial number allocated by the // manufacturer, which SHALL be encoded as byte string of length 14 // with each byte as the digit's value (not the ASCII encoding of the // digit; the digit 3 encodes as 0x03, not 0x33). The IMEI value // encoded SHALL NOT include Luhn checksum or SVN information. UEIDTypeIMEI )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Audience ¶
type Audience []StringOrURI
In the general case, the "aud" value is an array of case- sensitive strings, each containing a StringOrURI value. In the special case when the JWT has one audience, the "aud" value MAY be a single case-sensitive string containing a StringOrURI value.
func (Audience) MarshalCBOR ¶
MarshalCBOR encodes Audience as a StringOrURI, in case there is only one, or an array of StringOrURI's if there are multiple.
func (Audience) MarshalJSON ¶
MarshalJSON encodes the receiver Audience as a JSON string
func (*Audience) UnmarshalCBOR ¶
UnmarshalCBOR decodes audience claim data. This may be a single StringOrURI, or an array of such.
func (*Audience) UnmarshalJSON ¶
UnmarshalJSON decodes a JSON string into the receiver Audience
type COSEKey ¶
type COSEKey struct {
Type cose.KeyType `cbor:"1,keyasint" json:"kty"`
ID []byte `cbor:"2,keyasint,omitempty" json:"kid,omitempty"`
Algorithm cose.Algorithm `cbor:"3:keyasint,omitempty" json:"alg,omitempty"`
Ops []cose.KeyOp `cbor:"4,keyasint,omitempty" json:"ops,omitempty"`
BaseIV []byte `cbor:"5,keyasint,omitempty"`
// Additional parameter pairs for OKP and EC2.
Crv cose.Curve `cbor:"-1,keyasint,omitempty" json:"crv,omitempty"`
X []byte `cbor:"-2,keyasint,omitempty" json:"x,omitempty"`
Y []byte `cbor:"-3,keyasint,omitempty" json:"y,omitempty"`
D []byte `cbor:"-4,keyasint,omitempty" json:"d,omitempty"`
}
NOTE: supports only OKP and EC2 key
COSE_Key = {
1 => tstr / int, ; kty
? 2 => bstr, ; kid
? 3 => tstr / int, ; alg
? 4 => [+ (tstr / int) ], ; key_ops
? 5 => bstr, ; Base IV
* label => values
}
type CWTClaims ¶
type CWTClaims struct {
Issuer *string `cbor:"1,keyasint,omitempty" json:"iss,omitempty"`
Subject *string `cbor:"2,keyasint,omitempty" json:"sub,omitempty"`
Audience *Audience `cbor:"3,keyasint,omitempty" json:"aud,omitempty"`
Expiration *NumericDate `cbor:"4,keyasint,omitempty" json:"exp,omitempty"`
NotBefore *NumericDate `cbor:"5,keyasint,omitempty" json:"nbf,omitempty"`
IssuedAt *NumericDate `cbor:"6,keyasint,omitempty" json:"iat,omitempty"`
CwtID *[]byte `cbor:"7,keyasint,omitempty" json:"cti,omitempty"`
Cnf *KeyConfirmation `cbor:"8,keyasint,omitempty" json:"cnf,omitempty"`
}
Defined by RFC8392
type ComponentID ¶
type Eat ¶
type Eat struct {
Nonce *Nonce `cbor:"10,keyasint,omitempty" json:"eat_nonce,omitempty"`
UEID *UEID `cbor:"256,keyasint,omitempty" json:"ueid,omitempty"`
// TODO: support SUEIDs
// TODO: support oemid-pem = int type
OemID *[]byte `cbor:"258,keyasint,omitempty" json:"oemid,omitempty"`
HardwareModel *[]byte `cbor:"259,keyasint,omitempty" json:"hwmodel,omitempty"`
HardwareVersion *Version `cbor:"260,keyasint,omitempty" json:"hwversion,omitempty"`
Uptime *uint `cbor:"261,keyasint,omitempty" json:"uptime,omitempty"`
OemBoot *bool `cbor:"262,keyasint,omitempty" json:"oemboot,omitempty"`
DebugStatus *Debug `cbor:"263,keyasint,omitempty" json:"dbgstat,omitempty"`
Location *Location `cbor:"264,keyasint,omitempty" json:"location,omitempty"`
Profile *Profile `cbor:"265,keyasint,omitempty" json:"eat-profile,omitempty"`
Submods *Submods `cbor:"266,keyasint,omitempty" json:"submods,omitempty"`
BootCount *uint `cbor:"267,keyasint,omitempty" json:"bootcount,omitempty"`
BootSeed *[]byte `cbor:"268,keyasint,omitempty" json:"bootseed,omitempty"`
// TODO: DLOAs
SoftwareName *StringOrURI `cbor:"270,keyasint,omitempty" json:"swname,omitempty"`
SoftwareVersion *Version `cbor:"271,keyasint,omitempty" json:"swversion,omitempty"`
Manifests *[]Manifest `cbor:"272,keyasint,omitempty" json:"manifests,omitempty"`
Measurements *[]Measurement `cbor:"273,keyasint,omitempty" json:"measurements,omitempty"`
// TODO: MeasrementResults
// TODO: IntendedUse
CWTClaims
}
Eat is the internal representation of a EAT token
func (*Eat) FromJSON ¶
FromJSON deserializes the supplied JSON encoded EAT into the receiver Eat
Example ¶
t := Eat{}
data := []byte(`{"eat_nonce":"AAAAAAAAAAA="}`)
if err := t.FromJSON(data); err != nil {
panic(err)
}
if err := t.Nonce.Validate(); err != nil {
panic(err)
}
fmt.Printf("nonces found: %d\n", t.Nonce.Len())
fmt.Printf("nonce: %x\n", t.Nonce.GetI(0))
Output: nonces found: 1 nonce: 0000000000000000
func (Eat) ToJSON ¶
ToJSON serializes the receiver Eat into JSON encoded EAT
Example ¶
nonce := Nonce{}
if err := nonce.AddHex("0000000000000000"); err != nil {
panic(err)
}
// if required by the use case, add more nonces
t := Eat{
Nonce: &nonce,
}
j, err := t.ToJSON()
if err != nil {
panic(err)
}
fmt.Println(string(j))
Output: {"eat_nonce":"AAAAAAAAAAA="}
type KeyConfirmation ¶
type KeyConfirmation struct {
Key *COSEKey `cbor:"1,keyasint,omitempty" json:"jwk,omitempty"`
// TODO: EncryptedKey (currently go-cose doesn't support COSE_Encrypt0 / COSE_Encrypt)
Kid *[]byte `cbor:"3,keyasint,omitempty" json:"kid,omitempty"`
KeyThumbprint *[]byte `cbor:"5,keyasint,omitempty" json:"jkt,omitempty"`
}
type Location ¶
type Location struct {
Latitude Number `cbor:"1,keyasint" json:"lat"`
Longitude Number `cbor:"2,keyasint" json:"long"`
Altitude *Number `cbor:"3,keyasint,omitempty" json:"alt,omitempty"`
Accuracy *Number `cbor:"4,keyasint,omitempty" json:"accry,omitempty"`
AltitudeAccuracy *Number `cbor:"5,keyasint,omitempty" json:"alt-accry,omitempty"`
Heading *Number `cbor:"6,keyasint,omitempty" json:"heading,omitempty"`
Speed *Number `cbor:"7,keyasint,omitempty" json:"speed,omitempty"`
Timestamp *NumericDate `cbor:"8,keyasint,omitempty" json:"timestamp,omitempty"`
Age *uint `cbor:"9,keyasint,omitempty" json:"age,omitempty"`
}
Location models the location claim
type Manifest ¶
type Manifest struct {
Type int // coap-content-format, see https://www.iana.org/assignments/core-parameters/core-parameters.xhtml
Format []byte // bstr wrapped untagged-coswid, ...
// contains filtered or unexported fields
}
type MeasuredComponent ¶
type MeasuredComponent struct {
Id ComponentID `cbor:"1,keyasint" json:"id"`
Measurement *swid.HashEntry `cbor:"2,keyasint,omitempty" json:"measurement,omitempty"`
Signers *[][]byte `cbor:"3,keyasint,omitempty" json:"signers,omitempty"`
Flags *[]byte `cbor:"4,keyasint,omitempty" json:"flags,omitempty"`
RawMeasurement *[]byte `cbor:"5,keyasint,omitempty" json:"raw-measurement,omitempty"`
}
type Measurement ¶
type Measurement struct {
Type int // coap-content-format, see https://www.iana.org/assignments/core-parameters/core-parameters.xhtml
Format []byte // bstr wrapped untagged-coswid, measured-component, ...
// contains filtered or unexported fields
}
type Nonce ¶
type Nonce []nonce
A nonce-claim may be single Nonce or an array of two or more.
nonce-claim = (
nonce => nonce-type / [ 2* nonce-type ]
)
func (*Nonce) AddHex ¶
AddHex provides the same functionality as Add except it takes the nonce value as a hex-encoded string.
func (Nonce) GetI ¶
GetI returns the nonce found at the supplied index (counting from 0) or nil if the index is out of bounds.
func (Nonce) MarshalCBOR ¶
MarshalCBOR provides a suitable CBOR encoding for the receiver Nonce. In case there is only one nonce, the encoded produces a single bstr. If there are multiple, the encoder produces an array of bstr, one for each nonce.
func (Nonce) MarshalJSON ¶
MarshalJSON encodes the receiver Nonce as either a JSON string containing the base64 encoding of the binary nonce (if the array comprises only one element) or as an array of base64-encoded JSON strings.
func (*Nonce) UnmarshalCBOR ¶
UnmarshalCBOR decodes a EAT nonce. This may be a single byte string between 8 and 64 bytes long, or an array of two or more such strings.
func (*Nonce) UnmarshalJSON ¶
UnmarshalJSON decodes a EAT nonce in JSON format.
type Number ¶
type Number float64
Number models a CDDL number, i.e.:
uint / nint / float16 / float32 / float64
func (Number) MarshalCBOR ¶
MarshalCBOR encodes a Number using the smallest possible encoding. Note that choosing the smallest fitting float variant is decided by the encoding mode defined in cbor.go which is configured to use ShortestFloat == ShortestFloat16. What remains to be done here is intercepting the uint / nint cases and dispatch them to the default int marshaler.
type NumericDate ¶
NumericDate models RFC7519 NumericDate, i.e., the number of seconds since UNIX epoch
func (NumericDate) MarshalCBOR ¶
func (nd NumericDate) MarshalCBOR() ([]byte, error)
MarshalCBOR unwraps the receiver NumericDate exposing its underlying Time and dispatches it to our custom encoding mode, which automatically adds the required tag (TimeTag == cbor.EncTagRequired)
func (NumericDate) MarshalJSON ¶
func (nd NumericDate) MarshalJSON() ([]byte, error)
MarshalJSON unwraps the receiver NumericDate exposing its underlying Time and converts it to UNIX time.
func (*NumericDate) UnmarshalCBOR ¶
func (nd *NumericDate) UnmarshalCBOR(data []byte) error
UnmarshalCBOR decodes the data into a Time and sets the receiver NumericDate to the decoded value.
func (*NumericDate) UnmarshalJSON ¶
func (nd *NumericDate) UnmarshalJSON(data []byte) error
UnmarshalJSON populates the receiver NumericDate by interpreting the supplied data as UTF-8-encoded Unix timestamp.
type Profile ¶
type Profile struct {
// contains filtered or unexported fields
}
Profile is either an absolute URI (RFC3986) or an ASN.1 Object Identifier
func NewProfile ¶
NewProfile instantiates a Profile object from the given input string The string can either be an absolute URI or an ASN.1 Object Identifier in dotted-decimal notation. Relative Object Identifiers (e.g., .1.1.29) are not accepted.
func (Profile) MarshalCBOR ¶
MarshalCBOR encodes the Profile object as a CBOR text string (if it is a URL), or as CBOR byte string (if it is an ASN.1 OID)
func (Profile) MarshalJSON ¶
MarshalJSON encodes the receiver Profile into a JSON string
func (*Profile) Set ¶
Set sets the internal value of the Profile object to the given urlOrOID string
func (*Profile) UnmarshalCBOR ¶
UnmarshalCBOR attempts to initialize the Profile from the presented CBOR data. The data must be a CBOR text string, representing a URL or a CBOR byte string representing an Object Identifier
func (*Profile) UnmarshalJSON ¶
UnmarshalJSON attempts at decoding the supplied JSON data into the receiver Profile
type SecurityLevel ¶
type SecurityLevel uint
Security Level claim type
func (SecurityLevel) Validate ¶
func (s SecurityLevel) Validate() error
Validate SecLevel to make sure is with thin bounds allowed by the spec.
type StringOrURI ¶
type StringOrURI struct {
// contains filtered or unexported fields
}
StringOrURI is either an arbitrary text string or a RFC3986 compliant URI.
string-or-uri = tstr / uri
func (*StringOrURI) FromString ¶
func (s *StringOrURI) FromString(value string) error
FromString initializes the StringOrURI value from the specified string, overwriting any existing value. If the value contains a colon (":"), then an attempt will be made to parse it as a URI (see RFC7519, section 2), otherwise, the value is assumed to be a non-URI string.
func (*StringOrURI) FromURL ¶
func (s *StringOrURI) FromURL(value *url.URL)
FromURL initializes the StringOrURI value from the specified url.URL, overwriting any existing value.
func (StringOrURI) IsURI ¶
func (s StringOrURI) IsURI() bool
IsURI returns true iff the underlying value is a URI and not a string. NOTE: this only indicates whether the value was set as such -- it possible
that the arbitrary string value happens to be a valid URI, however, if it was not set as such, this will return false.
func (StringOrURI) MarshalCBOR ¶
func (s StringOrURI) MarshalCBOR() ([]byte, error)
MarshalCBOR will encode the StringOrURI value as a CBOR text string, wrapping it in Tag 32, if it's a URI. See RFC7049, Section 2.4.4.3.
func (StringOrURI) MarshalJSON ¶
func (s StringOrURI) MarshalJSON() ([]byte, error)
MarshalJSON encodes the receiver StringOrURI into a JSON string
func (StringOrURI) String ¶
func (s StringOrURI) String() string
String returns the string representation of the StringOrURI value.
func (StringOrURI) ToURL ¶
func (s StringOrURI) ToURL() (*url.URL, error)
ToURL will return the url.URL representation of the underlying value, if possible. This will attempt to parse the underlying string value as a URL if it isn't one already.
func (*StringOrURI) UnmarshalCBOR ¶
func (s *StringOrURI) UnmarshalCBOR(data []byte) error
UnmarshalCBOR attempts to initializes the StringOrURI from the presented CBOR data. The data must be a text string, possibly wrapped in a Tag with the value 32 (URI). See RFC7049, Section 2.4.4.3.
func (*StringOrURI) UnmarshalJSON ¶
func (s *StringOrURI) UnmarshalJSON(data []byte) error
UnmarshalJSON attempts at decoding the supplied JSON data into the receiver StringOrURI
type Submod ¶
type Submod struct {
// contains filtered or unexported fields
}
Submod is the type of a submod: either a raw EAT (wrapped in a Sign1 CWT), or a map of EAT claims
func (Submod) MarshalCBOR ¶
MarshalCBOR encodes the submod value wrapped in the Submod receiver to CBOR
func (Submod) MarshalJSON ¶
MarshalJSON encodes the submod value wrapped in the Submod receiver to JSON
func (*Submod) UnmarshalCBOR ¶
UnmarshalCBOR attempts to decode the supplied CBOR data into the Submod receiver, peeking into the stream to choose between one of the two target formats (i.e., eat-token or eat-claims)
func (*Submod) UnmarshalJSON ¶
UnmarshalJSON attempts to decode the supplied JSON data into the Submod receiver, peeking into the stream to choose between one of the two target formats (i.e., eat-token or eat-claims)
type Submods ¶
Submods models the submods type
type Version ¶
type Version struct {
Version string
Scheme *swid.VersionScheme
// contains filtered or unexported fields
}