diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2017-05-23 23:38:59 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2017-05-23 23:38:59 -0700 |
commit | 416f526a3d809d330b4a990bdf4a742384bde8f8 (patch) | |
tree | 93db904bb4dc50dd572d2cb4c54c0dee9bd12eb6 /src | |
parent | 0517d1ae49061f486e2e4d279d70b6b61361de2f (diff) | |
download | cryptography-416f526a3d809d330b4a990bdf4a742384bde8f8.tar.gz cryptography-416f526a3d809d330b4a990bdf4a742384bde8f8.tar.bz2 cryptography-416f526a3d809d330b4a990bdf4a742384bde8f8.zip |
add convenience methods for key_size on EC{Public,Private}Key (#3587)
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/ec.py | 8 | ||||
-rw-r--r-- | src/cryptography/hazmat/primitives/asymmetric/ec.py | 14 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/ec.py b/src/cryptography/hazmat/backends/openssl/ec.py index 68a35b21..3a81f919 100644 --- a/src/cryptography/hazmat/backends/openssl/ec.py +++ b/src/cryptography/hazmat/backends/openssl/ec.py @@ -135,6 +135,10 @@ class _EllipticCurvePrivateKey(object): curve = utils.read_only_property("_curve") + @property + def key_size(self): + return self.curve.key_size + def signer(self, signature_algorithm): _check_signature_algorithm(signature_algorithm) return _ECDSASignatureContext( @@ -231,6 +235,10 @@ class _EllipticCurvePublicKey(object): curve = utils.read_only_property("_curve") + @property + def key_size(self): + return self.curve.key_size + def verifier(self, signature, signature_algorithm): if not isinstance(signature, bytes): raise TypeError("signature must be bytes.") diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py index a527387b..7931b086 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/ec.py +++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py @@ -22,7 +22,7 @@ class EllipticCurve(object): @abc.abstractproperty def key_size(self): """ - The bit length of the base point of the curve. + Bit size of a secret scalar for the curve. """ @@ -63,6 +63,12 @@ class EllipticCurvePrivateKey(object): """ @abc.abstractproperty + def key_size(self): + """ + Bit size of a secret scalar for the curve. + """ + + @abc.abstractproperty def sign(self, data, signature_algorithm): """ Signs the data @@ -98,6 +104,12 @@ class EllipticCurvePublicKey(object): The EllipticCurve that this key is on. """ + @abc.abstractproperty + def key_size(self): + """ + Bit size of a secret scalar for the curve. + """ + @abc.abstractmethod def public_numbers(self): """ |