Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User parameter #182

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ dtls_security_parameters_t *dtls_security_new(void)

memset(security, 0, sizeof(*security));

security->cipher = TLS_NULL_WITH_NULL_NULL;
security->cipher_index = DTLS_CIPHER_INDEX_NULL;
security->compression = TLS_COMPRESSION_NULL;

return security;
Expand Down
27 changes: 25 additions & 2 deletions crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
#define DTLS_MASTER_SECRET_LENGTH 48
#define DTLS_RANDOM_LENGTH 32

/** Type of index in cipher parameter table */
typedef uint8_t dtls_cipher_index_t;
/** Index in cipher parameter table for NULL cipher */
#define DTLS_CIPHER_INDEX_NULL 0

/** Maximum number of cipher suites */
#define DTLS_MAX_CIPHER_SUITES 4

typedef enum { AES128=0
} dtls_crypto_alg;

Expand Down Expand Up @@ -105,7 +113,7 @@ typedef struct {
typedef struct {
dtls_compression_t compression; /**< compression method */

dtls_cipher_t cipher; /**< cipher type */
dtls_cipher_index_t cipher_index; /**< internal index for cipher_suite_params, DTLS_CIPHER_INDEX_NULL for TLS_NULL_WITH_NULL_NULL */
uint16_t epoch; /**< counter for cipher state changes*/
uint64_t rseq; /**< sequence number of last record sent */

Expand All @@ -122,6 +130,19 @@ typedef struct {

struct netq_t;

/**
* Set of user parameters used by the handshake.
*/
typedef struct dtls_user_parameters_t {
/**
* The list of cipher suites.
* The list must be terminated by TLS_NULL_WITH_NULL_NULL.
*/
dtls_cipher_t cipher_suites[DTLS_MAX_CIPHER_SUITES + 1];
unsigned int force_extended_master_secret:1; /** force extended master secret extension (RFC7627) */
unsigned int force_renegotiation_info:1; /** force renegotiation info extension (RFC5746) */
} dtls_user_parameters_t;

typedef struct {
union {
struct random_t {
Expand All @@ -135,9 +156,11 @@ typedef struct {
dtls_hs_state_t hs_state; /**< handshake protocol status */

dtls_compression_t compression; /**< compression method */
dtls_cipher_t cipher; /**< cipher type */
dtls_user_parameters_t user_parameters; /**< user parameters */
dtls_cipher_index_t cipher_index; /**< internal index for cipher_suite_params, DTLS_CIPHER_INDEX_NULL for TLS_NULL_WITH_NULL_NULL */
unsigned int do_client_auth:1;
unsigned int extended_master_secret:1;
unsigned int renegotiation_info:1;
union {
#ifdef DTLS_ECC
dtls_handshake_parameters_ecdsa_t ecdsa;
Expand Down
Loading