Content Decryption with AEAD_CHACHA20_POLY1305. :param ciphertext: ciphertext in bytes :param aad: additional authenticated data in bytes :param iv: initialization vector in bytes :param tag: authentication tag in bytes :param key: encrypted key in bytes
(self, ciphertext, aad, iv, tag, key)
| 37 | return ciphertext[:-16], ciphertext[-16:] |
| 38 | |
| 39 | def decrypt(self, ciphertext, aad, iv, tag, key): |
| 40 | """Content Decryption with AEAD_CHACHA20_POLY1305. |
| 41 | |
| 42 | :param ciphertext: ciphertext in bytes |
| 43 | :param aad: additional authenticated data in bytes |
| 44 | :param iv: initialization vector in bytes |
| 45 | :param tag: authentication tag in bytes |
| 46 | :param key: encrypted key in bytes |
| 47 | :return: message |
| 48 | """ |
| 49 | self.check_iv(iv) |
| 50 | chacha = ChaCha20Poly1305(key) |
| 51 | return chacha.decrypt(iv, ciphertext + tag, aad) |