SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SHAKE extendable-output functions

Detailed Description

Enable SHARKSSL_USE_SHAKE for SHAKE128 and SHAKE256.

Initialize an operation, call psa_xof_setup(), append input with psa_xof_update(), then read any needed output with psa_xof_output(). Further output calls continue the same stream. SHAKE accepts no customization context. The first output call ends input, including when requesting zero bytes. Call psa_xof_abort() after completion or an error to clear the state. These operations use caller-owned storage without heap allocation; serialize access to each operation.

Data Structures

struct  psa_xof_operation_s
 Opaque extendable-output function (XOF) state owned by the caller. More...
 

Typedefs

typedef struct psa_xof_operation_s psa_xof_operation_t
 Opaque extendable-output function (XOF) state owned by the caller. More...
 

Functions

psa_xof_operation_t psa_xof_operation_init (void)
 Create an inactive XOF operation. More...
 
psa_status_t psa_xof_setup (psa_xof_operation_t *operation, psa_algorithm_t alg)
 Start a SHAKE operation with no customization context. More...
 
psa_status_t psa_xof_set_context (psa_xof_operation_t *operation, const uint8_t *context, size_t context_length)
 Reject customization contexts for this provider's SHAKE algorithms. More...
 
psa_status_t psa_xof_update (psa_xof_operation_t *operation, const uint8_t *input, size_t input_length)
 Append SHAKE input before the first output call. More...
 
psa_status_t psa_xof_output (psa_xof_operation_t *operation, uint8_t *output, size_t output_length)
 Read bytes from the SHAKE output stream. More...
 
psa_status_t psa_xof_abort (psa_xof_operation_t *operation)
 Clear an XOF operation and reset it for setup or release. More...
 

Typedef Documentation

◆ psa_xof_operation_t

Opaque extendable-output function (XOF) state owned by the caller.

Initialize with PSA_XOF_OPERATION_INIT or psa_xof_operation_init(). Do not inspect or modify members. Input and output buffers must not overlap this object. Finish with psa_xof_abort() to clear it before reuse or release.

Function Documentation

◆ psa_xof_abort()

psa_status_t psa_xof_abort ( psa_xof_operation_t *  operation)

Clear an XOF operation and reset it for setup or release.

Safe for an initialized operation in any phase, including after an error.

Parameters
operationpsa_xof_operation_t *; required initialized operation.
Returns
psa_status_t; PSA_SUCCESS, or PSA_ERROR_INVALID_ARGUMENT for NULL.

◆ psa_xof_operation_init()

psa_xof_operation_t psa_xof_operation_init ( void  )

Create an inactive XOF operation.

Returns
psa_xof_operation_t; inactive state equivalent to 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 
)

Read bytes from the SHAKE output stream.

The first call finalizes input, even for zero output bytes. Further calls continue the stream; no later update is allowed. Abort after the last output.

Parameters
operationpsa_xof_operation_t *; required active SHAKE state.
outputuint8_t *; caller-owned buffer of at least output_length bytes, disjoint from operation; NULL only when output_length is 0.
output_lengthsize_t; requested byte count; 0 is allowed.
Returns
psa_status_t; PSA_SUCCESS, PSA_ERROR_INVALID_ARGUMENT for an invalid pointer, or PSA_ERROR_BAD_STATE for inactive/failed state. Abort after an error.

◆ psa_xof_set_context()

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

Reject customization contexts for this provider's SHAKE algorithms.

Do not call this function for SHAKE, even with an empty context. An active operation is cleared and marked failed; abort it before reuse.

Parameters
operationpsa_xof_operation_t *; operation to configure.
contextconst uint8_t *; ignored; no bytes are read or retained.
context_lengthsize_t; ignored requested context length in bytes.
Returns
psa_status_t; PSA_ERROR_INVALID_ARGUMENT just after setup or for NULL operation, otherwise PSA_ERROR_BAD_STATE. Never returns success.

◆ psa_xof_setup()

psa_status_t psa_xof_setup ( psa_xof_operation_t *  operation,
psa_algorithm_t  alg 
)

Start a SHAKE operation with no customization context.

Requires SHARKSSL_USE_SHAKE. Failure leaves an inactive operation inactive; attempting setup on an active operation does not replace it.

Parameters
operationpsa_xof_operation_t *; required initialized, inactive state.
algpsa_algorithm_t; PSA_ALG_SHAKE128 or PSA_ALG_SHAKE256.
Returns
psa_status_t; PSA_SUCCESS, PSA_ERROR_INVALID_ARGUMENT for NULL or a non-XOF selector, PSA_ERROR_BAD_STATE for active state, or PSA_ERROR_NOT_SUPPORTED for an unavailable algorithm.

◆ psa_xof_update()

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

Append SHAKE input before the first output call.

May be called repeatedly. Input is consumed synchronously and not retained.

Parameters
operationpsa_xof_operation_t *; required state after successful setup, with no output call yet.
inputconst uint8_t *; borrowed input, disjoint from operation; NULL is allowed only when input_length is 0.
input_lengthsize_t; input length in bytes; 0 is allowed.
Returns
psa_status_t; PSA_SUCCESS, PSA_ERROR_INVALID_ARGUMENT for an invalid pointer, or PSA_ERROR_BAD_STATE for invalid call order. Abort after an error.