aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/primitives/asymmetric/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptography/hazmat/primitives/asymmetric/utils.py')
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/utils.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cryptography/hazmat/primitives/asymmetric/utils.py b/src/cryptography/hazmat/primitives/asymmetric/utils.py
index 08bb40c7..cf5973a0 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/utils.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/utils.py
@@ -32,7 +32,11 @@ def decode_rfc6979_signature(signature):
def encode_rfc6979_signature(r, s):
- sig = _DSSSigValue()
- sig.setComponentByName('r', r)
- sig.setComponentByName('s', s)
+ try:
+ sig = _DSSSigValue()
+ sig.setComponentByName('r', r)
+ sig.setComponentByName('s', s)
+ except PyAsn1Error:
+ raise ValueError("Both r and s must be integers")
+
return encoder.encode(sig)