AWS IoT Device SDK C++ v2  1.34.0
AWS IoT Device SDK C++ v2
Public Member Functions | Static Public Member Functions | List of all members
Aws::Crt::Crypto::Hash Class Referencefinal

#include <Hash.h>

Public Member Functions

 ~Hash ()
 
 Hash (const Hash &)=delete
 
Hashoperator= (const Hash &)=delete
 
 Hash (Hash &&toMove)
 
Hashoperator= (Hash &&toMove)
 
 operator bool () const noexcept
 
int LastError () const noexcept
 
bool Update (const ByteCursor &toHash) noexcept
 
bool Digest (ByteBuf &output, size_t truncateTo=0) noexcept
 
bool ComputeOneShot (const ByteCursor &input, ByteBuf &output, size_t truncateTo=0) noexcept
 
size_t DigestSize () const noexcept
 

Static Public Member Functions

static Hash CreateSHA256 (Allocator *allocator=ApiAllocator()) noexcept
 
static Hash CreateSHA1 (Allocator *allocator=ApiAllocator()) noexcept
 
static Hash CreateMD5 (Allocator *allocator=ApiAllocator()) noexcept
 

Detailed Description

Streaming Hash object. The typical use case is for computing the hash of an object that is too large to load into memory. You can call Update() multiple times as you load chunks of data into memory. When you're finished simply call Digest(). After Digest() is called, this object is no longer usable.

Constructor & Destructor Documentation

◆ ~Hash()

Aws::Crt::Crypto::Hash::~Hash ( )

◆ Hash() [1/2]

Aws::Crt::Crypto::Hash::Hash ( const Hash )
delete

◆ Hash() [2/2]

Aws::Crt::Crypto::Hash::Hash ( Hash &&  toMove)

Member Function Documentation

◆ ComputeOneShot()

bool Aws::Crt::Crypto::Hash::ComputeOneShot ( const ByteCursor input,
ByteBuf output,
size_t  truncateTo = 0 
)
noexcept

Computes the hash of input and writes the digest into output. The available capacity of output must be large enough for the digest. See: SHA1_DIGEST_SIZE, SHA256_DIGEST_SIZE and MD5_DIGEST_SIZE for size hints. 'truncateTo' is for if you want truncated output (e.g. you only want the first 16 bytes of a SHA256 digest. Returns true on success. Call LastError() for the reason this call failed.

This is an API a user would use for smaller size inputs. For larger, streaming inputs, use multiple calls to Update() for each buffer, followed by a single call to Digest().

◆ CreateMD5()

Hash Aws::Crt::Crypto::Hash::CreateMD5 ( Allocator allocator = ApiAllocator())
staticnoexcept

Creates an instance of a Streaming MD5 Hash.

◆ CreateSHA1()

Hash Aws::Crt::Crypto::Hash::CreateSHA1 ( Allocator allocator = ApiAllocator())
staticnoexcept

Creates an instance of a Stream SHA1 Hash.

◆ CreateSHA256()

Hash Aws::Crt::Crypto::Hash::CreateSHA256 ( Allocator allocator = ApiAllocator())
staticnoexcept

Creates an instance of a Streaming SHA256 Hash.

◆ Digest()

bool Aws::Crt::Crypto::Hash::Digest ( ByteBuf output,
size_t  truncateTo = 0 
)
noexcept

Finishes the running hash operation and writes the digest into output. The available capacity of output must be large enough for the digest. See: SHA1_DIGEST_SIZE, SHA256_DIGEST_SIZE and MD5_DIGEST_SIZE for size hints. 'truncateTo' is for if you want truncated output (e.g. you only want the first 16 bytes of a SHA256 digest. Returns true on success. Call LastError() for the reason this call failed.

◆ DigestSize()

size_t Aws::Crt::Crypto::Hash::DigestSize ( ) const
noexcept

Returns the size of the digest for this hash algorithm. If this object is not valid, it will return 0 instead.

◆ LastError()

int Aws::Crt::Crypto::Hash::LastError ( ) const
inlinenoexcept

Returns the value of the last aws error encountered by operations on this instance.

◆ operator bool()

Aws::Crt::Crypto::Hash::operator bool ( ) const
noexcept

Returns true if the instance is in a valid state, false otherwise.

◆ operator=() [1/2]

Hash& Aws::Crt::Crypto::Hash::operator= ( const Hash )
delete

◆ operator=() [2/2]

Hash & Aws::Crt::Crypto::Hash::operator= ( Hash &&  toMove)

◆ Update()

bool Aws::Crt::Crypto::Hash::Update ( const ByteCursor toHash)
noexcept

Updates the running hash object with data in toHash. Returns true on success. Call LastError() for the reason this call failed.


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