Crypto++ 8.9
Free C++ class library of cryptographic schemes
|
Interface for hash functions and data processing part of MACs. More...
#include <cryptlib.h>
Public Member Functions | |
HashTransformation & | Ref () |
Provides a reference to this object. | |
virtual void | Update (const byte *input, size_t length)=0 |
Updates a hash with additional input. | |
virtual byte * | CreateUpdateSpace (size_t &size) |
Request space which can be written into by the caller. | |
virtual void | Final (byte *digest) |
Computes the hash of the current message. | |
virtual void | Restart () |
Restart the hash. | |
virtual unsigned int | DigestSize () const =0 |
Provides the digest size of the hash. | |
unsigned int | TagSize () const |
Provides the tag size of the hash. | |
virtual unsigned int | BlockSize () const |
Provides the block size of the compression function. | |
virtual unsigned int | OptimalBlockSize () const |
Provides the input block size most efficient for this hash. | |
virtual unsigned int | OptimalDataAlignment () const |
Provides input and output data alignment for optimal performance. | |
virtual void | CalculateDigest (byte *digest, const byte *input, size_t length) |
Updates the hash with additional input and computes the hash of the current message. | |
virtual bool | Verify (const byte *digest) |
Verifies the hash of the current message. | |
virtual bool | VerifyDigest (const byte *digest, const byte *input, size_t length) |
Updates the hash with additional input and verifies the hash of the current message. | |
virtual void | TruncatedFinal (byte *digest, size_t digestSize)=0 |
Computes the hash of the current message. | |
virtual void | CalculateTruncatedDigest (byte *digest, size_t digestSize, const byte *input, size_t length) |
Updates the hash with additional input and computes the hash of the current message. | |
virtual bool | TruncatedVerify (const byte *digest, size_t digestLength) |
Verifies the hash of the current message. | |
virtual bool | VerifyTruncatedDigest (const byte *digest, size_t digestLength, const byte *input, size_t length) |
Updates the hash with additional input and verifies the hash of the current message. | |
Public Member Functions inherited from Algorithm | |
Algorithm (bool checkSelfTestStatus=true) | |
Interface for all crypto algorithms. | |
virtual std::string | AlgorithmName () const |
Provides the name of this algorithm. | |
virtual std::string | AlgorithmProvider () const |
Retrieve the provider of this algorithm. | |
Public Member Functions inherited from Clonable | |
virtual Clonable * | Clone () const |
Copies this object. | |
Interface for hash functions and data processing part of MACs.
HashTransformation objects are stateful. They are created in an initial state, change state as Update() is called, and return to the initial state when Final() is called. This interface allows a large message to be hashed in pieces by calling Update() on each piece followed by calling Final().
Definition at line 1117 of file cryptlib.h.
|
inlinevirtual |
Definition at line 1120 of file cryptlib.h.
|
inline |
Provides a reference to this object.
Useful for passing a temporary object to a function that takes a non-const reference
Definition at line 1125 of file cryptlib.h.
|
pure virtual |
Updates a hash with additional input.
input | the additional input as a buffer |
length | the size of the buffer, in bytes |
Implemented in Adler32, AuthenticatedSymmetricCipherBase, BLAKE2s, BLAKE2b, CBC_MAC_Base, CMAC_Base, CRC32, CRC32C, DMAC_Base< T >, HMAC_Base, IteratedHashBase< T_HashWordType, HashTransformation >, IteratedHashBase< word32, HashTransformation >, IteratedHashBase< word32, MessageAuthenticationCode >, IteratedHashBase< word64, HashTransformation >, IteratedHashBase< word64, MessageAuthenticationCode >, Keccak, Weak::MD2, Poly1305_Base< T >, Poly1305TLS_Base, PK_MessageAccumulatorBase, SHA3, SHAKE, SipHash_Base< C, D, T_128bit >, SipHash_Base< 2, 4, false >, NullHash, TruncatedHashTemplate< T >, LSH256_Base, LSH512_Base, and ed25519_MessageAccumulator.
|
inlinevirtual |
Request space which can be written into by the caller.
size | the requested size of the buffer |
The purpose of this method is to help avoid extra memory allocations.
size is an IN and OUT parameter and used as a hint. When the call is made, size is the requested size of the buffer. When the call returns, size is the size of the array returned to the caller.
The base class implementation sets size to 0 and returns NULL or nullptr.
Reimplemented in IteratedHashBase< T_HashWordType, HashTransformation >, IteratedHashBase< word32, HashTransformation >, IteratedHashBase< word32, MessageAuthenticationCode >, IteratedHashBase< word64, HashTransformation >, and IteratedHashBase< word64, MessageAuthenticationCode >.
Definition at line 1140 of file cryptlib.h.
|
inlinevirtual |
Computes the hash of the current message.
digest | a pointer to the buffer to receive the hash |
Final() restarts the hash for a new message.
COUNTOF(digest) <= DigestSize()
or COUNTOF(digest) <= HASH::DIGESTSIZE
ensures the output byte buffer is large enough for the digest. Definition at line 1147 of file cryptlib.h.
|
inlinevirtual |
Restart the hash.
Discards the current state, and restart for a new message
Reimplemented in AuthenticatedSymmetricCipherBase, BLAKE2s, BLAKE2b, HMAC_Base, IteratedHashBase< T_HashWordType, HashTransformation >, IteratedHashBase< word32, HashTransformation >, IteratedHashBase< word32, MessageAuthenticationCode >, IteratedHashBase< word64, HashTransformation >, IteratedHashBase< word64, MessageAuthenticationCode >, Keccak, LSH256_Base, LSH512_Base, Poly1305_Base< T >, Poly1305TLS_Base, SHA3, SHAKE, TruncatedHashTemplate< T >, and ed25519_MessageAccumulator.
Definition at line 1152 of file cryptlib.h.
|
pure virtual |
Provides the digest size of the hash.
Implemented in Adler32, BLAKE2s, BLAKE2b, CBC_MAC_Base, CCM_Base, ChaCha20Poly1305_Base, XChaCha20Poly1305_Base, CMAC_Base, CRC32, CRC32C, PK_MessageAccumulator, DMAC_Base< T >, EAX_Base, GCM_Base, HMAC_Base, Keccak, LSH256_Base, LSH512_Base, Weak::MD2, Poly1305_Base< T >, Poly1305TLS_Base, SHA3, SHAKE, SipHash_Base< C, D, T_128bit >, SipHash_Base< 2, 4, false >, NullHash, TruncatedHashTemplate< T >, and VMAC_Base.
|
inline |
Provides the tag size of the hash.
Same as DigestSize().
Definition at line 1162 of file cryptlib.h.
|
inlinevirtual |
Provides the block size of the compression function.
BlockSize() will return 0 if the hash is not block based or does not have an equivalent block size. For example, Keccak and SHA-3 do not have a block size, but they do have an equivalent block size called rate expressed as r
.
Reimplemented in BLAKE2s, BLAKE2b, Keccak_Final< T_DigestSize >, Keccak_Final< 28 >, Keccak_Final< 32 >, Keccak_Final< 48 >, Keccak_Final< 64 >, LSH256_Base, LSH512_Base, Weak::MD2, Poly1305_Base< T >, Poly1305TLS_Base, SHA3_Final< T_DigestSize >, SHA3_Final< 28 >, SHA3_Final< 32 >, SHA3_Final< 48 >, SHA3_Final< 64 >, SHAKE_Final< T_Strength >, SHAKE_Final< 128 >, SHAKE_Final< 256 >, and VMAC_Base.
Definition at line 1170 of file cryptlib.h.
|
inlinevirtual |
Provides the input block size most efficient for this hash.
The base class implementation returns MandatoryBlockSize().
Optimal input length is n * OptimalBlockSize() - GetOptimalBlockSizeUsed()
for any n > 0
.
Reimplemented in CMAC_Base, HMAC_Base, IteratedHashBase< T_HashWordType, HashTransformation >, IteratedHashBase< word32, HashTransformation >, IteratedHashBase< word32, MessageAuthenticationCode >, IteratedHashBase< word64, HashTransformation >, IteratedHashBase< word64, MessageAuthenticationCode >, SipHash_Base< C, D, T_128bit >, and SipHash_Base< 2, 4, false >.
Definition at line 1177 of file cryptlib.h.
|
virtual |
Provides input and output data alignment for optimal performance.
Reimplemented in BLAKE2s, BLAKE2b, CCM_Base, ChaCha20Poly1305_Base, XChaCha20Poly1305_Base, CMAC_Base, EAX_Base, GCM_Base, IteratedHashBase< T_HashWordType, HashTransformation >, IteratedHashBase< word32, HashTransformation >, IteratedHashBase< word32, MessageAuthenticationCode >, IteratedHashBase< word64, HashTransformation >, IteratedHashBase< word64, MessageAuthenticationCode >, Keccak, LSH256_Base, LSH512_Base, SHA3, SHAKE, SipHash_Base< C, D, T_128bit >, SipHash_Base< 2, 4, false >, and VMAC_Base.
|
inlinevirtual |
Updates the hash with additional input and computes the hash of the current message.
digest | a pointer to the buffer to receive the hash |
input | the additional input as a buffer |
length | the size of the buffer, in bytes |
Use this if your input is in one piece and you don't want to call Update() and Final() separately
CalculateDigest() restarts the hash for the next message.
COUNTOF(digest) == DigestSize()
or COUNTOF(digest) == HASH::DIGESTSIZE
ensures the output byte buffer is a valid size. Definition at line 1193 of file cryptlib.h.
|
inlinevirtual |
Verifies the hash of the current message.
digest | a pointer to the buffer of an existing hash |
true
if the existing hash matches the computed hash, false
otherwise InvalidArgument() | if the existing hash's size exceeds DigestSize() |
Verify() performs a bitwise compare on the buffers using VerifyBufsEqual(), which is a constant time comparison function. digestLength cannot exceed DigestSize().
Verify() restarts the hash for the next message.
COUNTOF(digest) == DigestSize()
or COUNTOF(digest) == HASH::DIGESTSIZE
ensures the input byte buffer is a valid size. Definition at line 1205 of file cryptlib.h.
|
inlinevirtual |
Updates the hash with additional input and verifies the hash of the current message.
digest | a pointer to the buffer of an existing hash |
input | the additional input as a buffer |
length | the size of the buffer, in bytes |
true
if the existing hash matches the computed hash, false
otherwise InvalidArgument() | if the existing hash's size exceeds DigestSize() |
Use this if your input is in one piece and you don't want to call Update() and Verify() separately
VerifyDigest() performs a bitwise compare on the buffers using VerifyBufsEqual(), which is a constant time comparison function.
VerifyDigest() restarts the hash for the next message.
COUNTOF(digest) == DigestSize()
or COUNTOF(digest) == HASH::DIGESTSIZE
ensures the output byte buffer is a valid size. Definition at line 1221 of file cryptlib.h.
|
pure virtual |
Computes the hash of the current message.
digest | a pointer to the buffer to receive the hash |
digestSize | the size of the truncated digest, in bytes |
TruncatedFinal() calls Final() and then copies digestSize bytes to digest. The hash is restarted the hash for the next message.
COUNTOF(digest) <= DigestSize()
or COUNTOF(digest) <= HASH::DIGESTSIZE
ensures the output byte buffer is a valid size. Implemented in PK_MessageAccumulator, IteratedHashBase< T_HashWordType, HashTransformation >, IteratedHashBase< word32, HashTransformation >, IteratedHashBase< word32, MessageAuthenticationCode >, IteratedHashBase< word64, HashTransformation >, IteratedHashBase< word64, MessageAuthenticationCode >, SipHash_Base< C, D, T_128bit >, SipHash_Base< 2, 4, false >, NullHash, TruncatedHashTemplate< T >, Adler32, BLAKE2s, BLAKE2b, CRC32, CRC32C, Keccak, LSH256_Base, LSH512_Base, Weak::MD2, SHA3, SHAKE, AuthenticatedSymmetricCipherBase, CBC_MAC_Base, CMAC_Base, DMAC_Base< T >, HMAC_Base, Poly1305_Base< T >, Poly1305TLS_Base, and VMAC_Base.
|
inlinevirtual |
Updates the hash with additional input and computes the hash of the current message.
digest | a pointer to the buffer to receive the hash |
digestSize | the length of the truncated hash, in bytes |
input | the additional input as a buffer |
length | the size of the buffer, in bytes |
Use this if your input is in one piece and you don't want to call Update() and CalculateDigest() separately.
CalculateTruncatedDigest() restarts the hash for the next message.
digestSize <= DigestSize()
or digestSize <= HASH::DIGESTSIZE
ensures the output byte buffer is a valid size. Definition at line 1243 of file cryptlib.h.
|
virtual |
Verifies the hash of the current message.
digest | a pointer to the buffer of an existing hash |
digestLength | the size of the truncated hash, in bytes |
true
if the existing hash matches the computed hash, false
otherwise InvalidArgument() | if digestLength exceeds DigestSize() |
TruncatedVerify() is a truncated version of Verify(). It can operate on a buffer smaller than DigestSize(). However, digestLength cannot exceed DigestSize().
Verify() performs a bitwise compare on the buffers using VerifyBufsEqual(), which is a constant time comparison function. digestLength cannot exceed DigestSize().
TruncatedVerify() restarts the hash for the next message.
digestLength <= DigestSize()
or digestLength <= HASH::DIGESTSIZE
ensures the input byte buffer is a valid size. Reimplemented in NullHash, and TruncatedHashTemplate< T >.
|
inlinevirtual |
Updates the hash with additional input and verifies the hash of the current message.
digest | a pointer to the buffer of an existing hash |
digestLength | the size of the truncated hash, in bytes |
input | the additional input as a buffer |
length | the size of the buffer, in bytes |
true
if the existing hash matches the computed hash, false
otherwise InvalidArgument() | if digestLength exceeds DigestSize() |
Use this if your input is in one piece and you don't want to call Update() and TruncatedVerify() separately.
VerifyTruncatedDigest() is a truncated version of VerifyDigest(). It can operate on a buffer smaller than DigestSize(). However, digestLength cannot exceed DigestSize().
VerifyTruncatedDigest() restarts the hash for the next message.
digestLength <= DigestSize()
or digestLength <= HASH::DIGESTSIZE
ensures the input byte buffer is a valid size. Definition at line 1274 of file cryptlib.h.