From 590e04c43a9e4c2ef45dff492cd324839b4082cc Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Fri, 28 Aug 2015 14:26:30 -0600 Subject: [PATCH] formatting fixes for some of the tls examples --- tls/client-tls.c | 16 ++++++++-------- tls/server-tls-ecdhe.c | 12 ++++++------ tls/server-tls.c | 22 +++++++++++----------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tls/client-tls.c b/tls/client-tls.c index 244f45b5..5644dab5 100644 --- a/tls/client-tls.c +++ b/tls/client-tls.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include -#include +#include #include #include #include @@ -30,7 +30,7 @@ const char* cert = "../certs/ca-cert.pem"; -/* +/* * clients initial contact with server. (socket to connect, security layer) */ int ClientGreet(int sock, WOLFSSL* ssl) @@ -60,7 +60,7 @@ int ClientGreet(int sock, WOLFSSL* ssl) return ret; } -/* +/* * applies TLS 1.2 security layer to data being sent. */ int Security(int sock) @@ -101,10 +101,10 @@ int Security(int sock) return ret; } -/* - * Command line argumentCount and argumentValues +/* + * Command line argumentCount and argumentValues */ -int main(int argc, char** argv) +int main(int argc, char** argv) { int sockfd; /* socket file descriptor */ struct sockaddr_in servAddr; /* struct for server address */ @@ -123,8 +123,8 @@ int main(int argc, char** argv) printf("Failed to create socket. Error: %i\n", errno); return EXIT_FAILURE; } - - memset(&servAddr, 0, sizeof(servAddr)); /* clears memory block for use */ + + memset(&servAddr, 0, sizeof(servAddr)); /* clears memory block for use */ servAddr.sin_family = AF_INET; /* sets addressfamily to internet*/ servAddr.sin_port = htons(SERV_PORT); /* sets port to defined port */ diff --git a/tls/server-tls-ecdhe.c b/tls/server-tls-ecdhe.c index 7ac3eeb0..2f84979d 100644 --- a/tls/server-tls-ecdhe.c +++ b/tls/server-tls-ecdhe.c @@ -20,8 +20,8 @@ *============================================================================= * * This is a super basic example of what a TCP Server secured with TLS 1.2 - * might look like. This server can also resume the session if a client - * inadvertantly disconnects. + * might look like. This server can also resume the session if a client + * inadvertantly disconnects. */ #include @@ -39,10 +39,10 @@ #define DEFAULT_PORT 11111 -int AcceptAndRead(WOLFSSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in +int AcceptAndRead(WOLFSSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in clientAddr); -int AcceptAndRead(WOLFSSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in +int AcceptAndRead(WOLFSSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in clientAddr) { /* Create our reply message */ @@ -85,7 +85,7 @@ int AcceptAndRead(WOLFSSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in printf("Client: %s\n", buff); /* Reply back to the client */ - if ((ret = wolfSSL_write(ssl, reply, sizeof(reply)-1)) + if ((ret = wolfSSL_write(ssl, reply, sizeof(reply)-1)) < 0) { printf("wolfSSL_write error = %d\n", wolfSSL_get_error(ssl, ret)); @@ -115,7 +115,7 @@ int main() /* Create a ctx pointer for our ssl */ WOLFSSL_CTX* ctx; - /* + /* * Creates a socket that uses an internet IP address, * Sets the type to be Stream based (TCP), * 0 means choose the default protocol. diff --git a/tls/server-tls.c b/tls/server-tls.c index 1e1c9d34..4157be88 100644 --- a/tls/server-tls.c +++ b/tls/server-tls.c @@ -20,8 +20,8 @@ *============================================================================= * * This is a super basic example of what a TCP Server secured with TLS 1.2 - * might look like. This server can also resume the session if a client - * inadvertantly disconnects. + * might look like. This server can also resume the session if a client + * inadvertantly disconnects. */ #include @@ -38,10 +38,10 @@ #define DEFAULT_PORT 11111 -int AcceptAndRead(WOLFSSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in +int AcceptAndRead(WOLFSSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in clientAddr); -int AcceptAndRead(WOLFSSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in +int AcceptAndRead(WOLFSSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in clientAddr) { /* Create our reply message */ @@ -82,9 +82,9 @@ int AcceptAndRead(WOLFSSL_CTX* ctx, socklen_t sockfd, struct sockaddr_in if ((ret = wolfSSL_read(ssl, buff, sizeof(buff)-1)) > 0) { /* Print any data the client sends to the console */ printf("Client: %s\n", buff); - + /* Reply back to the client */ - if ((ret = wolfSSL_write(ssl, reply, sizeof(reply)-1)) + if ((ret = wolfSSL_write(ssl, reply, sizeof(reply)-1)) < 0) { printf("wolfSSL_write error = %d\n", wolfSSL_get_error(ssl, ret)); @@ -114,7 +114,7 @@ int main() /* Create a ctx pointer for our ssl */ WOLFSSL_CTX* ctx; - /* + /* * Creates a socket that uses an internet IP address, * Sets the type to be Stream based (TCP), * 0 means choose the default protocol. @@ -131,7 +131,7 @@ int main() /* If positive value, the socket is valid */ if (sockfd == -1) { printf("ERROR: failed to create the socket\n"); - return EXIT_FAILURE; /* Kill the server with exit status 1 */ + return EXIT_FAILURE; /* Kill the server with exit status 1 */ } /* create and initialize WOLFSSL_CTX structure */ @@ -141,7 +141,7 @@ int main() } /* Load server certificate into WOLFSSL_CTX */ - if (wolfSSL_CTX_use_certificate_file(ctx, "../certs/server-cert.pem", + if (wolfSSL_CTX_use_certificate_file(ctx, "../certs/server-cert.pem", SSL_FILETYPE_PEM) != SSL_SUCCESS) { fprintf(stderr, "Error loading certs/server-cert.pem, please check" "the file.\n"); @@ -149,7 +149,7 @@ int main() } /* Load server key into WOLFSSL_CTX */ - if (wolfSSL_CTX_use_PrivateKey_file(ctx, "../certs/server-key.pem", + if (wolfSSL_CTX_use_PrivateKey_file(ctx, "../certs/server-key.pem", SSL_FILETYPE_PEM) != SSL_SUCCESS) { fprintf(stderr, "Error loading certs/server-key.pem, please check" "the file.\n"); @@ -157,7 +157,7 @@ int main() } /* Initialize the server address struct to zero */ - memset((char *)&serverAddr, 0, sizeof(serverAddr)); + memset((char *)&serverAddr, 0, sizeof(serverAddr)); /* Fill the server's address family */ serverAddr.sin_family = AF_INET;