Entire-Metadata: .entire/metadata/fb87247f-2a75-407e-b336-cbc8c20ba5a6 Entire-Session: fb87247f-2a75-407e-b336-cbc8c20ba5a6 Entire-Strategy: manual-commit
106 lines
3.0 KiB
C
106 lines
3.0 KiB
C
/*
|
|
* (c) Copyright, Real-Time Innovations, 2025.
|
|
* All rights reserved.
|
|
*
|
|
* No duplications, whole or partial, manual or electronic, may be made
|
|
* without express written permission. Any such copies, or
|
|
* revisions thereof, must display this notice unaltered.
|
|
* This code contains trade secrets of Real-Time Innovations, Inc.
|
|
*/
|
|
|
|
#ifndef osapi_sha256_h
|
|
#define osapi_sha256_h
|
|
|
|
#include "osapi/osapi_dll.h"
|
|
#include "osapi/osapi_type.h"
|
|
|
|
#define RTI_OSAPI_SHA256_DIGEST_SIZE 32
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* @internal
|
|
* @brief SHA256 state structure for incremental hashing.
|
|
*/
|
|
struct RTIOsapiSHA256State {
|
|
RTI_UINT64 length;
|
|
RTI_UINT32 state[8];
|
|
RTI_UINT32 curlen;
|
|
RTI_UINT8 buf[64];
|
|
};
|
|
|
|
/**
|
|
* @internal
|
|
* @brief Initializes or resets a SHA256 state.
|
|
*
|
|
* @attention This SHA256 implementation is not intended for use in any
|
|
* security-related features and MUST NOT BE USED for such purposes.
|
|
*
|
|
* @param[out] self Pointer to the SHA256 state to initialize.
|
|
*/
|
|
extern RTIOsapiDllExport void RTIOsapiSHA256State_start(
|
|
struct RTIOsapiSHA256State *self);
|
|
|
|
/**
|
|
* @internal
|
|
* @brief Adds data to the SHA256 state.
|
|
*
|
|
* This processes the data and updates the internal state.
|
|
* Call repeatedly until all data is added, then call
|
|
* RTIOsapiSHA256State_finish.
|
|
*
|
|
* @attention This SHA256 implementation is not intended for use in any
|
|
* security-related features and MUST NOT BE USED for such purposes.
|
|
*
|
|
* @param[in,out] self Pointer to the SHA256 state.
|
|
* @param[in] input Pointer to the data buffer to add.
|
|
* @param[in] inputSize Size of the data buffer in bytes.
|
|
*/
|
|
extern RTIOsapiDllExport void RTIOsapiSHA256State_update(
|
|
struct RTIOsapiSHA256State *self,
|
|
const RTI_UINT8 *input,
|
|
RTI_UINT32 inputSize);
|
|
|
|
/**
|
|
* @internal
|
|
* @brief Finalizes the SHA256 hash and writes the digest.
|
|
*
|
|
* After calling this, RTIOsapiSHA256State_start must be used to reuse the
|
|
* state.
|
|
*
|
|
* @attention This SHA256 implementation is not intended for use in any
|
|
* security-related features and MUST NOT BE USED for such purposes.
|
|
*
|
|
* @param[in,out] self Pointer to the SHA256 state.
|
|
* @param[out] digest Pointer to a buffer to receive the hash.
|
|
*/
|
|
extern RTIOsapiDllExport void RTIOsapiSHA256State_finish(
|
|
struct RTIOsapiSHA256State *self,
|
|
RTI_UINT8 *digest);
|
|
|
|
/**
|
|
* @internal
|
|
* @brief Calculates the SHA256 hash of a buffer in one call.
|
|
*
|
|
* Combines start, update, and finish into a single operation.
|
|
*
|
|
* @attention This SHA256 implementation is not intended for use in any
|
|
* security-related features and MUST NOT BE USED for such purposes.
|
|
*
|
|
* @param[out] digest Pointer to a buffer to receive the hash.
|
|
* @param[in] input Pointer to the data buffer to hash.
|
|
* @param[in] inputSize Size of the data buffer in bytes.
|
|
*/
|
|
extern RTIOsapiDllExport void RTIOsapiSHA256_computeSHA256(
|
|
RTI_UINT8 *digest,
|
|
const char *input,
|
|
size_t inputSize);
|
|
|
|
#ifdef __cplusplus
|
|
} /* extern "C" */
|
|
#endif
|
|
|
|
#endif
|