aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/ec.py10
-rw-r--r--src/cryptography/hazmat/primitives/asymmetric/ec.py12
2 files changed, 22 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/ec.py b/src/cryptography/hazmat/backends/openssl/ec.py
index 2f476031..1e45e402 100644
--- a/src/cryptography/hazmat/backends/openssl/ec.py
+++ b/src/cryptography/hazmat/backends/openssl/ec.py
@@ -240,6 +240,11 @@ class _EllipticCurvePrivateKey(object):
self._ec_key
)
+ def sign(self, data, signature_algorithm):
+ signer = self.signer(signature_algorithm)
+ signer.update(data)
+ return signer.finalize()
+
@utils.register_interface(ec.EllipticCurvePublicKeyWithSerialization)
class _EllipticCurvePublicKey(object):
@@ -303,3 +308,8 @@ class _EllipticCurvePublicKey(object):
self._evp_pkey,
None
)
+
+ def verify(self, signature, data, signature_algorithm):
+ verifier = self.verifier(signature, signature_algorithm)
+ verifier.update(data)
+ verifier.verify()
diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py
index 907a6358..1c576c6d 100644
--- a/src/cryptography/hazmat/primitives/asymmetric/ec.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py
@@ -62,6 +62,12 @@ class EllipticCurvePrivateKey(object):
The EllipticCurve that this key is on.
"""
+ @abc.abstractproperty
+ def sign(self, data, signature_algorithm):
+ """
+ Signs the data
+ """
+
@six.add_metaclass(abc.ABCMeta)
class EllipticCurvePrivateKeyWithSerialization(EllipticCurvePrivateKey):
@@ -104,6 +110,12 @@ class EllipticCurvePublicKey(object):
Returns the key serialized as bytes.
"""
+ @abc.abstractmethod
+ def verify(self, signature, data, signature_algorithm):
+ """
+ Verifies the signature of the data.
+ """
+
EllipticCurvePublicKeyWithSerialization = EllipticCurvePublicKey