Skip to content

Commit 2f1d2df

Browse files
committed
Remove bloat
1 parent f4ecf7d commit 2f1d2df

2 files changed

Lines changed: 1 addition & 171 deletions

File tree

tls/client-tls13-certauth-c2s.c

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -49,75 +49,6 @@
4949
#define KEY_FILE "../certs/client-key.pem"
5050
#define CA_FILE "../certs/ca-cert.pem"
5151

52-
#if defined(WOLFSSL_TLS13) && defined(HAVE_SECRET_CALLBACK)
53-
54-
#ifndef WOLFSSL_SSLKEYLOGFILE_OUTPUT
55-
#define WOLFSSL_SSLKEYLOGFILE_OUTPUT "sslkeylog.log"
56-
#endif
57-
58-
/* Callback function for TLS v1.3 secrets for use with Wireshark */
59-
static int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret,
60-
int secretSz, void* ctx)
61-
{
62-
int i;
63-
const char* str = NULL;
64-
unsigned char clientRandom[32];
65-
int clientRandomSz;
66-
XFILE fp = stderr;
67-
if (ctx) {
68-
fp = XFOPEN((const char*)ctx, "ab");
69-
if (fp == XBADFILE) {
70-
return BAD_FUNC_ARG;
71-
}
72-
}
73-
74-
clientRandomSz = (int)wolfSSL_get_client_random(ssl, clientRandom,
75-
sizeof(clientRandom));
76-
77-
if (clientRandomSz <= 0) {
78-
printf("Error getting client random %d\n", clientRandomSz);
79-
}
80-
81-
#if 0
82-
printf("TLS Client Secret CB: Rand %d, Secret %d\n",
83-
clientRandomSz, secretSz);
84-
#endif
85-
86-
switch (id) {
87-
case CLIENT_EARLY_TRAFFIC_SECRET:
88-
str = "CLIENT_EARLY_TRAFFIC_SECRET"; break;
89-
case EARLY_EXPORTER_SECRET:
90-
str = "EARLY_EXPORTER_SECRET"; break;
91-
case CLIENT_HANDSHAKE_TRAFFIC_SECRET:
92-
str = "CLIENT_HANDSHAKE_TRAFFIC_SECRET"; break;
93-
case SERVER_HANDSHAKE_TRAFFIC_SECRET:
94-
str = "SERVER_HANDSHAKE_TRAFFIC_SECRET"; break;
95-
case CLIENT_TRAFFIC_SECRET:
96-
str = "CLIENT_TRAFFIC_SECRET_0"; break;
97-
case SERVER_TRAFFIC_SECRET:
98-
str = "SERVER_TRAFFIC_SECRET_0"; break;
99-
case EXPORTER_SECRET:
100-
str = "EXPORTER_SECRET"; break;
101-
}
102-
103-
fprintf(fp, "%s ", str);
104-
for (i = 0; i < clientRandomSz; i++) {
105-
fprintf(fp, "%02x", clientRandom[i]);
106-
}
107-
fprintf(fp, " ");
108-
for (i = 0; i < secretSz; i++) {
109-
fprintf(fp, "%02x", secret[i]);
110-
}
111-
fprintf(fp, "\n");
112-
113-
if (fp != stderr) {
114-
XFCLOSE(fp);
115-
}
116-
117-
return 0;
118-
}
119-
#endif /* WOLFSSL_TLS13 && HAVE_SECRET_CALLBACK */
120-
12152
int main(int argc, char** argv)
12253
{
12354
int ret = 0;
@@ -171,9 +102,6 @@ int main(int argc, char** argv)
171102
/*---------------------------------*/
172103
/* Start of wolfSSL initialization and configuration */
173104
/*---------------------------------*/
174-
#if 0
175-
wolfSSL_Debugging_ON();
176-
#endif
177105

178106
/* Initialize wolfSSL */
179107
if ((ret = wolfSSL_Init()) != WOLFSSL_SUCCESS) {
@@ -234,25 +162,12 @@ int main(int argc, char** argv)
234162
goto exit;
235163
}
236164

237-
#ifdef HAVE_SECRET_CALLBACK
238-
/* required for getting random used */
239-
wolfSSL_KeepArrays(ssl);
240-
241-
/* optional logging for wireshark */
242-
wolfSSL_set_tls13_secret_cb(ssl, Tls13SecretCallback,
243-
(void*)WOLFSSL_SSLKEYLOGFILE_OUTPUT);
244-
#endif
245-
246165
/* Connect to wolfSSL on the server side */
247166
if ((ret = wolfSSL_connect(ssl)) != WOLFSSL_SUCCESS) {
248167
fprintf(stderr, "ERROR: failed to connect to wolfSSL\n");
249168
goto exit;
250169
}
251170

252-
#ifdef HAVE_SECRET_CALLBACK
253-
wolfSSL_FreeArrays(ssl);
254-
#endif
255-
256171
/* Get a message for the server from stdin */
257172
printf("Message for server: ");
258173
memset(buff, 0, sizeof(buff));

tls/server-tls13-certauth-c2s.c

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -55,78 +55,9 @@
5555
#define CA_FILE "../certs/client-cert.pem"
5656

5757

58-
#if defined(WOLFSSL_TLS13) && defined(HAVE_SECRET_CALLBACK)
59-
60-
#ifndef WOLFSSL_SSLKEYLOGFILE_OUTPUT
61-
#define WOLFSSL_SSLKEYLOGFILE_OUTPUT "sslkeylog.log"
62-
#endif
63-
64-
/* Callback function for TLS v1.3 secrets for use with Wireshark */
65-
static int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret,
66-
int secretSz, void* ctx)
67-
{
68-
int i;
69-
const char* str = NULL;
70-
unsigned char serverRandom[32];
71-
int serverRandomSz;
72-
XFILE fp = stderr;
73-
if (ctx) {
74-
fp = XFOPEN((const char*)ctx, "ab");
75-
if (fp == XBADFILE) {
76-
return BAD_FUNC_ARG;
77-
}
78-
}
79-
80-
serverRandomSz = (int)wolfSSL_get_server_random(ssl, serverRandom,
81-
sizeof(serverRandom));
82-
83-
if (serverRandomSz <= 0) {
84-
printf("Error getting server random %d\n", serverRandomSz);
85-
}
86-
87-
#if 0
88-
printf("TLS Server Secret CB: Rand %d, Secret %d\n",
89-
serverRandomSz, secretSz);
90-
#endif
91-
92-
switch (id) {
93-
case CLIENT_EARLY_TRAFFIC_SECRET:
94-
str = "CLIENT_EARLY_TRAFFIC_SECRET"; break;
95-
case EARLY_EXPORTER_SECRET:
96-
str = "EARLY_EXPORTER_SECRET"; break;
97-
case CLIENT_HANDSHAKE_TRAFFIC_SECRET:
98-
str = "CLIENT_HANDSHAKE_TRAFFIC_SECRET"; break;
99-
case SERVER_HANDSHAKE_TRAFFIC_SECRET:
100-
str = "SERVER_HANDSHAKE_TRAFFIC_SECRET"; break;
101-
case CLIENT_TRAFFIC_SECRET:
102-
str = "CLIENT_TRAFFIC_SECRET_0"; break;
103-
case SERVER_TRAFFIC_SECRET:
104-
str = "SERVER_TRAFFIC_SECRET_0"; break;
105-
case EXPORTER_SECRET:
106-
str = "EXPORTER_SECRET"; break;
107-
}
108-
109-
fprintf(fp, "%s ", str);
110-
for (i = 0; i < (int)serverRandomSz; i++) {
111-
fprintf(fp, "%02x", serverRandom[i]);
112-
}
113-
fprintf(fp, " ");
114-
for (i = 0; i < secretSz; i++) {
115-
fprintf(fp, "%02x", secret[i]);
116-
}
117-
fprintf(fp, "\n");
118-
119-
if (fp != stderr) {
120-
XFCLOSE(fp);
121-
}
122-
123-
return 0;
124-
}
125-
#endif /* WOLFSSL_TLS13 && HAVE_SECRET_CALLBACK */
126-
12758
static int mSockfd = SOCKET_INVALID;
12859
static int mConnd = SOCKET_INVALID;
129-
static int mShutdown = 0;
60+
static volatile int mShutdown = 0;
13061

13162
#ifdef HAVE_SIGNAL
13263
static void sig_handler(const int sig)
@@ -269,9 +200,6 @@ int main(int argc, char** argv)
269200
/*---------------------------------*/
270201
/* Start of wolfSSL initialization and configuration */
271202
/*---------------------------------*/
272-
#if 0
273-
wolfSSL_Debugging_ON();
274-
#endif
275203

276204
/* Initialize wolfSSL */
277205
if ((ret = wolfSSL_Init()) != WOLFSSL_SUCCESS) {
@@ -324,15 +252,6 @@ int main(int argc, char** argv)
324252
/* Attach wolfSSL to the socket */
325253
wolfSSL_set_fd(ssl, mConnd);
326254

327-
#ifdef HAVE_SECRET_CALLBACK
328-
/* required for getting random used */
329-
wolfSSL_KeepArrays(ssl);
330-
331-
/* optional logging for wireshark */
332-
wolfSSL_set_tls13_secret_cb(ssl, Tls13SecretCallback,
333-
(void*)WOLFSSL_SSLKEYLOGFILE_OUTPUT);
334-
#endif
335-
336255
/* Establish TLS connection */
337256
if ((ret = wolfSSL_accept(ssl)) != WOLFSSL_SUCCESS) {
338257
fprintf(stderr, "wolfSSL_accept error = %d\n",
@@ -342,10 +261,6 @@ int main(int argc, char** argv)
342261

343262
printf("Client connected successfully\n");
344263

345-
#ifdef HAVE_SECRET_CALLBACK
346-
wolfSSL_FreeArrays(ssl);
347-
#endif
348-
349264
/* Read the client data into our buff array */
350265
memset(buff, 0, sizeof(buff));
351266
if ((ret = wolfSSL_read(ssl, buff, sizeof(buff)-1)) < 0) {

0 commit comments

Comments
 (0)