Skip to content

Commit

Permalink
Fix GH#705: nonce parameter can be explicitly None (typing) for DES
Browse files Browse the repository at this point in the history
  • Loading branch information
Legrandin committed Jan 27, 2023
1 parent dbe7867 commit 92129e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
14 changes: 6 additions & 8 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
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: DESMode
MODE_OPENPGP: DESMode
MODE_EAX: DESMode

Buffer = Union[bytes, bytearray, memoryview]

def new(key: Buffer,
def new(key: ByteString,
mode: DESMode,
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/DES3.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Dict, Tuple
from typing import Union, Dict, Tuple, ByteString, Optional

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

Buffer = Union[bytes, bytearray, memoryview]

def new(key: Buffer,
def new(key: ByteString,
mode: DES3Mode,
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 92129e9

Please sign in to comment.