TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ps_crypto_interface.h File Reference
#include <stddef.h>
#include <stdint.h>
#include "psa/protected_storage.h"
Include dependency graph for ps_crypto_interface.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  ps_crypto_t
 

Macros

#define PS_KEY_LEN_BYTES   16
 
#define PS_TAG_LEN_BYTES   16
 
#define PS_IV_LEN_BYTES   12
 

Functions

psa_status_t ps_crypto_init (void)
 Initializes the crypto engine. More...
 
psa_status_t ps_crypto_setkey (void)
 Sets the key to use for crypto operations for the current client. More...
 
psa_status_t ps_crypto_destroykey (void)
 Destroys the transient key used for crypto operations. More...
 
psa_status_t ps_crypto_encrypt_and_tag (union ps_crypto_t *crypto, const uint8_t *add, size_t add_len, const uint8_t *in, size_t in_len, uint8_t *out, size_t out_size, size_t *out_len)
 Encrypts and tags the given plaintext data. More...
 
psa_status_t ps_crypto_auth_and_decrypt (const union ps_crypto_t *crypto, const uint8_t *add, size_t add_len, uint8_t *in, size_t in_len, uint8_t *out, size_t out_size, size_t *out_len)
 Decrypts and authenticates the given encrypted data. More...
 
psa_status_t ps_crypto_generate_auth_tag (union ps_crypto_t *crypto, const uint8_t *add, uint32_t add_len)
 Generates authentication tag for given data. More...
 
psa_status_t ps_crypto_authenticate (const union ps_crypto_t *crypto, const uint8_t *add, uint32_t add_len)
 Authenticate given data against the tag. More...
 
void ps_crypto_set_iv (const union ps_crypto_t *crypto)
 Provides current IV value to crypto layer. More...
 
void ps_crypto_get_iv (union ps_crypto_t *crypto)
 Gets a new IV value into the crypto union. More...
 

Macro Definition Documentation

#define PS_IV_LEN_BYTES   12

Definition at line 22 of file ps_crypto_interface.h.

#define PS_KEY_LEN_BYTES   16

Definition at line 20 of file ps_crypto_interface.h.

#define PS_TAG_LEN_BYTES   16

Definition at line 21 of file ps_crypto_interface.h.

Function Documentation

psa_status_t ps_crypto_auth_and_decrypt ( const union ps_crypto_t crypto,
const uint8_t *  add,
size_t  add_len,
uint8_t *  in,
size_t  in_len,
uint8_t *  out,
size_t  out_size,
size_t *  out_len 
)

Decrypts and authenticates the given encrypted data.

Parameters
[in]cryptoPointer to the crypto union
[in]addPointer to the associated data
[in]add_lenLength of the associated data
[in]inPointer to the input data
[in]in_lenLength of the input data
[out]outPointer to the output buffer for decrypted data
[in]out_sizeSize of the output buffer
[out]out_lenOn success, the length of the output data
Returns
Returns values as described in psa_status_t

Definition at line 186 of file ps_crypto_interface.c.

Here is the call graph for this function:

psa_status_t ps_crypto_authenticate ( const union ps_crypto_t crypto,
const uint8_t *  add,
uint32_t  add_len 
)

Authenticate given data against the tag.

Parameters
[in]cryptoPointer to the crypto union
[in]addPointer to the data to authenticate
[in]add_lenLength of the data to authenticate
Returns
Returns values as described in psa_status_t

Definition at line 232 of file ps_crypto_interface.c.

psa_status_t ps_crypto_destroykey ( void  )

Destroys the transient key used for crypto operations.

Returns
Returns values as described in psa_status_t

Definition at line 99 of file ps_crypto_interface.c.

Here is the caller graph for this function:

psa_status_t ps_crypto_encrypt_and_tag ( union ps_crypto_t crypto,
const uint8_t *  add,
size_t  add_len,
const uint8_t *  in,
size_t  in_len,
uint8_t *  out,
size_t  out_size,
size_t *  out_len 
)

Encrypts and tags the given plaintext data.

Parameters
[in,out]cryptoPointer to the crypto union
[in]addPointer to the associated data
[in]add_lenLength of the associated data
[in]inPointer to the input data
[in]in_lenLength of the input data
[out]outPointer to the output buffer for encrypted data
[in]out_sizeSize of the output buffer
[out]out_lenOn success, the length of the output data
Returns
Returns values as described in psa_status_t

Definition at line 159 of file ps_crypto_interface.c.

Here is the call graph for this function:

psa_status_t ps_crypto_generate_auth_tag ( union ps_crypto_t crypto,
const uint8_t *  add,
uint32_t  add_len 
)

Generates authentication tag for given data.

Parameters
[in,out]cryptoPointer to the crypto union
[in]addPointer to the data to authenticate
[in]add_lenLength of the data to authenticate
Returns
Returns values as described in psa_status_t

Definition at line 213 of file ps_crypto_interface.c.

void ps_crypto_get_iv ( union ps_crypto_t crypto)

Gets a new IV value into the crypto union.

Parameters
[out]cryptoPointer to the crypto union

Definition at line 117 of file ps_crypto_interface.c.

Here is the call graph for this function:

psa_status_t ps_crypto_init ( void  )

Initializes the crypto engine.

Returns
Returns values as described in psa_status_t

Definition at line 42 of file ps_crypto_interface.c.

void ps_crypto_set_iv ( const union ps_crypto_t crypto)

Provides current IV value to crypto layer.

Parameters
[in]cryptoPointer to the crypto union

Definition at line 112 of file ps_crypto_interface.c.

Here is the call graph for this function:

Here is the caller graph for this function:

psa_status_t ps_crypto_setkey ( void  )

Sets the key to use for crypto operations for the current client.

Returns
Returns values as described in psa_status_t

Definition at line 50 of file ps_crypto_interface.c.

Here is the caller graph for this function: