16 #ifndef PS_CRYPTO_AEAD_ALG
17 #define PS_CRYPTO_AEAD_ALG PSA_ALG_GCM
21 #define PS_KEY_TYPE PSA_KEY_TYPE_AES
23 #define PS_KEY_USAGE (PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT)
26 #define PS_CRYPTO_ALG \
27 PSA_ALG_AEAD_WITH_TAG_LENGTH(PS_CRYPTO_AEAD_ALG, PS_TAG_LEN_BYTES)
38 static const uint8_t ps_key_label[] =
"storage_key";
71 sizeof(ps_key_label));
144 (void)
tfm_memcpy(&iv_l, ps_crypto_iv_buf,
sizeof(iv_l));
145 (void)
tfm_memcpy(&iv_h, (ps_crypto_iv_buf+
sizeof(iv_l)),
sizeof(iv_h));
153 (void)
tfm_memcpy(ps_crypto_iv_buf, &iv_l,
sizeof(iv_l));
154 (void)
tfm_memcpy((ps_crypto_iv_buf +
sizeof(iv_l)), &iv_h,
sizeof(iv_h));
174 out, out_size, out_len);
205 out, out_size, out_len);
#define PSA_ERROR_INVALID_SIGNATURE
void ps_crypto_set_iv(const union ps_crypto_t *crypto)
Provides current IV value to crypto layer.
Platform Security Architecture cryptography module.
psa_status_t ps_crypto_setkey(void)
Sets the key to use for crypto operations for the current client.
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.
#define PSA_KEY_DERIVATION_INPUT_LABEL
#define PSA_KEY_ATTRIBUTES_INIT
struct ps_crypto_t::@9 ref
psa_status_t ps_crypto_init(void)
Initializes the crypto engine.
#define psa_key_derivation_output_key
#define PSA_ERROR_GENERIC_ERROR
#define PSA_BYTES_TO_BITS(bytes)
#define psa_key_derivation_input_bytes
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.
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.
#define psa_key_derivation_setup
#define PSA_KEY_DERIVATION_OPERATION_INIT
char PS_ERROR_NOT_AEAD_ALG[(PSA_ALG_IS_AEAD(PSA_ALG_AEAD_WITH_TAG_LENGTH(PSA_ALG_GCM, 16)))?1:-1]
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.
#define psa_key_derivation_abort
__STATIC_INLINE void * tfm_memcpy(void *dest, const void *src, size_t num)
psa_status_t ps_crypto_destroykey(void)
Destroys the transient key used for crypto operations.
#define TFM_CRYPTO_ALG_HUK_DERIVATION
The algorithm identifier that refers to key derivation from the hardware unique key.
void ps_crypto_get_iv(union ps_crypto_t *crypto)
Gets a new IV value into the crypto union.
#define PSA_ALG_IS_AEAD(alg)
int32_t psa_status_t
Function return status.