Henry Case 5 anni fa
parent
commit
43ed9c9c3f
4 ha cambiato i file con 20 aggiunte e 26 eliminazioni
  1. +14
    -18
      bssl_perf/src/client.c
  2. +1
    -1
      bssl_perf/src/common.c
  3. +4
    -5
      bssl_perf/src/common.h
  4. +1
    -2
      bssl_perf/src/server.c

+ 14
- 18
bssl_perf/src/client.c Vedi File

@@ -52,8 +52,7 @@ int do_client_loop(SSL* ssl)
return 1;
}

void test_Handshake(size_t handshake_nb) {

void test_Handshake(const char* IP, size_t handshake_nb) {
SSL* ssl;
SSL_CTX* ctx;
int err;
@@ -63,16 +62,14 @@ void test_Handshake(size_t handshake_nb) {

DBG("Trying to connect");
for (size_t i=0; i<handshake_nb; i++) {
int fd = connect_once();
const int fd = connect_once(IP);

DBG("SSL ctx setup");
if (!(ssl = SSL_new(ctx))) {
ERR("Error creating an SSL context");
}
SSL_set_fd(ssl, fd);

DBG("SSL handshake");

// OZAPTF: do handshake thing
err = SSL_connect(ssl);
if (err<=0) {
@@ -84,10 +81,9 @@ void test_Handshake(size_t handshake_nb) {
close(fd);
}
SSL_CTX_free(ctx);

}

void test_Read() {
void test_Read(const char* IP) {
int err, nread=0;
SSL* ssl;
SSL_CTX* ctx;
@@ -96,7 +92,7 @@ void test_Read() {
ctx = setup_client_ctx();

DBG("Trying to connect");
int fd = connect_once();
int fd = connect_once(IP);

DBG("SSL ctx setup");
if (!(ssl = SSL_new(ctx))) {
@@ -140,7 +136,7 @@ void test_Read() {
close(fd);
}

void test_Write() {
void test_Write(const char* IP) {
SSL* ssl;
SSL_CTX* ctx;
int err,nread=0;
@@ -149,7 +145,7 @@ void test_Write() {
ctx = setup_client_ctx();

DBG("Trying to connect");
int fd = connect_once();
int fd = connect_once(IP);

DBG("SSL ctx setup");
if (!(ssl = SSL_new(ctx))) {
@@ -186,16 +182,16 @@ void test_Write() {

int main(int argc, char* argv[]) {

if (argc < 2) {
if (argc < 3) {
goto usage;
}

if (!strncmp("test_Handshake", argv[1], strlen("test_Handshake"))) {
test_Handshake(HANDHAKE_REPS);
} else if (!strncmp("test_Read", argv[1], strlen("test_Read"))) {
test_Read();
} else if (!strncmp("test_Write", argv[1], strlen("test_Write"))) {
test_Write();
if (!strncmp("test_Handshake", argv[2], strlen("test_Handshake"))) {
test_Handshake(argv[1], HANDHAKE_REPS);
} else if (!strncmp("test_Read", argv[2], strlen("test_Read"))) {
test_Read(argv[1]);
} else if (!strncmp("test_Write", argv[2], strlen("test_Write"))) {
test_Write(argv[1]);
} else {
printf("Unknown test");
goto usage;
@@ -206,7 +202,7 @@ exit:
return 0;

usage:
ERR("\n\nUsage: %s <host>:<port> test_name\nOptions for 'test_name':\n\t"
ERR("\n\nUsage: %s <host_ip> test_name\nOptions for 'test_name':\n\t"
"test_Handshake\n\ttest_Write\n\ttest_Read\n", argv[0]);
goto exit;
}

+ 1
- 1
bssl_perf/src/common.c Vedi File

@@ -13,7 +13,7 @@
/* -----------------------------------------------------------------------------
* @brief Performs TCP 3-way handshake with IP:PORT
* -------------------------------------------------------------------------------- */
int connect_once(void) {
int connect_once(const char* IP) {

struct sockaddr_in a;



+ 4
- 5
bssl_perf/src/common.h Vedi File

@@ -10,7 +10,6 @@
#endif

#define PORT 1443
#define IP "127.0.0.1"
#define SERVER "localhost"
#define CLIENT "localhost"
#define CACERT "etc/ca/ca.cert.pem"
@@ -51,14 +50,14 @@

#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))

int connect_once(void);
int connect_once(const char* IP);
void init(void);
void cleanup(void);
void fill_buffer_from_file(unsigned char *b, size_t sz);

// Available tests
void test_Write(void);
void test_Read(void);
void test_Handshake(size_t);
void test_Write(const char*);
void test_Read(const char*);
void test_Handshake(const char*, size_t);

#endif // __COMMON_H__

+ 1
- 2
bssl_perf/src/server.c Vedi File

@@ -114,7 +114,7 @@ static SSL_CTX* setup_server_ctx(const char* cert_name) {
ERR("Error setting cipher list");
}

if (!SSL_CTX_set1_curves(ctx, c->curves, 1)) {
if (!SSL_CTX_set1_curves(ctx, c->curves, 3)) {
ERR("Enforcing curve");
}

@@ -213,7 +213,6 @@ int main(int argc, char *argv[])

SSL_set_fd(ssl, fd);
ret = SSL_accept(ssl);
//printf("%s\n", SSL_get_curve_name(SSL_get_curve_id(ssl)));
if (ret<=0) {
ret = SSL_get_error(ssl, ret);



Caricamento…
Annulla
Salva