예제 #1
0
def test_ecc_decode_compressed_point_nonprime_characteristic_two():
    with pytest.raises(NotSupportedError) as excinfo:
        _ecc_decode_compressed_point(
            curve=ec.SECT409K1(),
            compressed_point="\x02skdgaiuhgijudflkjsdgfkjsdflgjhsd")

    excinfo.match(r"Non-prime curves are not supported at this time")
예제 #2
0
def test_ecc_decode_compressed_point_prime_unsupported():
    with pytest.raises(NotSupportedError) as excinfo:
        _ecc_decode_compressed_point(
            curve=ec.SECP192R1(),
            compressed_point="\x02skdgaiuhgijudflkjsdgfkjsdflgjhsd")

    excinfo.match(r"Curve secp192r1 is not supported at this time")
def test_ecc_decode_compressed_point_infinity():
    with pytest.raises(NotSupportedError) as excinfo:
        _ecc_decode_compressed_point(
            curve=ec.SECP384R1(),
            compressed_point=b''
        )

    excinfo.match(r'Points at infinity are not allowed')
def test_ecc_decode_compressed_point_prime_complex(patch_ecc_curve_parameters):
    patch_ecc_curve_parameters.__getitem__.return_value = _ECCCurveParameters(p=5, a=5, b=5, order=5)
    mock_curve = MagicMock()
    mock_curve.name = "secp_mock_curve"
    with pytest.raises(NotSupportedError) as excinfo:
        _ecc_decode_compressed_point(curve=mock_curve, compressed_point=VALUES["ecc_compressed_point"])

    excinfo.match(r"S not 1 :: Curve not supported at this time")
def test_ecc_decode_compressed_point_prime_not_characteristic_two(patch_pow):
    patch_pow.return_value = 0
    _, y = _ecc_decode_compressed_point(
        curve=ec.SECP384R1(),
        compressed_point=VALUES['ecc_compressed_point']
    )
    assert y == _ECC_CURVE_PARAMETERS['secp384r1'].p
def test_ecc_decode_compressed_point_prime_characteristic_two(patch_pow):
    patch_pow.return_value = 1
    _, y = _ecc_decode_compressed_point(
        curve=ec.SECP384R1(),
        compressed_point=VALUES['ecc_compressed_point']
    )
    assert y == 1
def test_ecc_decode_compressed_point_prime():
    x, y = _ecc_decode_compressed_point(
        curve=ec.SECP384R1(),
        compressed_point=VALUES['ecc_compressed_point']
    )
    numbers = VALUES['ecc_private_key_prime'].public_key().public_numbers()
    assert x == numbers.x
    assert y == numbers.y