Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Unreleased
- ``CWT.decode()`` now checks the CWT Claims header parameter in unprotected headers and in every COSE layer of a nested CWT, not only in the protected header of the innermost layer.
- ``CWT.decode()`` now requires header and payload claim values to be identical CBOR data items (e.g. ``1``, ``1.0`` and ``True`` no longer compare equal), as RFC 9597 requires.
- ``CWT.decode()`` now raises ``ValueError`` if the CWT Claims header parameter is not a map or occurs in both the protected and unprotected headers.
- Follow RFC 9864 (Fully-Specified Algorithms for JOSE and COSE), formerly draft-ietf-jose-fully-specified-algorithms-13.
- Add Ed25519 and Ed448 to supported JOSE algorithms.
- Mark EdDSA, ES256, ES384 and ES512 as deprecated in docs.
- Use Ed25519 instead of EdDSA in README examples.

Version 3.3.0
-------------
Expand Down
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ implementation compliant with:
- [RFC8392: CWT (CBOR Web Token)](https://tools.ietf.org/html/rfc8392)
- [RFC9597: CBOR Web Token (CWT) Claims in COSE Headers](https://www.rfc-editor.org/rfc/rfc9597.html)
- [draft-23: Use of HPKE with COSE](https://www.ietf.org/archive/id/draft-ietf-cose-hpke-23.html) - experimental
- [draft-13: Fully-Specified Algorithms for JOSE and COSE](https://www.ietf.org/archive/id/draft-ietf-jose-fully-specified-algorithms-13.html)
- [RFC9864: Fully-Specified Algorithms for JSON Object Signing and Encryption (JOSE) and CBOR Object Signing and Encryption (COSE)](https://www.rfc-editor.org/rfc/rfc9864.html)
- and related various specifications. See [Referenced Specifications](#referenced-specifications).

It is designed to make users who already know about [JWS](https://tools.ietf.org/html/rfc7515)/[JWE](https://tools.ietf.org/html/rfc7516)/[JWT](https://tools.ietf.org/html/rfc7519)
Expand Down Expand Up @@ -254,7 +254,7 @@ notary = Signer.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
"d": "L8JS08VsFZoZxGa9JvzYmCWOwg7zaKcei3KZmYsj7dc",
},
Expand All @@ -267,7 +267,7 @@ pub_key = COSEKey.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
},
)
Expand All @@ -278,7 +278,7 @@ try:
except Exception as err:
pytest.fail(f"failed to verify: {err}")
countersignature = COSEMessage.from_cose_signature(sig)
assert countersignature.protected[1] == -8 # alg: "EdDSA"
assert countersignature.protected[1] == -19 # alg: "Ed25519"
assert countersignature.unprotected[4] == b"01" # kid: b"01"
```

Expand Down Expand Up @@ -491,7 +491,7 @@ notary = Signer.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
"d": "L8JS08VsFZoZxGa9JvzYmCWOwg7zaKcei3KZmYsj7dc",
},
Expand All @@ -504,7 +504,7 @@ pub_key = COSEKey.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
},
)
Expand All @@ -515,7 +515,7 @@ try:
except Exception as err:
pytest.fail(f"failed to verify: {err}")
countersignature = COSEMessage.from_cose_signature(sig)
assert countersignature.protected[1] == -8 # alg: "EdDSA"
assert countersignature.protected[1] == -19 # alg: "Ed25519"
assert countersignature.unprotected[4] == b"01" # kid: b"01"
```

Expand Down Expand Up @@ -637,7 +637,7 @@ notary = Signer.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
"d": "L8JS08VsFZoZxGa9JvzYmCWOwg7zaKcei3KZmYsj7dc",
},
Expand All @@ -650,7 +650,7 @@ pub_key = COSEKey.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
},
)
Expand All @@ -661,7 +661,7 @@ try:
except Exception as err:
pytest.fail(f"failed to verify: {err}")
countersignature = COSEMessage.from_cose_signature(sig)
assert countersignature.protected[1] == -8 # alg: "EdDSA"
assert countersignature.protected[1] == -19 # alg: "Ed25519"
assert countersignature.unprotected[4] == b"01" # kid: b"01"
```

Expand Down Expand Up @@ -990,7 +990,7 @@ notary = Signer.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
"d": "L8JS08VsFZoZxGa9JvzYmCWOwg7zaKcei3KZmYsj7dc",
},
Expand All @@ -1003,7 +1003,7 @@ pub_key = COSEKey.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
},
)
Expand All @@ -1015,7 +1015,7 @@ try:
except Exception as err:
pytest.fail(f"failed to verify: {err}")
countersignature = COSEMessage.from_cose_signature(sig)
assert countersignature.protected[1] == -8 # alg: "EdDSA"
assert countersignature.protected[1] == -19 # alg: "Ed25519"
assert countersignature.unprotected[4] == b"01" # kid: b"01"
```

Expand Down Expand Up @@ -1139,7 +1139,7 @@ notary = Signer.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
"d": "L8JS08VsFZoZxGa9JvzYmCWOwg7zaKcei3KZmYsj7dc",
},
Expand All @@ -1161,7 +1161,7 @@ notary_pub_key = COSEKey.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
},
)
Expand All @@ -1172,7 +1172,7 @@ try:
except Exception as err:
pytest.fail(f"failed to verify: {err}")
countersignature = COSEMessage.from_cose_signature(sig)
assert countersignature.protected[1] == -8 # alg: "EdDSA"
assert countersignature.protected[1] == -19 # alg: "Ed25519"
assert countersignature.unprotected[4] == b"01" # kid: b"01"
```

Expand Down Expand Up @@ -1242,7 +1242,7 @@ notary = Signer.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
"d": "L8JS08VsFZoZxGa9JvzYmCWOwg7zaKcei3KZmYsj7dc",
},
Expand All @@ -1264,7 +1264,7 @@ notary_pub_key = COSEKey.from_jwk(
"kid": "01",
"kty": "OKP",
"crv": "Ed25519",
"alg": "EdDSA",
"alg": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
},
)
Expand All @@ -1276,7 +1276,7 @@ try:
except Exception as err:
pytest.fail(f"failed to verify: {err}")
countersignature = COSEMessage.from_cose_signature(sig)
assert countersignature.protected[1] == -8 # alg: "EdDSA"
assert countersignature.protected[1] == -19 # alg: "Ed25519"
assert countersignature.unprotected[4] == b"01" # kid: b"01"
```

Expand Down Expand Up @@ -1384,7 +1384,7 @@ private_key = COSEKey.from_jwk(
"kid": "01",
"kty": "OKP",
"key_ops": ["sign"],
"alg": "EdDSA",
"alg": "Ed25519",
"crv": "Ed25519",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
"d": "L8JS08VsFZoZxGa9JvzYmCWOwg7zaKcei3KZmYsj7dc",
Expand Down Expand Up @@ -1646,7 +1646,7 @@ token = cwt.encode(
"crv": "Ed25519",
"kid": "presenter-01",
"x": "2E6dX83gqD_D0eAmqnaHe1TC1xuld6iAKXfw2OVATr0",
"alg": "EdDSA",
"alg": "Ed25519",
},
},
},
Expand Down Expand Up @@ -1822,7 +1822,7 @@ Python CWT is (partially) compliant with following specifications:
- [RFC9597: CBOR Web Token (CWT) Claims in COSE Headers](https://www.rfc-editor.org/rfc/rfc9597.html)
- [RFC8152: CBOR Object Signing and Encryption (COSE)](https://tools.ietf.org/html/rfc8152)
- [draft-23: Use of HPKE with COSE](https://www.ietf.org/archive/id/draft-ietf-cose-hpke-23.html) - experimental
- [draft-13: Fully-Specified Algorithms for JOSE and COSE](https://www.ietf.org/archive/id/draft-ietf-jose-fully-specified-algorithms-13.html)
- [RFC9864: Fully-Specified Algorithms for JSON Object Signing and Encryption (JOSE) and CBOR Object Signing and Encryption (COSE)](https://www.rfc-editor.org/rfc/rfc9864.html)
- [Electronic Health Certificate Specification](https://github.com/ehn-dcc-development/hcert-spec/blob/main/hcert_spec.md)
- [Technical Specifications for Digital Green Certificates Volume 1](https://ec.europa.eu/health/sites/default/files/ehealth/docs/digital-green-certificates_v1_en.pdf)

Expand Down
16 changes: 9 additions & 7 deletions cwt/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,20 @@

# COSE Algorithms for Signature with OKP.
COSE_ALGORITHMS_SIG_OKP = {
"EdDSA": -8, # EdDSA
"Ed25519": -19, # EdDSA using Ed25519 curve
"Ed448": -53, # EdDSA using Ed448 curve
"EdDSA": -8, # EdDSA (Deprecated by RFC 9864)
"Ed25519": -19, # EdDSA using the Ed25519 parameter set in Section 5.1 of RFC 8032
"Ed448": -53, # EdDSA using the Ed448 parameter set in Section 5.2 of RFC 8032
}

# COSE Algorithms for Signature with EC2.
COSE_ALGORITHMS_SIG_EC2 = {
"ESP512": -52, # ECDSA using P-521 curve and SHA-512
"ESP384": -51, # ECDSA using P-384 curve and SHA-384
"ES256K": -47, # ECDSA using secp256k1 curve and SHA-256
"ES512": -36, # ECDSA w/ SHA-512 (any curve is not specified but python-cwt uses P-521 curve)
"ES384": -35, # ECDSA w/ SHA-384 (any curve is not specified but python-cwt uses P-384 curve)
"ES512": -36, # ECDSA w/ SHA-512 (Deprecated by RFC 9864; python-cwt uses P-521 curve)
"ES384": -35, # ECDSA w/ SHA-384 (Deprecated by RFC 9864; python-cwt uses P-384 curve)
"ESP256": -9, # ECDSA using P-256 curve and SHA-256
"ES256": -7, # ECDSA w/ SHA-256 (any curve is not specified but python-cwt uses P-256 curve)
"ES256": -7, # ECDSA w/ SHA-256 (Deprecated by RFC 9864; python-cwt uses P-256 curve)
}

# COSE Algorithms for Signature with RSA.
Expand All @@ -303,13 +303,15 @@
"RS512": -259,
"RS384": -258,
"RS256": -257,
"Ed448": -53,
"ES256K": -47,
"PS512": -39,
"PS384": -38,
"PS256": -37,
"ES512": -36,
"ES384": -35,
"EdDSA": -8,
"Ed25519": -19,
"EdDSA": -8, # Deprecated by RFC 9864
"ES256": -7,
"dir": -6,
"A128GCM": 1,
Expand Down
14 changes: 8 additions & 6 deletions docs/algorithms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ COSE Algorithms
+------------------------+--------+-------+-----------------------------------------------------+
| RS256 | ✅ | -257 | RSASSA-PKCS1-v1_5 using SHA-256 |
+------------------------+--------+-------+-----------------------------------------------------+
| Ed448 | ✅ | -53 | EdDSA using Ed448 curve |
| Ed448 | ✅ | -53 | | EdDSA using the Ed448 parameter set in |
| | | | | Section 5.2 of RFC 8032 |
+------------------------+--------+-------+-----------------------------------------------------+
| ESP512 | ✅ | -52 | ECDSA using P-521 curve and SHA-512 |
+------------------------+--------+-------+-----------------------------------------------------+
Expand Down Expand Up @@ -105,9 +106,9 @@ COSE Algorithms
+------------------------+--------+-------+-----------------------------------------------------+
| PS256 | ✅ | -37 | RSASSA-PSS w/ SHA-256 |
+------------------------+--------+-------+-----------------------------------------------------+
| ES512 | ✅ | -36 | ECDSA w/ SHA-512 |
| ES512 | ✅ | -36 | ECDSA w/ SHA-512 (Deprecated) |
+------------------------+--------+-------+-----------------------------------------------------+
| ES384 | ✅ | -35 | ECDSA w/ SHA-384 |
| ES384 | ✅ | -35 | ECDSA w/ SHA-384 (Deprecated) |
+------------------------+--------+-------+-----------------------------------------------------+
| ECDH-SS + A256KW | ✅ | -34 | | ECDH SS w/ Concat KDF and AES Key Wrap |
| | | | | w/ 256-bit key |
Expand Down Expand Up @@ -135,7 +136,8 @@ COSE Algorithms
+------------------------+--------+-------+-----------------------------------------------------+
| ECDH-ES + HKDF-256 | ✅ | -25 | ECDH ES w/ HKDF - generate key directly |
+------------------------+--------+-------+-----------------------------------------------------+
| Ed25519 | ✅ | -19 | EdDSA using Ed25519 curve |
| Ed25519 | ✅ | -19 | | EdDSA using the Ed25519 parameter set in |
| | | | | Section 5.1 of RFC 8032 |
+------------------------+--------+-------+-----------------------------------------------------+
| SHAKE128 | | -18 | SHAKE-128 256-bit Hash Value |
+------------------------+--------+-------+-----------------------------------------------------+
Expand All @@ -157,9 +159,9 @@ COSE Algorithms
+------------------------+--------+-------+-----------------------------------------------------+
| ESP256 | ✅ | -9 | ECDSA using P-256 curve and SHA-256 |
+------------------------+--------+-------+-----------------------------------------------------+
| EdDSA | ✅ | -8 | EdDSA |
| EdDSA | ✅ | -8 | EdDSA (Deprecated) |
+------------------------+--------+-------+-----------------------------------------------------+
| ES256 | ✅ | -7 | ECDSA w/ SHA-256 |
| ES256 | ✅ | -7 | ECDSA w/ SHA-256 (Deprecated) |
+------------------------+--------+-------+-----------------------------------------------------+
| direct | ✅ | -6 | Direct use of CEK |
+------------------------+--------+-------+-----------------------------------------------------+
Expand Down
Loading
Loading