![]() |
TF-M Reference Manual
1.2.0
TrustedFirmware-M
|
#include "ps_crypto_interface.h"
#include <stdbool.h>
#include "tfm_crypto_defs.h"
#include "psa/crypto.h"
#include "tfm_memory_utils.h"
Go to the source code of this file.
Macros | |
#define | PS_CRYPTO_AEAD_ALG PSA_ALG_GCM |
#define | PS_KEY_TYPE PSA_KEY_TYPE_AES |
#define | PS_KEY_USAGE (PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT) |
#define | PS_CRYPTO_ALG PSA_ALG_AEAD_WITH_TAG_LENGTH(PS_CRYPTO_AEAD_ALG, PS_TAG_LEN_BYTES) |
Typedefs | |
typedef char | PS_ERROR_NOT_AEAD_ALG [(PSA_ALG_IS_AEAD(PSA_ALG_AEAD_WITH_TAG_LENGTH(PSA_ALG_GCM, 16)))?1:-1] |
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... | |
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... | |
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... | |
#define PS_CRYPTO_AEAD_ALG PSA_ALG_GCM |
Definition at line 17 of file ps_crypto_interface.c.
#define PS_CRYPTO_ALG PSA_ALG_AEAD_WITH_TAG_LENGTH(PS_CRYPTO_AEAD_ALG, PS_TAG_LEN_BYTES) |
Definition at line 26 of file ps_crypto_interface.c.
#define PS_KEY_TYPE PSA_KEY_TYPE_AES |
Definition at line 21 of file ps_crypto_interface.c.
#define PS_KEY_USAGE (PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT) |
Definition at line 23 of file ps_crypto_interface.c.
typedef char PS_ERROR_NOT_AEAD_ALG[(PSA_ALG_IS_AEAD(PSA_ALG_AEAD_WITH_TAG_LENGTH(PSA_ALG_GCM,16)))?1:-1] |
Definition at line 36 of file ps_crypto_interface.c.
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.
[in] | crypto | Pointer to the crypto union |
[in] | add | Pointer to the associated data |
[in] | add_len | Length of the associated data |
[in] | in | Pointer to the input data |
[in] | in_len | Length of the input data |
[out] | out | Pointer to the output buffer for decrypted data |
[in] | out_size | Size of the output buffer |
[out] | out_len | On success, the length of the output data |
Definition at line 186 of file ps_crypto_interface.c.
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.
[in] | crypto | Pointer to the crypto union |
[in] | add | Pointer to the data to authenticate |
[in] | add_len | Length of the data to authenticate |
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.
Definition at line 99 of file ps_crypto_interface.c.
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.
[in,out] | crypto | Pointer to the crypto union |
[in] | add | Pointer to the associated data |
[in] | add_len | Length of the associated data |
[in] | in | Pointer to the input data |
[in] | in_len | Length of the input data |
[out] | out | Pointer to the output buffer for encrypted data |
[in] | out_size | Size of the output buffer |
[out] | out_len | On success, the length of the output data |
Definition at line 159 of file ps_crypto_interface.c.
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.
[in,out] | crypto | Pointer to the crypto union |
[in] | add | Pointer to the data to authenticate |
[in] | add_len | Length of the data to authenticate |
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.
[out] | crypto | Pointer to the crypto union |
Definition at line 117 of file ps_crypto_interface.c.
psa_status_t ps_crypto_init | ( | void | ) |
Initializes the crypto engine.
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.
[in] | crypto | Pointer to the crypto union |
Definition at line 112 of file ps_crypto_interface.c.
psa_status_t ps_crypto_setkey | ( | void | ) |
Sets the key to use for crypto operations for the current client.
Definition at line 50 of file ps_crypto_interface.c.