/opt/imh-python/lib/python3.9/site-packages/Crypto/Hash
NameSizeModeActions
__pycache__/-0755rm
BLAKE2b.py94240644editdlrm
BLAKE2b.pyi8770644editdlrm
BLAKE2s.py94300644editdlrm
BLAKE2s.pyi7390644editdlrm
CMAC.py104200644editdlrm
CMAC.pyi7970644editdlrm
HMAC.py70380644editdlrm
HMAC.pyi6240644editdlrm
keccak.py71060644editdlrm
keccak.pyi7410644editdlrm
MD2.py61110644editdlrm
MD2.pyi4920644editdlrm
MD4.py65820644editdlrm
MD4.pyi5320644editdlrm
MD5.py66180644editdlrm
MD5.pyi4920644editdlrm
Poly1305.py80740644editdlrm
Poly1305.pyi6650644editdlrm
RIPEMD.py11990644editdlrm
RIPEMD.pyi940644editdlrm
RIPEMD160.py63980644editdlrm
RIPEMD160.pyi5160644editdlrm
SHA.py11480644editdlrm
SHA.pyi1610644editdlrm
SHA1.py66900644editdlrm
SHA1.pyi5360644editdlrm
SHA3_224.py52900644editdlrm
SHA3_224.pyi5040644editdlrm
SHA3_256.py52900644editdlrm
SHA3_256.pyi5040644editdlrm
SHA3_384.py52900644editdlrm
SHA3_384.pyi5040644editdlrm
SHA3_512.py52920644editdlrm
SHA3_512.pyi5040644editdlrm
SHA224.py69010644editdlrm
SHA224.pyi5440644editdlrm
SHA256.py68970644editdlrm
SHA256.pyi6120644editdlrm
SHA384.py68990644editdlrm
SHA384.pyi5440644editdlrm
SHA512.py77200644editdlrm
SHA512.pyi6220644editdlrm
SHAKE128.py46440644editdlrm
SHAKE128.pyi4370644editdlrm
SHAKE256.py46440644editdlrm
SHAKE256.pyi4370644editdlrm
_BLAKE2b.cpython-39-x86_64-linux-gnu.so98560755editdlrm
_BLAKE2s.cpython-39-x86_64-linux-gnu.so99520755editdlrm
_ghash_clmul.cpython-39-x86_64-linux-gnu.so80160755editdlrm
_ghash_portable.cpython-39-x86_64-linux-gnu.so85920755editdlrm
_keccak.cpython-39-x86_64-linux-gnu.so106480755editdlrm
_MD2.cpython-39-x86_64-linux-gnu.so90480755editdlrm
_MD4.cpython-39-x86_64-linux-gnu.so96640755editdlrm
_MD5.cpython-39-x86_64-linux-gnu.so117600755editdlrm
_poly1305.cpython-39-x86_64-linux-gnu.so96000755editdlrm
_RIPEMD160.cpython-39-x86_64-linux-gnu.so105600755editdlrm
_SHA1.cpython-39-x86_64-linux-gnu.so148720755editdlrm
_SHA224.cpython-39-x86_64-linux-gnu.so177440755editdlrm
_SHA256.cpython-39-x86_64-linux-gnu.so177440755editdlrm
_SHA384.cpython-39-x86_64-linux-gnu.so213760755editdlrm
_SHA512.cpython-39-x86_64-linux-gnu.so214160755editdlrm
__init__.py11190644editdlrm
__init__.pyi00644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/Crypto/Hash/SHA3_224.py (5290B)
# -*- coding: utf-8 -*- # # =================================================================== # The contents of this file are dedicated to the public domain. To # the extent that dedication to the public domain is not available, # everyone is granted a worldwide, perpetual, royalty-free, # non-exclusive license to exercise all rights associated with the # contents of this file for any purpose whatsoever. # No rights are reserved. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # =================================================================== from Crypto.Util.py3compat import bord from Crypto.Util._raw_api import (load_pycryptodome_raw_lib, VoidPointer, SmartPointer, create_string_buffer, get_raw_buffer, c_size_t, c_uint8_ptr) from Crypto.Hash.keccak import _raw_keccak_lib class SHA3_224_Hash(object): """A SHA3-224 hash object. Do not instantiate directly. Use the :func:`new` function. :ivar oid: ASN.1 Object ID :vartype oid: string :ivar digest_size: the size in bytes of the resulting hash :vartype digest_size: integer """ # The size of the resulting hash in bytes. digest_size = 28 # ASN.1 Object ID oid = "2.16.840.1.101.3.4.2.7" def __init__(self, data, update_after_digest): self._update_after_digest = update_after_digest self._digest_done = False state = VoidPointer() result = _raw_keccak_lib.keccak_init(state.address_of(), c_size_t(self.digest_size * 2), 0x06) if result: raise ValueError("Error %d while instantiating SHA-3/224" % result) self._state = SmartPointer(state.get(), _raw_keccak_lib.keccak_destroy) 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._digest_done and not self._update_after_digest: raise TypeError("You can only call 'digest' or 'hexdigest' on this object") 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 SHA-3/224" % result) return self def digest(self): """Return the **binary** (non-printable) digest of the message that has been hashed so far. :return: The hash digest, computed over the data processed so far. Binary form. :rtype: byte string """ self._digest_done = True bfr = create_string_buffer(self.digest_size) result = _raw_keccak_lib.keccak_digest(self._state.get(), bfr, c_size_t(self.digest_size)) if result: raise ValueError("Error %d while instantiating SHA-3/224" % result) self._digest_value = get_raw_buffer(bfr) return self._digest_value def hexdigest(self): """Return the **printable** digest of the message that has been hashed so far. :return: The hash digest, computed over the data processed so far. Hexadecimal encoded. :rtype: string """ return "".join(["%02x" % bord(x) for x in self.digest()]) def new(self): """Create a fresh SHA3-224 hash object.""" return type(self)(None, self._update_after_digest) def new(*args, **kwargs): """Create a new hash object. Args: data (byte string/byte array/memoryview): The very first chunk of the message to hash. It is equivalent to an early call to :meth:`update`. update_after_digest (boolean): Whether :meth:`digest` can be followed by another :meth:`update` (default: ``False``). :Return: A :class:`SHA3_224_Hash` hash object """ data = kwargs.pop("data", None) update_after_digest = kwargs.pop("update_after_digest", False) if len(args) == 1: if data: raise ValueError("Initial data for hash specified twice") data = args[0] if kwargs: raise TypeError("Unknown parameters: " + str(kwargs)) return SHA3_224_Hash(data, update_after_digest) # The size of the resulting hash in bytes. digest_size = SHA3_224_Hash.digest_size