|
12 | 12 |
|
13 | 13 | import pytest |
14 | 14 |
|
15 | | -from cryptography import exceptions, utils, x509 |
| 15 | +from cryptography import exceptions, x509 |
16 | 16 | from cryptography.hazmat.primitives import hashes, serialization |
17 | 17 | from cryptography.hazmat.primitives.asymmetric import ec |
18 | 18 | from cryptography.hazmat.primitives.asymmetric.utils import ( |
19 | 19 | Prehashed, |
20 | 20 | encode_dss_signature, |
21 | 21 | ) |
22 | | -from cryptography.utils import CryptographyDeprecationWarning |
23 | 22 |
|
24 | 23 | from .fixtures_ec import EC_KEY_SECP384R1 |
25 | 24 | from .utils import skip_fips_traditional_openssl |
@@ -171,73 +170,6 @@ def test_invalid_private_numbers_public_numbers(): |
171 | 170 | ec.EllipticCurvePrivateNumbers(1, None) # type: ignore[arg-type] |
172 | 171 |
|
173 | 172 |
|
174 | | -def test_encode_point(): |
175 | | - # secp256r1 point |
176 | | - x = int( |
177 | | - "233ea3b0027127084cd2cd336a13aeef69c598d8af61369a36454a17c6c22aec", 16 |
178 | | - ) |
179 | | - y = int( |
180 | | - "3ea2c10a84153862be4ec82940f0543f9ba866af9751a6ee79d38460b35f442e", 16 |
181 | | - ) |
182 | | - pn = ec.EllipticCurvePublicNumbers(x, y, ec.SECP256R1()) |
183 | | - with pytest.warns(utils.PersistentlyDeprecated2019): |
184 | | - data = pn.encode_point() |
185 | | - assert data == binascii.unhexlify( |
186 | | - "04233ea3b0027127084cd2cd336a13aeef69c598d8af61369a36454a17c6c22ae" |
187 | | - "c3ea2c10a84153862be4ec82940f0543f9ba866af9751a6ee79d38460b35f442e" |
188 | | - ) |
189 | | - |
190 | | - |
191 | | -def test_from_encoded_point(): |
192 | | - # secp256r1 point |
193 | | - data = binascii.unhexlify( |
194 | | - "04233ea3b0027127084cd2cd336a13aeef69c598d8af61369a36454a17c6c22ae" |
195 | | - "c3ea2c10a84153862be4ec82940f0543f9ba866af9751a6ee79d38460b35f442e" |
196 | | - ) |
197 | | - with pytest.warns(CryptographyDeprecationWarning): |
198 | | - pn = ec.EllipticCurvePublicNumbers.from_encoded_point( |
199 | | - ec.SECP256R1(), data |
200 | | - ) |
201 | | - assert pn.x == int( |
202 | | - "233ea3b0027127084cd2cd336a13aeef69c598d8af61369a36454a17c6c22aec", 16 |
203 | | - ) |
204 | | - assert pn.y == int( |
205 | | - "3ea2c10a84153862be4ec82940f0543f9ba866af9751a6ee79d38460b35f442e", 16 |
206 | | - ) |
207 | | - |
208 | | - |
209 | | -def test_from_encoded_point_invalid_length(): |
210 | | - bad_data = binascii.unhexlify( |
211 | | - "04233ea3b0027127084cd2cd336a13aeef69c598d8af61369a36454a17c6c22ae" |
212 | | - "c3ea2c10a84153862be4ec82940f0543f9ba866af9751a6ee79d38460" |
213 | | - ) |
214 | | - with pytest.raises(ValueError): |
215 | | - with pytest.warns(CryptographyDeprecationWarning): |
216 | | - ec.EllipticCurvePublicNumbers.from_encoded_point( |
217 | | - ec.SECP384R1(), bad_data |
218 | | - ) |
219 | | - |
220 | | - |
221 | | -def test_from_encoded_point_unsupported_point_no_backend(): |
222 | | - # set to point type 2. |
223 | | - unsupported_type = binascii.unhexlify( |
224 | | - "02233ea3b0027127084cd2cd336a13aeef69c598d8af61369a36454a17c6c22a" |
225 | | - ) |
226 | | - with pytest.raises(ValueError): |
227 | | - with pytest.warns(CryptographyDeprecationWarning): |
228 | | - ec.EllipticCurvePublicNumbers.from_encoded_point( |
229 | | - ec.SECP256R1(), unsupported_type |
230 | | - ) |
231 | | - |
232 | | - |
233 | | -def test_from_encoded_point_not_a_curve(): |
234 | | - with pytest.raises(TypeError): |
235 | | - with pytest.warns(CryptographyDeprecationWarning): |
236 | | - ec.EllipticCurvePublicNumbers.from_encoded_point( |
237 | | - "notacurve", b"\x04data" # type: ignore[arg-type] |
238 | | - ) |
239 | | - |
240 | | - |
241 | 173 | def test_ec_public_numbers_repr(): |
242 | 174 | pn = ec.EllipticCurvePublicNumbers(2, 3, ec.SECP256R1()) |
243 | 175 | assert repr(pn) == "<EllipticCurvePublicNumbers(curve=secp256r1, x=2, y=3>" |
|
0 commit comments