Debian Codegraph @

crt/s2n/tls/s2n_client_hello.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 <stdint.h>
19
20 #include "api/s2n.h"
21 #include "stuffer/s2n_stuffer.h"
22 #include "tls/extensions/s2n_extension_list.h"
23 #include "tls/s2n_crypto_constants.h"
24 #include "utils/s2n_array.h"
25 /*
26 * the 'data' pointers in the below blobs
27 * point to data in the raw_message stuffer
28 */
29 struct s2n_client_hello {
30 struct s2n_blob raw_message;
31 uint8_t random[S2N_TLS_RANDOM_DATA_LEN];
32
33 s2n_parsed_extensions_list extensions;
34 struct s2n_blob cipher_suites;
35 struct s2n_blob session_id;
36 struct s2n_blob compression_methods;
37 /* The protocol version as written in the client hello */
38 uint8_t legacy_version;
39 /* The protocol written on the record header containing the client hello */
40 uint8_t legacy_record_version;
41 /* Tracks if we have recorded the version in the first record */
42 unsigned int record_version_recorded : 1;
43
44 unsigned int callback_invoked : 1;
45 unsigned int callback_async_blocked : 1;
46 unsigned int callback_async_done : 1;
47 /*
48 * Marks if the client hello has been parsed.
49 *
50 * While a client_hello is only parsed once, it is possible to parse
51 * two different client_hello during a single handshake if the server
52 * issues a hello retry.
53 */
54 unsigned int parsed : 1;
55 /*
56 * SSLv2 ClientHellos have a different format.
57 * Cipher suites are each three bytes instead of two.
58 * And due to how s2n-tls parses the record,
59 * the raw_message will not contain the protocol version.
60 */
61 unsigned int sslv2 : 1;
62 /*
63 * The memory for this structure can be either owned by the application
64 * or tied to and managed by a connection.
65 *
66 * If owned by the application, it can be freed using s2n_client_hello_free.
67 * Otherwise, it is freed with s2n_connection_free.
68 *
69 * We could simplify this by moving the client hello structure off of the
70 * connection structure.
71 */
72 unsigned int alloced : 1;
73 };
74
75 int s2n_client_hello_free_raw_message(struct s2n_client_hello *client_hello);
76
77 struct s2n_client_hello *s2n_connection_get_client_hello(struct s2n_connection *conn);
78
79 ssize_t s2n_client_hello_get_raw_message_length(struct s2n_client_hello *ch);
80 ssize_t s2n_client_hello_get_raw_message(struct s2n_client_hello *ch, uint8_t *out, uint32_t max_length);
81
82 ssize_t s2n_client_hello_get_cipher_suites_length(struct s2n_client_hello *ch);
83 ssize_t s2n_client_hello_get_cipher_suites(struct s2n_client_hello *ch, uint8_t *out, uint32_t max_length);
84
85 int s2n_client_hello_get_parsed_extension(s2n_tls_extension_type extension_type,
86 s2n_parsed_extensions_list *parsed_extension_list, s2n_parsed_extension **parsed_extension);
87 ssize_t s2n_client_hello_get_extensions_length(struct s2n_client_hello *ch);
88 ssize_t s2n_client_hello_get_extensions(struct s2n_client_hello *ch, uint8_t *out, uint32_t max_length);
89
90 int s2n_client_hello_get_random(struct s2n_client_hello *ch, uint8_t *out, uint32_t max_length);