mirror of
https://github.com/saymrwulf/cryptography.git
synced 2026-05-14 20:37:55 +00:00
This commit is contained in:
parent
39738d7741
commit
62f1155062
2 changed files with 13 additions and 1 deletions
|
|
@ -186,7 +186,9 @@ fn derive_private_key(
|
|||
point.mul_generator(&curve, &private_value, &bn_ctx)?;
|
||||
let ec = openssl::ec::EcKey::from_private_components(&curve, &private_value, &point)
|
||||
.map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid EC key"))?;
|
||||
check_key_infinity(&ec)?;
|
||||
ec.check_key().map_err(|_| {
|
||||
pyo3::exceptions::PyValueError::new_err("Invalid EC key (key out of range, infinity, etc.)")
|
||||
})?;
|
||||
let pkey = openssl::pkey::PKey::from_ec_key(ec)?;
|
||||
|
||||
Ok(ECPrivateKey {
|
||||
|
|
|
|||
|
|
@ -144,6 +144,16 @@ def test_derive_point_at_infinity(backend):
|
|||
ec.derive_private_key(q, ec.SECP256R1())
|
||||
|
||||
|
||||
def test_derive_point_invalid_key(backend):
|
||||
curve = ec.SECP256R1()
|
||||
_skip_curve_unsupported(backend, curve)
|
||||
with pytest.raises(ValueError):
|
||||
ec.derive_private_key(
|
||||
0xE2563328DFABF68188606B91324281C1D58A4456431B09D510B35FECC9F307CA1822846FA2671371A9A81BAC0E35749D,
|
||||
curve,
|
||||
)
|
||||
|
||||
|
||||
def test_ec_numbers():
|
||||
numbers = ec.EllipticCurvePrivateNumbers(
|
||||
1, ec.EllipticCurvePublicNumbers(2, 3, DummyCurve())
|
||||
|
|
|
|||
Loading…
Reference in a new issue