blob: a2c0652c62915fafe85cbd6da9ea6fb2274e6b3e [file] [log] [blame]
Antonio de Angelis8908f472018-08-31 15:44:25 +01001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#include "tfm_crypto_veneers.h"
9#include "secure_fw/services/crypto/tfm_crypto_api.h"
10#include "tfm_secure_api.h"
11#include "tfm_api.h"
12#include "spm_api.h"
13
14#include "psa_crypto.h"
15
16#include "crypto_psa_wrappers.h"
17
18__tfm_secure_gateway_attributes__
19enum tfm_crypto_err_t tfm_crypto_veneer_import_key(psa_key_slot_t key,
20 psa_key_type_t type,
21 const uint8_t *data,
22 size_t data_length)
23{
24 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_import_key,
25 key, type, data, data_length);
26}
27
28__tfm_secure_gateway_attributes__
29enum tfm_crypto_err_t tfm_crypto_veneer_destroy_key(psa_key_slot_t key)
30{
31 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_destroy_key,
32 key, 0, 0, 0);
33}
34
35__tfm_secure_gateway_attributes__
36enum tfm_crypto_err_t tfm_crypto_veneer_get_key_information(
37 psa_key_slot_t key,
38 psa_key_type_t *type,
39 size_t *bits)
40{
41 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_get_key_information,
42 key, type, bits, 0);
43}
44
45__tfm_secure_gateway_attributes__
46enum tfm_crypto_err_t tfm_crypto_veneer_export_key(psa_key_slot_t key,
47 uint8_t *data,
48 size_t data_size,
49 size_t *data_length)
50{
51 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_export_key,
52 key, data, data_size, data_length);
53}
54
55
56__tfm_secure_gateway_attributes__
57enum tfm_crypto_err_t tfm_crypto_veneer_encrypt_set_iv(
58 psa_cipher_operation_t *operation,
59 const unsigned char *iv,
60 size_t iv_length)
61{
62 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_encrypt_set_iv,
63 operation, iv, iv_length, 0);
64}
65
66__tfm_secure_gateway_attributes__
67enum tfm_crypto_err_t tfm_crypto_veneer_encrypt_setup(
68 psa_cipher_operation_t *operation,
69 psa_key_slot_t key,
70 psa_algorithm_t alg)
71{
72 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_encrypt_setup,
73 operation, key, alg, 0);
74}
75
76__tfm_secure_gateway_attributes__
77enum tfm_crypto_err_t tfm_crypto_veneer_decrypt_setup(
78 psa_cipher_operation_t *operation,
79 psa_key_slot_t key,
80 psa_algorithm_t alg)
81{
82 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_decrypt_setup,
83 operation, key, alg, 0);
84}
85
86__tfm_secure_gateway_attributes__
87enum tfm_crypto_err_t tfm_crypto_veneer_cipher_update(
88 psa_cipher_operation_t *operation,
89 struct psa_cipher_update_input *input_s,
90 struct psa_cipher_update_output *output_s)
91{
92 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_cipher_update_wrapper,
93 operation, input_s, output_s, 0);
94}
95
96__tfm_secure_gateway_attributes__
97enum tfm_crypto_err_t tfm_crypto_veneer_cipher_abort(
98 psa_cipher_operation_t *operation)
99{
100 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_cipher_abort,
101 operation, 0, 0, 0);
102}
103
104__tfm_secure_gateway_attributes__
105enum tfm_crypto_err_t tfm_crypto_veneer_cipher_finish(
106 psa_cipher_operation_t *operation,
107 uint8_t *output,
108 size_t output_size,
109 size_t *output_length)
110{
111 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_cipher_finish,
112 operation, output, output_size, output_length);
113}
Antonio de Angelisa6f72162018-09-05 11:00:37 +0100114
115__tfm_secure_gateway_attributes__
116enum tfm_crypto_err_t tfm_crypto_veneer_hash_start(
117 psa_hash_operation_t *operation,
118 psa_algorithm_t alg)
119{
120 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_hash_start,
121 operation, alg, 0, 0);
122}
123
124__tfm_secure_gateway_attributes__
125enum tfm_crypto_err_t tfm_crypto_veneer_hash_update(
126 psa_hash_operation_t *operation,
127 const uint8_t *input,
128 size_t input_length)
129{
130 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_hash_update,
131 operation, input, input_length, 0);
132}
133
134__tfm_secure_gateway_attributes__
135enum tfm_crypto_err_t tfm_crypto_veneer_hash_finish(
136 psa_hash_operation_t *operation,
137 uint8_t *hash,
138 size_t hash_size,
139 size_t *hash_length)
140{
141 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_hash_finish,
142 operation, hash, hash_size, hash_length);
143}
144
145__tfm_secure_gateway_attributes__
146enum tfm_crypto_err_t tfm_crypto_veneer_hash_verify(
147 psa_hash_operation_t *operation,
148 const uint8_t *hash,
149 size_t hash_length)
150{
151 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_hash_verify,
152 operation, hash, hash_length, 0);
153}
154
155__tfm_secure_gateway_attributes__
156enum tfm_crypto_err_t tfm_crypto_veneer_hash_abort(
157 psa_hash_operation_t *operation)
158{
159 TFM_CORE_SFN_REQUEST(TFM_SP_CRYPTO_ID, tfm_crypto_hash_abort,
160 operation, 0, 0, 0);
161}