Mbed TLS v4.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Typedefs | Functions
Interruptible public-key export

Typedefs

typedef struct
psa_export_public_key_iop_s 
psa_export_public_key_iop_t
 

Functions

uint32_t psa_export_public_key_iop_get_num_ops (psa_export_public_key_iop_t *operation)
 Get the number of ops that an export public-key operation has taken so far. If the operation has completed, then this will represent the number of ops required for the entire operation. After initialization or calling psa_export_public_key_iop_abort() on the operation, a value of 0 will be returned. More...
 
psa_status_t psa_export_public_key_iop_setup (psa_export_public_key_iop_t *operation, mbedtls_svc_key_id_t key)
 Start an interruptible operation to export a public key or the public part of a key pair in binary format. More...
 
psa_status_t psa_export_public_key_iop_complete (psa_export_public_key_iop_t *operation, uint8_t *data, size_t data_size, size_t *data_length)
 Continue and eventually complete the action of exporting a public key, in an interruptible manner. More...
 
psa_status_t psa_export_public_key_iop_abort (psa_export_public_key_iop_t *operation)
 Abort an interruptible public-key export operation. More...
 

Detailed Description

Typedef Documentation

The type of the state data structure for interruptible public-key export operations.

Before calling any function on an interruptible export public-key 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 5579 of file crypto.h.

Function Documentation

psa_status_t psa_export_public_key_iop_abort ( psa_export_public_key_iop_t operation)

Abort an interruptible public-key export operation.

Warning
This is a beta API, and thus subject to change at any point. It is not bound by the usual interface stability promises.
Note
This function clears the number of ops completed as part of the operation. Please ensure you copy this value via psa_export_public_key_iop_get_num_ops() if required before calling.
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 psa_export_public_key_iop_setup() again.
You may call this function any time after the operation object has been initialized. In particular, calling psa_export_public_key_iop_abort() after the operation has already been terminated by a call to psa_export_public_key_iop_abort() or psa_export_public_key_iop_complete() is safe.
Parameters
[in,out]operationThe psa_export_public_key_iop_t to use
Return values
PSA_SUCCESSThe operation was aborted successfully.
PSA_ERROR_BAD_STATEThe library has not been previously initialized by psa_crypto_init().
PSA_ERROR_CORRUPTION_DETECTED
psa_status_t psa_export_public_key_iop_complete ( psa_export_public_key_iop_t operation,
uint8_t *  data,
size_t  data_size,
size_t *  data_length 
)

Continue and eventually complete the action of exporting a public key, in an interruptible manner.

See Also
psa_export_public_key_iop_setup()
Warning
This is a beta API, and thus subject to change at any point. It is not bound by the usual interface stability promises.
Note
This function combined with psa_export_public_key_iop_setup() is equivalent to psa_export_public_key() but this function can return early and resume according to the limit set with psa_interruptible_set_max_ops() to reduce the maximum time spent in a function call.
Users should call this function on the same operation object repeatedly whilst it returns PSA_OPERATION_INCOMPLETE, stopping when it returns either PSA_SUCCESS or an error. Alternatively users can call psa_export_public_key_iop_abort() at any point if they no longer want the result.
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 psa_export_public_key_iop_abort().
Parameters
[in,out]operationThe psa_export_public_key_iop_t to use. This must be initialized first, and have had psa_export_public_key_iop_setup() called with it first.
[out]dataBuffer where the key data is to be written.
[in]data_sizeSize of the data buffer in bytes. This must be appropriate for the key:
  • The required output size is PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(type, bits) where type is the key type and bits is the key size in bits.
  • PSA_EXPORT_PUBLIC_KEY_MAX_SIZE evaluates to the maximum output size of any supported public key or public part of a key pair.
[out]data_lengthOn success, the number of bytes that make up the key data.
Return values
PSA_SUCCESSSuccess. The first (*data_length) bytes of data contain the exported public key.
PSA_ERROR_BAD_STATEThe following conditions can result in this error:
  • The library has not been previously initialized by psa_crypto_init().
  • The operation state is not valid: it must be active.
PSA_ERROR_BUFFER_TOO_SMALLThe size of the data buffer is too small. PSA_EXPORT_PUBLIC_KEY_OUTPUT_SIZE(), PSA_EXPORT_PUBLIC_KEY_MAX_SIZE.
PSA_ERROR_INSUFFICIENT_MEMORY
PSA_ERROR_COMMUNICATION_FAILURE
PSA_ERROR_CORRUPTION_DETECTED
PSA_ERROR_STORAGE_FAILURE
PSA_ERROR_DATA_CORRUPT
PSA_ERROR_DATA_INVALID
PSA_OPERATION_INCOMPLETEOperation was interrupted due to the setting of psa_interruptible_set_max_ops(). There is still work to be done. Call this function again with the same operation object.
uint32_t psa_export_public_key_iop_get_num_ops ( psa_export_public_key_iop_t operation)

Get the number of ops that an export public-key operation has taken so far. If the operation has completed, then this will represent the number of ops required for the entire operation. After initialization or calling psa_export_public_key_iop_abort() on the operation, a value of 0 will be returned.

Warning
This is a beta API, and thus subject to change at any point. It is not bound by the usual interface stability promises. This is a helper provided to help you tune the value passed to psa_interruptible_set_max_ops().
Parameters
operationThe psa_export_public_key_iop_t to use. This must be initialized first.
Returns
Number of ops that the operation has taken so far.
psa_status_t psa_export_public_key_iop_setup ( psa_export_public_key_iop_t operation,
mbedtls_svc_key_id_t  key 
)

Start an interruptible operation to export a public key or the public part of a key pair in binary format.

See Also
psa_export_public_key_iop_complete()
Warning
This is a beta API, and thus subject to change at any point. It is not bound by the usual interface stability promises.
Note
This function combined with psa_export_public_key_iop_complete() is equivalent to psa_export_public_key() but psa_export_public_key_iop_complete() can return early and resume according to the limit set with psa_interruptible_set_max_ops() to reduce the maximum time spent in a function.
Users should call psa_export_public_key_iop_complete() repeatedly on the same operation object after a successful call to this function until psa_export_public_key_iop_complete() either returns PSA_SUCCESS or an error. psa_export_public_key_iop_complete() will return PSA_OPERATION_INCOMPLETE if there is more work to do. Alternatively users can call psa_export_public_key_iop_abort() at any point if they no longer want the result.
This function clears the number of ops completed as part of the operation. Please ensure you copy this value via psa_export_public_key_iop_get_num_ops() if required before calling.
If this function returns an error status, the operation enters an error state and must be aborted by calling psa_export_public_key_iop_abort().
Parameters
[in,out]operationThe psa_export_public_key_iop_t to use. This must be initialized as per the documentation for psa_export_public_key_iop_t, and be inactive.
[in]keyIdentifier of the key to export.
Return values
PSA_SUCCESSThe operation started successfully. Call psa_export_public_key_iop_complete() with the same context to complete the operation.
PSA_ERROR_INVALID_HANDLEkey is not a valid key identifier.
PSA_ERROR_INVALID_ARGUMENTThe key is neither a public key nor a key pair.
PSA_ERROR_NOT_SUPPORTEDThe following conditions can result in this error:
  • The key's storage location does not support export of the key.
  • The implementation does not support export of keys with this key type.
PSA_ERROR_BAD_STATEThe following conditions can result in this error:
  • The library has not been previously initialized by psa_crypto_init().
  • The operation state is not valid: it must be inactive.
PSA_ERROR_COMMUNICATION_FAILURE
PSA_ERROR_CORRUPTION_DETECTED
PSA_ERROR_STORAGE_FAILURE
PSA_ERROR_DATA_CORRUPT
PSA_ERROR_DATA_INVALID
PSA_ERROR_INSUFFICIENT_MEMORY