Example #1
0
    async def _send_encrypted(self, m: DecryptedMessage):
        """Send an encrypted message."""

        e = NSTPMessage()
        e.encrypted_message.ciphertext = crypto_secretbox(
            m.SerializeToString(), self.writer_nonce, self.writer_key)
        e.encrypted_message.nonce = self.writer_nonce
        sodium_increment(self.writer_nonce)
        message_data = e.SerializeToString()
        self.writer.write(message_data)
        await self.writer.drain()
Example #2
0
def test_sodium_increment():
    maxint = 32 * b"\xff"
    zero = 32 * b"\x00"
    one = b"\x01" + 31 * b"\x00"
    two = b"\x02" + 31 * b"\x00"

    res = c.sodium_increment(maxint)
    assert res == zero

    res = c.sodium_increment(res)
    assert res == one

    res = c.sodium_increment(res)
    assert res == two
Example #3
0
def test_sodium_increment():
    maxint = 32 * b'\xff'
    zero = 32 * b'\x00'
    one = b'\x01' + 31 * b'\x00'
    two = b'\x02' + 31 * b'\x00'

    res = c.sodium_increment(maxint)
    assert res == zero

    res = c.sodium_increment(res)
    assert res == one

    res = c.sodium_increment(res)
    assert res == two
Example #4
0
def test_sodium_increment():
    maxint = 32 * b'\xff'
    zero = 32 * b'\x00'
    one = b'\x01' + 31 * b'\x00'
    two = b'\x02' + 31 * b'\x00'

    res = c.sodium_increment(maxint)
    assert res == zero

    res = c.sodium_increment(res)
    assert res == one

    res = c.sodium_increment(res)
    assert res == two