diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2019-01-20 15:02:59 -0600 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2019-01-20 15:02:59 -0600 |
commit | a07b1f5463361570c3248c1096ffd8b3bff0bfa5 (patch) | |
tree | 66bc3e076557579ad062dea6a08a716519857b11 /src/cryptography/hazmat/backends/openssl/backend.py | |
parent | 5fe88ea0500c6e418492f4b166c0d4a24e9632cc (diff) | |
download | cryptography-a07b1f5463361570c3248c1096ffd8b3bff0bfa5.tar.gz cryptography-a07b1f5463361570c3248c1096ffd8b3bff0bfa5.tar.bz2 cryptography-a07b1f5463361570c3248c1096ffd8b3bff0bfa5.zip |
add support for encoding compressed points (#4638)
* add support for encoding compressed points
* review feedback
Diffstat (limited to 'src/cryptography/hazmat/backends/openssl/backend.py')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/backend.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py index ab0daa28..b5232ba0 100644 --- a/src/cryptography/hazmat/backends/openssl/backend.py +++ b/src/cryptography/hazmat/backends/openssl/backend.py @@ -1690,6 +1690,10 @@ class Backend(object): "format must be an item from the PrivateFormat enum" ) + # X9.62 encoding is only valid for EC public keys + if encoding is serialization.Encoding.X962: + raise ValueError("X9.62 format is only valid for EC public keys") + # Raw format and encoding are only valid for X25519, Ed25519, X448, and # Ed448 keys. We capture those cases before this method is called so if # we see those enum values here it means the caller has passed them to @@ -1792,6 +1796,13 @@ class Backend(object): if not isinstance(encoding, serialization.Encoding): raise TypeError("encoding must be an item from the Encoding enum") + # Compressed/UncompressedPoint are only valid for EC keys and those + # cases are handled by the ECPublicKey public_bytes method before this + # method is called + if format in (serialization.PublicFormat.UncompressedPoint, + serialization.PublicFormat.CompressedPoint): + raise ValueError("Point formats are not valid for this key type") + # Raw format and encoding are only valid for X25519, Ed25519, X448, and # Ed448 keys. We capture those cases before this method is called so if # we see those enum values here it means the caller has passed them to |