提交
This commit is contained in:
1 parent
59fafb92d5
commit
6abfb6e251
1512 files changed
+1565614
-275592
No files matched your search
@@ -14,6 +14,8 @@ from Crypto.Cipher._mode_eax import EaxMode
|
||||
from Crypto.Cipher._mode_gcm import GcmMode
|
||||
from Crypto.Cipher._mode_siv import SivMode
|
||||
from Crypto.Cipher._mode_ocb import OcbMode
|
||||
from Crypto.Cipher._mode_kw import KWMode
|
||||
from Crypto.Cipher._mode_kwp import KWPMode
|
||||
|
||||
MODE_ECB: Literal[1]
|
||||
MODE_CBC: Literal[2]
|
||||
@@ -26,6 +28,8 @@ MODE_EAX: Literal[9]
|
||||
MODE_SIV: Literal[10]
|
||||
MODE_GCM: Literal[11]
|
||||
MODE_OCB: Literal[12]
|
||||
MODE_KW: Literal[13]
|
||||
MODE_KWP: Literal[14]
|
||||
|
||||
# MODE_ECB
|
||||
@overload
|
||||
@@ -151,6 +155,20 @@ def new(key: Buffer,
|
||||
use_aesni : bool = ...) -> \
|
||||
OcbMode: ...
|
||||
|
||||
# MODE_KW
|
||||
@overload
|
||||
def new(key: Buffer,
|
||||
mode: Literal[13],
|
||||
use_aesni : bool = ...) -> \
|
||||
KWMode: ...
|
||||
|
||||
# MODE_KWP
|
||||
@overload
|
||||
def new(key: Buffer,
|
||||
mode: Literal[14],
|
||||
use_aesni : bool = ...) -> \
|
||||
KWPMode: ...
|
||||
|
||||
|
||||
block_size: int
|
||||
key_size: Tuple[int, int, int]
|
||||
@@ -32,7 +32,7 @@ from ._pkcs1_oaep_decode import oaep_decode
|
||||
|
||||
|
||||
class PKCS1OAEP_Cipher:
|
||||
"""Cipher object for PKCS#1 v1.5 OAEP.
|
||||
"""Cipher object for PKCS#1 OAEP.
|
||||
Do not create directly: use :func:`new` instead."""
|
||||
|
||||
def __init__(self, key, hashAlgo, mgfunc, label, randfunc):
|
||||
@@ -45,7 +45,9 @@ class PKCS1OAEP_Cipher:
|
||||
hashAlgo : hash object
|
||||
The hash function to use. This can be a module under `Crypto.Hash`
|
||||
or an existing hash object created from any of such modules. If not specified,
|
||||
`Crypto.Hash.SHA1` is used.
|
||||
`Crypto.Hash.SHA1` is used, matching the RSAES-OAEP default
|
||||
defined in RFC8017. New protocols should use SHA-256 or a stronger
|
||||
hash function.
|
||||
mgfunc : callable
|
||||
A mask generation function that accepts two parameters: a string to
|
||||
use as seed, and the lenth of the mask to generate, in bytes.
|
||||
@@ -205,7 +207,9 @@ def new(key, hashAlgo=None, mgfunc=None, label=b'', randfunc=None):
|
||||
:param hashAlgo:
|
||||
The hash function to use. This can be a module under `Crypto.Hash`
|
||||
or an existing hash object created from any of such modules.
|
||||
If not specified, `Crypto.Hash.SHA1` is used.
|
||||
If not specified, `Crypto.Hash.SHA1` is used, matching the RSAES-OAEP
|
||||
default defined in RFC8017. New protocols should use SHA-256 or a stronger
|
||||
hash function.
|
||||
:type hashAlgo: hash object
|
||||
|
||||
:param mgfunc:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -299,7 +299,7 @@ def _create_ctr_cipher(factory, **kwargs):
|
||||
64 bits will be created though - you must really think through all
|
||||
security consequences of using such a short block size.
|
||||
|
||||
initial_value : posive integer or bytes/bytearray/memoryview
|
||||
initial_value : positive integer or bytes/bytearray/memoryview
|
||||
The initial value for the counter. If not present, the cipher will
|
||||
start counting from 0. The value is incremented by one for each block.
|
||||
The counter number is encoded in big endian mode.
|
||||
|
||||
@@ -244,7 +244,7 @@ class GcmMode(object):
|
||||
nonce=nonce_ctr,
|
||||
**cipher_params)
|
||||
|
||||
# Step 5 - Bootstrat GHASH
|
||||
# Step 5 - Bootstrap GHASH
|
||||
self._signer = _GHASH(hash_subkey, ghash_c)
|
||||
|
||||
# Step 6 - Prepare GCTR cipher for GMAC
|
||||
@@ -379,7 +379,8 @@ class GcmMode(object):
|
||||
self._msg_len += len(plaintext)
|
||||
|
||||
# See NIST SP 800 38D, 5.2.1.1
|
||||
if self._msg_len > 2**39 - 256:
|
||||
# Maximum size is 2**39 - 256 bits
|
||||
if self._msg_len > 68719476704:
|
||||
raise ValueError("Plaintext exceeds maximum length")
|
||||
|
||||
return ciphertext
|
||||
|
||||
@@ -13,7 +13,7 @@ def W(cipher: ModuleType,
|
||||
S = [plaintext[i:i+8] for i in range(0, len(plaintext), 8)]
|
||||
n = len(S)
|
||||
s = 6 * (n - 1)
|
||||
A = S[0]
|
||||
A = bytes(S[0])
|
||||
R = deque(S[1:])
|
||||
|
||||
for t in range(1, s + 1):
|
||||
@@ -31,7 +31,7 @@ def W_inverse(cipher: ModuleType,
|
||||
C = [ciphertext[i:i+8] for i in range(0, len(ciphertext), 8)]
|
||||
n = len(C)
|
||||
s = 6 * (n - 1)
|
||||
A = C[0]
|
||||
A = bytes(C[0])
|
||||
R = deque(C[1:])
|
||||
|
||||
for t in range(s, 0, -1):
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user