Skip to content

Commit

Permalink
fix mac_len
Browse files Browse the repository at this point in the history
  • Loading branch information
eos175 committed May 4, 2021
1 parent 97f0f82 commit 1ad963e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pycrypto/aes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def cfb128_decrypt(data: bytes, key: bytes, iv: bytes) -> bytes:



def gcm_encrypt(data: bytes, key: bytes, nonce: bytes) -> bytes:
cipher = AES.new(key, AES.MODE_GCM, nonce)
def gcm_encrypt(data: bytes, key: bytes, nonce: bytes, mac_len: int = None) -> bytes:
cipher = AES.new(key, AES.MODE_GCM, nonce, mac_len=mac_len)
return cipher.encrypt(data), cipher.digest()

def gcm_decrypt(data: bytes, key: bytes, nonce: bytes, tag: bytes) -> bytes or None:
Expand All @@ -35,8 +35,8 @@ def gcm_decrypt(data: bytes, key: bytes, nonce: bytes, tag: bytes) -> bytes or N



def ccm_encrypt(data: bytes, key: bytes, nonce: bytes) -> bytes:
cipher = AES.new(key, AES.MODE_CCM, nonce)
def ccm_encrypt(data: bytes, key: bytes, nonce: bytes, mac_len: int = None) -> bytes:
cipher = AES.new(key, AES.MODE_CCM, nonce, mac_len=mac_len)
return cipher.encrypt(data), cipher.digest()

def ccm_decrypt(data: bytes, key: bytes, nonce: bytes, tag: bytes) -> bytes or None:
Expand Down

0 comments on commit 1ad963e

Please sign in to comment.