Skip to content

Commit bb5a467

Browse files
c2botplookerpaulbastian
authored
311 cbor tag (#316)
* remove cose_sign1 tag from examples * add text requiring support for untagged CWT form * tweak language around CBOR tag * further update to language * further tweak * Update draft-ietf-oauth-status-list.md * Update draft-ietf-oauth-status-list.md --------- Co-authored-by: Tobias Looker <[email protected]> Co-authored-by: Paul Bastian <[email protected]>
1 parent af0fcf9 commit bb5a467

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

draft-ietf-oauth-status-list.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ The following is a non-normative example of a Status List Token in JWT format:
445445

446446
## Status List Token in CWT Format {#status-list-token-cwt}
447447

448-
The Status List Token MUST be encoded as a "CBOR Web Token (CWT)" according to {{RFC8392}}.
448+
The Status List Token MUST be encoded as a "CBOR Web Token (CWT)" according to {{RFC8392}}. The Status List Token MUST not be tagged with the tags defined in section 6 of {{RFC8392}} or in section 2 of {{RFC9052}}.
449449

450450
The following content applies to the protected header of the CWT:
451451

@@ -463,11 +463,11 @@ The following additional rules apply:
463463

464464
1. The CWT MAY contain other claims.
465465

466-
2. The CWT MUST be secured using a cryptographic signature or MAC algorithm. Relying Parties MUST reject CWTs with an invalid signature.
466+
1. The CWT MUST be secured using a cryptographic signature or MAC algorithm. Relying Parties MUST reject CWTs with an invalid signature.
467467

468-
3. Relying Parties MUST reject CWTs that are not valid in all other respects per "CBOR Web Token (CWT)" {{RFC8392}}.
468+
1. Relying Parties MUST reject CWTs that are not valid in all other respects per "CBOR Web Token (CWT)" {{RFC8392}}.
469469

470-
4. Application of additional restrictions and policies are at the discretion of the Relying Party.
470+
1. Application of additional restrictions and policies are at the discretion of the Relying Party.
471471

472472
The following is a non-normative example of a Status List Token in CWT format in Hex:
473473

@@ -1968,6 +1968,7 @@ CBOR encoding:
19681968

19691969
-14
19701970

1971+
* remove cose_sign1 tag from statuslist in cwt form examples
19711972
* slightly restructure/clarify referenced token cose section
19721973
* Add ASN.1 module
19731974

src/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
git+https://github.com/wbond/oscrypto.git@1547f535001ba568b239b8797465536759c742a3
33
# Normal dependencies
44
jwcrypto==1.5.6
5-
cbor2==5.6.2
6-
cwt==2.7.4
5+
cbor2==5.7.1
6+
cwt==3.2.0
77
py_markdown_table==1.3.0

src/status_token.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import json
2-
from datetime import datetime, timedelta
2+
from datetime import UTC, datetime, timedelta
33
from typing import Dict
44

5-
from cbor2 import dumps
5+
from cbor2 import CBORTag, dumps
66
from cwt import COSE, COSEHeaders, COSEKey, CWTClaims
77
from jwcrypto import jwk, jwt
88

@@ -77,7 +77,7 @@ def get(self, pos: int) -> int:
7777

7878
def buildJWT(
7979
self,
80-
iat: datetime = datetime.utcnow(),
80+
iat: datetime = datetime.now(UTC),
8181
exp: datetime | None = None,
8282
ttl: timedelta | None = None,
8383
optional_claims: Dict | None = None,
@@ -115,7 +115,7 @@ def buildJWT(
115115

116116
def buildCWT(
117117
self,
118-
iat: datetime = datetime.utcnow(),
118+
iat: datetime = datetime.now(UTC),
119119
exp: datetime | None = None,
120120
ttl: timedelta | None = None,
121121
optional_claims: Dict | None = None,
@@ -158,10 +158,12 @@ def buildCWT(
158158
# The sender side:
159159
sender = COSE.new()
160160
encoded = sender.encode(
161-
dumps(claims),
162-
key,
161+
payload=dumps(claims),
162+
key=key,
163163
protected=protected_header,
164164
unprotected=unprotected_header,
165165
)
166166

167+
# removes cose_sign1 tag (only 1 byte long for tag 18)
168+
encoded = encoded[1:]
167169
return encoded

0 commit comments

Comments
 (0)