diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2018-12-18 09:48:51 +0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2018-12-17 20:48:51 -0500 |
commit | 7deaf5a8397b3c1fae5e6e3ffb788146f24c4af4 (patch) | |
tree | 74c2dad2f2fac8b9633f0c7170fb26de7f826012 /src/cryptography/hazmat/primitives | |
parent | 3c137d909dc004fbcab4a1593c3a6430882fd853 (diff) | |
download | cryptography-7deaf5a8397b3c1fae5e6e3ffb788146f24c4af4.tar.gz cryptography-7deaf5a8397b3c1fae5e6e3ffb788146f24c4af4.tar.bz2 cryptography-7deaf5a8397b3c1fae5e6e3ffb788146f24c4af4.zip |
handle empty byte string in from_encoded_point (#4649)
* handle empty byte string in from_encoded_point
* move the error
Diffstat (limited to 'src/cryptography/hazmat/primitives')
-rw-r--r-- | src/cryptography/hazmat/primitives/asymmetric/ec.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py index 125235f8..c93cc090 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/ec.py +++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py @@ -155,9 +155,13 @@ class EllipticCurvePublicKey(object): @classmethod def from_encoded_point(cls, curve, data): utils._check_bytes("data", data) + if not isinstance(curve, EllipticCurve): raise TypeError("curve must be an EllipticCurve instance") + if len(data) == 0: + raise ValueError("data must not be an empty byte string") + if six.indexbytes(data, 0) not in [0x02, 0x03, 0x04]: raise ValueError("Unsupported elliptic curve point type") |