1
0

crypto.py: rm {En,De}codeAES_base64. instead use {En,De}codeAES_bytes

This commit is contained in:
SomberNight
2022-07-12 12:47:52 +02:00
parent d067e0e314
commit 79fec3417a
2 changed files with 3 additions and 13 deletions

View File

@@ -167,12 +167,6 @@ def aes_decrypt_with_iv(key: bytes, iv: bytes, data: bytes) -> bytes:
raise InvalidPassword()
def EncodeAES_base64(secret: bytes, msg: bytes) -> bytes:
"""Returns base64 encoded ciphertext."""
e = EncodeAES_bytes(secret, msg)
return base64.b64encode(e)
def EncodeAES_bytes(secret: bytes, msg: bytes) -> bytes:
assert_bytes(msg)
iv = bytes(os.urandom(16))
@@ -180,11 +174,6 @@ def EncodeAES_bytes(secret: bytes, msg: bytes) -> bytes:
return iv + ct
def DecodeAES_base64(secret: bytes, ciphertext_b64: Union[bytes, str]) -> bytes:
ciphertext = bytes(base64.b64decode(ciphertext_b64))
return DecodeAES_bytes(secret, ciphertext)
def DecodeAES_bytes(secret: bytes, ciphertext: bytes) -> bytes:
assert_bytes(ciphertext)
iv, e = ciphertext[:16], ciphertext[16:]