cryptoTools::SHAx Class Reference

Provides a common interface for all the hashfunctions of the SHA-2 family. More...

#include <shax.hpp>

+ Inheritance diagram for cryptoTools::SHAx:
+ Collaboration diagram for cryptoTools::SHAx:

Public Member Functions

virtual void preprocess (std::vector< uint8_t > initialMessage)
 Parses a vector of bytes and applies to it the transformations specified in the NIST's specification.
virtual void round (unsigned int counter)
 Performs a round over the 16 message bytes contained in M, starting at counter and finishing at counter+"something". In the end, the internal state H is updated to the new value.
virtual void hash (std::vector< uint8_t > initialMessage)
 Performs all the steps necessary to hash the message given on the input. In the end, the internal state H contains the digest of the message.
virtual std::vector< uint8_t > getHash ()
 Returns a vector of uint8_t containing the hash.
virtual std::string getType ()
 To know which hashfunction it is.
virtual uint32_t getHashLength ()
 To know the bitlength of the hash we should expect.

Detailed Description

Provides a common interface for all the hashfunctions of the SHA-2 family.

These were implemented using the NIST specification. It is available here.

See Also
shatest.cpp

Definition at line 38 of file shax.hpp.

Member Function Documentation

virtual std::vector<uint8_t> cryptoTools::SHAx::getHash ( )
inlinevirtual

Returns a vector of uint8_t containing the hash.

Reimplemented in cryptoTools::SHA256, cryptoTools::SHA512, and cryptoTools::SHA384.

Definition at line 80 of file shax.hpp.

{
std::vector<uint8_t> emptyVector;
return emptyVector;
};
virtual uint32_t cryptoTools::SHAx::getHashLength ( )
inlinevirtual

To know the bitlength of the hash we should expect.

Returns
The length of the hash, in bits.

Reimplemented in cryptoTools::SHA256, cryptoTools::SHA512, and cryptoTools::SHA384.

Definition at line 101 of file shax.hpp.

{
return 0;
}
virtual std::string cryptoTools::SHAx::getType ( )
inlinevirtual

To know which hashfunction it is.

Returns
The name of the hashfunction.

Reimplemented in cryptoTools::SHA256, cryptoTools::SHA512, and cryptoTools::SHA384.

Definition at line 91 of file shax.hpp.

{
return "You shouldn't see this: there is a problem with the SHA functions";
};
virtual void cryptoTools::SHAx::hash ( std::vector< uint8_t >  initialMessage)
inlinevirtual

Performs all the steps necessary to hash the message given on the input. In the end, the internal state H contains the digest of the message.

Calls preprocess over its input and then uses a loop over the length of the message to call round on each of its blocks.

Parameters
initialMessageA byte vector containing the message to hash.

Reimplemented in cryptoTools::SHA256, cryptoTools::SHA512, and cryptoTools::SHA384.

Definition at line 75 of file shax.hpp.

{};
virtual void cryptoTools::SHAx::preprocess ( std::vector< uint8_t >  initialMessage)
inlinevirtual

Parses a vector of bytes and applies to it the transformations specified in the NIST's specification.

Once the call to this function is finished, the M attribute is correctly assigned i.e. it contains 32 bits words, the padding and the length of the initial input. The internal state is also initialised.

Parameters
initialMessageA byte vector containing the message to hash.

Reimplemented in cryptoTools::SHA256, cryptoTools::SHA512, and cryptoTools::SHA384.

Definition at line 53 of file shax.hpp.

{};
virtual void cryptoTools::SHAx::round ( unsigned int  counter)
inlinevirtual

Performs a round over the 16 message bytes contained in M, starting at counter and finishing at counter+"something". In the end, the internal state H is updated to the new value.

Reimplemented in cryptoTools::SHA256, cryptoTools::SHA512, and cryptoTools::SHA384.

Definition at line 61 of file shax.hpp.

{};

The documentation for this class was generated from the following file: