11import secrets
2- import typing as t
2+ from typing import Any , Union
33
44from .models import (
55 CompactEncryption ,
3333 "perform_decrypt" ,
3434]
3535
36- EncryptionData = t . Union [CompactEncryption , GeneralJSONEncryption , FlattenedJSONEncryption ]
36+ EncryptionData = Union [CompactEncryption , GeneralJSONEncryption , FlattenedJSONEncryption ]
3737
3838
3939def perform_encrypt (obj : EncryptionData , registry : JWERegistry ) -> None :
@@ -137,10 +137,10 @@ def _perform_decrypt(obj: EncryptionData, registry: JWERegistry) -> None:
137137
138138
139139def pre_encrypt_recipients (
140- enc : JWEEncModel , recipients : list [Recipient [t . Any ]], registry : JWERegistry
141- ) -> tuple [bytes , list [tuple [JWEKeyAgreement , Recipient [t . Any ]]]]:
140+ enc : JWEEncModel , recipients : list [Recipient [Any ]], registry : JWERegistry
141+ ) -> tuple [bytes , list [tuple [JWEKeyAgreement , Recipient [Any ]]]]:
142142 cek : bytes = b""
143- delayed_tasks : list [tuple [JWEKeyAgreement , Recipient [t . Any ]]] = []
143+ delayed_tasks : list [tuple [JWEKeyAgreement , Recipient [Any ]]] = []
144144 for recipient in recipients :
145145 alg = __prepare_recipient_algorithm (recipient , registry )
146146
@@ -167,7 +167,7 @@ def pre_encrypt_recipients(
167167 return cek , delayed_tasks
168168
169169
170- def __prepare_recipient_algorithm (recipient : Recipient [t . Any ], registry : JWERegistry ) -> JWEAlgModel :
170+ def __prepare_recipient_algorithm (recipient : Recipient [Any ], registry : JWERegistry ) -> JWEAlgModel :
171171 headers = recipient .headers ()
172172 registry .check_header (headers )
173173 # 1. Determine the Key Management Mode employed by the algorithm used
@@ -181,7 +181,7 @@ def __prepare_recipient_algorithm(recipient: Recipient[t.Any], registry: JWERegi
181181 return alg
182182
183183
184- def __pre_encrypt_direct_mode (alg : JWEAlgModel , enc : JWEEncModel , recipient : Recipient [t . Any ]) -> bytes :
184+ def __pre_encrypt_direct_mode (alg : JWEAlgModel , enc : JWEEncModel , recipient : Recipient [Any ]) -> bytes :
185185 cek : bytes
186186 if isinstance (alg , JWEKeyAgreement ):
187187 # 3. When Direct Key Agreement is employed,
@@ -202,7 +202,7 @@ def __pre_encrypt_direct_mode(alg: JWEAlgModel, enc: JWEEncModel, recipient: Rec
202202
203203
204204def post_encrypt_recipients (
205- enc : JWEEncModel , tasks : list [tuple [JWEKeyAgreement , Recipient [t . Any ]]], cek : bytes , tag : bytes
205+ enc : JWEEncModel , tasks : list [tuple [JWEKeyAgreement , Recipient [Any ]]], cek : bytes , tag : bytes
206206) -> None :
207207 for alg , recipient in tasks :
208208 if alg .tag_aware :
@@ -214,7 +214,7 @@ def post_encrypt_recipients(
214214 recipient .encrypted_key = alg .wrap_cek_with_auk (cek , agreed_upon_key )
215215
216216
217- def decrypt_recipient (alg : JWEAlgModel , enc : JWEEncModel , recipient : Recipient [t . Any ], tag : bytes ) -> bytes :
217+ def decrypt_recipient (alg : JWEAlgModel , enc : JWEEncModel , recipient : Recipient [Any ], tag : bytes ) -> bytes :
218218 cek : bytes
219219 if alg .direct_mode :
220220 # 10. When Direct Key Agreement or Direct Encryption are employed,
0 commit comments