You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/src/trezor/crypto/aes.py

72 lines
1.6 KiB

from trezorcrypto import AES
def AES_ECB_Encrypt(key: bytes) -> AES:
"""
Create AES encryption context in ECB mode
"""
return AES(AES.ECB | AES.Encrypt, key)
def AES_ECB_Decrypt(key: bytes) -> AES:
"""
Create AES decryption context in ECB mode
"""
return AES(AES.ECB | AES.Decrypt, key)
def AES_CBC_Encrypt(key: bytes, iv: bytes) -> AES:
"""
Create AES encryption context in CBC mode
"""
return AES(AES.CBC | AES.Encrypt, key, iv)
def AES_CBC_Decrypt(key: bytes, iv: bytes) -> AES:
"""
Create AES decryption context in CBC mode
"""
return AES(AES.CBC | AES.Decrypt, key, iv)
def AES_CFB_Encrypt(key: bytes, iv: bytes) -> AES:
"""
Create AES encryption context in CFB mode
"""
return AES(AES.CFB | AES.Encrypt, key, iv)
def AES_CFB_Decrypt(key: bytes, iv: bytes) -> AES:
"""
Create AES decryption context in CFB mode
"""
return AES(AES.CFB | AES.Decrypt, key, iv)
def AES_OFB_Encrypt(key: bytes, iv: bytes) -> AES:
"""
Create AES encryption context in OFB mode
"""
return AES(AES.OFB | AES.Encrypt, key, iv)
def AES_OFB_Decrypt(key: bytes, iv: bytes) -> AES:
"""
Create AES decryption context in OFB mode
"""
return AES(AES.OFB | AES.Decrypt, key, iv)
def AES_CTR_Encrypt(key: bytes) -> AES:
"""
Create AES encryption context in CTR mode
"""
return AES(AES.CTR | AES.Encrypt, key)
def AES_CTR_Decrypt(key: bytes) -> AES:
"""
Create AES decryption context in CTR mode
"""
return AES(AES.CTR | AES.Decrypt, key)