Skip to content

Commit 42b0289

Browse files
committed
Merge branch 'develop' into python_3_10
2 parents a7a3007 + 815d5b6 commit 42b0289

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

doc/jwe.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ There is a lower level way of doing the same, it will look like this::
4343
>>> from cryptojwt.jwk.rsa import import_private_rsa_key_from_file
4444
>>> from cryptojwt.jwe.jwe_rsa import JWE_RSA
4545

46-
>>> priv_key = import_private_rsa_key_from_file(KEY)
46+
>>> priv_key = import_private_rsa_key_from_file('certs/key.pem')
4747
>>> pub_key = priv_key.public_key()
4848
>>> plain = b'Now is the time for all good men to come to the aid of ...'
49-
>>> _rsa = JWE_RSA(plain, alg="RSA1_5", enc="A128CBC-HS256")
49+
>>> _rsa = JWE_RSA(plain, alg="RSA-OAEP", enc="A128CBC-HS256")
5050
>>> jwe = _rsa.encrypt(pub_key)
5151

5252
Here the key is an cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey
@@ -61,7 +61,7 @@ Decrypting using the encrypted message above.
6161
>>> from cryptojwt.jwe.jwe import factory
6262
>>> from cryptojwt.jwk.rsa import RSAKey
6363

64-
>>> _decryptor = factory(jwe, alg="RSA1_5", enc="A128CBC-HS256")
64+
>>> _decryptor = factory(jwe, alg="RSA-OAEP", enc="A128CBC-HS256")
6565
>>> _dkey = RSAKey(priv_key=priv_key)
6666
>>> msg = _decryptor.decrypt(jwe, [_dkey])
6767

src/cryptojwt/jwe/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
],
3333
}
3434

35+
DEPRECATED = {
36+
"alg": ["RSA1_5"],
37+
"enc": [],
38+
}
39+
3540

3641
class Encrypter(object):
3742
"""Abstract base class for encryption algorithms."""

src/cryptojwt/jwx.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
"""A basic class on which to build the JWS and JWE classes."""
22
import json
33
import logging
4+
import warnings
45

56
import requests
67

78
from cryptojwt.jwk import JWK
89
from cryptojwt.key_bundle import KeyBundle
910

1011
from .exception import HeaderError
12+
from .jwe import DEPRECATED
1113
from .jwk.jwk import key_from_jwk_dict
1214
from .jwk.rsa import RSAKey
1315
from .jwk.rsa import import_rsa_key
@@ -91,6 +93,8 @@ def __init__(self, msg=None, with_digest=False, httpc=None, **kwargs):
9193
raise ValueError("x5u")
9294
else:
9395
self._dict[key] = _val
96+
if key in DEPRECATED and _val in DEPRECATED[key]:
97+
warnings.warn(f"{key}={_val} deprecated")
9498

9599
def _set_jwk(self, val):
96100
if isinstance(val, dict):

src/cryptojwt/key_jar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ def load_keys(self, issuer_id, jwks_uri="", jwks=None, replace=False):
318318
should be replace.
319319
:return: Dictionary with usage as key and keys as values
320320
"""
321-
322321
logger.debug("Initiating key bundle for issuer: %s" % issuer_id)
323322

324323
_issuer = self.return_issuer(issuer_id)

0 commit comments

Comments
 (0)