Update documentation for multipart hash operations

This commit is contained in:
Andrew Thoelke 2019-09-11 22:53:21 +01:00
parent 340984b003
commit 272ba1dd96

View File

@ -946,7 +946,7 @@ static psa_hash_operation_t psa_hash_operation_init(void);
* -# Allocate an operation object which will be passed to all the functions * -# Allocate an operation object which will be passed to all the functions
* listed here. * listed here.
* -# Initialize the operation object with one of the methods described in the * -# Initialize the operation object with one of the methods described in the
* documentation for #psa_hash_operation_t, e.g. PSA_HASH_OPERATION_INIT. * documentation for #psa_hash_operation_t, e.g. #PSA_HASH_OPERATION_INIT.
* -# Call psa_hash_setup() to specify the algorithm. * -# Call psa_hash_setup() to specify the algorithm.
* -# Call psa_hash_update() zero, one or more times, passing a fragment * -# Call psa_hash_update() zero, one or more times, passing a fragment
* of the message each time. The hash that is calculated is the hash * of the message each time. The hash that is calculated is the hash
@ -954,14 +954,16 @@ static psa_hash_operation_t psa_hash_operation_init(void);
* -# To calculate the hash, call psa_hash_finish(). * -# To calculate the hash, call psa_hash_finish().
* To compare the hash with an expected value, call psa_hash_verify(). * To compare the hash with an expected value, call psa_hash_verify().
* *
* The application may call psa_hash_abort() at any time after the operation * If an error occurs at any step after a call to psa_hash_setup(), the
* operation will need to be reset by a call to psa_hash_abort(). The
* application may call psa_hash_abort() at any time after the operation
* has been initialized. * has been initialized.
* *
* After a successful call to psa_hash_setup(), the application must * After a successful call to psa_hash_setup(), the application must
* eventually terminate the operation. The following events terminate an * eventually terminate the operation. The following events terminate an
* operation: * operation:
* - A failed call to psa_hash_update(). * - A successful call to psa_hash_finish() or psa_hash_verify().
* - A call to psa_hash_finish(), psa_hash_verify() or psa_hash_abort(). * - A call to psa_hash_abort().
* *
* \param[in,out] operation The operation object to set up. It must have * \param[in,out] operation The operation object to set up. It must have
* been initialized as per the documentation for * been initialized as per the documentation for
@ -976,8 +978,7 @@ static psa_hash_operation_t psa_hash_operation_init(void);
* \retval #PSA_ERROR_INVALID_ARGUMENT * \retval #PSA_ERROR_INVALID_ARGUMENT
* \p alg is not a hash algorithm. * \p alg is not a hash algorithm.
* \retval #PSA_ERROR_BAD_STATE * \retval #PSA_ERROR_BAD_STATE
* The operation state is not valid (already set up and not * The operation state is not valid (it must be inactive).
* subsequently completed).
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_INSUFFICIENT_MEMORY
* \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_COMMUNICATION_FAILURE
* \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE
@ -994,7 +995,8 @@ psa_status_t psa_hash_setup(psa_hash_operation_t *operation,
* *
* The application must call psa_hash_setup() before calling this function. * The application must call psa_hash_setup() before calling this function.
* *
* If this function returns an error status, the operation becomes inactive. * If this function returns an error status, the operation enters an error
* state and must be aborted by calling psa_hash_abort().
* *
* \param[in,out] operation Active hash operation. * \param[in,out] operation Active hash operation.
* \param[in] input Buffer containing the message fragment to hash. * \param[in] input Buffer containing the message fragment to hash.
@ -1003,7 +1005,7 @@ psa_status_t psa_hash_setup(psa_hash_operation_t *operation,
* \retval #PSA_SUCCESS * \retval #PSA_SUCCESS
* Success. * Success.
* \retval #PSA_ERROR_BAD_STATE * \retval #PSA_ERROR_BAD_STATE
* The operation state is not valid (not set up, or already completed). * The operation state is not valid (it muct be active).
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_INSUFFICIENT_MEMORY
* \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_COMMUNICATION_FAILURE
* \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE
@ -1023,7 +1025,9 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation,
* This function calculates the hash of the message formed by concatenating * This function calculates the hash of the message formed by concatenating
* the inputs passed to preceding calls to psa_hash_update(). * the inputs passed to preceding calls to psa_hash_update().
* *
* When this function returns, the operation becomes inactive. * When this function returns successfuly, the operation becomes inactive.
* If this function returns an error status, the operation enters an error
* state and must be aborted by calling psa_hash_abort().
* *
* \warning Applications should not call this function if they expect * \warning Applications should not call this function if they expect
* a specific value for the hash. Call psa_hash_verify() instead. * a specific value for the hash. Call psa_hash_verify() instead.
@ -1044,7 +1048,7 @@ psa_status_t psa_hash_update(psa_hash_operation_t *operation,
* \retval #PSA_SUCCESS * \retval #PSA_SUCCESS
* Success. * Success.
* \retval #PSA_ERROR_BAD_STATE * \retval #PSA_ERROR_BAD_STATE
* The operation state is not valid (not set up, or already completed). * The operation state is not valid (it must be active).
* \retval #PSA_ERROR_BUFFER_TOO_SMALL * \retval #PSA_ERROR_BUFFER_TOO_SMALL
* The size of the \p hash buffer is too small. You can determine a * The size of the \p hash buffer is too small. You can determine a
* sufficient buffer size by calling #PSA_HASH_SIZE(\c alg) * sufficient buffer size by calling #PSA_HASH_SIZE(\c alg)
@ -1072,7 +1076,9 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation,
* compares the calculated hash with the expected hash passed as a * compares the calculated hash with the expected hash passed as a
* parameter to this function. * parameter to this function.
* *
* When this function returns, the operation becomes inactive. * When this function returns successfuly, the operation becomes inactive.
* If this function returns an error status, the operation enters an error
* state and must be aborted by calling psa_hash_abort().
* *
* \note Implementations shall make the best effort to ensure that the * \note Implementations shall make the best effort to ensure that the
* comparison between the actual hash and the expected hash is performed * comparison between the actual hash and the expected hash is performed
@ -1088,7 +1094,7 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation,
* The hash of the message was calculated successfully, but it * The hash of the message was calculated successfully, but it
* differs from the expected hash. * differs from the expected hash.
* \retval #PSA_ERROR_BAD_STATE * \retval #PSA_ERROR_BAD_STATE
* The operation state is not valid (not set up, or already completed). * The operation state is not valid (it must be active).
* \retval #PSA_ERROR_INSUFFICIENT_MEMORY * \retval #PSA_ERROR_INSUFFICIENT_MEMORY
* \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_COMMUNICATION_FAILURE
* \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE
@ -1110,11 +1116,7 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
* psa_hash_setup() again. * psa_hash_setup() again.
* *
* You may call this function any time after the operation object has * You may call this function any time after the operation object has
* been initialized by any of the following methods: * been initialized by one of the methods described in #psa_hash_operation_t.
* - A call to psa_hash_setup(), whether it succeeds or not.
* - Initializing the \c struct to all-bits-zero.
* - Initializing the \c struct to logical zeros, e.g.
* `psa_hash_operation_t operation = {0}`.
* *
* In particular, calling psa_hash_abort() after the operation has been * In particular, calling psa_hash_abort() after the operation has been
* terminated by a call to psa_hash_abort(), psa_hash_finish() or * terminated by a call to psa_hash_abort(), psa_hash_finish() or
@ -1123,8 +1125,6 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
* \param[in,out] operation Initialized hash operation. * \param[in,out] operation Initialized hash operation.
* *
* \retval #PSA_SUCCESS * \retval #PSA_SUCCESS
* \retval #PSA_ERROR_BAD_STATE
* \p operation is not an active hash operation.
* \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_COMMUNICATION_FAILURE
* \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE
* \retval #PSA_ERROR_CORRUPTION_DETECTED * \retval #PSA_ERROR_CORRUPTION_DETECTED
@ -1152,9 +1152,9 @@ psa_status_t psa_hash_abort(psa_hash_operation_t *operation);
* *
* \retval #PSA_SUCCESS * \retval #PSA_SUCCESS
* \retval #PSA_ERROR_BAD_STATE * \retval #PSA_ERROR_BAD_STATE
* \p source_operation is not an active hash operation. * The \p source_operation state is not valid (it must be active).
* \retval #PSA_ERROR_BAD_STATE * \retval #PSA_ERROR_BAD_STATE
* \p target_operation is active. * The \p target_operation state is not valid (it must be inactive).
* \retval #PSA_ERROR_COMMUNICATION_FAILURE * \retval #PSA_ERROR_COMMUNICATION_FAILURE
* \retval #PSA_ERROR_HARDWARE_FAILURE * \retval #PSA_ERROR_HARDWARE_FAILURE
* \retval #PSA_ERROR_CORRUPTION_DETECTED * \retval #PSA_ERROR_CORRUPTION_DETECTED