Skip to content

Commit

Permalink
Update copyright.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanr committed May 4, 2014
1 parent e6c7f4e commit 87e3169
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions server-vs-client.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2011 Vincent Bernat <[email protected]>
* Copyright (c) 2014 Ivan Ristic <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
Expand Down Expand Up @@ -231,7 +232,7 @@ static void* server_thread(void *arg) {
}

static pthread_t start_server(const char *ciphersuite,
const char *certificate) {
const char *certificate, const char *params) {
SSL_CTX *ctx;

start("Initializing server");
Expand Down Expand Up @@ -260,7 +261,7 @@ static pthread_t start_server(const char *ciphersuite,
/* DH */
DH *dh;
BIO *bio;
bio = BIO_new_file(certificate, "r");
bio = BIO_new_file(params, "r");
if (!bio)
fail("Unable to read certificate:\n%s",
ERR_error_string(ERR_get_error(), NULL));
Expand All @@ -276,7 +277,7 @@ static pthread_t start_server(const char *ciphersuite,
EC_KEY *ecdh = NULL;
EC_GROUP *ecg = NULL;

bio = BIO_new_file(certificate, "r");
bio = BIO_new_file(params, "r");
if (!bio)
fail("Unable to read certificate:\n%s",
ERR_error_string(ERR_get_error(), NULL));
Expand Down Expand Up @@ -312,13 +313,14 @@ int
main(int argc, char * const argv[]) {
if ((argc != 3)&&(argc != 4)&&(argc != 5)) {
fprintf(stderr, "Usage: \n");
fprintf(stderr, " %s ciphersuite certificate [[handshakes] [writes]]\n", argv[0]);
fprintf(stderr, " %s ciphersuite certificate [params [handshakes [writes]]]\n", argv[0]);
fprintf(stderr, "\n");
fprintf(stderr, " - `ciphersuite` is the name of cipher suite to use. Use\n");
fprintf(stderr, " `openssl ciphers` to choose one.\n");
fprintf(stderr, "\n");
fprintf(stderr, " - `certificate` is the name of the file containing\n");
fprintf(stderr, " the certificate, the key and appropriate additional parameters.\n");
fprintf(stderr, " - `certificate` is the name of the file containing the key and certificate.\n");
fprintf(stderr, "\n");
fprintf(stderr, " - `params` is the name of the file containing DH or ECDH params.\n");
fprintf(stderr, "\n");
fprintf(stderr, " - `handshakes` is the number of handshakes you wish to\n");
fprintf(stderr, " test. Defaults to 1000.\n");
Expand All @@ -331,13 +333,18 @@ main(int argc, char * const argv[]) {

const char *ciphersuite = argv[1];
const char *certificate = argv[2];
const char *params = NULL;

if (argc > 3) {
handshake_count = atoi(argv[3]);
params = argv[3];
}

if (argc > 4) {
data_writes = atoi(argv[4]);
handshake_count = atoi(argv[4]);
}

if (argc > 5) {
data_writes = atoi(argv[5]);
if (data_writes > 0) {
data_write_len = 16384;
handshake_count = 1;
Expand All @@ -358,7 +365,7 @@ main(int argc, char * const argv[]) {
start("Prepare client and server");
if (socketpair(AF_UNIX, SOCK_STREAM, 0, clientserver))
fail("Unable to get a socket pair for client/server communication:\n%m");
server = start_server(ciphersuite, certificate);
server = start_server(ciphersuite, certificate, params);
client = start_client(ciphersuite);

struct result *client_result, *server_result;
Expand Down

0 comments on commit 87e3169

Please sign in to comment.