Debian Codegraph @

crt/s2n/tls/extensions/s2n_server_sct_list.c

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 #include "tls/extensions/s2n_server_sct_list.h"
17
18 #include "stuffer/s2n_stuffer.h"
19 #include "tls/s2n_connection.h"
20 #include "tls/s2n_tls.h"
21 #include "utils/s2n_blob.h"
22 #include "utils/s2n_safety.h"
23
24 static bool s2n_server_sct_list_should_send(struct s2n_connection *conn);
25 static int s2n_server_sct_list_send(struct s2n_connection *conn, struct s2n_stuffer *out);
26 static int s2n_server_sct_list_recv(struct s2n_connection *conn, struct s2n_stuffer *extension);
27
28 const s2n_extension_type s2n_server_sct_list_extension = {
29 .iana_value = TLS_EXTENSION_SCT_LIST,
30 .is_response = true,
31 .send = s2n_server_sct_list_send,
32 .recv = s2n_server_sct_list_recv,
33 .should_send = s2n_server_sct_list_should_send,
34 .if_missing = s2n_extension_noop_if_missing,
35 };
36
37 static bool s2n_server_sct_list_should_send(struct s2n_connection *conn)
38 {
39 return s2n_server_can_send_sct_list(conn);
40 }
41
42 int s2n_server_sct_list_send(struct s2n_connection *conn, struct s2n_stuffer *out)
43 {
44 POSIX_ENSURE_REF(conn);
45 struct s2n_blob *sct_list = &conn->handshake_params.our_chain_and_key->sct_list;
46
47 POSIX_ENSURE_REF(sct_list);
48 POSIX_GUARD(s2n_stuffer_write(out, sct_list));
49
50 return S2N_SUCCESS;
51 }
52
53 int s2n_server_sct_list_recv(struct s2n_connection *conn, struct s2n_stuffer *extension)
54 {
55 POSIX_ENSURE_REF(conn);
56
57 struct s2n_blob sct_list = { 0 };
58 size_t data_available = s2n_stuffer_data_available(extension);
59 POSIX_GUARD(s2n_blob_init(&sct_list,
60 s2n_stuffer_raw_read(extension, data_available),
61 data_available));
62 POSIX_ENSURE_REF(sct_list.data);
63
64 POSIX_GUARD(s2n_dup(&sct_list, &conn->ct_response));
65
66 return S2N_SUCCESS;
67 }