Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of typing.ByteString #738

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions lib/Crypto/Cipher/AES.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import ByteString, Dict, Optional, Tuple, Union, overload
from typing import Dict, Tuple, overload
from typing_extensions import Literal

from Crypto.Cipher._mode_ecb import EcbMode
Expand Down Expand Up @@ -27,124 +27,124 @@ MODE_OCB: Literal[12]

# MODE_ECB
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[1],
use_aesni : bool = ...) -> \
EcbMode: ...

# MODE_CBC
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[2],
iv : Optional[ByteString] = ...,
iv : bytes | bytearray | None = ...,
use_aesni : bool = ...) -> \
CbcMode: ...

@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[2],
IV : Optional[ByteString] = ...,
IV : bytes | bytearray | None = ...,
use_aesni : bool = ...) -> \
CbcMode: ...

# MODE_CFB
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[3],
iv : Optional[ByteString] = ...,
iv : bytes | bytearray | None = ...,
segment_size : int = ...,
use_aesni : bool = ...) -> \
CfbMode: ...

@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[3],
IV : Optional[ByteString] = ...,
IV : bytes | bytearray | None = ...,
segment_size : int = ...,
use_aesni : bool = ...) -> \
CfbMode: ...

# MODE_OFB
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[5],
iv : Optional[ByteString] = ...,
iv : bytes | bytearray | None = ...,
use_aesni : bool = ...) -> \
OfbMode: ...

@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[5],
IV : Optional[ByteString] = ...,
IV : bytes | bytearray | None = ...,
use_aesni : bool = ...) -> \
OfbMode: ...

# MODE_CTR
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[6],
nonce : Optional[ByteString] = ...,
initial_value : Union[int, ByteString] = ...,
nonce : bytes | bytearray | None = ...,
initial_value : int | bytes | bytearray = ...,
counter : Dict = ...,
use_aesni : bool = ...) -> \
CtrMode: ...

# MODE_OPENPGP
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[7],
iv : Optional[ByteString] = ...,
iv : bytes | bytearray | None = ...,
use_aesni : bool = ...) -> \
OpenPgpMode: ...

@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[7],
IV : Optional[ByteString] = ...,
IV : bytes | bytearray | None = ...,
use_aesni : bool = ...) -> \
OpenPgpMode: ...

# MODE_CCM
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[8],
nonce : Optional[ByteString] = ...,
nonce : bytes | bytearray | None = ...,
mac_len : int = ...,
assoc_len : int = ...,
use_aesni : bool = ...) -> \
CcmMode: ...

# MODE_EAX
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[9],
nonce : Optional[ByteString] = ...,
nonce : bytes | bytearray | None = ...,
mac_len : int = ...,
use_aesni : bool = ...) -> \
EaxMode: ...

# MODE_GCM
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[10],
nonce : Optional[ByteString] = ...,
nonce : bytes | bytearray | None = ...,
use_aesni : bool = ...) -> \
SivMode: ...

# MODE_SIV
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[11],
nonce : Optional[ByteString] = ...,
nonce : bytes | bytearray | None = ...,
mac_len : int = ...,
use_aesni : bool = ...) -> \
GcmMode: ...

# MODE_OCB
@overload
def new(key: ByteString,
def new(key: bytes | bytearray,
mode: Literal[12],
nonce : Optional[ByteString] = ...,
nonce : bytes | bytearray | None = ...,
mac_len : int = ...,
use_aesni : bool = ...) -> \
OcbMode: ...
Expand Down
12 changes: 6 additions & 6 deletions lib/Crypto/Cipher/ARC2.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Dict, Iterable, Optional, ByteString
from typing import Union, Dict, Iterable

from Crypto.Cipher._mode_ecb import EcbMode
from Crypto.Cipher._mode_cbc import CbcMode
Expand All @@ -18,14 +18,14 @@ MODE_CTR: ARC2Mode
MODE_OPENPGP: ARC2Mode
MODE_EAX: ARC2Mode

def new(key: ByteString,
def new(key: bytes | bytearray,
mode: ARC2Mode,
iv : Optional[ByteString] = ...,
IV : Optional[ByteString] = ...,
nonce : Optional[ByteString] = ...,
iv : bytes | bytearray | None = ...,
IV : bytes | bytearray | None = ...,
nonce : bytes | bytearray | None = ...,
segment_size : int = ...,
mac_len : int = ...,
initial_value : Union[int, ByteString] = ...,
initial_value : int | bytes | bytearray = ...,
counter : Dict = ...) -> \
Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...

Expand Down
10 changes: 5 additions & 5 deletions lib/Crypto/Cipher/ARC4.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import Any, Union, Iterable, ByteString
from typing import Any, Iterable

class ARC4Cipher:
block_size: int
key_size: int

def __init__(self, key: ByteString, *args: Any, **kwargs: Any) -> None: ...
def encrypt(self, plaintext: ByteString) -> bytes: ...
def decrypt(self, ciphertext: ByteString) -> bytes: ...
def __init__(self, key: bytes | bytearray, *args: Any, **kwargs: Any) -> None: ...
def encrypt(self, plaintext: bytes | bytearray) -> bytes: ...
def decrypt(self, ciphertext: bytes | bytearray) -> bytes: ...

def new(key: ByteString, drop : int = ...) -> ARC4Cipher: ...
def new(key: bytes | bytearray, drop : int = ...) -> ARC4Cipher: ...

block_size: int
key_size: Iterable[int]
12 changes: 6 additions & 6 deletions lib/Crypto/Cipher/Blowfish.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Dict, Iterable, ByteString, Optional
from typing import Union, Dict, Iterable

from Crypto.Cipher._mode_ecb import EcbMode
from Crypto.Cipher._mode_cbc import CbcMode
Expand All @@ -18,14 +18,14 @@ MODE_CTR: BlowfishMode
MODE_OPENPGP: BlowfishMode
MODE_EAX: BlowfishMode

def new(key: ByteString,
def new(key: bytes | bytearray,
mode: BlowfishMode,
iv : Optional[ByteString] = ...,
IV : Optional[ByteString] = ...,
nonce : Optional[ByteString] = ...,
iv : bytes | bytearray | None = ...,
IV : bytes | bytearray | None = ...,
nonce : bytes | bytearray | None = ...,
segment_size : int = ...,
mac_len : int = ...,
initial_value : Union[int, ByteString] = ...,
initial_value : int | bytes | bytearray = ...,
counter : Dict = ...) -> \
Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...

Expand Down
12 changes: 6 additions & 6 deletions lib/Crypto/Cipher/CAST.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Dict, Iterable, Optional, ByteString
from typing import Union, Dict, Iterable

from Crypto.Cipher._mode_ecb import EcbMode
from Crypto.Cipher._mode_cbc import CbcMode
Expand All @@ -18,14 +18,14 @@ MODE_CTR: CASTMode
MODE_OPENPGP: CASTMode
MODE_EAX: CASTMode

def new(key: ByteString,
def new(key: bytes | bytearray,
mode: CASTMode,
iv : Optional[ByteString] = ...,
IV : Optional[ByteString] = ...,
nonce : Optional[ByteString] = ...,
iv : bytes | bytearray | None = ...,
IV : bytes | bytearray | None = ...,
nonce : bytes | bytearray | None = ...,
segment_size : int = ...,
mac_len : int = ...,
initial_value : Union[int, ByteString] = ...,
initial_value : int | bytes | bytearray = ...,
counter : Dict = ...) -> \
Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...

Expand Down
16 changes: 8 additions & 8 deletions lib/Crypto/Cipher/ChaCha20.pyi
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from typing import Union, overload, ByteString, Optional
from typing import Union, overload

def _HChaCha20(key: ByteString, nonce: ByteString) -> bytearray: ...
def _HChaCha20(key: bytes | bytearray, nonce: bytes | bytearray) -> bytearray: ...

class ChaCha20Cipher:
block_size: int
nonce: bytes

def __init__(self, key: ByteString, nonce: ByteString) -> None: ...
def __init__(self, key: bytes | bytearray, nonce: bytes | bytearray) -> None: ...
@overload
def encrypt(self, plaintext: ByteString) -> bytes: ...
def encrypt(self, plaintext: bytes | bytearray) -> bytes: ...
@overload
def encrypt(self, plaintext: ByteString, output: Union[bytearray, memoryview]) -> None: ...
def encrypt(self, plaintext: bytes | bytearray, output: Union[bytearray, memoryview]) -> None: ...
@overload
def decrypt(self, plaintext: ByteString) -> bytes: ...
def decrypt(self, plaintext: bytes | bytearray) -> bytes: ...
@overload
def decrypt(self, plaintext: ByteString, output: Union[bytearray, memoryview]) -> None: ...
def decrypt(self, plaintext: bytes | bytearray, output: Union[bytearray, memoryview]) -> None: ...
def seek(self, position: int) -> None: ...

def new(key: ByteString, nonce: Optional[ByteString] = ...) -> ChaCha20Cipher: ...
def new(key: bytes | bytearray, nonce: bytes | bytearray | None = ...) -> ChaCha20Cipher: ...

block_size: int
key_size: int
22 changes: 11 additions & 11 deletions lib/Crypto/Cipher/ChaCha20_Poly1305.pyi
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
from typing import Union, Tuple, overload, ByteString, Optional
from typing import Union, Tuple, overload

class ChaCha20Poly1305Cipher:
nonce: bytes

def __init__(self, key: ByteString, nonce: ByteString) -> None: ...
def update(self, data: ByteString) -> None: ...
def __init__(self, key: bytes | bytearray, nonce: bytes | bytearray) -> None: ...
def update(self, data: bytes | bytearray) -> None: ...
@overload
def encrypt(self, plaintext: ByteString) -> bytes: ...
def encrypt(self, plaintext: bytes | bytearray) -> bytes: ...
@overload
def encrypt(self, plaintext: ByteString, output: Union[bytearray, memoryview]) -> None: ...
def encrypt(self, plaintext: bytes | bytearray, output: Union[bytearray, memoryview]) -> None: ...
@overload
def decrypt(self, plaintext: ByteString) -> bytes: ...
def decrypt(self, plaintext: bytes | bytearray) -> bytes: ...
@overload
def decrypt(self, plaintext: ByteString, output: Union[bytearray, memoryview]) -> None: ...
def decrypt(self, plaintext: bytes | bytearray, output: Union[bytearray, memoryview]) -> None: ...
def digest(self) -> bytes: ...
def hexdigest(self) -> str: ...
def verify(self, received_mac_tag: ByteString) -> None: ...
def verify(self, received_mac_tag: bytes | bytearray) -> None: ...
def hexverify(self, received_mac_tag: str) -> None: ...
def encrypt_and_digest(self, plaintext: ByteString) -> Tuple[bytes, bytes]: ...
def decrypt_and_verify(self, ciphertext: ByteString, received_mac_tag: ByteString) -> bytes: ...
def encrypt_and_digest(self, plaintext: bytes | bytearray) -> Tuple[bytes, bytes]: ...
def decrypt_and_verify(self, ciphertext: bytes | bytearray, received_mac_tag: bytes | bytearray) -> bytes: ...

def new(key: ByteString, nonce: Optional[ByteString] = ...) -> ChaCha20Poly1305Cipher: ...
def new(key: bytes | bytearray, nonce: bytes | bytearray | None = ...) -> ChaCha20Poly1305Cipher: ...

block_size: int
key_size: int
12 changes: 6 additions & 6 deletions lib/Crypto/Cipher/DES.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Dict, Iterable, ByteString, Optional
from typing import Union, Dict

from Crypto.Cipher._mode_ecb import EcbMode
from Crypto.Cipher._mode_cbc import CbcMode
Expand All @@ -18,14 +18,14 @@ MODE_CTR: DESMode
MODE_OPENPGP: DESMode
MODE_EAX: DESMode

def new(key: ByteString,
def new(key: bytes | bytearray,
mode: DESMode,
iv : Optional[ByteString] = ...,
IV : Optional[ByteString] = ...,
nonce : Optional[ByteString] = ...,
iv : bytes | bytearray | None = ...,
IV : bytes | bytearray | None = ...,
nonce : bytes | bytearray | None = ...,
segment_size : int = ...,
mac_len : int = ...,
initial_value : Union[int, ByteString] = ...,
initial_value : int | bytes | bytearray = ...,
counter : Dict = ...) -> \
Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...

Expand Down
12 changes: 6 additions & 6 deletions lib/Crypto/Cipher/DES3.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Dict, Tuple, ByteString, Optional
from typing import Union, Dict, Tuple

from Crypto.Cipher._mode_ecb import EcbMode
from Crypto.Cipher._mode_cbc import CbcMode
Expand All @@ -20,14 +20,14 @@ MODE_CTR: DES3Mode
MODE_OPENPGP: DES3Mode
MODE_EAX: DES3Mode

def new(key: ByteString,
def new(key: bytes | bytearray,
mode: DES3Mode,
iv : Optional[ByteString] = ...,
IV : Optional[ByteString] = ...,
nonce : Optional[ByteString] = ...,
iv : bytes | bytearray | None = ...,
IV : bytes | bytearray | None = ...,
nonce : bytes | bytearray | None = ...,
segment_size : int = ...,
mac_len : int = ...,
initial_value : Union[int, ByteString] = ...,
initial_value : int | bytes | bytearray = ...,
counter : Dict = ...) -> \
Union[EcbMode, CbcMode, CfbMode, OfbMode, CtrMode, OpenPgpMode]: ...

Expand Down
Loading