Debian Codegraph @

crt/s2n/tls/s2n_psk.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 "api/s2n.h"
19 #include "crypto/s2n_hmac.h"
20 #include "stuffer/s2n_stuffer.h"
21 #include "tls/s2n_early_data.h"
22 #include "utils/s2n_array.h"
23 #include "utils/s2n_blob.h"
24 #include "utils/s2n_result.h"
25
26 typedef enum {
27 S2N_PSK_TYPE_RESUMPTION = 0,
28 S2N_PSK_TYPE_EXTERNAL,
29 } s2n_psk_type;
30
31 typedef enum {
32 S2N_PSK_KE_UNKNOWN = 0,
33 S2N_PSK_KE,
34 S2N_PSK_DHE_KE,
35 } s2n_psk_key_exchange_mode;
36
37 struct s2n_psk {
38 s2n_psk_type type;
39 struct s2n_blob identity;
40 struct s2n_blob secret;
41 s2n_hmac_algorithm hmac_alg;
42 uint32_t ticket_age_add;
43 uint64_t ticket_issue_time;
44 struct s2n_blob early_secret;
45 struct s2n_early_data_config early_data_config;
46
47 /* This field is used with session tickets to track the lifetime
48 * of the original full handshake across multiple tickets.
49 * See https://tools.ietf.org/rfc/rfc8446#section-4.6.1
50 */
51 uint64_t keying_material_expiration;
52 };
53 S2N_RESULT s2n_psk_init(struct s2n_psk *psk, s2n_psk_type type);
54 S2N_CLEANUP_RESULT s2n_psk_wipe(struct s2n_psk *psk);
55 S2N_RESULT s2n_psk_clone(struct s2n_psk *new_psk, struct s2n_psk *original_psk);
56
57 struct s2n_psk_parameters {
58 s2n_psk_type type;
59 struct s2n_array psk_list;
60 uint16_t binder_list_size;
61 uint16_t chosen_psk_wire_index;
62 struct s2n_psk *chosen_psk;
63 s2n_psk_key_exchange_mode psk_ke_mode;
64 };
65 S2N_RESULT s2n_psk_parameters_init(struct s2n_psk_parameters *params);
66 S2N_RESULT s2n_psk_parameters_offered_psks_size(struct s2n_psk_parameters *params, uint32_t *size);
67 S2N_CLEANUP_RESULT s2n_psk_parameters_wipe(struct s2n_psk_parameters *params);
68 S2N_CLEANUP_RESULT s2n_psk_parameters_wipe_secrets(struct s2n_psk_parameters *params);
69
70 struct s2n_offered_psk {
71 struct s2n_blob identity;
72 uint16_t wire_index;
73 uint32_t obfuscated_ticket_age;
74 };
75
76 struct s2n_offered_psk_list {
77 struct s2n_connection *conn;
78 struct s2n_stuffer wire_data;
79 uint16_t wire_index;
80 };
81
82 S2N_RESULT s2n_finish_psk_extension(struct s2n_connection *conn);
83
84 int s2n_psk_calculate_binder_hash(struct s2n_connection *conn, s2n_hmac_algorithm hmac_alg,
85 const struct s2n_blob *partial_client_hello, struct s2n_blob *output_binder_hash);
86 int s2n_psk_calculate_binder(struct s2n_psk *psk, const struct s2n_blob *binder_hash,
87 struct s2n_blob *output_binder);
88 int s2n_psk_verify_binder(struct s2n_connection *conn, struct s2n_psk *psk,
89 const struct s2n_blob *partial_client_hello, struct s2n_blob *binder_to_verify);
90
91 S2N_RESULT s2n_connection_set_psk_type(struct s2n_connection *conn, s2n_psk_type type);
92 S2N_RESULT s2n_psk_validate_keying_material(struct s2n_connection *conn);