Esempio n. 1
0
    def public_key(self, key):
        if isinstance(key, bytes):
            self._crypto = Crypto.from_bytes(key)
        else:
            self._crypto = Crypto(key)

        self._public_key = self._crypto.foreign_pubkey
Esempio n. 2
0
    def public_key(self, key: Union[EllipticCurvePublicKey, bytes]) -> None:
        if isinstance(key, bytes):
            self._crypto = Crypto.from_bytes(key)
        else:
            self._crypto = Crypto(key)

        self._public_key = self._crypto.foreign_pubkey
def public_key():
    public_key = unhexlify(
        b'041815d5382df79bd792a8d8342fbc717eacef6a258f779279e5463573e06b'
        b'f84c6a88fac904870bf3a26f856e65f483195c4323eef47a048f23a031da6bd0929d'
    )

    c = Crypto.from_bytes(public_key)
    return c.foreign_pubkey
Esempio n. 4
0
def console(console_address, console_name, uuid_dummy, console_liveid,
            console_flags, public_key_bytes):
    c = Crypto.from_bytes(public_key_bytes)
    console = Console(console_address, console_name, uuid_dummy,
                      console_liveid, console_flags, c.foreign_pubkey)
    console.add_manager(StumpManager)
    console.add_manager(MediaManager)
    console.add_manager(TextManager)
    console.add_manager(InputManager)
    return console
Esempio n. 5
0
def console():
    pkey = unhexlify(
        b'041815d5382df79bd792a8d8342fbc717eacef6a258f779279e5463573e06b'
        b'f84c6a88fac904870bf3a26f856e65f483195c4323eef47a048f23a031da6bd0929d'
    )

    c = Crypto.from_bytes(pkey)
    return Console('10.0.0.23', 'XboxOne',
                   uuid.UUID('de305d54-75b4-431b-adb2-eb6b9e546014'),
                   'FFFFFFFFFFF', enum.PrimaryDeviceFlag.AllowConsoleUsers,
                   c.foreign_pubkey)
def test_from_bytes(public_key_bytes, public_key):
    from xbox.sg.crypto import Crypto
    c1 = Crypto.from_bytes(public_key_bytes)
    c2 = Crypto.from_bytes(public_key_bytes, PublicKeyType.EC_DH_P256)

    # invalid public key type passed
    with pytest.raises(ValueError):
        Crypto.from_bytes(public_key_bytes, PublicKeyType.EC_DH_P521)
    # invalid keylength
    with pytest.raises(ValueError):
        Crypto.from_bytes(public_key_bytes[5:])
    # invalid parameter
    with pytest.raises(ValueError):
        Crypto.from_bytes(123)

    assert c1.foreign_pubkey.public_numbers() == public_key.public_numbers()
    assert c2.foreign_pubkey.public_numbers() == public_key.public_numbers()
Esempio n. 7
0
def test_from_bytes():
    from xbox.sg.crypto import Crypto
    public_key = unhexlify(
        '041db1e7943878b28c773228ebdcfb05b985be4a386a55f50066231360785f61b'
        '60038caf182d712d86c8a28a0e7e2733a0391b1169ef2905e4e21555b432b262d')

    c1 = Crypto.from_bytes(public_key)
    c2 = Crypto.from_bytes(public_key, PublicKeyType.EC_DH_P256)

    # invalid public key type passed
    with pytest.raises(ValueError):
        Crypto.from_bytes(public_key, PublicKeyType.EC_DH_P521)
    # invalid keylength
    with pytest.raises(ValueError):
        Crypto.from_bytes(public_key[5:])
    # invalid parameter
    with pytest.raises(ValueError):
        Crypto.from_bytes(123)

    assert c1.foreign_pubkey.public_numbers().encode_point() == public_key
    assert c2.foreign_pubkey.public_numbers().encode_point() == public_key
Esempio n. 8
0
def public_key(public_key_bytes):
    c = Crypto.from_bytes(public_key_bytes)
    return c.foreign_pubkey