aboutsummaryrefslogtreecommitdiff
path: root/frozen_deps/Cryptodome/Hash/SHA3_384.py
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2022-11-17 18:08:59 -0800
committerDeterminant <[email protected]>2022-11-17 18:08:59 -0800
commit8154806fe2fccacdc3dafaa68181a07bcf8d6c4c (patch)
treef477e6a005599bb88c18db142c267b9297c6060b /frozen_deps/Cryptodome/Hash/SHA3_384.py
parentbe4dc086591c9bced04a507d127c83811c5700c4 (diff)
v0.1.7
Diffstat (limited to 'frozen_deps/Cryptodome/Hash/SHA3_384.py')
-rw-r--r--frozen_deps/Cryptodome/Hash/SHA3_384.py42
1 files changed, 37 insertions, 5 deletions
diff --git a/frozen_deps/Cryptodome/Hash/SHA3_384.py b/frozen_deps/Cryptodome/Hash/SHA3_384.py
index e6baf3f..26eeb79 100644
--- a/frozen_deps/Cryptodome/Hash/SHA3_384.py
+++ b/frozen_deps/Cryptodome/Hash/SHA3_384.py
@@ -24,7 +24,7 @@ from Cryptodome.Util._raw_api import (load_pycryptodome_raw_lib,
VoidPointer, SmartPointer,
create_string_buffer,
get_raw_buffer, c_size_t,
- c_uint8_ptr)
+ c_uint8_ptr, c_ubyte)
from Cryptodome.Hash.keccak import _raw_keccak_lib
@@ -46,14 +46,18 @@ class SHA3_384_Hash(object):
# ASN.1 Object ID
oid = "2.16.840.1.101.3.4.2.9"
+ # Input block size for HMAC
+ block_size = 104
+
def __init__(self, data, update_after_digest):
self._update_after_digest = update_after_digest
self._digest_done = False
+ self._padding = 0x06
state = VoidPointer()
result = _raw_keccak_lib.keccak_init(state.address_of(),
c_size_t(self.digest_size * 2),
- 0x06)
+ c_ubyte(24))
if result:
raise ValueError("Error %d while instantiating SHA-3/384"
% result)
@@ -93,7 +97,8 @@ class SHA3_384_Hash(object):
bfr = create_string_buffer(self.digest_size)
result = _raw_keccak_lib.keccak_digest(self._state.get(),
bfr,
- c_size_t(self.digest_size))
+ c_size_t(self.digest_size),
+ c_ubyte(self._padding))
if result:
raise ValueError("Error %d while instantiating SHA-3/384"
% result)
@@ -111,10 +116,34 @@ class SHA3_384_Hash(object):
return "".join(["%02x" % bord(x) for x in self.digest()])
- def new(self):
+ def copy(self):
+ """Return a copy ("clone") of the hash object.
+
+ The copy will have the same internal state as the original hash
+ object.
+ This can be used to efficiently compute the digests of strings that
+ share a common initial substring.
+
+ :return: A hash object of the same type
+ """
+
+ clone = self.new()
+ result = _raw_keccak_lib.keccak_copy(self._state.get(),
+ clone._state.get())
+ if result:
+ raise ValueError("Error %d while copying SHA3-384" % result)
+ return clone
+
+ def new(self, data=None):
+ """Create a fresh SHA3-256 hash object."""
+
+ return type(self)(data, self._update_after_digest)
+
+
+ def new(self, data=None):
"""Create a fresh SHA3-384 hash object."""
- return type(self)(None, self._update_after_digest)
+ return type(self)(data, self._update_after_digest)
def new(*args, **kwargs):
@@ -145,3 +174,6 @@ def new(*args, **kwargs):
# The size of the resulting hash in bytes.
digest_size = SHA3_384_Hash.digest_size
+
+# Input block size for HMAC
+block_size = 104