1. CMOX_HASH

1.1. CMOX HASH PUBLIC CONSTANTS

group CMOX_HASH_PUBLIC_CONSTANTS

Variables

const cmox_hash_algo_t CMOX_SHA1_ALGO

Identifier of the SHA1 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHA224_ALGO

Identifier of the SHA224 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHA256_ALGO

Identifier of the SHA256 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHA384_ALGO

Identifier of the SHA384 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHA512_ALGO

Identifier of the SHA512 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHA512_224_ALGO

Identifier of the SHA512/224 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHA512_256_ALGO

Identifier of the SHA512/256 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHA3_224_ALGO

Identifier of the SHA3-224 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHA3_256_ALGO

Identifier of the SHA3-256 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHA3_384_ALGO

Identifier of the SHA3-384 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHA3_512_ALGO

Identifier of the SHA3-512 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHAKE128_ALGO

Identifier of the SHAKE128 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SHAKE256_ALGO

Identifier of the SHAKE256 hash function for single-call function (Defined internally).

const cmox_hash_algo_t CMOX_SM3_ALGO

Identifier of the SM3 hash function for single-call function (Defined internally).

1.2. CMOX HASH PUBLIC METHODS

group CMOX_HASH_PUBLIC_METHODS

Functions

cmox_hash_retval_t cmox_hash_cleanup ( cmox_hash_handle_t * P_pThis )

Cleanup the hash handler.

Parameters :

P_pThis – Hash handler to cleanup

Returns :

cmox_hash_retval_t Hash return value

cmox_hash_retval_t cmox_hash_init ( cmox_hash_handle_t * P_pThis )

Initialize the hash handle based on the selected algorithm.

Note

The hash handle must be derived from an algorithm-specific handle using the correct construct

Parameters :

P_pThis – Hash handle to initialize

Returns :

cmox_hash_retval_t Hash return value

cmox_hash_retval_t cmox_hash_setTagLen ( cmox_hash_handle_t * P_pThis , size_t P_tagLen )

Set the size of the digest.

Parameters :
  • P_pThis – Hash handle to set

  • P_tagLen – Size in bytes of the tag

Returns :

cmox_hash_retval_t Hash return value

cmox_hash_retval_t cmox_hash_append ( cmox_hash_handle_t * P_pThis , const uint8_t * P_pInput , size_t P_inputLen )

Append part or the totality of the plaintext to the hash handle.

Parameters :
  • P_pThis – Hash handle to use for hashing the data

  • P_pInput – Buffer of bytes containing the data to hash

  • P_inputLen – Size in bytes of the data to hash

Returns :

cmox_hash_retval_t Hash return value

cmox_hash_retval_t cmox_hash_generateTag ( cmox_hash_handle_t * P_pThis , uint8_t * P_pDigest , size_t * P_pDigestLen )

Generate the digest of the already appended data.

Parameters :
  • P_pThis – Hash handle used for appending the data to hash

  • P_pDigest – Buffer of bytes where the digest will be stored

  • P_pDigestLen – Number of bytes generated by the function. It is an optional parameter and can be set to NULL if not needed.

Returns :

cmox_hash_retval_t Hash return value

cmox_hash_retval_t cmox_hash_compute ( cmox_hash_algo_t P_algo , const uint8_t * P_pPlaintext , size_t P_plaintextLen , uint8_t * P_pDigest , const size_t P_expectedDigestLen , size_t * P_pComputedDigestLen )

Compute the digest of a message using a hash algorithm.

Parameters :
  • P_algo – Identifier of the hash algorithm to use for the computation. This parameter can be one of the following:

    • CMOX_SHA1_ALGO

    • CMOX_SHA224_ALGO

    • CMOX_SHA256_ALGO

    • CMOX_SHA384_ALGO

    • CMOX_SHA512_ALGO

    • CMOX_SHA512_224_ALGO

    • CMOX_SHA512_256_ALGO

    • CMOX_SHA3_224_ALGO

    • CMOX_SHA3_256_ALGO

    • CMOX_SHA3_384_ALGO

    • CMOX_SHA3_512_ALGO

    • CMOX_SHAKE128_ALGO

    • CMOX_SHAKE256_ALGO

    • CMOX_SM3_ALGO

  • P_pPlaintext – Buffer of bytes containing the message to hash

  • P_plaintextLen – Size in bytes of the message to hash

  • P_pDigest – Buffer of bytes that will contain the computed digest

  • P_expectedDigestLen – Desired size in bytes of the digest to compute

  • P_pComputedDigestLen – Number of bytes generated by the function. It is an optional parameter and can be set to NULL if not needed.

Returns :

cmox_hash_retval_t

1.3. CMOX HASH PUBLIC TYPES

group CMOX_HASH_PUBLIC_TYPES

Typedefs

typedef const struct cmox_hash_vtableStruct_st * cmox_hash_vtable_t

Hash Virtual Table.

This type specifies a pointer to the virtual table containing the methods for a particular algorithm (e.g. SHA256 or SM3)

typedef const struct cmox_hash_algoStruct_st * cmox_hash_algo_t

Hash algorithm type.

This type specifies the algorithm to use with the hash module (e.g. SHA256). The type is defined as a pointer to a structure, that contains the functions for the specific algorithm, defined in the library internally

struct cmox_hash_handle_t
#include <cmox_hash.h>

Hash handle structure definition.