Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb_mbedtls::MbedTlsWrapper::SHA256State Class Reference

Public Member Functions

void AddString (const std::string &str)
void AddBytes (duckdb::data_ptr_t input_bytes, duckdb::idx_t len)
void AddBytes (duckdb::const_data_ptr_t input_bytes, duckdb::idx_t len)
void AddSalt (unsigned char *salt, size_t salt_len)
std::string Finalize ()
void FinishHex (char *out)
void FinalizeDerivedKey (duckdb::data_ptr_t hash)

Private Attributes

void * sha_context

Constructor & Destructor Documentation

◆ SHA256State()

MbedTlsWrapper::SHA256State::SHA256State ( )
597646 : sha_context(new mbedtls_sha256_context()) {
597647 auto context = reinterpret_cast<mbedtls_sha256_context *>(sha_context);
597648
597649 mbedtls_sha256_init(context);
597650
597651 if (mbedtls_sha256_starts(context, false)) {
597652 throw std::runtime_error("SHA256 Error");
597653 }
int mbedtls_sha256_starts(mbedtls_sha256_context *ctx, int is224)
This function starts a SHA-224 or SHA-256 checksum calculation.
Definition duckdb.cpp:596790
struct mbedtls_sha256_context mbedtls_sha256_context
The SHA-256 context structure.
void mbedtls_sha256_init(mbedtls_sha256_context *ctx)
This function initializes a SHA-256 context.
Definition duckdb.cpp:596767

◆ ~SHA256State()

MbedTlsWrapper::SHA256State::~SHA256State ( )
597656 {
597657 auto context = reinterpret_cast<mbedtls_sha256_context *>(sha_context);
597658 mbedtls_sha256_free(context);
597659 delete context;
void mbedtls_sha256_free(mbedtls_sha256_context *ctx)
This function clears a SHA-256 context.
Definition duckdb.cpp:596772

Member Function Documentation

◆ AddString()

void MbedTlsWrapper::SHA256State::AddString ( const std::string & str)
597662 {
597663 auto context = reinterpret_cast<mbedtls_sha256_context *>(sha_context);
597664 if (mbedtls_sha256_update(context, (unsigned char *)str.data(), str.size())) {
597665 throw std::runtime_error("SHA256 Error");
597666 }
int mbedtls_sha256_update(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-256 checksum calculation.
Definition duckdb.cpp:597187

◆ AddBytes() [1/2]

void MbedTlsWrapper::SHA256State::AddBytes ( duckdb::data_ptr_t input_bytes,
duckdb::idx_t len )
597676 {
597677 AddBytes(duckdb::const_data_ptr_t(input_bytes), len);

◆ AddBytes() [2/2]

void MbedTlsWrapper::SHA256State::AddBytes ( duckdb::const_data_ptr_t input_bytes,
duckdb::idx_t len )
597669 {
597670 auto context = reinterpret_cast<mbedtls_sha256_context *>(sha_context);
597671 if (mbedtls_sha256_update(context, input_bytes, len)) {
597672 throw std::runtime_error("SHA256 Error");
597673 }

◆ AddSalt()

void MbedTlsWrapper::SHA256State::AddSalt ( unsigned char * salt,
size_t salt_len )
597680 {
597681 auto context = reinterpret_cast<mbedtls_sha256_context *>(sha_context);
597682 if (mbedtls_sha256_update(context, salt, salt_len)) {
597683 throw std::runtime_error("SHA256 Error");
597684 }

◆ Finalize()

std::string MbedTlsWrapper::SHA256State::Finalize ( )
597695 {
597696 auto context = reinterpret_cast<mbedtls_sha256_context *>(sha_context);
597697
597698 string hash;
597699 hash.resize(MbedTlsWrapper::SHA256_HASH_LENGTH_BYTES);
597700
597701 if (mbedtls_sha256_finish(context, (unsigned char *)hash.data())) {
597702 throw std::runtime_error("SHA256 Error");
597703 }
597704
597705 return hash;
int mbedtls_sha256_finish(mbedtls_sha256_context *ctx, unsigned char *output)
This function finishes the SHA-256 operation, and writes the result to the output buffer.
Definition duckdb.cpp:597242

◆ FinishHex()

void MbedTlsWrapper::SHA256State::FinishHex ( char * out)
597708 {
597709 auto context = reinterpret_cast<mbedtls_sha256_context *>(sha_context);
597710
597711 string hash;
597712 hash.resize(MbedTlsWrapper::SHA256_HASH_LENGTH_BYTES);
597713
597714 if (mbedtls_sha256_finish(context, (unsigned char *)hash.data())) {
597715 throw std::runtime_error("SHA256 Error");
597716 }
597717
597718 MbedTlsWrapper::ToBase16(const_cast<char *>(hash.c_str()), out, MbedTlsWrapper::SHA256_HASH_LENGTH_BYTES);

◆ FinalizeDerivedKey()

void MbedTlsWrapper::SHA256State::FinalizeDerivedKey ( duckdb::data_ptr_t hash)
597687 {
597688 auto context = reinterpret_cast<mbedtls_sha256_context *>(sha_context);
597689
597690 if (mbedtls_sha256_finish(context, (duckdb::data_ptr_t)hash)) {
597691 throw std::runtime_error("SHA256 Error");
597692 }

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