| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "tls/extensions/s2n_ec_point_format.h" |
| 17 |
|
| 18 |
#include <stdint.h> |
| 19 |
|
| 20 |
#include "tls/extensions/s2n_client_supported_groups.h" |
| 21 |
#include "tls/s2n_tls.h" |
| 22 |
#include "utils/s2n_safety.h" |
| 23 |
|
| 24 |
static int s2n_ec_point_format_send(struct s2n_connection *conn, struct s2n_stuffer *out); |
| 25 |
static int s2n_ec_point_format_recv(struct s2n_connection *conn, struct s2n_stuffer *extension); |
| 26 |
|
| 27 |
const s2n_extension_type s2n_client_ec_point_format_extension = { |
| 28 |
.iana_value = TLS_EXTENSION_EC_POINT_FORMATS, |
| 29 |
.is_response = false, |
| 30 |
.send = s2n_ec_point_format_send, |
| 31 |
.recv = s2n_ec_point_format_recv, |
| 32 |
.should_send = s2n_extension_should_send_if_ecc_enabled, |
| 33 |
.if_missing = s2n_extension_noop_if_missing, |
| 34 |
}; |
| 35 |
|
| 36 |
static bool s2n_server_ec_point_format_should_send(struct s2n_connection *conn); |
| 37 |
|
| 38 |
const s2n_extension_type s2n_server_ec_point_format_extension = { |
| 39 |
.iana_value = TLS_EXTENSION_EC_POINT_FORMATS, |
| 40 |
.is_response = true, |
| 41 |
.send = s2n_ec_point_format_send, |
| 42 |
.recv = s2n_extension_recv_noop, |
| 43 |
.should_send = s2n_server_ec_point_format_should_send, |
| 44 |
.if_missing = s2n_extension_noop_if_missing, |
| 45 |
}; |
| 46 |
|
| 47 |
static bool s2n_server_ec_point_format_should_send(struct s2n_connection *conn) |
| 48 |
{ |
| 49 |
return conn && conn->secure && conn->secure->cipher_suite |
| 50 |
&& s2n_kex_includes(conn->secure->cipher_suite->key_exchange_alg, &s2n_ecdhe); |
| 51 |
} |
| 52 |
|
| 53 |
static int s2n_ec_point_format_send(struct s2n_connection *conn, struct s2n_stuffer *out) |
| 54 |
{ |
| 55 |
|
| 56 |
POSIX_GUARD(s2n_stuffer_write_uint8(out, 1)); |
| 57 |
|
| 58 |
|
| 59 |
POSIX_GUARD(s2n_stuffer_write_uint8(out, TLS_EC_POINT_FORMAT_UNCOMPRESSED)); |
| 60 |
|
| 61 |
return S2N_SUCCESS; |
| 62 |
} |
| 63 |
|
| 64 |
static int s2n_ec_point_format_recv(struct s2n_connection *conn, struct s2n_stuffer *extension) |
| 65 |
{ |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
conn->ec_point_formats = 1; |
| 79 |
return S2N_SUCCESS; |
| 80 |
} |