XenevaOS
Loading...
Searching...
No Matches
Functions
psa_crypto_cipher.h File Reference
#include <mbedtls/cipher.h>
#include <psa/crypto.h>
Include dependency graph for psa_crypto_cipher.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

psa_status_t mbedtls_cipher_values_from_psa (psa_algorithm_t alg, psa_key_type_t key_type, size_t *key_bits, mbedtls_cipher_mode_t *mode, mbedtls_cipher_id_t *cipher_id)
 
psa_status_t mbedtls_psa_cipher_encrypt_setup (mbedtls_psa_cipher_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg)
 Set the key for a multipart symmetric encryption operation.
 
psa_status_t mbedtls_psa_cipher_decrypt_setup (mbedtls_psa_cipher_operation_t *operation, const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg)
 Set the key for a multipart symmetric decryption operation.
 
psa_status_t mbedtls_psa_cipher_set_iv (mbedtls_psa_cipher_operation_t *operation, const uint8_t *iv, size_t iv_length)
 
psa_status_t mbedtls_psa_cipher_update (mbedtls_psa_cipher_operation_t *operation, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
 
psa_status_t mbedtls_psa_cipher_finish (mbedtls_psa_cipher_operation_t *operation, uint8_t *output, size_t output_size, size_t *output_length)
 
psa_status_t mbedtls_psa_cipher_abort (mbedtls_psa_cipher_operation_t *operation)
 
psa_status_t mbedtls_psa_cipher_encrypt (const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *iv, size_t iv_length, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
 
psa_status_t mbedtls_psa_cipher_decrypt (const psa_key_attributes_t *attributes, const uint8_t *key_buffer, size_t key_buffer_size, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
 

Function Documentation

◆ mbedtls_cipher_values_from_psa()

psa_status_t mbedtls_cipher_values_from_psa ( psa_algorithm_t  alg,
psa_key_type_t  key_type,
size_t *  key_bits,
mbedtls_cipher_mode_t *  mode,
mbedtls_cipher_id_t *  cipher_id 
)

Get Mbed TLS cipher information given the cipher algorithm PSA identifier as well as the PSA type and size of the key to be used with the cipher algorithm.

Parameters
[in]algPSA cipher algorithm identifier
[in]key_typePSA key type
[in,out]key_bitsSize of the key in bits. The value provided in input might be updated if necessary.
[out]modeMbed TLS cipher mode
[out]cipher_idMbed TLS cipher algorithm identifier
Returns
On success PSA_SUCCESS is returned and key_bits, mode and cipher_id are properly updated. PSA_ERROR_NOT_SUPPORTED is returned if the cipher algorithm is not supported.

◆ mbedtls_psa_cipher_abort()

psa_status_t mbedtls_psa_cipher_abort ( mbedtls_psa_cipher_operation_t *  operation)

Abort a cipher operation.

Aborting an operation frees all associated resources except for the operation structure itself. Once aborted, the operation object can be reused for another operation.

Note
The signature of this function is that of a PSA driver cipher_abort entry point. This function behaves as a cipher_abort entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in,out]operationInitialized cipher operation.
Return values
PSA_SUCCESS\emptydescription

◆ mbedtls_psa_cipher_decrypt()

psa_status_t mbedtls_psa_cipher_decrypt ( const psa_key_attributes_t *  attributes,
const uint8_t *  key_buffer,
size_t  key_buffer_size,
psa_algorithm_t  alg,
const uint8_t *  input,
size_t  input_length,
uint8_t *  output,
size_t  output_size,
size_t *  output_length 
)

Decrypt a message using a symmetric cipher.

Note
The signature of this function is that of a PSA driver cipher_decrypt entry point. This function behaves as a cipher_decrypt entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in]attributesThe attributes of the key to use for the operation.
[in]key_bufferThe buffer containing the key context.
[in]key_buffer_sizeSize of the key_buffer buffer in bytes.
[in]algThe cipher algorithm to compute (PSA_ALG_XXX value such that PSA_ALG_IS_CIPHER(alg) is true).
[in]inputBuffer containing the iv and the ciphertext.
[in]input_lengthSize of the input buffer in bytes.
[out]outputBuffer where the output is to be written.
[in]output_sizeSize of the output buffer in bytes.
[out]output_lengthOn success, the number of bytes that make up the returned output. Initialized to zero by the core.
Return values
PSA_SUCCESS\emptydescription
PSA_ERROR_NOT_SUPPORTED\emptydescription
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription
PSA_ERROR_BUFFER_TOO_SMALLThe size of the output buffer is too small.
PSA_ERROR_INVALID_ARGUMENTThe size of iv is not acceptable for the chosen algorithm, or the chosen algorithm does not use an IV. The total input size passed to this operation is not valid for this particular algorithm. For example, the algorithm is a based on block cipher and requires a whole number of blocks, but the total input size is not a multiple of the block size.
PSA_ERROR_INVALID_PADDINGThis is a decryption operation for an algorithm that includes padding, and the ciphertext does not contain valid padding.

◆ mbedtls_psa_cipher_decrypt_setup()

psa_status_t mbedtls_psa_cipher_decrypt_setup ( mbedtls_psa_cipher_operation_t *  operation,
const psa_key_attributes_t *  attributes,
const uint8_t *  key_buffer,
size_t  key_buffer_size,
psa_algorithm_t  alg 
)

Set the key for a multipart symmetric decryption operation.

Note
The signature of this function is that of a PSA driver cipher_decrypt_setup entry point. This function behaves as a cipher_decrypt_setup entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in,out]operationThe operation object to set up. It has been initialized as per the documentation for psa_cipher_operation_t and not yet in use.
[in]attributesThe attributes of the key to use for the operation.
[in]key_bufferThe buffer containing the key context.
[in]key_buffer_sizeSize of the key_buffer buffer in bytes.
[in]algThe cipher algorithm to compute (PSA_ALG_XXX value such that PSA_ALG_IS_CIPHER(alg) is true).
Return values
PSA_SUCCESS\emptydescription
PSA_ERROR_NOT_SUPPORTED\emptydescription
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription

◆ mbedtls_psa_cipher_encrypt()

psa_status_t mbedtls_psa_cipher_encrypt ( const psa_key_attributes_t *  attributes,
const uint8_t *  key_buffer,
size_t  key_buffer_size,
psa_algorithm_t  alg,
const uint8_t *  iv,
size_t  iv_length,
const uint8_t *  input,
size_t  input_length,
uint8_t *  output,
size_t  output_size,
size_t *  output_length 
)

Encrypt a message using a symmetric cipher.

Note
The signature of this function is that of a PSA driver cipher_encrypt entry point. This function behaves as a cipher_encrypt entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in]attributesThe attributes of the key to use for the operation.
[in]key_bufferThe buffer containing the key context.
[in]key_buffer_sizeSize of the key_buffer buffer in bytes.
[in]algThe cipher algorithm to compute (PSA_ALG_XXX value such that PSA_ALG_IS_CIPHER(alg) is true).
[in]ivBuffer containing the IV for encryption. The IV has been generated by the core.
[in]iv_lengthSize of the iv in bytes.
[in]inputBuffer containing the message to encrypt.
[in]input_lengthSize of the input buffer in bytes.
[in,out]outputBuffer where the output is to be written.
[in]output_sizeSize of the output buffer in bytes.
[out]output_lengthOn success, the number of bytes that make up the returned output. Initialized to zero by the core.
Return values
PSA_SUCCESS\emptydescription
PSA_ERROR_NOT_SUPPORTED\emptydescription
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription
PSA_ERROR_BUFFER_TOO_SMALLThe size of the output buffer is too small.
PSA_ERROR_INVALID_ARGUMENTThe size iv_length is not acceptable for the chosen algorithm, or the chosen algorithm does not use an IV. The total input size passed to this operation is not valid for this particular algorithm. For example, the algorithm is a based on block cipher and requires a whole number of blocks, but the total input size is not a multiple of the block size.
PSA_ERROR_INVALID_PADDINGThis is a decryption operation for an algorithm that includes padding, and the ciphertext does not contain valid padding.

◆ mbedtls_psa_cipher_encrypt_setup()

psa_status_t mbedtls_psa_cipher_encrypt_setup ( mbedtls_psa_cipher_operation_t *  operation,
const psa_key_attributes_t *  attributes,
const uint8_t *  key_buffer,
size_t  key_buffer_size,
psa_algorithm_t  alg 
)

Set the key for a multipart symmetric encryption operation.

Note
The signature of this function is that of a PSA driver cipher_encrypt_setup entry point. This function behaves as a cipher_encrypt_setup entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in,out]operationThe operation object to set up. It has been initialized as per the documentation for psa_cipher_operation_t and not yet in use.
[in]attributesThe attributes of the key to use for the operation.
[in]key_bufferThe buffer containing the key context.
[in]key_buffer_sizeSize of the key_buffer buffer in bytes.
[in]algThe cipher algorithm to compute (PSA_ALG_XXX value such that PSA_ALG_IS_CIPHER(alg) is true).
Return values
PSA_SUCCESS\emptydescription
PSA_ERROR_NOT_SUPPORTED\emptydescription
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription
PSA_ERROR_CORRUPTION_DETECTED\emptydescription

◆ mbedtls_psa_cipher_finish()

psa_status_t mbedtls_psa_cipher_finish ( mbedtls_psa_cipher_operation_t *  operation,
uint8_t *  output,
size_t  output_size,
size_t *  output_length 
)

Finish encrypting or decrypting a message in a cipher operation.

Note
The signature of this function is that of a PSA driver cipher_finish entry point. This function behaves as a cipher_finish entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in,out]operationActive cipher operation.
[out]outputBuffer where the output is to be written.
[in]output_sizeSize of the output buffer in bytes.
[out]output_lengthOn success, the number of bytes that make up the returned output.
Return values
PSA_SUCCESS\emptydescription
PSA_ERROR_INVALID_ARGUMENTThe total input size passed to this operation is not valid for this particular algorithm. For example, the algorithm is a based on block cipher and requires a whole number of blocks, but the total input size is not a multiple of the block size.
PSA_ERROR_INVALID_PADDINGThis is a decryption operation for an algorithm that includes padding, and the ciphertext does not contain valid padding.
PSA_ERROR_BUFFER_TOO_SMALLThe size of the output buffer is too small.
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription

◆ mbedtls_psa_cipher_set_iv()

psa_status_t mbedtls_psa_cipher_set_iv ( mbedtls_psa_cipher_operation_t *  operation,
const uint8_t *  iv,
size_t  iv_length 
)

Set the IV for a symmetric encryption or decryption operation.

This function sets the IV (initialization vector), nonce or initial counter value for the encryption or decryption operation.

Note
The signature of this function is that of a PSA driver cipher_set_iv entry point. This function behaves as a cipher_set_iv entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in,out]operationActive cipher operation.
[in]ivBuffer containing the IV to use.
[in]iv_lengthSize of the IV in bytes. It is guaranteed by the core to be less or equal to PSA_CIPHER_IV_MAX_SIZE.
Return values
PSA_SUCCESS\emptydescription
PSA_ERROR_INVALID_ARGUMENTThe size of iv is not acceptable for the chosen algorithm, or the chosen algorithm does not use an IV.
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription

◆ mbedtls_psa_cipher_update()

psa_status_t mbedtls_psa_cipher_update ( mbedtls_psa_cipher_operation_t *  operation,
const uint8_t *  input,
size_t  input_length,
uint8_t *  output,
size_t  output_size,
size_t *  output_length 
)

Encrypt or decrypt a message fragment in an active cipher operation.

Note
The signature of this function is that of a PSA driver cipher_update entry point. This function behaves as a cipher_update entry point as defined in the PSA driver interface specification for transparent drivers.
Parameters
[in,out]operationActive cipher operation.
[in]inputBuffer containing the message fragment to encrypt or decrypt.
[in]input_lengthSize of the input buffer in bytes.
[out]outputBuffer where the output is to be written.
[in]output_sizeSize of the output buffer in bytes.
[out]output_lengthOn success, the number of bytes that make up the returned output.
Return values
PSA_SUCCESS\emptydescription
PSA_ERROR_BUFFER_TOO_SMALLThe size of the output buffer is too small.
PSA_ERROR_INSUFFICIENT_MEMORY\emptydescription