Key Decryption with AES GCM. :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 :return: messag
(self, ciphertext, aad, iv, tag, key)
| 121 | return ciphertext, enc.tag |
| 122 | |
| 123 | def decrypt(self, ciphertext, aad, iv, tag, key): |
| 124 | """Key Decryption with AES GCM. |
| 125 | |
| 126 | :param ciphertext: ciphertext in bytes |
| 127 | :param aad: additional authenticated data in bytes |
| 128 | :param iv: initialization vector in bytes |
| 129 | :param tag: authentication tag in bytes |
| 130 | :param key: encrypted key in bytes |
| 131 | :return: message |
| 132 | """ |
| 133 | self.check_iv(iv) |
| 134 | cipher = Cipher(AES(key), GCM(iv, tag), backend=default_backend()) |
| 135 | d = cipher.decryptor() |
| 136 | d.authenticate_additional_data(aad) |
| 137 | return d.update(ciphertext) + d.finalize() |
| 138 | |
| 139 | |
| 140 | JWE_ENC_ALGORITHMS = [ |