| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 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 |
|
| 48 |
|
| 49 |
|
| 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); |