| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include <stdint.h> |
| 17 |
|
| 18 |
#include "tls/extensions/s2n_ems.h" |
| 19 |
#include "tls/s2n_tls.h" |
| 20 |
#include "utils/s2n_safety.h" |
| 21 |
|
| 22 |
static int s2n_server_ems_recv(struct s2n_connection *conn, struct s2n_stuffer *extension); |
| 23 |
static bool s2n_server_ems_should_send(struct s2n_connection *conn); |
| 24 |
static int s2n_server_ems_if_missing(struct s2n_connection *conn); |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
const s2n_extension_type s2n_server_ems_extension = { |
| 36 |
.iana_value = TLS_EXTENSION_EMS, |
| 37 |
.is_response = true, |
| 38 |
.send = s2n_extension_send_noop, |
| 39 |
.recv = s2n_server_ems_recv, |
| 40 |
.should_send = s2n_server_ems_should_send, |
| 41 |
.if_missing = s2n_server_ems_if_missing, |
| 42 |
}; |
| 43 |
|
| 44 |
static int s2n_server_ems_recv(struct s2n_connection *conn, struct s2n_stuffer *extension) |
| 45 |
{ |
| 46 |
POSIX_ENSURE_REF(conn); |
| 47 |
|
| 48 |
|
| 49 |
POSIX_ENSURE(s2n_stuffer_data_available(extension) == 0, S2N_ERR_UNSUPPORTED_EXTENSION); |
| 50 |
conn->ems_negotiated = true; |
| 51 |
|
| 52 |
return S2N_SUCCESS; |
| 53 |
} |
| 54 |
|
| 55 |
static bool s2n_server_ems_should_send(struct s2n_connection *conn) |
| 56 |
{ |
| 57 |
return conn && conn->actual_protocol_version < S2N_TLS13; |
| 58 |
} |
| 59 |
|
| 60 |
static int s2n_server_ems_if_missing(struct s2n_connection *conn) |
| 61 |
{ |
| 62 |
POSIX_ENSURE_REF(conn); |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
POSIX_ENSURE(!conn->ems_negotiated, S2N_ERR_MISSING_EXTENSION); |
| 71 |
|
| 72 |
return S2N_SUCCESS; |
| 73 |
} |