opyeb cborlab

cborlab · COSE

COSE_Sign1 and signature verification

What the four slots of Tag 18 hold, and how the signature is computed from the Sig_structure.

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

SlotTypeContents
0bstrprotected header - an encoded CBOR map in a byte string
1mapunprotected header - values that are not protected
2bstr or nullpayload - the signed body, null when detached
3bstrsignature - 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

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.

Open the tool

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.