From ee2b932c6a492eae2d1fde1c2ffcb0cd9e5071eb Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Tue, 13 Aug 2024 12:16:30 -0400 Subject: [PATCH] Correct type annotations --- src/allmydata/crypto/aes.py | 6 +++--- src/allmydata/mutable/common.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/allmydata/crypto/aes.py b/src/allmydata/crypto/aes.py index 5c512c980..4119f080b 100644 --- a/src/allmydata/crypto/aes.py +++ b/src/allmydata/crypto/aes.py @@ -83,7 +83,7 @@ def encrypt_data(encryptor: Encryptor, plaintext: bytes) -> bytes: return encryptor.encrypt_context.update(plaintext) -def create_decryptor(key: bytes, iv: Optional[bytes]=None) -> Encryptor: +def create_decryptor(key: bytes, iv: Optional[bytes]=None) -> Decryptor: """ Create and return a new object which can do AES decryptions with the given key and initialization vector (IV). The default IV is 16 @@ -135,7 +135,7 @@ def _create_cryptor(key: bytes, iv: Optional[bytes]) -> CipherContext: return cipher.encryptor() # type: ignore[return-type] -def _validate_key(key): +def _validate_key(key: bytes) -> bytes: """ confirm `key` is suitable for AES encryption, or raise ValueError """ @@ -146,7 +146,7 @@ def _validate_key(key): return key -def _validate_iv(iv): +def _validate_iv(iv: Optional[bytes]) -> bytes: """ Returns a suitable initialiation vector. If `iv` is `None`, a default is returned. If `iv` is not a suitable initialization diff --git a/src/allmydata/mutable/common.py b/src/allmydata/mutable/common.py index a498ab02a..d663638e7 100644 --- a/src/allmydata/mutable/common.py +++ b/src/allmydata/mutable/common.py @@ -74,7 +74,7 @@ def encrypt_privkey(writekey: bytes, privkey: bytes) -> bytes: crypttext = aes.encrypt_data(encryptor, privkey) return crypttext -def decrypt_privkey(writekey: bytes, enc_privkey: bytes) -> rsa.PrivateKey: +def decrypt_privkey(writekey: bytes, enc_privkey: bytes) -> bytes: """ The inverse of ``encrypt_privkey``. """