def AES_cbc_decrypt(token: bytes, ciphertext: bytes) -> bytes:
"""Decrypt cipher text with device token."""
key, iv = key_iv(token)
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=_backend)
decryptor = cipher.decryptor()
padded_plaintext = decryptor.update(bytes(ciphertext)) \
+ decryptor.finalize()
unpadder = padding.PKCS7(128).unpadder()
unpadded_plaintext = unpadder.update(padded_plaintext)
unpadded_plaintext += unpadder.finalize()
return unpadded_plaintext
评论列表
文章目录