COSE_Sign1 and signature verification
COSE writes signed and encrypted messages as CBOR. COSE_Sign1 carries the signature of one signer: a four-element array wrapped in tag 18.
The four slots
| Slot | Type | Contents |
|---|---|---|
| 0 | bstr | protected header - an encoded CBOR map in a byte string |
| 1 | map | unprotected header - values that are not protected |
| 2 | bstr or null | payload - the signed body, null when detached |
| 3 | bstr | signature - the signature value |
The header is split so that only part of it is signed. The protected part is a byte string and goes into the signature input unchanged; the unprotected part carries values that may change in transit, such as a certificate chain used to find the key.
Header labels that matter
- 1
alg- the signature algorithm: ES256 is -7, EdDSA -8, ES384 -35, ES512 -36, PS256 -37, RS256 -257. - 2
crit- labels a receiver must understand or reject the message - 3
content type- the media type or CoAP content format of the payload - 4
kid- a key identifier, often a byte string - 33
x5chain- a certificate chain, with 32x5bag, 34x5tand 35x5ualongside
The signed input: Sig_structure
The signature covers a CBOR array, not the payload alone. The first element is the string "Signature1", and in this profile external_aad is an empty byte string.
Sig_structure = [ "Signature1", protected_bstr, h'', payload_bstr ]
So any change to the protected header breaks the signature. This tool reads the protected bstr and payload bstr straight from the input, rebuilds the Sig_structure and verifies it with the public key.
CWT claims
When the payload is a tag 61 (CWT) map or a map with integer labels, it is read as RFC 8392 claims: 1 iss, 2 sub, 3 aud, 4 exp, 5 nbf, 6 iat, 7 cti. exp, nbf and iat are epoch seconds, so a readable time is shown beside them.
A valid signature says the holder of the key approved these bytes. Whether the key itself can be trusted, and whether its certificate was revoked, is a separate question this tool does not answer.
Questions
Is Tag 18 required?
No. A four-element array typed [bstr, map, bstr|null, bstr] is read as a bare COSE_Sign1 the same way.
Which algorithms are verified?
ES256, ES384, ES512 (ECDSA), EdDSA (Ed25519), PS256, PS384, PS512 (RSA-PSS) and RS256, RS384, RS512 through WebCrypto. The HMAC family needs a shared secret and is not handled here.
Which key formats are accepted?
JWK JSON or an SPKI PEM. The key is used in page memory only and is never stored.
The cose-es256 preset is an ES256-signed CWT and cose-eddsa an EdDSA-signed JSON payload, each shipped with its public key.
Written against RFC 8949 (CBOR), RFC 9052 (COSE), RFC 8392 (CWT) and the IANA COSE algorithm registry. Every byte string and key here is synthetic.