Beispiel #1
0
    def test_wrong_passphrase_pickle(self):
        alice = Account()
        passphrase = "It's a secret to everybody"
        pickle = alice.pickle(passphrase)

        with pytest.raises(OlmAccountError):
            Account.from_pickle(pickle, "")
Beispiel #2
0
 def _create_session(self):
     alice = Account()
     bob = Account()
     bob.generate_one_time_keys(1)
     id_key = bob.identity_keys["curve25519"]
     one_time = list(bob.one_time_keys["curve25519"].values())[0]
     session = OutboundSession(alice, id_key, one_time)
     return alice, bob, session
Beispiel #3
0
    def test_valid_signature(self, message):
        alice = Account()

        signature = alice.sign(message)
        signing_key = alice.identity_keys["ed25519"]

        assert signature
        assert signing_key

        ed25519_verify(signing_key, message, signature)
Beispiel #4
0
    def test_valid_signature(self):
        message = "It's a secret to everybody"
        alice = Account()

        signature = alice.sign(message)
        signing_key = alice.identity_keys["ed25519"]

        assert signature
        assert signing_key

        ed25519_verify(signing_key, message, signature)
Beispiel #5
0
    def test_invalid_signature(self, message):
        alice = Account()
        bob = Account()

        signature = alice.sign(message)
        signing_key = bob.identity_keys["ed25519"]

        assert signature
        assert signing_key

        with pytest.raises(OlmVerifyError):
            ed25519_verify(signing_key, message, signature)
Beispiel #6
0
    def test_twice_signature_verification(self):
        alice = Account()
        message = b"Test"

        signature = alice.sign(message)
        signing_key = alice.identity_keys["ed25519"]

        assert signature
        assert signing_key

        ed25519_verify(signing_key, message, signature)

        assert signature == alice.sign(message)
        ed25519_verify(signing_key, message, signature)
Beispiel #7
0
def olm_machine():
    key_pair = Account().identity_keys

    bob_device = OlmDevice(BOB_DEVICE, BOB_DEVICE_ID, key_pair)

    store = SqliteMemoryStore(ALICE_ID, ALICE_DEVICE_ID)
    client = Olm(ALICE_ID, ALICE_DEVICE_ID, store)
    client.device_store.add(bob_device)
    store.save_device_keys(client.device_store)
    return client
Beispiel #8
0
    def test_publish_one_time_keys(self):
        alice = Account()
        alice.generate_one_time_keys(10)
        one_time_keys = alice.one_time_keys

        assert one_time_keys
        assert len(one_time_keys["curve25519"]) == 10

        alice.mark_keys_as_published()
        assert not alice.one_time_keys["curve25519"]
Beispiel #9
0
 def test_clear(self):
     alice = Account()
     del alice
Beispiel #10
0
 def test_max_one_time_keys(self):
     alice = Account()
     assert isinstance(alice.max_one_time_keys, int)
Beispiel #11
0
 def test_one_time_keys(self):
     alice = Account()
     alice.generate_one_time_keys(10)
     one_time_keys = alice.one_time_keys
     assert one_time_keys
     assert len(one_time_keys["curve25519"]) == 10
Beispiel #12
0
 def test_passphrase_pickle(self):
     alice = Account()
     passphrase = "It's a secret to everybody"
     pickle = alice.pickle(passphrase)
     assert (alice.identity_keys == Account.from_pickle(
         pickle, passphrase).identity_keys)
Beispiel #13
0
 def test_invalid_unpickle(self):
     with pytest.raises(ValueError):
         Account.from_pickle(b"")
Beispiel #14
0
 def test_account_pickle(self):
     alice = Account()
     pickle = alice.pickle()
     assert (alice.identity_keys == Account.from_pickle(pickle)
             .identity_keys)
Beispiel #15
0
 def test_account_creation(self):
     alice = Account()
     assert alice.identity_keys
     assert len(alice.identity_keys) == 2