1 /*
2  * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef TS_CRYPTO_AEAD_H
7 #define TS_CRYPTO_AEAD_H
8 
9 #include <stdint.h>
10 
11 /**
12  * Protocol definitions for aead operations
13  * using the packed-c serialization.
14  */
15 
16 /****************************************
17  * aead_setup operation definition (encrypt or decrypt)
18  */
19 
20 /* Mandatory fixed sized input parameters */
21 struct __attribute__ ((__packed__)) ts_crypto_aead_setup_in
22 {
23   uint32_t key_id;
24   uint32_t alg;
25 };
26 
27 /* Mandatory fixed sized output parameters */
28 struct __attribute__ ((__packed__)) ts_crypto_aead_setup_out
29 {
30   uint32_t op_handle;
31 };
32 
33 /****************************************
34  * aead_generate_nonce operation definition
35  */
36 
37 /* Mandatory fixed sized input parameters */
38 struct __attribute__ ((__packed__)) ts_crypto_aead_generate_nonce_in
39 {
40   uint32_t op_handle;
41 };
42 
43 /* Variable length output parameter tags */
44 enum
45 {
46     TS_CRYPTO_AEAD_GENERATE_NONCE_OUT_TAG_NONCE  = 1
47 };
48 
49 /****************************************
50  * aead_set_nonce operation definition
51  */
52 
53 /* Mandatory fixed sized input parameters */
54 struct __attribute__ ((__packed__)) ts_crypto_aead_set_nonce_in
55 {
56   uint32_t op_handle;
57 };
58 
59 /* Variable length input parameter tags */
60 enum
61 {
62     TS_CRYPTO_AEAD_SET_NONCE_IN_TAG_NONCE  = 1
63 };
64 
65 /****************************************
66  * aead_set_lengths operation definition
67  */
68 
69 /* Mandatory fixed sized input parameters */
70 struct __attribute__ ((__packed__)) ts_crypto_aead_set_lengths_in
71 {
72   uint32_t op_handle;
73   uint32_t ad_length;
74   uint32_t plaintext_length;
75 };
76 
77 /****************************************
78  * aead_update_ad operation definition
79  */
80 
81 /* Mandatory fixed sized input parameters */
82 struct __attribute__ ((__packed__)) ts_crypto_aead_update_ad_in
83 {
84   uint32_t op_handle;
85 };
86 
87 /* Variable length input parameter tags */
88 enum
89 {
90     TS_CRYPTO_AEAD_UPDATE_AD_IN_TAG_DATA  = 1
91 };
92 
93 /****************************************
94  * aead_update operation definition
95  */
96 
97 /* Mandatory fixed sized input parameters */
98 struct __attribute__ ((__packed__)) ts_crypto_aead_update_in
99 {
100   uint32_t op_handle;
101 };
102 
103 /* Variable length input parameter tags */
104 enum
105 {
106     TS_CRYPTO_AEAD_UPDATE_IN_TAG_DATA  = 1
107 };
108 
109 /* Variable length output parameter tags */
110 enum
111 {
112     TS_CRYPTO_AEAD_UPDATE_OUT_TAG_DATA  = 1
113 };
114 
115 /****************************************
116  * aead_finish operation definition
117  */
118 
119 /* Mandatory fixed sized input parameters */
120 struct __attribute__ ((__packed__)) ts_crypto_aead_finish_in
121 {
122   uint32_t op_handle;
123 };
124 
125 /* Variable length output parameter tags */
126 enum
127 {
128     TS_CRYPTO_AEAD_FINISH_OUT_TAG_CIPHERTEXT  = 1,
129     TS_CRYPTO_AEAD_FINISH_OUT_TAG_TAG  = 2
130 };
131 
132 /****************************************
133  * aead_verify operation definition
134  */
135 
136 /* Mandatory fixed sized input parameters */
137 struct __attribute__ ((__packed__)) ts_crypto_aead_verify_in
138 {
139   uint32_t op_handle;
140 };
141 
142 /* Variable length input parameter tags */
143 enum
144 {
145     TS_CRYPTO_AEAD_VERIFY_IN_TAG_TAG  = 1
146 };
147 
148 /* Variable length output parameter tags */
149 enum
150 {
151     TS_CRYPTO_AEAD_VERIFY_OUT_TAG_PLAINTEXT  = 1
152 };
153 
154 /****************************************
155  * aead_abort operation definition
156  */
157 
158 /* Mandatory fixed sized input parameters */
159 struct __attribute__ ((__packed__)) ts_crypto_aead_abort_in
160 {
161   uint32_t op_handle;
162 };
163 
164 
165 #endif /* TS_CRYPTO_AEAD_H */
166