NCBI C++ ToolKit
Functions
psa_crypto_hash.h File Reference
#include <psa/crypto.h>
+ Include dependency graph for psa_crypto_hash.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Go to the SVN repository for this file.

Functions

psa_status_t mbedtls_psa_hash_compute (psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *hash, size_t hash_size, size_t *hash_length)
 Calculate the hash (digest) of a message using Mbed TLS routines. More...
 
psa_status_t mbedtls_psa_hash_setup (mbedtls_psa_hash_operation_t *operation, psa_algorithm_t alg)
 Set up a multipart hash operation using Mbed TLS routines. More...
 
psa_status_t mbedtls_psa_hash_clone (const mbedtls_psa_hash_operation_t *source_operation, mbedtls_psa_hash_operation_t *target_operation)
 Clone an Mbed TLS hash operation. More...
 
psa_status_t mbedtls_psa_hash_update (mbedtls_psa_hash_operation_t *operation, const uint8_t *input, size_t input_length)
 Add a message fragment to a multipart Mbed TLS hash operation. More...
 
psa_status_t mbedtls_psa_hash_finish (mbedtls_psa_hash_operation_t *operation, uint8_t *hash, size_t hash_size, size_t *hash_length)
 Finish the calculation of the Mbed TLS-calculated hash of a message. More...
 
psa_status_t mbedtls_psa_hash_abort (mbedtls_psa_hash_operation_t *operation)
 Abort an Mbed TLS hash operation. More...
 

Function Documentation

◆ mbedtls_psa_hash_abort()

psa_status_t mbedtls_psa_hash_abort ( mbedtls_psa_hash_operation_t operation)

Abort an Mbed TLS hash operation.

Note
The signature of this function is that of a PSA driver hash_abort entry point. This function behaves as a hash_abort entry point as defined in the PSA driver interface specification for transparent drivers.

Aborting an operation frees all associated resources except for the operation structure itself. Once aborted, the operation object can be reused for another operation by calling mbedtls_psa_hash_setup() again.

You may call this function any time after the operation object has been initialized by one of the methods described in psa_hash_operation_t.

In particular, calling mbedtls_psa_hash_abort() after the operation has been terminated by a call to mbedtls_psa_hash_abort(), mbedtls_psa_hash_finish() or mbedtls_psa_hash_verify() is safe and has no effect.

Parameters
[in,out]operationInitialized hash operation.
Return values
PSA_SUCCESS\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription

◆ mbedtls_psa_hash_clone()

psa_status_t mbedtls_psa_hash_clone ( const mbedtls_psa_hash_operation_t source_operation,
mbedtls_psa_hash_operation_t target_operation 
)

Clone an Mbed TLS hash operation.

Note
The signature of this function is that of a PSA driver hash_clone entry point. This function behaves as a hash_clone entry point as defined in the PSA driver interface specification for transparent drivers.

This function copies the state of an ongoing hash operation to a new operation object. In other words, this function is equivalent to calling mbedtls_psa_hash_setup() on target_operation with the same algorithm that source_operation was set up for, then mbedtls_psa_hash_update() on target_operation with the same input that that was passed to source_operation. After this function returns, the two objects are independent, i.e. subsequent calls involving one of the objects do not affect the other object.

Parameters
[in]source_operationThe active hash operation to clone.
[in,out]target_operationThe operation object to set up. It must be initialized but not active.
Return values
PSA_SUCCESS\emptydescription
PSA_ERROR_BAD_STATEThe source_operation state is not valid (it must be active).
PSA_ERROR_BAD_STATEThe target_operation state is not valid (it must be inactive).
PSA_ERROR_CORRUPTION_DETECTED\emptydescription
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription

◆ mbedtls_psa_hash_compute()

psa_status_t mbedtls_psa_hash_compute ( psa_algorithm_t  alg,
const uint8_t input,
size_t  input_length,
uint8_t hash,
size_t  hash_size,
size_t *  hash_length 
)

Calculate the hash (digest) of a message using Mbed TLS routines.

Note
The signature of this function is that of a PSA driver hash_compute entry point. This function behaves as a hash_compute entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
algThe hash algorithm to compute (PSA_ALG_XXX value such that PSA_ALG_IS_HASH(alg) is true).
[in]inputBuffer containing the message to hash.
input_lengthSize of the input buffer in bytes.
[out]hashBuffer where the hash is to be written.
hash_sizeSize of the hash buffer in bytes.
[out]hash_lengthOn success, the number of bytes that make up the hash value. This is always PSA_HASH_LENGTH(alg).
Return values
PSA_SUCCESSSuccess.
PSA_ERROR_NOT_SUPPORTEDalg is not supported
PSA_ERROR_BUFFER_TOO_SMALLhash_size is too small
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription

◆ mbedtls_psa_hash_finish()

psa_status_t mbedtls_psa_hash_finish ( mbedtls_psa_hash_operation_t operation,
uint8_t hash,
size_t  hash_size,
size_t *  hash_length 
)

Finish the calculation of the Mbed TLS-calculated hash of a message.

Note
The signature of this function is that of a PSA driver hash_finish entry point. This function behaves as a hash_finish entry point as defined in the PSA driver interface specification for transparent drivers.

The application must call mbedtls_psa_hash_setup() before calling this function. This function calculates the hash of the message formed by concatenating the inputs passed to preceding calls to mbedtls_psa_hash_update().

When this function returns successfully, the operation becomes inactive. If this function returns an error status, the operation enters an error state and must be aborted by calling mbedtls_psa_hash_abort().

Parameters
[in,out]operationActive hash operation.
[out]hashBuffer where the hash is to be written.
hash_sizeSize of the hash buffer in bytes.
[out]hash_lengthOn success, the number of bytes that make up the hash value. This is always PSA_HASH_LENGTH(alg) where alg is the hash algorithm that is calculated.
Return values
PSA_SUCCESSSuccess.
PSA_ERROR_BAD_STATEThe operation state is not valid (it must be active).
PSA_ERROR_BUFFER_TOO_SMALLThe size of the hash buffer is too small. You can determine a sufficient buffer size by calling PSA_HASH_LENGTH(alg) where alg is the hash algorithm that is calculated.
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription

◆ mbedtls_psa_hash_setup()

psa_status_t mbedtls_psa_hash_setup ( mbedtls_psa_hash_operation_t operation,
psa_algorithm_t  alg 
)

Set up a multipart hash operation using Mbed TLS routines.

Note
The signature of this function is that of a PSA driver hash_setup entry point. This function behaves as a hash_setup entry point as defined in the PSA driver interface specification for transparent drivers.

If an error occurs at any step after a call to mbedtls_psa_hash_setup(), the operation will need to be reset by a call to mbedtls_psa_hash_abort(). The core may call mbedtls_psa_hash_abort() at any time after the operation has been initialized.

After a successful call to mbedtls_psa_hash_setup(), the core must eventually terminate the operation. The following events terminate an operation:

Parameters
[in,out]operationThe operation object to set up. It must have been initialized to all-zero and not yet be in use.
algThe hash algorithm to compute (PSA_ALG_XXX value such that PSA_ALG_IS_HASH(alg) is true).
Return values
PSA_SUCCESSSuccess.
PSA_ERROR_NOT_SUPPORTEDalg is not supported
PSA_ERROR_BAD_STATEThe operation state is not valid (it must be inactive).
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription

◆ mbedtls_psa_hash_update()

psa_status_t mbedtls_psa_hash_update ( mbedtls_psa_hash_operation_t operation,
const uint8_t input,
size_t  input_length 
)

Add a message fragment to a multipart Mbed TLS hash operation.

Note
The signature of this function is that of a PSA driver hash_update entry point. This function behaves as a hash_update entry point as defined in the PSA driver interface specification for transparent drivers.

The application must call mbedtls_psa_hash_setup() before calling this function.

If this function returns an error status, the operation enters an error state and must be aborted by calling mbedtls_psa_hash_abort().

Parameters
[in,out]operationActive hash operation.
[in]inputBuffer containing the message fragment to hash.
input_lengthSize of the input buffer in bytes.
Return values
PSA_SUCCESSSuccess.
PSA_ERROR_BAD_STATEThe operation state is not valid (it must be active).
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription
Modified on Tue Jul 23 17:48:30 2024 by modify_doxy.py rev. 669887