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

SHA-384 message-digest. More...

#include <base/security/SHA384.h>

Inherits Object, and PushInterface.

Public Member Functions

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

Static Public Member Functions

static String getDigest (const uint8 *buffer, MemorySize size)
 

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-384 message-digest.

Implementation of the SHA-384 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-384 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";
SHA384 checksum;
checksum.push(message.getBytes(), message.getLength());
checksum.pushEnd();
fout << "message digest: " << checksum.getValue() << ENDL;
See also
MD5Sum SHA1 SHA256 SHA512
Version
1.0
Examples
testsuite/digest.cpp.

Constructor & Destructor Documentation

◆ SHA384()

SHA384::SHA384 ( )
noexcept

Initializes object.

Member Function Documentation

◆ getBase64()

String SHA384::getBase64 ( ) const
noexcept

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

◆ getDigest() [1/2]

static String SHA384::getDigest ( const uint8 *  buffer,
MemorySize  size 
)
inlinestatic

Returns the digest of the given message.

◆ getDigest() [2/2]

uint8 SHA384::getDigest ( MemorySize  index) const

Returns n'th byte of the digest.

◆ getDigestSize()

MemorySize SHA384::getDigestSize ( ) const
noexcept

Returns the size of the digest in bytes.

◆ getTotalSize()

uint64 SHA384::getTotalSize ( ) const
inlinenoexcept

Returns the total size of the original message.

◆ getValue()

String SHA384::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 SHA384::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 SHA384::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 SHA384::BLOCK_SIZE = 128
static

Internal block size in bytes.

◆ MAXIMUM_SIZE

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

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

◆ MESSAGE_SCHEDULE

const unsigned int SHA384::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
SHA384::pushEnd
void pushEnd() noexcept
String
String.
Definition: String.h:102
SHA384::getValue
String getValue() const noexcept
SHA384::push
MemorySize push(const uint8 *buffer, MemorySize size)
SHA384
SHA-384 message-digest.
Definition: SHA384.h:48