Merge pull request #255 from dgarske/tls13_secret_fix

Fix set secret callback to be prior to connect.
pull/257/head
Sean Parkinson 2021-04-27 09:50:32 +10:00 committed by GitHub
commit 2113622af0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -46,7 +46,7 @@
#endif #endif
/* Callback function for TLS v1.3 secrets for use with Wireshark */ /* Callback function for TLS v1.3 secrets for use with Wireshark */
int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret, static int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret,
int secretSz, void* ctx) int secretSz, void* ctx)
{ {
int i; int i;
@ -82,7 +82,7 @@ int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret,
} }
fprintf(fp, "%s ", str); fprintf(fp, "%s ", str);
for (i = 0; i < clientRandomSz; i++) { for (i = 0; i < (int)clientRandomSz; i++) {
fprintf(fp, "%02x", clientRandom[i]); fprintf(fp, "%02x", clientRandom[i]);
} }
fprintf(fp, " "); fprintf(fp, " ");
@ -181,18 +181,18 @@ int main(int argc, char** argv)
goto exit; goto exit;
} }
#ifdef HAVE_SECRET_CALLBACK
/* optional logging for wireshark */
wolfSSL_set_tls13_secret_cb(ssl, Tls13SecretCallback,
(void*)WOLFSSL_SSLKEYLOGFILE_OUTPUT);
#endif
/* Connect to wolfSSL on the server side */ /* Connect to wolfSSL on the server side */
if ((ret = wolfSSL_connect(ssl)) != WOLFSSL_SUCCESS) { if ((ret = wolfSSL_connect(ssl)) != WOLFSSL_SUCCESS) {
fprintf(stderr, "ERROR: failed to connect to wolfSSL\n"); fprintf(stderr, "ERROR: failed to connect to wolfSSL\n");
goto exit; goto exit;
} }
#ifdef HAVE_SECRET_CALLBACK
/* optional logging for wireshark */
wolfSSL_set_tls13_secret_cb(ssl, Tls13SecretCallback,
WOLFSSL_SSLKEYLOGFILE_OUTPUT);
#endif
/* Get a message for the server from stdin */ /* Get a message for the server from stdin */
printf("Message for server: "); printf("Message for server: ");
memset(buff, 0, sizeof(buff)); memset(buff, 0, sizeof(buff));

View File

@ -47,7 +47,7 @@
#endif #endif
/* Callback function for TLS v1.3 secrets for use with Wireshark */ /* Callback function for TLS v1.3 secrets for use with Wireshark */
int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret, static int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret,
int secretSz, void* ctx) int secretSz, void* ctx)
{ {
int i; int i;
@ -83,7 +83,7 @@ int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret,
} }
fprintf(fp, "%s ", str); fprintf(fp, "%s ", str);
for (i = 0; i < serverRandomSz; i++) { for (i = 0; i < (int)serverRandomSz; i++) {
fprintf(fp, "%02x", serverRandom[i]); fprintf(fp, "%02x", serverRandom[i]);
} }
fprintf(fp, " "); fprintf(fp, " ");
@ -198,7 +198,7 @@ int main(int argc, char** argv)
#ifdef HAVE_SECRET_CALLBACK #ifdef HAVE_SECRET_CALLBACK
/* optional logging for wireshark */ /* optional logging for wireshark */
wolfSSL_set_tls13_secret_cb(ssl, Tls13SecretCallback, wolfSSL_set_tls13_secret_cb(ssl, Tls13SecretCallback,
WOLFSSL_SSLKEYLOGFILE_OUTPUT); (void*)WOLFSSL_SSLKEYLOGFILE_OUTPUT);
#endif #endif
/* Establish TLS connection */ /* Establish TLS connection */