Mbed TLS v4.1.1
Loading...
Searching...
No Matches
Extendable-operation functions (XOF)

Macros

#define PSA_XOF_OPERATION_INIT   { 0, 0, 0, 0, 0, 0, 0, { 0 } }

Typedefs

typedef struct psa_xof_operation_s psa_xof_operation_t

Functions

static psa_xof_operation_t psa_xof_operation_init (void)
psa_status_t psa_xof_setup (psa_xof_operation_t *operation, psa_algorithm_t alg)
psa_status_t psa_xof_set_context (psa_xof_operation_t *operation, const uint8_t *context, size_t context_length)
psa_status_t psa_xof_update (psa_xof_operation_t *operation, const uint8_t *input, size_t input_length)
psa_status_t psa_xof_output (psa_xof_operation_t *operation, uint8_t *output, size_t output_length)
psa_status_t psa_xof_abort (psa_xof_operation_t *operation)

Detailed Description

Macro Definition Documentation

◆ PSA_XOF_OPERATION_INIT

#define PSA_XOF_OPERATION_INIT   { 0, 0, 0, 0, 0, 0, 0, { 0 } }

This macro returns a suitable initializer for a XOF operation object of type psa_xof_operation_t.

Definition at line 116 of file crypto_struct.h.

Referenced by psa_xof_operation_init().

Typedef Documentation

◆ psa_xof_operation_t

The type of the state data structure for multipart XOF operations.

Before calling any function on a XOF operation object, the application must initialize it by any of the following means:

This is an implementation-defined struct. Applications should not make any assumptions about the content of this structure. Implementation details can change in future versions without notice.

Definition at line 1208 of file crypto.h.

Function Documentation

◆ psa_xof_abort()

psa_status_t psa_xof_abort ( psa_xof_operation_t * operation)

Abort a multipart XOF (extendable-operation function) operation.

Parameters
[in,out]operationThe operation object to abort. It must have been initialized as per the documentation for psa_xof_operation_t and not yet in use.
Return values
PSA_SUCCESSSuccess.
PSA_ERROR_INSUFFICIENT_MEMORY
PSA_ERROR_COMMUNICATION_FAILURE
PSA_ERROR_HARDWARE_FAILURE
PSA_ERROR_CORRUPTION_DETECTED
PSA_ERROR_BAD_STATEThe operation state is corrupted.

◆ psa_xof_operation_init()

psa_xof_operation_t psa_xof_operation_init ( void )
static

Return an initial value for a XOF operation object.

Referenced by psa_xof_operation_init().

◆ psa_xof_output()

psa_status_t psa_xof_output ( psa_xof_operation_t * operation,
uint8_t * output,
size_t output_length )

Extract output from a multipart XOF (extendable-operation function) operation.

This function switches the operation to output mode, even when output_length is 0.

Parameters
[in,out]operationThe operation object to use. It must have been set up with psa_xof_setup(). It must have a context set with psa_xof_set_context() if the algorithm requires it. It must not yet have been aborted with psa_xof_abort().
[out]outputOn success, the output fragment.
output_lengthThe number of bytes to write to output.
Return values
PSA_SUCCESSSuccess.
PSA_ERROR_INSUFFICIENT_MEMORY
PSA_ERROR_COMMUNICATION_FAILURE
PSA_ERROR_HARDWARE_FAILURE
PSA_ERROR_CORRUPTION_DETECTED
PSA_ERROR_BAD_STATEThe operation state is not valid (it must be active, and it must have a context set if the algorithm requires it).

◆ psa_xof_set_context()

psa_status_t psa_xof_set_context ( psa_xof_operation_t * operation,
const uint8_t * context,
size_t context_length )

Pass a context to a multipart XOF (extendable-operation function) operation.

Parameters
[in,out]operationThe operation object to use. It must have been set up with psa_xof_setup(), and must not yet have been received a context with psa_xof_set_context(), received input with psa_xof_update(), switched to output mode with psa_xof_output(), or aborted with psa_xof_abort().
[in]contextThe context to use.
context_lengthSize of the context buffer in bytes.
Return values
PSA_SUCCESSSuccess.
PSA_ERROR_INVALID_ARGUMENTThe algorithm used by operation does not allow a context, or the context value is invalid for this algorithm.
PSA_ERROR_INSUFFICIENT_MEMORY
PSA_ERROR_COMMUNICATION_FAILURE
PSA_ERROR_HARDWARE_FAILURE
PSA_ERROR_CORRUPTION_DETECTED
PSA_ERROR_BAD_STATEThe operation state is not valid (it must be active, it must not already have a context set, it must not already have input, and it must not have already been switched to output mode).

◆ psa_xof_setup()

psa_status_t psa_xof_setup ( psa_xof_operation_t * operation,
psa_algorithm_t alg )

Set up a multipart XOF (extendable-operation function) operation.

The sequence of operations to calculate a XOF is as follows:

  1. Allocate an operation object which will be passed to all the functions listed here.
  2. Initialize the operation object with one of the methods described in the documentation for psa_xof_operation_t, e.g. PSA_XOF_OPERATION_INIT.
  3. Call psa_xof_setup() to specify the algorithm.
  4. If the XOF uses a context, call psa_xof_set_context().
  5. Call psa_xof_update() zero, one or more times, passing successive fragments of the input.
  6. Call psa_xof_output() zero, one or more times to obtain successive fragments of the output.
  7. Call psa_xof_abort() to free the resources associated with the operation (other than the operation object itself).

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

After a successful call to psa_xof_setup(), the application must eventually terminate the operation by calling psa_xof_abort().

Parameters
[in,out]operationThe operation object to set up. It must have been initialized as per the documentation for psa_xof_operation_t and not yet in use.
algThe XOF algorithm to compute (PSA_ALG_XXX value such that PSA_ALG_IS_XOF(alg) is true).
Return values
PSA_SUCCESSSuccess.
PSA_ERROR_NOT_SUPPORTEDalg is not supported.
PSA_ERROR_INSUFFICIENT_MEMORY
PSA_ERROR_COMMUNICATION_FAILURE
PSA_ERROR_HARDWARE_FAILURE
PSA_ERROR_CORRUPTION_DETECTED
PSA_ERROR_BAD_STATEThe operation state is not valid (it must be inactive).

◆ psa_xof_update()

psa_status_t psa_xof_update ( psa_xof_operation_t * operation,
const uint8_t * input,
size_t input_length )

Pass input to a multipart XOF (extendable-operation function) operation.

This function switches the operation to input mode, even when input_length is 0.

Parameters
[in,out]operationThe operation object to use. It must have been set up with psa_xof_setup(). It must have a context set with psa_xof_set_context() if the algorithm requires it. It must not yet have been switched to output mode with psa_xof_output() or aborted with psa_xof_abort().
[in]inputThe input fragment.
input_lengthSize of the input buffer in bytes.
Return values
PSA_SUCCESSSuccess.
PSA_ERROR_INSUFFICIENT_MEMORY
PSA_ERROR_COMMUNICATION_FAILURE
PSA_ERROR_HARDWARE_FAILURE
PSA_ERROR_CORRUPTION_DETECTED
PSA_ERROR_BAD_STATEThe operation state is not valid (it must be active, it must have a context set if the algorithm requires it, and it must not yet have been switched to output mode).