Henry Case преди 5 години
родител
ревизия
43ed9c9c3f
променени са 4 файла, в които са добавени 20 реда и са изтрити 26 реда
  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 Целия файл

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


void test_Handshake(size_t handshake_nb) {

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


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


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

DBG("SSL handshake"); DBG("SSL handshake");

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

} }


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


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


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


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


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


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


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


if (argc < 2) {
if (argc < 3) {
goto usage; 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 { } else {
printf("Unknown test"); printf("Unknown test");
goto usage; goto usage;
@@ -206,7 +202,7 @@ exit:
return 0; return 0;


usage: 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]); "test_Handshake\n\ttest_Write\n\ttest_Read\n", argv[0]);
goto exit; goto exit;
} }

+ 1
- 1
bssl_perf/src/common.c Целия файл

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


struct sockaddr_in a; struct sockaddr_in a;




+ 4
- 5
bssl_perf/src/common.h Целия файл

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


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


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


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


// Available tests // 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__ #endif // __COMMON_H__

+ 1
- 2
bssl_perf/src/server.c Целия файл

@@ -114,7 +114,7 @@ static SSL_CTX* setup_server_ctx(const char* cert_name) {
ERR("Error setting cipher list"); 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"); ERR("Enforcing curve");
} }


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


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




Зареждане…
Отказ
Запис