| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#pragma once |
| 17 |
|
| 18 |
#include <stdint.h> |
| 19 |
|
| 20 |
#include "crypto/s2n_hmac.h" |
| 21 |
#include "stuffer/s2n_stuffer.h" |
| 22 |
|
| 23 |
#define S2N_TLS_CONTENT_TYPE_LENGTH 1 |
| 24 |
|
| 25 |
#define S2N_TLS_SSLV2_HEADER_FLAG (0x80) |
| 26 |
#define S2N_TLS_SSLV2_HEADER_FLAG_UINT16 (S2N_TLS_SSLV2_HEADER_FLAG << 8) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#define S2N_TLS_RECORD_HEADER_LENGTH (S2N_TLS_CONTENT_TYPE_LENGTH + S2N_TLS_PROTOCOL_VERSION_LEN + 2) |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
#define S2N_TLS_MAXIMUM_FRAGMENT_LENGTH (1 << 14) |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
#define S2N_TLS12_ENCRYPTION_OVERHEAD_SIZE 1024 |
| 51 |
#define S2N_TLS12_MAX_RECORD_LEN_FOR(frag) \ |
| 52 |
((frag) + S2N_TLS12_ENCRYPTION_OVERHEAD_SIZE + S2N_TLS_RECORD_HEADER_LENGTH) |
| 53 |
#define S2N_TLS12_MAXIMUM_RECORD_LENGTH S2N_TLS12_MAX_RECORD_LEN_FOR(S2N_TLS_MAXIMUM_FRAGMENT_LENGTH) |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
#define S2N_TLS13_ENCRYPTION_OVERHEAD_SIZE 255 |
| 61 |
#define S2N_TLS13_MAX_RECORD_LEN_FOR(frag) ((frag) + S2N_TLS_CONTENT_TYPE_LENGTH \ |
| 62 |
+ S2N_TLS13_ENCRYPTION_OVERHEAD_SIZE \ |
| 63 |
+ S2N_TLS_RECORD_HEADER_LENGTH) |
| 64 |
#define S2N_TLS13_MAXIMUM_RECORD_LENGTH S2N_TLS13_MAX_RECORD_LEN_FOR(S2N_TLS_MAXIMUM_FRAGMENT_LENGTH) |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
#define S2N_TLS_MAX_RECORD_LEN_FOR(frag) S2N_TLS12_MAX_RECORD_LEN_FOR(frag) |
| 70 |
#define S2N_TLS_MAXIMUM_RECORD_LENGTH S2N_TLS_MAX_RECORD_LEN_FOR(S2N_TLS_MAXIMUM_FRAGMENT_LENGTH) |
| 71 |
|
| 72 |
S2N_RESULT s2n_record_max_write_size(struct s2n_connection *conn, uint16_t max_fragment_size, uint16_t *max_record_size); |
| 73 |
S2N_RESULT s2n_record_max_write_payload_size(struct s2n_connection *conn, uint16_t *max_fragment_size); |
| 74 |
S2N_RESULT s2n_record_min_write_payload_size(struct s2n_connection *conn, uint16_t *payload_size); |
| 75 |
S2N_RESULT s2n_record_write(struct s2n_connection *conn, uint8_t content_type, struct s2n_blob *in); |
| 76 |
int s2n_record_writev(struct s2n_connection *conn, uint8_t content_type, const struct iovec *in, int in_count, size_t offs, size_t to_write); |
| 77 |
int s2n_record_parse(struct s2n_connection *conn); |
| 78 |
int s2n_record_header_parse(struct s2n_connection *conn, uint8_t *content_type, uint16_t *fragment_length); |
| 79 |
int s2n_tls13_parse_record_type(struct s2n_stuffer *stuffer, uint8_t *record_type); |
| 80 |
int s2n_sslv2_record_header_parse(struct s2n_connection *conn, uint8_t *record_type, uint8_t *client_protocol_version, uint16_t *fragment_length); |
| 81 |
int s2n_verify_cbc(struct s2n_connection *conn, struct s2n_hmac_state *hmac, struct s2n_blob *decrypted); |
| 82 |
S2N_RESULT s2n_aead_aad_init(const struct s2n_connection *conn, uint8_t *sequence_number, uint8_t content_type, uint16_t record_length, struct s2n_blob *ad); |
| 83 |
S2N_RESULT s2n_tls13_aead_aad_init(uint16_t record_length, uint8_t tag_length, struct s2n_blob *ad); |
| 84 |
S2N_RESULT s2n_record_wipe(struct s2n_connection *conn); |