Skip to content

Commit

Permalink
dtls: divide dtls_security_parameters_t
Browse files Browse the repository at this point in the history
dtls_security_parameters_t is now divided into
dtls_security_parameters_t, which contains the values needed for the
current cipher in use and dtls_handshake_parameters_t, which contains
the values for the cipher which is currently negotiated in the
handshake. This makes it possible to just store one version of this
struct and save some memory per connection.

Signed-off-by: Hauke Mehrtens <[email protected]>
  • Loading branch information
hauke committed Jul 28, 2013
1 parent 9dfe110 commit 5f8df35
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 141 deletions.
22 changes: 15 additions & 7 deletions crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ typedef struct {
uint8 other_eph_pub_y[32];
uint8 other_pub_x[32];
uint8 other_pub_y[32];
} dtls_security_parameters_ecdsa_t;
} dtls_handshake_parameters_ecdsa_t;

typedef struct {
uint8 client_random[32]; /**< client random gmt and bytes */
Expand All @@ -96,9 +96,6 @@ typedef struct {

dtls_cipher_t cipher; /**< cipher type */

/** the session's master secret */
uint8 master_secret[DTLS_MASTER_SECRET_LENGTH];

/**
* The key block generated from PRF applied to client and server
* random bytes. The actual size is given by the selected cipher and
Expand All @@ -109,11 +106,22 @@ typedef struct {

dtls_cipher_context_t *read_cipher; /**< decryption context */
dtls_cipher_context_t *write_cipher; /**< encryption context */

dtls_security_parameters_ecdsa_t ecdsa;
int do_client_auth;
} dtls_security_parameters_t;

typedef struct {
uint8 client_random[32]; /**< client random gmt and bytes */
uint8 server_random[32]; /**< server random gmt and bytes */

dtls_compression_t compression; /**< compression method */
dtls_cipher_t cipher; /**< cipher type */
unsigned int do_client_auth:1;

/** the session's master secret */
uint8 master_secret[DTLS_MASTER_SECRET_LENGTH];

dtls_handshake_parameters_ecdsa_t ecdsa;
} dtls_handshake_parameters_t;

/* The following macros provide access to the components of the
* key_block in the security parameters. */

Expand Down
Loading

0 comments on commit 5f8df35

Please sign in to comment.