Base Framework
Public Member Functions | Static Public Attributes | List of all members
SHA512 Class Reference

SHA-512 message-digest. More...

#include <base/security/SHA512.h>

Inherits Object, and PushInterface.

Public Member Functions

 SHA512 () noexcept
 
MemorySize push (const uint8 *buffer, MemorySize size)
 
void pushEnd () noexcept
 
uint64 getTotalSize () const noexcept
 
String getValue () const noexcept
 
String getBase64 () const noexcept
 
- Public Member Functions inherited from PushInterface
virtual void flush ()
 
virtual bool pushBegin (uint64 totalSize)
 

Static Public Attributes

static const unsigned int BLOCK_SIZE = 128
 
static const uint64 MAXIMUM_SIZE = (1ULL << (64 - 3)) - 1
 
static const unsigned int MESSAGE_SCHEDULE = 80
 

Detailed Description

SHA-512 message-digest.

Implementation of the SHA-512 message-digest algorithm (see FIPS PUB 180-2). This class takes a message of arbitrary length and produces a 128-bit "fingerprint"/"message digest" of the message. According to the RFC it is computationally infeasible to produce two messages having the same message digest, or to produce any message having a given prespecified target message digest.

The SHA-512 is designed to have the following properties: it is computationally infeasible to find a message which corresponds to a given message digest, or to find two different messages which produce the same message digest.

String message = "abcdefghijklmnopqrstuvwxyz";
SHA512 checksum;
checksum.push(message.getBytes(), message.getLength());
checksum.pushEnd();
fout << "message digest: " << checksum.getValue() << ENDL;
See also
MD5Sum SHA1 SHA256 SHA384
Version
1.0
Examples
testsuite/digest.cpp.

Constructor & Destructor Documentation

◆ SHA512()

SHA512::SHA512 ( )
noexcept

Initializes object.

Member Function Documentation

◆ getBase64()

String SHA512::getBase64 ( ) const
noexcept

Returns the message digest encoded in Base64. This is only valid after pushEnd() has been invoked.

◆ getTotalSize()

uint64 SHA512::getTotalSize ( ) const
inlinenoexcept

Returns the total size of the original message.

◆ getValue()

String SHA512::getValue ( ) const
noexcept

Returns the message digest encoded in hex. This is only valid after pushEnd() has been invoked.

Examples
testsuite/digest.cpp.

◆ push()

MemorySize SHA512::push ( const uint8 *  buffer,
MemorySize  size 
)
virtual

Updates the checksum corresponding to the specified data. May be called multiple times. Raises OutOfRange if the total number of octets exceed the limit specified by MAXIMUM_SIZE.

Parameters
bufferThe buffer holding the data.
sizeThe number of octets in the buffer.

Implements PushInterface.

Examples
testsuite/digest.cpp.

◆ pushEnd()

void SHA512::pushEnd ( )
virtualnoexcept

This function should be invoked when the entire message has been pushed. Do NOT use push() after invoking this function.

Reimplemented from PushInterface.

Examples
testsuite/digest.cpp.

Member Data Documentation

◆ BLOCK_SIZE

const unsigned int SHA512::BLOCK_SIZE = 128
static

Internal block size in bytes.

◆ MAXIMUM_SIZE

const uint64 SHA512::MAXIMUM_SIZE = (1ULL << (64 - 3)) - 1
static

Specifies the maximum length (in bytes) of the original message.

◆ MESSAGE_SCHEDULE

const unsigned int SHA512::MESSAGE_SCHEDULE = 80
static

The message schedule size.

String::getBytes
const uint8 * getBytes() const noexcept
Definition: String.h:1510
String::getLength
MemorySize getLength() const noexcept
Definition: String.h:510
SHA512
SHA-512 message-digest.
Definition: SHA512.h:49
SHA512::getValue
String getValue() const noexcept
String
String.
Definition: String.h:102
SHA512::push
MemorySize push(const uint8 *buffer, MemorySize size)
SHA512::pushEnd
void pushEnd() noexcept