Skip to content

Commit 1e4d1d7

Browse files
committed
fix: move RSA1_5 security warning to its instance
1 parent 8ced1fd commit 1e4d1d7

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/joserfc/_rfc7518/jwe_algs.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ def __init__(self, name: str, description: str, pad_fn: padding.AsymmetricPaddin
6060
self.description = description
6161
self.padding = pad_fn
6262
self.recommended = recommended
63-
if name == "RSA1_5":
64-
self.security_warning = 'JWE algorithm "RSA1_5" is deprecated, via draft-ietf-jose-deprecate-none-rsa15-02'
6563

6664
def encrypt_cek(self, cek: bytes, recipient: Recipient[RSAKey]) -> bytes:
6765
key = recipient.recipient_key
@@ -295,17 +293,17 @@ def decrypt_cek(self, recipient: Recipient[OctKey]) -> bytes:
295293
return self.key_wrapping.unwrap_cek(recipient.encrypted_key, kek)
296294

297295

296+
RSA1_5 = RSAAlgModel("RSA1_5", "RSAES-PKCS1-v1_5", padding.PKCS1v15())
297+
RSA1_5.security_warning = 'JWE algorithm "RSA1_5" is deprecated, via draft-ietf-jose-deprecate-none-rsa15-02'
298+
298299
A128KW = AESAlgModel(128, True) # A128KW, Recommended
299300
A192KW = AESAlgModel(192) # A192KW
300301
A256KW = AESAlgModel(256, True) # A256KW, Recommended
301302

302303

303304
#: https://www.rfc-editor.org/rfc/rfc7518#section-4.1
304305
JWE_ALG_MODELS: list[JWEAlgModel] = [
305-
# Avoid all RSA-PKCS1 v1.5 encryption algorithms ([RFC8017], Section 7.2),
306-
# preferring RSAES-OAEP ([RFC8017], Section 7.1).
307-
# https://www.rfc-editor.org/rfc/rfc8725#section-3.2
308-
RSAAlgModel("RSA1_5", "RSAES-PKCS1-v1_5", padding.PKCS1v15()),
306+
RSA1_5,
309307
RSAAlgModel(
310308
"RSA-OAEP",
311309
"RSAES OAEP using default parameters",

0 commit comments

Comments
 (0)