This commit is contained in:
Iliyan Angelov
2025-11-19 12:27:01 +02:00
parent 2043ac897c
commit 34b4c969d4
469 changed files with 26870 additions and 8329 deletions

View File

@@ -5,32 +5,33 @@
from __future__ import annotations
import abc
import typing
from cryptography.hazmat.bindings._rust import openssl as rust_openssl
from cryptography.utils import Buffer
__all__ = [
"HashAlgorithm",
"HashContext",
"Hash",
"ExtendableOutputFunction",
"MD5",
"SHA1",
"SHA512_224",
"SHA512_256",
"SHA224",
"SHA256",
"SHA384",
"SHA512",
"SHA3_224",
"SHA3_256",
"SHA3_384",
"SHA3_512",
"SHA224",
"SHA256",
"SHA384",
"SHA512",
"SHA512_224",
"SHA512_256",
"SHAKE128",
"SHAKE256",
"MD5",
"SM3",
"BLAKE2b",
"BLAKE2s",
"SM3",
"ExtendableOutputFunction",
"Hash",
"HashAlgorithm",
"HashContext",
"XOFHash",
]
@@ -51,7 +52,7 @@ class HashAlgorithm(metaclass=abc.ABCMeta):
@property
@abc.abstractmethod
def block_size(self) -> typing.Optional[int]:
def block_size(self) -> int | None:
"""
The internal block size of the hash function, or None if the hash
function does not use blocks internally (e.g. SHA3).
@@ -67,7 +68,7 @@ class HashContext(metaclass=abc.ABCMeta):
"""
@abc.abstractmethod
def update(self, data: bytes) -> None:
def update(self, data: Buffer) -> None:
"""
Processes the provided bytes through the hash.
"""
@@ -88,6 +89,8 @@ class HashContext(metaclass=abc.ABCMeta):
Hash = rust_openssl.hashes.Hash
HashContext.register(Hash)
XOFHash = rust_openssl.hashes.XOFHash
class ExtendableOutputFunction(metaclass=abc.ABCMeta):
"""