| 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 "tls/s2n_connection.h" |
| 22 |
#include "utils/s2n_blob.h" |
| 23 |
|
| 24 |
|
| 25 |
#define S2N_MAX_KEY_BLOCK_LEN 160 |
| 26 |
|
| 27 |
union p_hash_state { |
| 28 |
struct s2n_hmac_state s2n_hmac; |
| 29 |
}; |
| 30 |
|
| 31 |
struct s2n_prf_working_space { |
| 32 |
union p_hash_state p_hash; |
| 33 |
uint8_t digest0[S2N_MAX_DIGEST_LEN]; |
| 34 |
uint8_t digest1[S2N_MAX_DIGEST_LEN]; |
| 35 |
}; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
struct s2n_key_material { |
| 45 |
|
| 46 |
uint8_t key_block[S2N_MAX_KEY_BLOCK_LEN]; |
| 47 |
|
| 48 |
|
| 49 |
struct s2n_blob client_mac; |
| 50 |
struct s2n_blob server_mac; |
| 51 |
struct s2n_blob client_key; |
| 52 |
struct s2n_blob server_key; |
| 53 |
struct s2n_blob client_iv; |
| 54 |
struct s2n_blob server_iv; |
| 55 |
}; |
| 56 |
|
| 57 |
S2N_RESULT s2n_key_material_init(struct s2n_key_material *key_material, struct s2n_connection *conn); |
| 58 |
|
| 59 |
S2N_RESULT s2n_prf_new(struct s2n_connection *conn); |
| 60 |
S2N_RESULT s2n_prf_wipe(struct s2n_connection *conn); |
| 61 |
S2N_RESULT s2n_prf_free(struct s2n_connection *conn); |
| 62 |
|
| 63 |
int s2n_prf_calculate_master_secret(struct s2n_connection *conn, struct s2n_blob *premaster_secret); |
| 64 |
int s2n_prf_hybrid_master_secret(struct s2n_connection *conn, struct s2n_blob *premaster_secret); |
| 65 |
S2N_RESULT s2n_prf_generate_key_material(struct s2n_connection *conn, struct s2n_key_material *key_material); |
| 66 |
int s2n_prf_key_expansion(struct s2n_connection *conn); |
| 67 |
int s2n_prf_server_finished(struct s2n_connection *conn); |
| 68 |
int s2n_prf_client_finished(struct s2n_connection *conn); |