Skip to content

Commit

Permalink
Merge e698072 into 69e9735
Browse files Browse the repository at this point in the history
  • Loading branch information
tomato42 committed Aug 25, 2020
2 parents 69e9735 + e698072 commit 51ce2bb
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 76 deletions.
17 changes: 17 additions & 0 deletions src/ecdsa/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Common functions for providing cross-python version compatibility.
"""
import sys
import re
from six import integer_types


Expand All @@ -23,6 +24,18 @@ def normalise_bytes(buffer_object):
def hmac_compat(ret):
return ret

if sys.version_info < (2, 7) or sys.version_info < (2, 7, 4):

def remove_whitespace(text):
"""Removes all whitespace from passed in string"""
return re.sub(r"\s+", "", text)

else:

def remove_whitespace(text):
"""Removes all whitespace from passed in string"""
return re.sub(r"\s+", "", text, flags=re.UNICODE)


else:
if sys.version_info < (3, 4):
Expand All @@ -41,3 +54,7 @@ def hmac_compat(data):
def normalise_bytes(buffer_object):
"""Cast the input into array of bytes."""
return memoryview(buffer_object).cast("B")

def remove_whitespace(text):
"""Removes all whitespace from passed in string"""
return re.sub(r"\s+", "", text, flags=re.UNICODE)
7 changes: 5 additions & 2 deletions src/ecdsa/ecdh.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class NoCurveError(Exception):


class InvalidCurveError(Exception):
"""ECDH. Raised in case the public and private keys use different curves."""
"""
ECDH. Raised in case the public and private keys use different curves.
"""

pass

Expand Down Expand Up @@ -174,7 +176,8 @@ def load_private_key_der(self, private_key_der):
Note, the only DER format supported is the RFC5915
Look at keys.py:SigningKey.from_der()
:param private_key_der: string with the DER encoding of private ECDSA key
:param private_key_der: string with the DER encoding of private ECDSA
key
:type private_key_der: string
:raises InvalidCurveError: private_key curve not the same as self.curve
Expand Down

0 comments on commit 51ce2bb

Please sign in to comment.