summaryrefslogtreecommitdiff
path: root/jwt/algorithms.py
diff options
context:
space:
mode:
authorSomeguy123 <Someguy123@users.noreply.github.com>2020-05-24 02:58:27 +0100
committerGitHub <noreply@github.com>2020-05-24 07:58:27 +0600
commit75c849efcfaccfcd268d820245197f7abbd35825 (patch)
treee370e06cf18998dac74434b83c5eaac72a3e75a2 /jwt/algorithms.py
parent8556a1590532d58c540256ae1824688ec6c7abe2 (diff)
downloadpyjwt-75c849efcfaccfcd268d820245197f7abbd35825.tar.gz
Add support for Ed25519 / EdDSA, with unit tests (#455)
Diffstat (limited to 'jwt/algorithms.py')
-rw-r--r--jwt/algorithms.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/jwt/algorithms.py b/jwt/algorithms.py
index 293a470..5e65d9f 100644
--- a/jwt/algorithms.py
+++ b/jwt/algorithms.py
@@ -43,6 +43,7 @@ try:
has_crypto = True
except ImportError:
has_crypto = False
+ has_ed25519 = False
requires_cryptography = set(
[
@@ -56,6 +57,7 @@ requires_cryptography = set(
"PS256",
"PS384",
"PS512",
+ "EdDSA",
]
)
@@ -86,8 +88,18 @@ def get_default_algorithms():
"PS256": RSAPSSAlgorithm(RSAPSSAlgorithm.SHA256),
"PS384": RSAPSSAlgorithm(RSAPSSAlgorithm.SHA384),
"PS512": RSAPSSAlgorithm(RSAPSSAlgorithm.SHA512),
+
}
)
+ # Older versions of the `cryptography` libraries may not have Ed25519 available.
+ # Needs a minimum of version 2.6
+ try:
+ from jwt.contrib.algorithms.py_ed25519 import Ed25519Algorithm
+ default_algorithms.update({
+ "EdDSA": Ed25519Algorithm(),
+ })
+ except ImportError:
+ pass
return default_algorithms