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
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __PS_CRYPTO_INTERFACE_H__
9 #define __PS_CRYPTO_INTERFACE_H__
10 
11 #include <stddef.h>
12 #include <stdint.h>
13 
14 #include "psa/protected_storage.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #define PS_KEY_LEN_BYTES 16
21 #define PS_TAG_LEN_BYTES 16
22 #define PS_IV_LEN_BYTES 12
23 
24 /* Union containing crypto policy implementations. The ref member provides the
25  * reference implementation. Further members can be added to the union to
26  * provide alternative implementations.
27  */
28 union ps_crypto_t {
29  struct {
30  uint8_t tag[PS_TAG_LEN_BYTES];
31  uint8_t iv[PS_IV_LEN_BYTES];
32  } ref;
33 };
34 
41 
48 
55 
71  const uint8_t *add,
72  size_t add_len,
73  const uint8_t *in,
74  size_t in_len,
75  uint8_t *out,
76  size_t out_size,
77  size_t *out_len);
78 
94  const uint8_t *add,
95  size_t add_len,
96  uint8_t *in,
97  size_t in_len,
98  uint8_t *out,
99  size_t out_size,
100  size_t *out_len);
101 
112  const uint8_t *add,
113  uint32_t add_len);
114 
125  const uint8_t *add,
126  uint32_t add_len);
127 
133 void ps_crypto_set_iv(const union ps_crypto_t *crypto);
134 
140 void ps_crypto_get_iv(union ps_crypto_t *crypto);
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /* __PS_CRYPTO_INTERFACE_H__ */
#define PS_TAG_LEN_BYTES
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.
void ps_crypto_get_iv(union ps_crypto_t *crypto)
Gets a new IV value into the crypto union.
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.
struct ps_crypto_t::@9 ref
psa_status_t ps_crypto_destroykey(void)
Destroys the transient key used for crypto operations.
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.
psa_status_t ps_crypto_init(void)
Initializes the crypto engine.
#define PS_IV_LEN_BYTES
void ps_crypto_set_iv(const union ps_crypto_t *crypto)
Provides current IV value to crypto layer.
psa_status_t ps_crypto_setkey(void)
Sets the key to use for crypto operations for the current client.
uint8_t iv[12]
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43
uint8_t tag[16]
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.