Skip to content

Commit

Permalink
Fix GH#705: nonce parameter can be explicitly None (typing) for CAST …
Browse files Browse the repository at this point in the history
…and ARC2/4
  • Loading branch information
Legrandin committed Jan 27, 2023
1 parent 92129e9 commit 37315bc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 31 deletions.
14 changes: 6 additions & 8 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
from typing import Union, Dict, Iterable, Optional, ByteString

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

Buffer = Union[bytes, bytearray, memoryview]

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

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

Buffer = Union[bytes, bytearray, memoryview]
from typing import Any, Union, Iterable, ByteString

class ARC4Cipher:
block_size: int
key_size: int

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

def new(key: Buffer, drop : int = ...) -> ARC4Cipher: ...
def new(key: ByteString, drop : int = ...) -> ARC4Cipher: ...

block_size: int
key_size: Iterable[int]
14 changes: 6 additions & 8 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
from typing import Union, Dict, Iterable, ByteString, Optional

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

Buffer = Union[bytes, bytearray, memoryview]

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

Expand Down
14 changes: 6 additions & 8 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
from typing import Union, Dict, Iterable, Optional, ByteString

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

Buffer = Union[bytes, bytearray, memoryview]

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

Expand Down

0 comments on commit 37315bc

Please sign in to comment.