Debian Codegraph @

crt/s2n/tests/cbmc/include/cbmc_proof/make_common_datastructures.h

raw symbols SCIP
1 /*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 #pragma once
17
18 #include <cbmc_proof/cbmc_utils.h>
19
20 #include "api/s2n.h"
21 #include "crypto/s2n_certificate.h"
22 #include "crypto/s2n_dhe.h"
23 #include "crypto/s2n_evp.h"
24 #include "crypto/s2n_hash.h"
25 #include "crypto/s2n_hmac.h"
26 #include "crypto/s2n_libcrypto.h"
27 #include "stuffer/s2n_stuffer.h"
28 #include "tls/s2n_config.h"
29 #include "tls/s2n_connection.h"
30 #include "tls/s2n_security_policies.h"
31 #include "utils/s2n_array.h"
32 #include "utils/s2n_blob.h"
33 #include "utils/s2n_map_internal.h"
34 #include "utils/s2n_safety_macros.h"
35 #include "utils/s2n_socket.h"
36
37 /*
38 * Checks whether s2n_blob is bounded by max_size.
39 */
40 bool s2n_blob_is_bounded(const struct s2n_blob *blob, const size_t max_size);
41
42 /*
43 * Checks whether s2n_stuffer is bounded by max_size.
44 */
45 bool s2n_stuffer_is_bounded(const struct s2n_stuffer *stuffer, const size_t max_size);
46
47 /*
48 * Populates the fields of a pre-allocated s2n_blob for CBMC proofs.
49 */
50 void cbmc_populate_s2n_blob(struct s2n_blob *blob);
51
52 /*
53 * Properly allocates s2n_blob for CBMC proofs.
54 */
55 struct s2n_blob *cbmc_allocate_s2n_blob();
56
57 /*
58 * Populates the fields of a pre-allocated s2n_stuffer for CBMC proofs.
59 */
60 void cbmc_populate_s2n_stuffer(struct s2n_stuffer *stuffer);
61
62 /*
63 * Properly allocates s2n_stuffer for CBMC proofs.
64 */
65 struct s2n_stuffer *cbmc_allocate_s2n_stuffer();
66
67 /*
68 * Ensures a valid const string is allocated,
69 * with as much nondet as possible, len < max_size.
70 */
71 const char *ensure_c_str_is_allocated(size_t max_size);
72
73 /*
74 * Nondeterministically return a valid-allocated const string or NULL,
75 * with as much nondet as possible, len < max_size.
76 */
77 const char *nondet_c_str_is_allocated(size_t max_size);
78
79 /*
80 * Populates the fields of a pre-allocated s2n_stuffer_reservation for CBMC proofs.
81 */
82 void cbmc_populate_s2n_stuffer_reservation(struct s2n_stuffer_reservation *reservation);
83
84 /*
85 * Properly allocates s2n_stuffer_reservation for CBMC proofs.
86 */
87 struct s2n_stuffer_reservation *cbmc_allocate_s2n_stuffer_reservation();
88
89 /*
90 * Checks whether s2n_array is bounded by max_len and max_element_size.
91 */
92 bool s2n_array_is_bounded(const struct s2n_array *array, const size_t max_len, const size_t max_element_size);
93
94 /*
95 * Populates the fields of a pre-allocated s2n_array for CBMC proofs.
96 */
97 void cbmc_populate_s2n_array(struct s2n_array *array);
98
99 /*
100 * Properly allocates s2n_array for CBMC proofs.
101 */
102 struct s2n_array *cbmc_allocate_s2n_array();
103
104 /*
105 * Populates the fields of a pre-allocated s2n_dh_params for CBMC proofs.
106 */
107 void cbmc_populate_s2n_dh_params(struct s2n_dh_params *s2n_dh_params);
108
109 /*
110 * Properly allocates s2n_dh_params for CBMC proofs.
111 */
112 struct s2n_dh_params *cbmc_allocate_dh_params();
113
114 /*
115 * Populates the fields of a pre-allocated BIGNUM for CBMC proofs.
116 */
117 void cbmc_populate_BIGNUM(BIGNUM *bignum);
118
119 /*
120 * Properly allocates BIGNUM for CBMC proofs.
121 */
122 BIGNUM *cbmc_allocate_BIGNUM();
123
124 /*
125 * Populates the fields of a pre-allocated EC_GROUP for CBMC proofs.
126 */
127 void cbmc_populate_EC_GROUP(EC_GROUP *ec_group);
128
129 /*
130 * Properly allocates EC_GROUP for CBMC proofs.
131 */
132 EC_GROUP *cbmc_allocate_EC_GROUP();
133
134 /*
135 * Populates the fields of a pre-allocated EC_KEY for CBMC proofs.
136 */
137 void cbmc_populate_EC_KEY(EC_KEY *ec_key);
138
139 /*
140 * Properly allocates EC_KEY for CBMC proofs.
141 */
142 EC_KEY *cbmc_allocate_EC_KEY();
143
144 /*
145 * Populates the fields of a pre-allocated EVP_PKEY for CBMC proofs.
146 */
147 void cbmc_populate_EVP_PKEY(EVP_PKEY *evp_pkey);
148
149 /*
150 * Properly allocates EVP_PKEY for CBMC proofs.
151 */
152 EVP_PKEY *cbmc_allocate_EVP_PKEY();
153
154 /*
155 * Populates the fields of a pre-allocated EVP_PKEY_CTX for CBMC proofs.
156 */
157 void cbmc_populate_EVP_PKEY_CTX(EVP_PKEY_CTX *evp_pkey_ctx);
158
159 /*
160 * Properly allocates EVP_PKEY_CTX for CBMC proofs.
161 */
162 EVP_PKEY_CTX *cbmc_allocate_EVP_PKEY_CTX();
163
164 /*
165 * Populates the fields of a pre-allocated EVP_MD_CTX for CBMC proofs.
166 */
167 void cbmc_populate_EVP_MD_CTX(EVP_MD_CTX *ctx);
168
169 /*
170 * Properly allocates EVP_MD_CTX for CBMC proofs.
171 */
172 EVP_MD_CTX* cbmc_allocate_EVP_MD_CTX();
173
174 /*
175 * Populates the fields of a pre-allocated s2n_evp_digest for CBMC proofs.
176 */
177 void cbmc_populate_s2n_evp_digest(struct s2n_evp_digest *evp_digest);
178
179 /*
180 * Properly allocates s2n_evp_digest for CBMC proofs.
181 */
182 struct s2n_evp_digest* cbmc_allocate_s2n_evp_digest();
183
184 /*
185 * Populates the fields of a pre-allocated s2n_hash_state for CBMC proofs.
186 */
187 void cbmc_populate_s2n_hash_state(struct s2n_hash_state *state);
188
189 /*
190 * Properly allocates s2n_hash_state for CBMC proofs.
191 */
192 struct s2n_hash_state *cbmc_allocate_s2n_hash_state();
193
194 /*
195 * Populates the fields of a pre-allocated s2n_hmac_state for CBMC proofs.
196 */
197 void cbmc_populate_s2n_hmac_state(struct s2n_hmac_state *state);
198
199 /*
200 * Properly allocates s2n_hmac_state for CBMC proofs.
201 */
202 struct s2n_hmac_state* cbmc_allocate_s2n_hmac_state();
203
204 /*
205 * Populates the fields of a pre-allocated s2n_hmac_evp_backup for CBMC proofs.
206 */
207 void cbmc_populate_s2n_hmac_evp_backup(struct s2n_hmac_evp_backup *backup);
208
209 /*
210 * Properly allocates s2n_hmac_state for CBMC proofs.
211 */
212 struct s2n_hmac_evp_backup* cbmc_allocate_s2n_hmac_evp_backup();
213
214 /*
215 * Populates the fields of a pre-allocated s2n_map for CBMC proofs.
216 */
217 void cbmc_populate_s2n_map(struct s2n_map *s2n_map);
218
219 /*
220 * Properly allocates s2n_map for CBMC proofs.
221 */
222 struct s2n_map *cbmc_allocate_s2n_map();
223
224 /*
225 * Properly allocates s2n_cipher_preferences for CBMC proofs.
226 */
227 struct s2n_cipher_preferences *cbmc_allocate_s2n_cipher_preferences();
228
229 /*
230 * Properly allocates s2n_kem_preferences for CBMC proofs.
231 */
232 struct s2n_kem_preferences *cbmc_allocate_s2n_kem_preferences();
233
234 /*
235 * Properly allocates s2n_signature_preferences for CBMC proofs.
236 */
237 struct s2n_signature_preferences *cbmc_allocate_s2n_signature_preferences();
238
239 /*
240 * Properly allocates s2n_ecc_preferences for CBMC proofs.
241 */
242 struct s2n_ecc_preferences *cbmc_allocate_s2n_ecc_preferences();
243
244 /*
245 * Properly allocates s2n_security_policy for CBMC proofs.
246 */
247 struct s2n_security_policy *cbmc_allocate_s2n_security_policy();
248
249 /*
250 * Properly allocates X509_STORE for CBMC proofs.
251 */
252 X509_STORE *cbmc_allocate_X509_STORE();
253
254 /*
255 * Populates the fields of a pre-allocated s2n_x509_trust_store for CBMC proofs.
256 */
257 void cbmc_populate_s2n_x509_trust_store(struct s2n_x509_trust_store *s2n_x509_trust_store);
258
259 /*
260 * Properly allocates s2n_config for CBMC proofs.
261 */
262 struct s2n_config *cbmc_allocate_s2n_config();
263
264 /*
265 * Populates the fields of a pre-allocated s2n_pkey for CBMC proofs.
266 */
267 void cbmc_populate_s2n_pkey(struct s2n_pkey *s2n_pkey);
268
269 /*
270 * Properly allocates s2n_pkey for CBMC proofs.
271 */
272 struct s2n_pkey *cbmc_allocate_s2n_pkey();
273
274 /*
275 * Populates the fields of a pre-allocated s2n_ecc_evp_params for CBMC proofs.
276 */
277 void cbmc_populate_s2n_ecc_evp_params(struct s2n_ecc_evp_params *s2n_ecc_evp_params);
278
279 /*
280 * Properly allocates s2n_ecc_named_curve for CBMC proofs.
281 */
282 struct s2n_ecc_named_curve *cbmc_allocate_s2n_ecc_named_curve();
283
284 /*
285 * Properly allocates s2n_kem for CBMC proofs.
286 */
287 struct s2n_kem *cbmc_allocate_s2n_kem();
288
289 /*
290 * Properly allocates s2n_kem_group for CBMC proofs.
291 */
292 struct s2n_kem_group *cbmc_allocate_s2n_kem_group();
293
294 /*
295 * Populates the fields of a pre-allocated s2n_kem_params for CBMC proofs.
296 */
297 void cbmc_populate_s2n_kem_params(struct s2n_kem_params *s2n_kem_params);
298
299 /*
300 * Populates the fields of a pre-allocated s2n_kem_group_params for CBMC proofs.
301 */
302 void cbmc_populate_s2n_kem_group_params(struct s2n_kem_group_params *s2n_kem_group_params);
303
304 /*
305 * Properly allocates s2n_kem_group_params for CBMC proofs.
306 */
307 struct s2n_kem_group_params *cbmc_allocate_s2n_kem_group_params();
308
309 /*
310 * Populates the fields of a pre-allocated s2n_signature_scheme for CBMC proofs.
311 */
312 void cbmc_populate_s2n_signature_scheme(struct s2n_signature_scheme *s2n_signature_scheme);
313
314 /*
315 * Properly allocates s2n_kex for CBMC proofs.
316 */
317 struct s2n_kex *cbmc_allocate_s2n_kex();
318
319 /*
320 * Properly allocates s2n_cipher for CBMC proofs.
321 */
322 struct s2n_cipher *cbmc_allocate_s2n_cipher();
323
324 /*
325 * Properly allocates s2n_record_algorithm for CBMC proofs.
326 */
327 struct s2n_record_algorithm *cbmc_allocate_s2n_record_algorithm();
328
329 /*
330 * Properly allocates s2n_cipher_suite for CBMC proofs.
331 */
332 struct s2n_cipher_suite *cbmc_allocate_s2n_cipher_suite();
333
334 /*
335 * Populates the fields of a pre-allocated s2n_session_key for CBMC proofs.
336 */
337 void cbmc_populate_s2n_session_key(struct s2n_session_key *s2n_session_key);
338
339 /*
340 * Populates the fields of a pre-allocated s2n_crypto_parameters for CBMC proofs.
341 */
342 void cbmc_populate_s2n_crypto_parameters(struct s2n_crypto_parameters *s2n_crypto_parameters);
343
344 /*
345 * Properly allocates s2n_crypto_parameters for CBMC proofs.
346 */
347 struct s2n_crypto_parameters *cbmc_allocate_s2n_crypto_parameters();
348
349 /*
350 * Populates the fields of a pre-allocated s2n_cert for CBMC proofs.
351 */
352 void cbmc_populate_s2n_cert(struct s2n_cert *s2n_cert);
353
354 /*
355 * Properly allocates s2n_cert for CBMC proofs.
356 */
357 struct s2n_cert *cbmc_allocate_s2n_cert();
358
359 /*
360 * Populates the fields of a pre-allocated s2n_cert_chain for CBMC proofs.
361 */
362 void cbmc_populate_s2n_cert_chain(struct s2n_cert_chain *s2n_cert_chain);
363
364 /*
365 * Properly allocates s2n_cert_chain for CBMC proofs.
366 */
367 struct s2n_cert_chain *cbmc_allocate_s2n_cert_chain();
368
369 /*
370 * Populates the fields of a pre-allocated s2n_cert_chain_and_key for CBMC proofs.
371 */
372 void cbmc_populate_s2n_cert_chain_and_key(struct s2n_cert_chain_and_key *s2n_cert_chain_and_key);
373
374 /*
375 * Populates the fields of a pre-allocated s2n_handshake_parameters for CBMC proofs.
376 */
377 void cbmc_populate_s2n_handshake_parameters(struct s2n_handshake_parameters *s2n_handshake_parameters);
378
379 /*
380 * Populates the fields of a pre-allocated s2n_early_data_config for CBMC proofs.
381 */
382 void cbmc_populate_s2n_early_data_config(struct s2n_early_data_config *s2n_early_data_config);
383
384 /*
385 * Populates the fields of a pre-allocated s2n_psk for CBMC proofs.
386 */
387 void cbmc_populate_s2n_psk(struct s2n_psk *s2n_psk);
388
389 /*
390 * Properly allocates s2n_psk for CBMC proofs.
391 */
392 struct s2n_psk *cbmc_allocate_s2n_psk();
393
394 /*
395 * Populates the fields of a pre-allocated s2n_psk_parameters for CBMC proofs.
396 */
397 void cbmc_populate_s2n_psk_parameters(struct s2n_psk_parameters *s2n_psk_parameters);
398
399 /*
400 * Populates the fields of a pre-allocated s2n_prf_working_space for CBMC proofs.
401 */
402 void cbmc_populate_s2n_prf_working_space(struct s2n_prf_working_space *s2n_prf_working_space);
403
404 /*
405 * Populates the fields of a pre-allocated s2n_handshake for CBMC proofs.
406 */
407 void cbmc_populate_s2n_handshake(struct s2n_handshake *s2n_handshake);
408
409 /*
410 * Populates the fields of a pre-allocated s2n_client_hello for CBMC proofs.
411 */
412 void cbmc_populate_s2n_client_hello(struct s2n_client_hello *s2n_client_hello);
413
414 /*
415 * Populates the fields of a pre-allocated s2n_x509_validator for CBMC proofs.
416 */
417 void cbmc_populate_s2n_x509_validator(struct s2n_x509_validator *s2n_x509_validator);
418
419 /*
420 * Populates the fields of a pre-allocated s2n_ticket_fields for CBMC proofs.
421 */
422 void cbmc_populate_s2n_ticket_fields(struct s2n_ticket_fields *s2n_ticket_fields);
423
424 /*
425 * Populates the fields of a pre-allocated s2n_connection for CBMC proofs.
426 */
427 void cbmc_populate_s2n_connection(struct s2n_connection *s2n_connection);
428
429 /*
430 * Properly allocates s2n_connection for CBMC proofs.
431 */
432 struct s2n_connection *cbmc_allocate_s2n_connection();
433
434 struct s2n_socket_read_io_context *cbmc_allocate_s2n_socket_read_io_context();
435
436 struct s2n_socket_write_io_context *cbmc_allocate_s2n_socket_write_io_context();