Fix "backed" typo in crypto.py

This commit is contained in:
JeremyRand 2020-05-03 03:08:28 +00:00
parent 484e317bfa
commit 62ca53cdf4
No known key found for this signature in database
GPG key ID: B3F2D165786D6570

View file

@ -281,7 +281,7 @@ def chacha20_poly1305_encrypt(*, key: bytes, nonce: bytes, associated_data: byte
if HAS_CRYPTOGRAPHY:
a = CG_aead.ChaCha20Poly1305(key)
return a.encrypt(nonce, data, associated_data)
raise Exception("no chacha20 backed found")
raise Exception("no chacha20 backend found")
def chacha20_poly1305_decrypt(*, key: bytes, nonce: bytes, associated_data: bytes, data: bytes) -> bytes:
@ -300,7 +300,7 @@ def chacha20_poly1305_decrypt(*, key: bytes, nonce: bytes, associated_data: byte
return a.decrypt(nonce, data, associated_data)
except cryptography.exceptions.InvalidTag as e:
raise ValueError("invalid tag") from e
raise Exception("no chacha20 backed found")
raise Exception("no chacha20 backend found")
def chacha20_encrypt(*, key: bytes, nonce: bytes, data: bytes) -> bytes:
@ -317,4 +317,4 @@ def chacha20_encrypt(*, key: bytes, nonce: bytes, data: bytes) -> bytes:
cipher = CG_Cipher(algo, mode=None, backend=CG_default_backend())
encryptor = cipher.encryptor()
return encryptor.update(data)
raise Exception("no chacha20 backed found")
raise Exception("no chacha20 backend found")