aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/primitives/asymmetric
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-11-27 10:40:12 -1000
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-11-27 10:43:49 -1000
commitaa7dacaf53e150d9d6e58224c46b88214f2957df (patch)
tree90b716eda89e7f94d65add0bceeb4e38011da3ee /src/cryptography/hazmat/primitives/asymmetric
parent65d054d1a9b8b122096d7994fc2fe675c06f423f (diff)
downloadcryptography-aa7dacaf53e150d9d6e58224c46b88214f2957df.tar.gz
cryptography-aa7dacaf53e150d9d6e58224c46b88214f2957df.tar.bz2
cryptography-aa7dacaf53e150d9d6e58224c46b88214f2957df.zip
add encode_rfc6979_signature and refactor tests to use it
Diffstat (limited to 'src/cryptography/hazmat/primitives/asymmetric')
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/utils.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cryptography/hazmat/primitives/asymmetric/utils.py b/src/cryptography/hazmat/primitives/asymmetric/utils.py
index 5e35b3f6..0140e6c1 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/utils.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/utils.py
@@ -4,7 +4,7 @@
from __future__ import absolute_import, division, print_function
-from pyasn1.codec.der import decoder
+from pyasn1.codec.der import decoder, encoder
from pyasn1.type import namedtype, univ
@@ -20,3 +20,10 @@ def decode_rfc6979_signature(signature):
r = int(data[0].getComponentByName('r'))
s = int(data[0].getComponentByName('s'))
return (r, s)
+
+
+def encode_rfc6979_signature(r, s):
+ sig = _DSSSigValue()
+ sig.setComponentByName('r', r)
+ sig.setComponentByName('s', s)
+ return encoder.encode(sig)