aboutsummaryrefslogtreecommitdiff
path: root/frozen_deps/Cryptodome/Hash
diff options
context:
space:
mode:
Diffstat (limited to 'frozen_deps/Cryptodome/Hash')
-rw-r--r--frozen_deps/Cryptodome/Hash/BLAKE2b.py4
-rw-r--r--frozen_deps/Cryptodome/Hash/BLAKE2s.py2
-rw-r--r--frozen_deps/Cryptodome/Hash/CMAC.py12
-rw-r--r--frozen_deps/Cryptodome/Hash/HMAC.py27
-rw-r--r--frozen_deps/Cryptodome/Hash/KangarooTwelve.py78
-rw-r--r--frozen_deps/Cryptodome/Hash/TupleHash128.py18
-rw-r--r--frozen_deps/Cryptodome/Hash/TupleHash128.pyi4
-rw-r--r--frozen_deps/Cryptodome/Hash/TupleHash256.py3
-rw-r--r--frozen_deps/Cryptodome/Hash/TurboSHAKE128.py112
-rw-r--r--frozen_deps/Cryptodome/Hash/TurboSHAKE128.pyi17
-rw-r--r--frozen_deps/Cryptodome/Hash/TurboSHAKE256.py22
-rw-r--r--frozen_deps/Cryptodome/Hash/TurboSHAKE256.pyi12
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_BLAKE2b.abi3.sobin21888 -> 27424 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_BLAKE2b.cpython-39-x86_64-linux-gnu.sobin20015 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_BLAKE2s.abi3.sobin21712 -> 26952 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_BLAKE2s.cpython-39-x86_64-linux-gnu.sobin20807 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_MD2.abi3.sobin20128 -> 23136 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_MD2.cpython-39-x86_64-linux-gnu.sobin16919 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_MD4.abi3.sobin25576 -> 27192 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_MD4.cpython-39-x86_64-linux-gnu.sobin19072 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_MD5.abi3.sobin31704 -> 32008 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_MD5.cpython-39-x86_64-linux-gnu.sobin25434 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_RIPEMD160.abi3.sobin55608 -> 60728 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_RIPEMD160.cpython-39-x86_64-linux-gnu.sobin27226 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_SHA1.abi3.sobin74416 -> 72064 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_SHA1.cpython-39-x86_64-linux-gnu.sobin84273 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_SHA224.abi3.sobin43792 -> 45768 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_SHA224.cpython-39-x86_64-linux-gnu.sobin35822 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_SHA256.abi3.sobin43872 -> 45832 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_SHA256.cpython-39-x86_64-linux-gnu.sobin35806 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_SHA384.abi3.sobin50520 -> 54160 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_SHA384.cpython-39-x86_64-linux-gnu.sobin41869 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_SHA512.abi3.sobin50624 -> 54200 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_SHA512.cpython-39-x86_64-linux-gnu.sobin41967 -> 0 bytes
-rw-r--r--frozen_deps/Cryptodome/Hash/__init__.py49
-rw-r--r--frozen_deps/Cryptodome/Hash/__init__.pyi57
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_ghash_clmul.abi3.sobin50160 -> 58376 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_ghash_clmul.cpython-39-x86_64-linux-gnu.sobin34203 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_ghash_portable.abi3.sobin17432 -> 25024 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_ghash_portable.cpython-39-x86_64-linux-gnu.sobin18711 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_keccak.abi3.sobin35064 -> 41632 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_keccak.cpython-39-x86_64-linux-gnu.sobin26749 -> 0 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_poly1305.abi3.sobin33360 -> 33424 bytes
-rwxr-xr-xfrozen_deps/Cryptodome/Hash/_poly1305.cpython-39-x86_64-linux-gnu.sobin25921 -> 0 bytes
-rw-r--r--frozen_deps/Cryptodome/Hash/cSHAKE128.py6
45 files changed, 336 insertions, 87 deletions
diff --git a/frozen_deps/Cryptodome/Hash/BLAKE2b.py b/frozen_deps/Cryptodome/Hash/BLAKE2b.py
index d7e968f..85da887 100644
--- a/frozen_deps/Cryptodome/Hash/BLAKE2b.py
+++ b/frozen_deps/Cryptodome/Hash/BLAKE2b.py
@@ -233,13 +233,13 @@ def new(**kwargs):
raise ValueError("'digest_bytes' not in range 1..64")
else:
if not (8 <= digest_bits <= 512) or (digest_bits % 8):
- raise ValueError("'digest_bytes' not in range 8..512, "
+ raise ValueError("'digest_bits' not in range 8..512, "
"with steps of 8")
digest_bytes = digest_bits // 8
key = kwargs.pop("key", b"")
if len(key) > 64:
- raise ValueError("BLAKE2s key cannot exceed 64 bytes")
+ raise ValueError("BLAKE2b key cannot exceed 64 bytes")
if kwargs:
raise TypeError("Unknown parameters: " + str(kwargs))
diff --git a/frozen_deps/Cryptodome/Hash/BLAKE2s.py b/frozen_deps/Cryptodome/Hash/BLAKE2s.py
index a16b515..43be5c4 100644
--- a/frozen_deps/Cryptodome/Hash/BLAKE2s.py
+++ b/frozen_deps/Cryptodome/Hash/BLAKE2s.py
@@ -233,7 +233,7 @@ def new(**kwargs):
raise ValueError("'digest_bytes' not in range 1..32")
else:
if not (8 <= digest_bits <= 256) or (digest_bits % 8):
- raise ValueError("'digest_bytes' not in range 8..256, "
+ raise ValueError("'digest_bits' not in range 8..256, "
"with steps of 8")
digest_bytes = digest_bits // 8
diff --git a/frozen_deps/Cryptodome/Hash/CMAC.py b/frozen_deps/Cryptodome/Hash/CMAC.py
index e831700..8feb79f 100644
--- a/frozen_deps/Cryptodome/Hash/CMAC.py
+++ b/frozen_deps/Cryptodome/Hash/CMAC.py
@@ -242,11 +242,15 @@ class CMAC(object):
raise ValueError("MAC check failed")
def hexverify(self, hex_mac_tag):
- """Return the **printable** MAC tag of the message authenticated so far.
+ """Verify that a given **printable** MAC (computed by another party)
+ is valid.
- :return: The MAC tag, computed over the data processed so far.
- Hexadecimal encoded.
- :rtype: string
+ Args:
+ hex_mac_tag (string): the expected MAC of the message, as a hexadecimal string.
+
+ Raises:
+ ValueError: if the MAC does not match. It means that the message
+ has been tampered with or that the MAC key is incorrect.
"""
self.verify(unhexlify(tobytes(hex_mac_tag)))
diff --git a/frozen_deps/Cryptodome/Hash/HMAC.py b/frozen_deps/Cryptodome/Hash/HMAC.py
index 165dd83..615056a 100644
--- a/frozen_deps/Cryptodome/Hash/HMAC.py
+++ b/frozen_deps/Cryptodome/Hash/HMAC.py
@@ -35,13 +35,28 @@ from Cryptodome.Util.py3compat import bord, tobytes
from binascii import unhexlify
-from Cryptodome.Hash import MD5
from Cryptodome.Hash import BLAKE2s
from Cryptodome.Util.strxor import strxor
from Cryptodome.Random import get_random_bytes
__all__ = ['new', 'HMAC']
+_hash2hmac_oid = {
+ '1.3.14.3.2.26': '1.2.840.113549.2.7', # SHA-1
+ '2.16.840.1.101.3.4.2.4': '1.2.840.113549.2.8', # SHA-224
+ '2.16.840.1.101.3.4.2.1': '1.2.840.113549.2.9', # SHA-256
+ '2.16.840.1.101.3.4.2.2': '1.2.840.113549.2.10', # SHA-384
+ '2.16.840.1.101.3.4.2.3': '1.2.840.113549.2.11', # SHA-512
+ '2.16.840.1.101.3.4.2.5': '1.2.840.113549.2.12', # SHA-512_224
+ '2.16.840.1.101.3.4.2.6': '1.2.840.113549.2.13', # SHA-512_256
+ '2.16.840.1.101.3.4.2.7': '2.16.840.1.101.3.4.2.13', # SHA-3 224
+ '2.16.840.1.101.3.4.2.8': '2.16.840.1.101.3.4.2.14', # SHA-3 256
+ '2.16.840.1.101.3.4.2.9': '2.16.840.1.101.3.4.2.15', # SHA-3 384
+ '2.16.840.1.101.3.4.2.10': '2.16.840.1.101.3.4.2.16', # SHA-3 512
+}
+
+_hmac2hash_oid = {v: k for k, v in _hash2hmac_oid.items()}
+
class HMAC(object):
"""An HMAC hash object.
@@ -49,11 +64,15 @@ class HMAC(object):
:ivar digest_size: the size in bytes of the resulting MAC tag
:vartype digest_size: integer
+
+ :ivar oid: the ASN.1 object ID of the HMAC algorithm.
+ Only present if the algorithm was officially assigned one.
"""
def __init__(self, key, msg=b"", digestmod=None):
if digestmod is None:
+ from Cryptodome.Hash import MD5
digestmod = MD5
if msg is None:
@@ -64,6 +83,12 @@ class HMAC(object):
self._digestmod = digestmod
+ # Hash OID --> HMAC OID
+ try:
+ self.oid = _hash2hmac_oid[digestmod.oid]
+ except (KeyError, AttributeError):
+ pass
+
if isinstance(key, memoryview):
key = key.tobytes()
diff --git a/frozen_deps/Cryptodome/Hash/KangarooTwelve.py b/frozen_deps/Cryptodome/Hash/KangarooTwelve.py
index 44d935f..60ced57 100644
--- a/frozen_deps/Cryptodome/Hash/KangarooTwelve.py
+++ b/frozen_deps/Cryptodome/Hash/KangarooTwelve.py
@@ -28,16 +28,10 @@
# POSSIBILITY OF SUCH DAMAGE.
# ===================================================================
-from Cryptodome.Util._raw_api import (VoidPointer, SmartPointer,
- create_string_buffer,
- get_raw_buffer, c_size_t,
- c_uint8_ptr, c_ubyte)
-
from Cryptodome.Util.number import long_to_bytes
from Cryptodome.Util.py3compat import bchr
-from .keccak import _raw_keccak_lib
-
+from . import TurboSHAKE128
def _length_encode(x):
if x == 0:
@@ -70,7 +64,8 @@ class K12_XOF(object):
self._padding = None # Final padding is only decided in read()
# Internal hash that consumes FinalNode
- self._hash1 = self._create_keccak()
+ # The real domain separation byte will be known before squeezing
+ self._hash1 = TurboSHAKE128.new(domain=1)
self._length1 = 0
# Internal hash that produces CV_i (reset each time)
@@ -83,42 +78,6 @@ class K12_XOF(object):
if data:
self.update(data)
- def _create_keccak(self):
- state = VoidPointer()
- result = _raw_keccak_lib.keccak_init(state.address_of(),
- c_size_t(32), # 32 bytes of capacity (256 bits)
- c_ubyte(12)) # Reduced number of rounds
- if result:
- raise ValueError("Error %d while instantiating KangarooTwelve"
- % result)
- return SmartPointer(state.get(), _raw_keccak_lib.keccak_destroy)
-
- def _update(self, data, hash_obj):
- result = _raw_keccak_lib.keccak_absorb(hash_obj.get(),
- c_uint8_ptr(data),
- c_size_t(len(data)))
- if result:
- raise ValueError("Error %d while updating KangarooTwelve state"
- % result)
-
- def _squeeze(self, hash_obj, length, padding):
- bfr = create_string_buffer(length)
- result = _raw_keccak_lib.keccak_squeeze(hash_obj.get(),
- bfr,
- c_size_t(length),
- c_ubyte(padding))
- if result:
- raise ValueError("Error %d while extracting from KangarooTwelve"
- % result)
-
- return get_raw_buffer(bfr)
-
- def _reset(self, hash_obj):
- result = _raw_keccak_lib.keccak_reset(hash_obj.get())
- if result:
- raise ValueError("Error %d while resetting KangarooTwelve state"
- % result)
-
def update(self, data):
"""Hash the next piece of data.
@@ -127,7 +86,7 @@ class K12_XOF(object):
Args:
data (byte string/byte array/memoryview): The next chunk of the
- message to hash.
+ message to hash.
"""
if self._state == SQUEEZING:
@@ -138,7 +97,7 @@ class K12_XOF(object):
if next_length + len(self._custom) <= 8192:
self._length1 = next_length
- self._update(data, self._hash1)
+ self._hash1.update(data)
return self
# Switch to tree hashing
@@ -148,7 +107,7 @@ class K12_XOF(object):
data_mem = memoryview(data)
assert(self._length1 < 8192)
dtc = min(len(data), 8192 - self._length1)
- self._update(data_mem[:dtc], self._hash1)
+ self._hash1.update(data_mem[:dtc])
self._length1 += dtc
if self._length1 < 8192:
@@ -158,10 +117,10 @@ class K12_XOF(object):
assert(self._length1 == 8192)
divider = b'\x03' + b'\x00' * 7
- self._update(divider, self._hash1)
+ self._hash1.update(divider)
self._length1 += 8
- self._hash2 = self._create_keccak()
+ self._hash2 = TurboSHAKE128.new(domain=0x0B)
self._length2 = 0
self._ctr = 1
@@ -178,15 +137,15 @@ class K12_XOF(object):
while index < len_data:
new_index = min(index + 8192 - self._length2, len_data)
- self._update(data_mem[index:new_index], self._hash2)
+ self._hash2.update(data_mem[index:new_index])
self._length2 += new_index - index
index = new_index
if self._length2 == 8192:
- cv_i = self._squeeze(self._hash2, 32, 0x0B)
- self._update(cv_i, self._hash1)
+ cv_i = self._hash2.read(32)
+ self._hash1.update(cv_i)
self._length1 += 32
- self._reset(self._hash2)
+ self._hash2._reset()
self._length2 = 0
self._ctr += 1
@@ -210,7 +169,7 @@ class K12_XOF(object):
custom_was_consumed = False
if self._state == SHORT_MSG:
- self._update(self._custom, self._hash1)
+ self._hash1.update(self._custom)
self._padding = 0x07
self._state = SQUEEZING
@@ -225,20 +184,21 @@ class K12_XOF(object):
# Is there still some leftover data in hash2?
if self._length2 > 0:
- cv_i = self._squeeze(self._hash2, 32, 0x0B)
- self._update(cv_i, self._hash1)
+ cv_i = self._hash2.read(32)
+ self._hash1.update(cv_i)
self._length1 += 32
- self._reset(self._hash2)
+ self._hash2._reset()
self._length2 = 0
self._ctr += 1
trailer = _length_encode(self._ctr - 1) + b'\xFF\xFF'
- self._update(trailer, self._hash1)
+ self._hash1.update(trailer)
self._padding = 0x06
self._state = SQUEEZING
- return self._squeeze(self._hash1, length, self._padding)
+ self._hash1._domain = self._padding
+ return self._hash1.read(length)
def new(self, data=None, custom=b''):
return type(self)(data, custom)
diff --git a/frozen_deps/Cryptodome/Hash/TupleHash128.py b/frozen_deps/Cryptodome/Hash/TupleHash128.py
index 5c910e4..49aeccc 100644
--- a/frozen_deps/Cryptodome/Hash/TupleHash128.py
+++ b/frozen_deps/Cryptodome/Hash/TupleHash128.py
@@ -47,20 +47,21 @@ class TupleHash(object):
self._cshake = cshake._new(b'', custom, b'TupleHash')
self._digest = None
- def update(self, data):
- """Authenticate the next byte string in the tuple.
+ def update(self, *data):
+ """Authenticate the next tuple of byte strings.
+ TupleHash guarantees the logical separation between each byte string.
Args:
- data (bytes/bytearray/memoryview): The next byte string.
+ data (bytes/bytearray/memoryview): One or more items to hash.
"""
if self._digest is not None:
raise TypeError("You cannot call 'update' after 'digest' or 'hexdigest'")
- if not is_bytes(data):
- raise TypeError("You can only call 'update' on bytes")
-
- self._cshake.update(_encode_str(tobytes(data)))
+ for item in data:
+ if not is_bytes(item):
+ raise TypeError("You can only call 'update' on bytes" )
+ self._cshake.update(_encode_str(item))
return self
@@ -132,7 +133,4 @@ def new(**kwargs):
custom = kwargs.pop("custom", b'')
- if kwargs:
- raise TypeError("Unknown parameters: " + str(kwargs))
-
return TupleHash(custom, cSHAKE128, digest_bytes)
diff --git a/frozen_deps/Cryptodome/Hash/TupleHash128.pyi b/frozen_deps/Cryptodome/Hash/TupleHash128.pyi
index 3b1e81e..2e0ea83 100644
--- a/frozen_deps/Cryptodome/Hash/TupleHash128.pyi
+++ b/frozen_deps/Cryptodome/Hash/TupleHash128.pyi
@@ -1,4 +1,4 @@
-from typing import Any, Union
+from typing import Any, Union, List, Tuple
from types import ModuleType
Buffer = Union[bytes, bytearray, memoryview]
@@ -9,7 +9,7 @@ class TupleHash(object):
custom: bytes,
cshake: ModuleType,
digest_size: int) -> None: ...
- def update(self, data: Buffer) -> TupleHash: ...
+ def update(self, *data: Buffer) -> TupleHash: ...
def digest(self) -> bytes: ...
def hexdigest(self) -> str: ...
def new(self,
diff --git a/frozen_deps/Cryptodome/Hash/TupleHash256.py b/frozen_deps/Cryptodome/Hash/TupleHash256.py
index 9b4fba0..40a824a 100644
--- a/frozen_deps/Cryptodome/Hash/TupleHash256.py
+++ b/frozen_deps/Cryptodome/Hash/TupleHash256.py
@@ -67,7 +67,4 @@ def new(**kwargs):
custom = kwargs.pop("custom", b'')
- if kwargs:
- raise TypeError("Unknown parameters: " + str(kwargs))
-
return TupleHash(custom, cSHAKE256, digest_bytes)
diff --git a/frozen_deps/Cryptodome/Hash/TurboSHAKE128.py b/frozen_deps/Cryptodome/Hash/TurboSHAKE128.py
new file mode 100644
index 0000000..92ac59e
--- /dev/null
+++ b/frozen_deps/Cryptodome/Hash/TurboSHAKE128.py
@@ -0,0 +1,112 @@
+from Cryptodome.Util._raw_api import (VoidPointer, SmartPointer,
+ create_string_buffer,
+ get_raw_buffer, c_size_t,
+ c_uint8_ptr, c_ubyte)
+
+from Cryptodome.Util.number import long_to_bytes
+from Cryptodome.Util.py3compat import bchr
+
+from .keccak import _raw_keccak_lib
+
+
+class TurboSHAKE(object):
+ """A TurboSHAKE hash object.
+ Do not instantiate directly.
+ Use the :func:`new` function.
+ """
+
+ def __init__(self, capacity, domain_separation, data):
+
+ state = VoidPointer()
+ result = _raw_keccak_lib.keccak_init(state.address_of(),
+ c_size_t(capacity),
+ c_ubyte(12)) # Reduced number of rounds
+ if result:
+ raise ValueError("Error %d while instantiating TurboSHAKE"
+ % result)
+ self._state = SmartPointer(state.get(), _raw_keccak_lib.keccak_destroy)
+
+ self._is_squeezing = False
+ self._capacity = capacity
+ self._domain = domain_separation
+
+ if data:
+ self.update(data)
+
+
+ def update(self, data):
+ """Continue hashing of a message by consuming the next chunk of data.
+
+ Args:
+ data (byte string/byte array/memoryview): The next chunk of the message being hashed.
+ """
+
+ if self._is_squeezing:
+ raise TypeError("You cannot call 'update' after the first 'read'")
+
+ result = _raw_keccak_lib.keccak_absorb(self._state.get(),
+ c_uint8_ptr(data),
+ c_size_t(len(data)))
+ if result:
+ raise ValueError("Error %d while updating TurboSHAKE state"
+ % result)
+ return self
+
+ def read(self, length):
+ """
+ Compute the next piece of XOF output.
+
+ .. note::
+ You cannot use :meth:`update` anymore after the first call to
+ :meth:`read`.
+
+ Args:
+ length (integer): the amount of bytes this method must return
+
+ :return: the next piece of XOF output (of the given length)
+ :rtype: byte string
+ """
+
+ self._is_squeezing = True
+ bfr = create_string_buffer(length)
+ result = _raw_keccak_lib.keccak_squeeze(self._state.get(),
+ bfr,
+ c_size_t(length),
+ c_ubyte(self._domain))
+ if result:
+ raise ValueError("Error %d while extracting from TurboSHAKE"
+ % result)
+
+ return get_raw_buffer(bfr)
+
+ def new(self, data=None):
+ return type(self)(self._capacity, self._domain, data)
+
+ def _reset(self):
+ result = _raw_keccak_lib.keccak_reset(self._state.get())
+ if result:
+ raise ValueError("Error %d while resetting TurboSHAKE state"
+ % result)
+ self._is_squeezing = False
+
+
+def new(**kwargs):
+ """Create a new TurboSHAKE128 object.
+
+ Args:
+ domain (integer):
+ Optional - A domain separation byte, between 0x01 and 0x7F.
+ The default value is 0x1F.
+ data (bytes/bytearray/memoryview):
+ Optional - The very first chunk of the message to hash.
+ It is equivalent to an early call to :meth:`update`.
+
+ :Return: A :class:`TurboSHAKE` object
+ """
+
+ domain_separation = kwargs.get('domain', 0x1F)
+ if not (0x01 <= domain_separation <= 0x7F):
+ raise ValueError("Incorrect domain separation value (%d)" %
+ domain_separation)
+ data = kwargs.get('data')
+ return TurboSHAKE(32, domain_separation, data=data)
diff --git a/frozen_deps/Cryptodome/Hash/TurboSHAKE128.pyi b/frozen_deps/Cryptodome/Hash/TurboSHAKE128.pyi
new file mode 100644
index 0000000..d74c9c0
--- /dev/null
+++ b/frozen_deps/Cryptodome/Hash/TurboSHAKE128.pyi
@@ -0,0 +1,17 @@
+from typing import Union, Optional
+from typing_extensions import TypedDict, Unpack, NotRequired
+
+Buffer = Union[bytes, bytearray, memoryview]
+
+class TurboSHAKE(object):
+
+ def __init__(self, capacity: int, domain_separation: int, data: Union[Buffer, None]) -> None: ...
+ def update(self, data: Buffer) -> TurboSHAKE : ...
+ def read(self, length: int) -> bytes: ...
+ def new(self, data: Optional[Buffer]=None) -> TurboSHAKE: ...
+
+class Args(TypedDict):
+ domain: NotRequired[int]
+ data: NotRequired[Buffer]
+
+def new(**kwargs: Unpack[Args]) -> TurboSHAKE: ...
diff --git a/frozen_deps/Cryptodome/Hash/TurboSHAKE256.py b/frozen_deps/Cryptodome/Hash/TurboSHAKE256.py
new file mode 100644
index 0000000..ce27a48
--- /dev/null
+++ b/frozen_deps/Cryptodome/Hash/TurboSHAKE256.py
@@ -0,0 +1,22 @@
+from .TurboSHAKE128 import TurboSHAKE
+
+def new(**kwargs):
+ """Create a new TurboSHAKE256 object.
+
+ Args:
+ domain (integer):
+ Optional - A domain separation byte, between 0x01 and 0x7F.
+ The default value is 0x1F.
+ data (bytes/bytearray/memoryview):
+ Optional - The very first chunk of the message to hash.
+ It is equivalent to an early call to :meth:`update`.
+
+ :Return: A :class:`TurboSHAKE` object
+ """
+
+ domain_separation = kwargs.get('domain', 0x1F)
+ if not (0x01 <= domain_separation <= 0x7F):
+ raise ValueError("Incorrect domain separation value (%d)" %
+ domain_separation)
+ data = kwargs.get('data')
+ return TurboSHAKE(64, domain_separation, data=data)
diff --git a/frozen_deps/Cryptodome/Hash/TurboSHAKE256.pyi b/frozen_deps/Cryptodome/Hash/TurboSHAKE256.pyi
new file mode 100644
index 0000000..561e946
--- /dev/null
+++ b/frozen_deps/Cryptodome/Hash/TurboSHAKE256.pyi
@@ -0,0 +1,12 @@
+from typing import Union
+from typing_extensions import TypedDict, Unpack, NotRequired
+
+from .TurboSHAKE128 import TurboSHAKE
+
+Buffer = Union[bytes, bytearray, memoryview]
+
+class Args(TypedDict):
+ domain: NotRequired[int]
+ data: NotRequired[Buffer]
+
+def new(**kwargs: Unpack[Args]) -> TurboSHAKE: ...
diff --git a/frozen_deps/Cryptodome/Hash/_BLAKE2b.abi3.so b/frozen_deps/Cryptodome/Hash/_BLAKE2b.abi3.so
index dfdf331..40cf664 100755
--- a/frozen_deps/Cryptodome/Hash/_BLAKE2b.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_BLAKE2b.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_BLAKE2b.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_BLAKE2b.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index 7338d66..0000000
--- a/frozen_deps/Cryptodome/Hash/_BLAKE2b.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_BLAKE2s.abi3.so b/frozen_deps/Cryptodome/Hash/_BLAKE2s.abi3.so
index 26e69e8..04a1ace 100755
--- a/frozen_deps/Cryptodome/Hash/_BLAKE2s.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_BLAKE2s.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_BLAKE2s.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_BLAKE2s.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index db4ebde..0000000
--- a/frozen_deps/Cryptodome/Hash/_BLAKE2s.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_MD2.abi3.so b/frozen_deps/Cryptodome/Hash/_MD2.abi3.so
index 576ba1e..1573ca3 100755
--- a/frozen_deps/Cryptodome/Hash/_MD2.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_MD2.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_MD2.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_MD2.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index e56703c..0000000
--- a/frozen_deps/Cryptodome/Hash/_MD2.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_MD4.abi3.so b/frozen_deps/Cryptodome/Hash/_MD4.abi3.so
index 0afc5ca..8f41e31 100755
--- a/frozen_deps/Cryptodome/Hash/_MD4.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_MD4.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_MD4.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_MD4.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index fbf60b8..0000000
--- a/frozen_deps/Cryptodome/Hash/_MD4.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_MD5.abi3.so b/frozen_deps/Cryptodome/Hash/_MD5.abi3.so
index 38caf8d..b22cf36 100755
--- a/frozen_deps/Cryptodome/Hash/_MD5.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_MD5.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_MD5.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_MD5.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index dbe7d60..0000000
--- a/frozen_deps/Cryptodome/Hash/_MD5.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_RIPEMD160.abi3.so b/frozen_deps/Cryptodome/Hash/_RIPEMD160.abi3.so
index 2c02e71..78faa00 100755
--- a/frozen_deps/Cryptodome/Hash/_RIPEMD160.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_RIPEMD160.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_RIPEMD160.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_RIPEMD160.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index 6d3560a..0000000
--- a/frozen_deps/Cryptodome/Hash/_RIPEMD160.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_SHA1.abi3.so b/frozen_deps/Cryptodome/Hash/_SHA1.abi3.so
index 2d86b06..acd08ad 100755
--- a/frozen_deps/Cryptodome/Hash/_SHA1.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_SHA1.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_SHA1.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_SHA1.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index 49b0829..0000000
--- a/frozen_deps/Cryptodome/Hash/_SHA1.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_SHA224.abi3.so b/frozen_deps/Cryptodome/Hash/_SHA224.abi3.so
index c462c9b..9cf3ef6 100755
--- a/frozen_deps/Cryptodome/Hash/_SHA224.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_SHA224.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_SHA224.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_SHA224.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index ebaa441..0000000
--- a/frozen_deps/Cryptodome/Hash/_SHA224.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_SHA256.abi3.so b/frozen_deps/Cryptodome/Hash/_SHA256.abi3.so
index c51c162..6dffb17 100755
--- a/frozen_deps/Cryptodome/Hash/_SHA256.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_SHA256.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_SHA256.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_SHA256.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index af2b809..0000000
--- a/frozen_deps/Cryptodome/Hash/_SHA256.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_SHA384.abi3.so b/frozen_deps/Cryptodome/Hash/_SHA384.abi3.so
index 4a4237e..7c72fd0 100755
--- a/frozen_deps/Cryptodome/Hash/_SHA384.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_SHA384.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_SHA384.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_SHA384.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index ae78f57..0000000
--- a/frozen_deps/Cryptodome/Hash/_SHA384.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_SHA512.abi3.so b/frozen_deps/Cryptodome/Hash/_SHA512.abi3.so
index ff9a01f..058653c 100755
--- a/frozen_deps/Cryptodome/Hash/_SHA512.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_SHA512.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_SHA512.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_SHA512.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index 4565097..0000000
--- a/frozen_deps/Cryptodome/Hash/_SHA512.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/__init__.py b/frozen_deps/Cryptodome/Hash/__init__.py
index 4bda084..80446e4 100644
--- a/frozen_deps/Cryptodome/Hash/__init__.py
+++ b/frozen_deps/Cryptodome/Hash/__init__.py
@@ -19,6 +19,51 @@
# ===================================================================
__all__ = ['HMAC', 'MD2', 'MD4', 'MD5', 'RIPEMD160', 'SHA1',
- 'SHA224', 'SHA256', 'SHA384', 'SHA512', 'CMAC', 'Poly1305',
+ 'SHA224', 'SHA256', 'SHA384', 'SHA512',
+ 'SHA3_224', 'SHA3_256', 'SHA3_384', 'SHA3_512',
+ 'CMAC', 'Poly1305',
'cSHAKE128', 'cSHAKE256', 'KMAC128', 'KMAC256',
- 'TupleHash128', 'TupleHash256', 'KangarooTwelve']
+ 'TupleHash128', 'TupleHash256', 'KangarooTwelve',
+ 'TurboSHAKE128', 'TurboSHAKE256']
+
+def new(name):
+ """Return a new hash instance, based on its name or
+ on its ASN.1 Object ID"""
+
+ name = name.upper()
+ if name in ("1.3.14.3.2.26", "SHA1", "SHA-1"):
+ from . import SHA1
+ return SHA1.new()
+ if name in ("2.16.840.1.101.3.4.2.4", "SHA224", "SHA-224"):
+ from . import SHA224
+ return SHA224.new()
+ if name in ("2.16.840.1.101.3.4.2.1", "SHA256", "SHA-256"):
+ from . import SHA256
+ return SHA256.new()
+ if name in ("2.16.840.1.101.3.4.2.2", "SHA384", "SHA-384"):
+ from . import SHA384
+ return SHA384.new()
+ if name in ("2.16.840.1.101.3.4.2.3", "SHA512", "SHA-512"):
+ from . import SHA512
+ return SHA512.new()
+ if name in ("2.16.840.1.101.3.4.2.5", "SHA512-224", "SHA-512-224"):
+ from . import SHA512
+ return SHA512.new(truncate='224')
+ if name in ("2.16.840.1.101.3.4.2.6", "SHA512-256", "SHA-512-256"):
+ from . import SHA512
+ return SHA512.new(truncate='256')
+ if name in ("2.16.840.1.101.3.4.2.7", "SHA3-224", "SHA-3-224"):
+ from . import SHA3_224
+ return SHA3_224.new()
+ if name in ("2.16.840.1.101.3.4.2.8", "SHA3-256", "SHA-3-256"):
+ from . import SHA3_256
+ return SHA3_256.new()
+ if name in ("2.16.840.1.101.3.4.2.9", "SHA3-384", "SHA-3-384"):
+ from . import SHA3_384
+ return SHA3_384.new()
+ if name in ("2.16.840.1.101.3.4.2.10", "SHA3-512", "SHA-3-512"):
+ from . import SHA3_512
+ return SHA3_512.new()
+ else:
+ raise ValueError("Unknown hash %s" % str(name))
+
diff --git a/frozen_deps/Cryptodome/Hash/__init__.pyi b/frozen_deps/Cryptodome/Hash/__init__.pyi
index e69de29..b072157 100644
--- a/frozen_deps/Cryptodome/Hash/__init__.pyi
+++ b/frozen_deps/Cryptodome/Hash/__init__.pyi
@@ -0,0 +1,57 @@
+from typing import overload
+from typing_extensions import Literal
+
+from Cryptodome.Hash.SHA1 import SHA1Hash
+from Cryptodome.Hash.SHA224 import SHA224Hash
+from Cryptodome.Hash.SHA256 import SHA256Hash
+from Cryptodome.Hash.SHA384 import SHA384Hash
+from Cryptodome.Hash.SHA512 import SHA512Hash
+from Cryptodome.Hash.SHA3_224 import SHA3_224_Hash
+from Cryptodome.Hash.SHA3_256 import SHA3_256_Hash
+from Cryptodome.Hash.SHA3_384 import SHA3_384_Hash
+from Cryptodome.Hash.SHA3_512 import SHA3_512_Hash
+
+@overload
+def new(name: Literal["1.3.14.3.2.26"]) -> SHA1Hash: ...
+@overload
+def new(name: Literal["SHA1"]) -> SHA1Hash: ...
+@overload
+def new(name: Literal["2.16.840.1.101.3.4.2.4"]) -> SHA224Hash: ...
+@overload
+def new(name: Literal["SHA224"]) -> SHA224Hash: ...
+@overload
+def new(name: Literal["2.16.840.1.101.3.4.2.1"]) -> SHA256Hash: ...
+@overload
+def new(name: Literal["SHA256"]) -> SHA256Hash: ...
+@overload
+def new(name: Literal["2.16.840.1.101.3.4.2.2"]) -> SHA384Hash: ...
+@overload
+def new(name: Literal["SHA384"]) -> SHA384Hash: ...
+@overload
+def new(name: Literal["2.16.840.1.101.3.4.2.3"]) -> SHA512Hash: ...
+@overload
+def new(name: Literal["SHA512"]) -> SHA512Hash: ...
+@overload
+def new(name: Literal["2.16.840.1.101.3.4.2.5"]) -> SHA512Hash: ...
+@overload
+def new(name: Literal["SHA512-224"]) -> SHA512Hash: ...
+@overload
+def new(name: Literal["2.16.840.1.101.3.4.2.6"]) -> SHA512Hash: ...
+@overload
+def new(name: Literal["SHA512-256"]) -> SHA512Hash: ...
+@overload
+def new(name: Literal["2.16.840.1.101.3.4.2.7"]) -> SHA3_224_Hash: ...
+@overload
+def new(name: Literal["SHA3-224"]) -> SHA3_224_Hash: ...
+@overload
+def new(name: Literal["2.16.840.1.101.3.4.2.8"]) -> SHA3_256_Hash: ...
+@overload
+def new(name: Literal["SHA3-256"]) -> SHA3_256_Hash: ...
+@overload
+def new(name: Literal["2.16.840.1.101.3.4.2.9"]) -> SHA3_384_Hash: ...
+@overload
+def new(name: Literal["SHA3-384"]) -> SHA3_384_Hash: ...
+@overload
+def new(name: Literal["2.16.840.1.101.3.4.2.10"]) -> SHA3_512_Hash: ...
+@overload
+def new(name: Literal["SHA3-512"]) -> SHA3_512_Hash: ...
diff --git a/frozen_deps/Cryptodome/Hash/_ghash_clmul.abi3.so b/frozen_deps/Cryptodome/Hash/_ghash_clmul.abi3.so
index 248bdb7..d13832c 100755
--- a/frozen_deps/Cryptodome/Hash/_ghash_clmul.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_ghash_clmul.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_ghash_clmul.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_ghash_clmul.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index 74005c5..0000000
--- a/frozen_deps/Cryptodome/Hash/_ghash_clmul.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_ghash_portable.abi3.so b/frozen_deps/Cryptodome/Hash/_ghash_portable.abi3.so
index 292f45d..555c6fc 100755
--- a/frozen_deps/Cryptodome/Hash/_ghash_portable.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_ghash_portable.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_ghash_portable.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_ghash_portable.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index dbed009..0000000
--- a/frozen_deps/Cryptodome/Hash/_ghash_portable.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_keccak.abi3.so b/frozen_deps/Cryptodome/Hash/_keccak.abi3.so
index b251995..4e494b0 100755
--- a/frozen_deps/Cryptodome/Hash/_keccak.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_keccak.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_keccak.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_keccak.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index f4e20c7..0000000
--- a/frozen_deps/Cryptodome/Hash/_keccak.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_poly1305.abi3.so b/frozen_deps/Cryptodome/Hash/_poly1305.abi3.so
index e8da59e..901b8c2 100755
--- a/frozen_deps/Cryptodome/Hash/_poly1305.abi3.so
+++ b/frozen_deps/Cryptodome/Hash/_poly1305.abi3.so
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/_poly1305.cpython-39-x86_64-linux-gnu.so b/frozen_deps/Cryptodome/Hash/_poly1305.cpython-39-x86_64-linux-gnu.so
deleted file mode 100755
index 99ca9c3..0000000
--- a/frozen_deps/Cryptodome/Hash/_poly1305.cpython-39-x86_64-linux-gnu.so
+++ /dev/null
Binary files differ
diff --git a/frozen_deps/Cryptodome/Hash/cSHAKE128.py b/frozen_deps/Cryptodome/Hash/cSHAKE128.py
index 7c2f30a..064b3d6 100644
--- a/frozen_deps/Cryptodome/Hash/cSHAKE128.py
+++ b/frozen_deps/Cryptodome/Hash/cSHAKE128.py
@@ -28,7 +28,7 @@
# POSSIBILITY OF SUCH DAMAGE.
# ===================================================================
-from Cryptodome.Util.py3compat import bchr
+from Cryptodome.Util.py3compat import bchr, concat_buffers
from Cryptodome.Util._raw_api import (VoidPointer, SmartPointer,
create_string_buffer,
@@ -69,13 +69,13 @@ def _encode_str(x):
if bitlen >= (1 << 2040):
raise ValueError("String too large to encode in cSHAKE")
- return _left_encode(bitlen) + x
+ return concat_buffers(_left_encode(bitlen), x)
def _bytepad(x, length):
"""Zero pad byte string as defined in NIST SP 800-185"""
- to_pad = _left_encode(length) + x
+ to_pad = concat_buffers(_left_encode(length), x)
# Note: this implementation works with byte aligned strings,
# hence no additional bit padding is needed at this point.