def test_chacha_encrypt(self):
        # RFC 7539 in text test vector
        key = bytearray(range(0x00, 0x20))
        nonce = bytearray(b'\x00' * 7 + b'\x4a' + b'\x00' * 4)
        chacha = ChaCha(key, nonce)
        self.assertIsNotNone(chacha)
        chacha.counter = 1

        plaintext = bytearray(b'Ladies and Gentlemen of the class of \'99: '
                              b'If I could offer you only one tip for the '
                              b'future, sunscreen would be it.')

        self.assertEqual(len(plaintext), 64 + 50)

        #import pdb; pdb.set_trace()
        ciphertext = chacha.encrypt(plaintext)

        self.assertEqual(
            ciphertext,
            bytearray(
                b'\x6e\x2e\x35\x9a\x25\x68\xf9\x80\x41\xba\x07\x28\xdd\x0d\x69\x81'
                b'\xe9\x7e\x7a\xec\x1d\x43\x60\xc2\x0a\x27\xaf\xcc\xfd\x9f\xae\x0b'
                b'\xf9\x1b\x65\xc5\x52\x47\x33\xab\x8f\x59\x3d\xab\xcd\x62\xb3\x57'
                b'\x16\x39\xd6\x24\xe6\x51\x52\xab\x8f\x53\x0c\x35\x9f\x08\x61\xd8'
                b'\x07\xca\x0d\xbf\x50\x0d\x6a\x61\x56\xa3\x8e\x08\x8a\x22\xb6\x5e'
                b'\x52\xbc\x51\x4d\x16\xcc\xf8\x06\x81\x8c\xe9\x1a\xb7\x79\x37\x36'
                b'\x5a\xf9\x0b\xbf\x74\xa3\x5b\xe6\xb4\x0b\x8e\xed\xf2\x78\x5e\x42'
                b'\x87\x4d'))

        crib = chacha.decrypt(ciphertext)

        self.assertEqual(crib, plaintext)
    def test_chacha_encrypt(self):
        # RFC 7539 in text test vector
        key = bytearray(range(0x00, 0x20))
        nonce = bytearray(b'\x00'*7 + b'\x4a' + b'\x00'*4)
        chacha = ChaCha(key, nonce)
        self.assertIsNotNone(chacha)
        chacha.counter = 1

        plaintext = bytearray(b'Ladies and Gentlemen of the class of \'99: '
                              b'If I could offer you only one tip for the '
                              b'future, sunscreen would be it.')

        self.assertEqual(len(plaintext), 64+50)

        #import pdb; pdb.set_trace()
        ciphertext = chacha.encrypt(plaintext)

        self.assertEqual(ciphertext, bytearray(
            b'\x6e\x2e\x35\x9a\x25\x68\xf9\x80\x41\xba\x07\x28\xdd\x0d\x69\x81'
            b'\xe9\x7e\x7a\xec\x1d\x43\x60\xc2\x0a\x27\xaf\xcc\xfd\x9f\xae\x0b'
            b'\xf9\x1b\x65\xc5\x52\x47\x33\xab\x8f\x59\x3d\xab\xcd\x62\xb3\x57'
            b'\x16\x39\xd6\x24\xe6\x51\x52\xab\x8f\x53\x0c\x35\x9f\x08\x61\xd8'
            b'\x07\xca\x0d\xbf\x50\x0d\x6a\x61\x56\xa3\x8e\x08\x8a\x22\xb6\x5e'
            b'\x52\xbc\x51\x4d\x16\xcc\xf8\x06\x81\x8c\xe9\x1a\xb7\x79\x37\x36'
            b'\x5a\xf9\x0b\xbf\x74\xa3\x5b\xe6\xb4\x0b\x8e\xed\xf2\x78\x5e\x42'
            b'\x87\x4d'
            ))

        crib = chacha.decrypt(ciphertext)

        self.assertEqual(crib, plaintext)