gose/cose
Typed accessors and builders for COSE message header parameters.
Phantom-state vocabulary
Each COSE message module uses a phantom state type named after the
RFC 9052 operation it performs: Sign1 uses Unsigned/Signed,
Encrypt0 and Encrypt use Unencrypted/Encrypted, Mac0 uses
Untagged/Tagged, and Sign uses Building/Signed for its builder
body. The names match the RFC terminology rather than a single uniform
vocabulary.
Types
Well-known CoAP content format identifiers and media type strings used in the COSE content type header (label 3).
pub type ContentType {
TextPlain
OctetStream
Json
Cbor
Cwt
CoseSign
CoseSign1
CoseEncrypt
CoseEncrypt0
CoseMac
CoseMac0
CoseKey
CoseKeySet
IntContentType(Int)
TextContentType(String)
}
Constructors
-
TextPlain -
OctetStream -
Json -
Cbor -
Cwt -
CoseSign -
CoseSign1 -
CoseEncrypt -
CoseEncrypt0 -
CoseMac -
CoseMac0 -
CoseKey -
CoseKeySet -
IntContentType(Int) -
TextContentType(String)
A COSE header parameter with typed labels and values for well-known
headers, plus an Unknown fallback for non-standard parameters.
pub type Header {
Alg(Int)
Crit(List(Int))
ContentType(ContentType)
Kid(BitArray)
Iv(BitArray)
PartialIv(BitArray)
Unknown(cbor.Value, cbor.Value)
}
Constructors
-
Alg(Int) -
Crit(List(Int)) -
ContentType(ContentType) -
Kid(BitArray) -
Iv(BitArray) -
PartialIv(BitArray) -
Unknown(cbor.Value, cbor.Value)
Values
pub fn algorithm(
headers: List(Header),
) -> Result(Int, gose.GoseError)
Extract the algorithm identifier (label 1).
pub fn content_type(
headers: List(Header),
) -> Result(ContentType, gose.GoseError)
Extract the content type (label 3).
pub fn critical(
headers: List(Header),
) -> Result(List(Int), gose.GoseError)
Extract the critical headers list (label 2).
pub fn iv(
headers: List(Header),
) -> Result(BitArray, gose.GoseError)
Extract the IV (label 5).
pub fn kid(
headers: List(Header),
) -> Result(BitArray, gose.GoseError)
Extract the key ID (label 4).
pub fn partial_iv(
headers: List(Header),
) -> Result(BitArray, gose.GoseError)
Extract the partial IV (label 6).