예제 #1
0
    def test_key_encoding(vectors):
        priv = EccPrivate()
        pub = EccPublic()
        raw_priv = EccPrivate()
        raw_pub = EccPublic()

        # Test default encode/decode key
        priv.decode_key(vectors[EccPrivate].key)
        pub.decode_key(vectors[EccPublic].key)
        assert priv.encode_key() == vectors[EccPrivate].key
        assert pub.encode_key() == vectors[EccPublic].key

        # Test EccPrivate.encode_key_raw/decode_key_raw
        key = vectors[EccPrivate].raw_key
        raw_priv.decode_key_raw(key[0:32], key[32:64], key[64:96])
        qx, qy, d = raw_priv.encode_key_raw()
        assert qx[0:32] == vectors[EccPrivate].raw_key[0:32]
        assert qy[0:32] == vectors[EccPrivate].raw_key[32:64]
        assert d[0:32] == vectors[EccPrivate].raw_key[64:96]
        # Verify ECC key is the same as the raw key
        qx, qy, d = priv.encode_key_raw()
        assert qx[0:32] == vectors[EccPrivate].raw_key[0:32]
        assert qy[0:32] == vectors[EccPrivate].raw_key[32:64]
        assert d[0:32] == vectors[EccPrivate].raw_key[64:96]

        # Test EccPublic.encode_key_raw/decode_key_raw
        key = vectors[EccPublic].raw_key
        raw_pub.decode_key_raw(key[0:32], key[32:64])
        qx, qy = raw_pub.encode_key_raw()
        assert qx[0:32] == vectors[EccPublic].raw_key[0:32]
        assert qy[0:32] == vectors[EccPublic].raw_key[32:64]
        # Verify ECC public key is the same as the raw key
        qx, qy = pub.encode_key_raw()
        assert qx[0:32] == vectors[EccPublic].raw_key[0:32]
        assert qy[0:32] == vectors[EccPublic].raw_key[32:64]
예제 #2
0
def test_key_encoding(vectors):
    priv = EccPrivate()
    pub = EccPublic()

    priv.decode_key(vectors[EccPrivate].key)
    pub.decode_key(vectors[EccPublic].key)

    assert priv.encode_key() == vectors[EccPrivate].key
    assert pub.encode_key() == vectors[EccPublic].key
예제 #3
0
def test_key_encoding(vectors):
    priv = EccPrivate()
    pub = EccPublic()
    raw_priv = EccPrivate()
    raw_pub = EccPublic()


    # Test default encode/decode key
    priv.decode_key(vectors[EccPrivate].key)
    pub.decode_key(vectors[EccPublic].key)
    assert priv.encode_key() == vectors[EccPrivate].key
    assert pub.encode_key() == vectors[EccPublic].key

    # Test EccPrivate.encode_key_raw/decode_key_raw
    key = vectors[EccPrivate].raw_key
    raw_priv.decode_key_raw(key[0:31], key[32:63], key[64:-1])
    qx, qy, d = raw_priv.encode_key_raw()
    assert qx[0:31] == vectors[EccPrivate].raw_key[0:31]
    assert qy[0:31] == vectors[EccPrivate].raw_key[32:63]
    assert d[0:31] == vectors[EccPrivate].raw_key[64:-1]
    # Verify ECC key is the same as the raw key
    qx, qy, d = priv.encode_key_raw()
    assert qx[0:31] == vectors[EccPrivate].raw_key[0:31]
    assert qy[0:31] == vectors[EccPrivate].raw_key[32:63]
    assert d[0:31] == vectors[EccPrivate].raw_key[64:-1]

    # Test EccPublic.encode_key_raw/decode_key_raw
    key = vectors[EccPublic].raw_key
    raw_pub.decode_key_raw(key[0:31], key[32:-1])
    qx, qy = raw_pub.encode_key_raw()
    assert qx[0:31] == vectors[EccPublic].raw_key[0:31]
    assert qy[0:31] == vectors[EccPublic].raw_key[32:63]
    # Verify ECC public key is the same as the raw key
    qx, qy = pub.encode_key_raw()
    assert qx[0:31] == vectors[EccPublic].raw_key[0:31]
    assert qy[0:31] == vectors[EccPublic].raw_key[32:63]