Skip to content

Commit

Permalink
Add renegotiation info to test clients.
Browse files Browse the repository at this point in the history
Signed-off-by: Achim Kraus <[email protected]>
  • Loading branch information
boaks committed Jan 25, 2023
1 parent 207ab44 commit d706c66
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 10 additions & 4 deletions tests/dtls-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,15 @@ send_to_peer(struct dtls_context_t *ctx,

static const dtls_cipher_t* ciphers = NULL;
static unsigned int force_extended_master_secret = 0;
static unsigned int force_renegotiation_info = 0;

static void
get_user_parameters(struct dtls_context_t *ctx,
session_t *session, dtls_user_parameters_t *user_parameters) {
(void) ctx;
(void) session;
user_parameters->force_extended_master_secret = force_extended_master_secret;
user_parameters->force_renegotiation_info = force_renegotiation_info;
if (ciphers) {
int index = 0;
while (index < DTLS_MAX_CIPHER_SUITES) {
Expand Down Expand Up @@ -353,9 +355,9 @@ usage( const char *program, const char *version) {
fprintf(stderr, "%s v%s -- DTLS client implementation\n"
"(c) 2011-2014 Olaf Bergmann <[email protected]>\n\n"
#ifdef DTLS_PSK
"usage: %s [-i file] [-k file] [-o file] [-p port] [-v num] [-c cipher-suites] [-e] addr [port]\n"
"usage: %s [-i file] [-k file] [-o file] [-p port] [-v num] [-c cipher-suites] [-e] [-r] addr [port]\n"
#else /* DTLS_PSK */
"usage: %s [-o file] [-p port] [-v num] [-c cipher-suites] [-e] addr [port]\n"
"usage: %s [-o file] [-p port] [-v num] [-c cipher-suites] [-e] [-r] addr [port]\n"
#endif /* DTLS_PSK */
#ifdef DTLS_PSK
"\t-i file\t\tread PSK identity from file\n"
Expand All @@ -364,7 +366,8 @@ usage( const char *program, const char *version) {
"\t-o file\t\toutput received data to this file (use '-' for STDOUT)\n"
"\t-p port\t\tlisten on specified port (default is %d)\n"
"\t-v num\t\tverbosity level (default: 3)\n"
"\t-e\t\tforce extended master secret (RFC7627)\n",
"\t-e\t\tforce extended master secret (RFC7627)\n"
"\t-r\t\tforce renegotiation info (RFC5746)\n",
program, version, program, DEFAULT_PORT);
cipher_suites_usage(stderr, "\t");
}
Expand Down Expand Up @@ -421,7 +424,7 @@ main(int argc, char **argv) {
memcpy(psk_key, PSK_DEFAULT_KEY, psk_key_length);
#endif /* DTLS_PSK */

while ((opt = getopt(argc, argv, "ep:o:v:c:" PSK_OPTIONS)) != -1) {
while ((opt = getopt(argc, argv, "rep:o:v:c:" PSK_OPTIONS)) != -1) {
switch (opt) {
#ifdef DTLS_PSK
case 'i' :
Expand Down Expand Up @@ -466,6 +469,9 @@ main(int argc, char **argv) {
case 'e' :
force_extended_master_secret = 1;
break;
case 'r' :
force_renegotiation_info = 1;
break;
default:
usage(argv[0], dtls_package_version());
exit(1);
Expand Down
12 changes: 9 additions & 3 deletions tests/dtls-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,15 @@ send_to_peer(struct dtls_context_t *ctx,

static const dtls_cipher_t* ciphers = NULL;
static unsigned int force_extended_master_secret = 0;
static unsigned int force_renegotiation_info = 0;

static void
get_user_parameters(struct dtls_context_t *ctx,
session_t *session, dtls_user_parameters_t *user_parameters) {
(void) ctx;
(void) session;
user_parameters->force_extended_master_secret = force_extended_master_secret;
user_parameters->force_renegotiation_info = force_renegotiation_info;
if (ciphers) {
int index = 0;
while (index < DTLS_MAX_CIPHER_SUITES) {
Expand Down Expand Up @@ -309,11 +311,12 @@ usage(const char *program, const char *version) {

fprintf(stderr, "%s v%s -- DTLS server implementation\n"
"(c) 2011-2014 Olaf Bergmann <[email protected]>\n\n"
"usage: %s [-A address] [-p port] [-v num] [-c cipher-suites] [-e]\n"
"usage: %s [-A address] [-p port] [-v num] [-c cipher-suites] [-e] [-r]\n"
"\t-A address\t\tlisten on specified address (default is ::)\n"
"\t-p port\t\tlisten on specified port (default is %d)\n"
"\t-v num\t\tverbosity level (default: 3)\n"
"\t-e\t\tforce extended master secret (RFC7627)\n",
"\t-e\t\tforce extended master secret (RFC7627)\n"
"\t-r\t\tforce renegotiation info (RFC5746)\n",
program, version, program, DEFAULT_PORT);
cipher_suites_usage(stderr, "\t");
}
Expand Down Expand Up @@ -356,7 +359,7 @@ main(int argc, char **argv) {
listen_addr.sin6_family = AF_INET6;
listen_addr.sin6_addr = in6addr_any;

while ((opt = getopt(argc, argv, "eA:p:v:c:")) != -1) {
while ((opt = getopt(argc, argv, "reA:p:v:c:")) != -1) {
switch (opt) {
case 'A' :
if (resolve_address(optarg, (struct sockaddr *)&listen_addr) < 0) {
Expand All @@ -376,6 +379,9 @@ main(int argc, char **argv) {
case 'e' :
force_extended_master_secret = 1;
break;
case 'r' :
force_renegotiation_info = 1;
break;
default:
usage(argv[0], dtls_package_version());
exit(1);
Expand Down

0 comments on commit d706c66

Please sign in to comment.