mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-03-04 13:09:46 +00:00
Correct type annotations
This commit is contained in:
parent
50fe6b3249
commit
ee2b932c6a
@ -83,7 +83,7 @@ def encrypt_data(encryptor: Encryptor, plaintext: bytes) -> bytes:
|
|||||||
return encryptor.encrypt_context.update(plaintext)
|
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
|
Create and return a new object which can do AES decryptions with
|
||||||
the given key and initialization vector (IV). The default IV is 16
|
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]
|
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
|
confirm `key` is suitable for AES encryption, or raise ValueError
|
||||||
"""
|
"""
|
||||||
@ -146,7 +146,7 @@ def _validate_key(key):
|
|||||||
return key
|
return key
|
||||||
|
|
||||||
|
|
||||||
def _validate_iv(iv):
|
def _validate_iv(iv: Optional[bytes]) -> bytes:
|
||||||
"""
|
"""
|
||||||
Returns a suitable initialiation vector. If `iv` is `None`, a
|
Returns a suitable initialiation vector. If `iv` is `None`, a
|
||||||
default is returned. If `iv` is not a suitable initialization
|
default is returned. If `iv` is not a suitable initialization
|
||||||
|
@ -74,7 +74,7 @@ def encrypt_privkey(writekey: bytes, privkey: bytes) -> bytes:
|
|||||||
crypttext = aes.encrypt_data(encryptor, privkey)
|
crypttext = aes.encrypt_data(encryptor, privkey)
|
||||||
return crypttext
|
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``.
|
The inverse of ``encrypt_privkey``.
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user