mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
dtls-srtp: no ekm cross check on single threaded/no pthread conf
This commit is contained in:
@@ -1770,11 +1770,18 @@ static void Usage(void)
|
|||||||
* calls srtp_helper_get_ekm() to wait and then get the ekm computed by the
|
* calls srtp_helper_get_ekm() to wait and then get the ekm computed by the
|
||||||
* server, then check if it matches the one computed by itself.
|
* server, then check if it matches the one computed by itself.
|
||||||
*/
|
*/
|
||||||
static int client_srtp_test(WOLFSSL *ssl, srtp_test_helper *srtp_helper)
|
static int client_srtp_test(WOLFSSL *ssl, func_args *args)
|
||||||
{
|
{
|
||||||
byte *srtp_secret, *other_secret = NULL, *p;
|
size_t srtp_secret_length;
|
||||||
size_t srtp_secret_length, other_size = 0;
|
byte *srtp_secret, *p;
|
||||||
int ret;
|
int ret;
|
||||||
|
#if !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
|
srtp_test_helper *srtp_helper = args->srtp_helper;
|
||||||
|
byte *other_secret = NULL;
|
||||||
|
size_t other_size = 0;
|
||||||
|
#else
|
||||||
|
(void)args;
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = wolfSSL_export_dtls_srtp_keying_material(ssl, NULL,
|
ret = wolfSSL_export_dtls_srtp_keying_material(ssl, NULL,
|
||||||
&srtp_secret_length);
|
&srtp_secret_length);
|
||||||
@@ -1797,11 +1804,12 @@ static int client_srtp_test(WOLFSSL *ssl, srtp_test_helper *srtp_helper)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("DTLS SRTP: Exported key material:\n");
|
printf("DTLS SRTP: Exported key material: ");
|
||||||
for (p = srtp_secret; p < srtp_secret + srtp_secret_length; p++)
|
for (p = srtp_secret; p < srtp_secret + srtp_secret_length; p++)
|
||||||
printf("%02X", *p);
|
printf("%02X", *p);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
|
#if !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
if (srtp_helper != NULL) {
|
if (srtp_helper != NULL) {
|
||||||
srtp_helper_get_ekm(srtp_helper, &other_secret, &other_size);
|
srtp_helper_get_ekm(srtp_helper, &other_secret, &other_size);
|
||||||
|
|
||||||
@@ -1817,6 +1825,7 @@ static int client_srtp_test(WOLFSSL *ssl, srtp_test_helper *srtp_helper)
|
|||||||
/* we are delegated from server to free this buffer */
|
/* we are delegated from server to free this buffer */
|
||||||
XFREE(other_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(other_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
|
||||||
@@ -3976,7 +3985,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
|
|
||||||
#ifdef WOLFSSL_SRTP
|
#ifdef WOLFSSL_SRTP
|
||||||
if (dtlsSrtpProfiles != NULL) {
|
if (dtlsSrtpProfiles != NULL) {
|
||||||
err = client_srtp_test(ssl, ((func_args*)args)->srtp_helper);
|
err = client_srtp_test(ssl, (func_args*)args);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
if (exitWithRet) {
|
if (exitWithRet) {
|
||||||
((func_args*)args)->return_code = err;
|
((func_args*)args)->return_code = err;
|
||||||
@@ -4341,7 +4350,7 @@ exit:
|
|||||||
|
|
||||||
StartTCP();
|
StartTCP();
|
||||||
|
|
||||||
#ifdef WOLFSSL_SRTP
|
#if defined(WOLFSSL_SRTP) && !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
args.srtp_helper = NULL;
|
args.srtp_helper = NULL;
|
||||||
#endif
|
#endif
|
||||||
args.argc = argc;
|
args.argc = argc;
|
||||||
|
@@ -1290,11 +1290,16 @@ static void Usage(void)
|
|||||||
* calls srtp_helper_set_ekm() to wake the client and share the ekm with
|
* calls srtp_helper_set_ekm() to wake the client and share the ekm with
|
||||||
* him. The client will check that the ekm matches the one computed by itself.
|
* him. The client will check that the ekm matches the one computed by itself.
|
||||||
*/
|
*/
|
||||||
static int server_srtp_test(WOLFSSL *ssl, srtp_test_helper *srtp_helper)
|
static int server_srtp_test(WOLFSSL *ssl, func_args *args)
|
||||||
{
|
{
|
||||||
size_t srtp_secret_length;
|
size_t srtp_secret_length;
|
||||||
byte *srtp_secret, *p;
|
byte *srtp_secret, *p;
|
||||||
int ret;
|
int ret;
|
||||||
|
#if !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
|
srtp_test_helper *srtp_helper = args->srtp_helper;
|
||||||
|
#else
|
||||||
|
(void)args;
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = wolfSSL_export_dtls_srtp_keying_material(ssl, NULL,
|
ret = wolfSSL_export_dtls_srtp_keying_material(ssl, NULL,
|
||||||
&srtp_secret_length);
|
&srtp_secret_length);
|
||||||
@@ -1317,20 +1322,22 @@ static int server_srtp_test(WOLFSSL *ssl, srtp_test_helper *srtp_helper)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("DTLS SRTP: Exported key material:\n");
|
printf("DTLS SRTP: Exported key material: ");
|
||||||
for (p = srtp_secret; p < srtp_secret + srtp_secret_length; p++)
|
for (p = srtp_secret; p < srtp_secret + srtp_secret_length; p++)
|
||||||
printf("%02X", *p);
|
printf("%02X", *p);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if (srtp_helper != NULL) {
|
#if !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
|
if (srtp_helper != NULL) {
|
||||||
srtp_helper_set_ekm(srtp_helper, srtp_secret, srtp_secret_length);
|
srtp_helper_set_ekm(srtp_helper, srtp_secret, srtp_secret_length);
|
||||||
|
|
||||||
/* client code will free srtp_secret buffer after checking for
|
/* client code will free srtp_secret buffer after checking for
|
||||||
correctness */
|
correctness */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
#endif /* _POSIX_THREADS */
|
||||||
XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
XFREE(srtp_secret, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -3146,7 +3153,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
|
|||||||
|
|
||||||
#ifdef WOLFSSL_SRTP
|
#ifdef WOLFSSL_SRTP
|
||||||
if (dtlsSrtpProfiles != NULL) {
|
if (dtlsSrtpProfiles != NULL) {
|
||||||
err = server_srtp_test(ssl, ((func_args*)args)->srtp_helper);
|
err = server_srtp_test(ssl, (func_args*)args);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
if (exitWithRet) {
|
if (exitWithRet) {
|
||||||
((func_args*)args)->return_code = err;
|
((func_args*)args)->return_code = err;
|
||||||
@@ -3423,7 +3430,7 @@ exit:
|
|||||||
args.argv = argv;
|
args.argv = argv;
|
||||||
args.signal = &ready;
|
args.signal = &ready;
|
||||||
args.return_code = 0;
|
args.return_code = 0;
|
||||||
#ifdef WOLFSSL_SRTP
|
#if defined(WOLFSSL_SRTP) && !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
args.srtp_helper = NULL;
|
args.srtp_helper = NULL;
|
||||||
#endif
|
#endif
|
||||||
InitTcpReady(&ready);
|
InitTcpReady(&ready);
|
||||||
|
@@ -321,7 +321,7 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
|||||||
int reqClientCert;
|
int reqClientCert;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WOLFSSL_SRTP
|
#if defined(WOLFSSL_SRTP) && !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
srtp_test_helper srtp_helper;
|
srtp_test_helper srtp_helper;
|
||||||
#endif
|
#endif
|
||||||
/* Is Valid Cipher and Version Checks */
|
/* Is Valid Cipher and Version Checks */
|
||||||
@@ -452,11 +452,12 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
|||||||
|
|
||||||
InitTcpReady(&ready);
|
InitTcpReady(&ready);
|
||||||
|
|
||||||
#ifdef WOLFSSL_SRTP
|
#if defined(WOLFSSL_SRTP) && !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
srtp_helper_init(&srtp_helper);
|
srtp_helper_init(&srtp_helper);
|
||||||
cliArgs.srtp_helper = &srtp_helper;
|
cliArgs.srtp_helper = &srtp_helper;
|
||||||
svrArgs.srtp_helper = &srtp_helper;
|
svrArgs.srtp_helper = &srtp_helper;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WOLFSSL_TIRTOS
|
#ifdef WOLFSSL_TIRTOS
|
||||||
fdOpenSession(Task_self());
|
fdOpenSession(Task_self());
|
||||||
#endif
|
#endif
|
||||||
@@ -570,7 +571,7 @@ static int execute_test_case(int svr_argc, char** svr_argv,
|
|||||||
#endif
|
#endif
|
||||||
FreeTcpReady(&ready);
|
FreeTcpReady(&ready);
|
||||||
|
|
||||||
#ifdef WOLFSSL_SRTP
|
#if defined (WOLFSSL_SRTP) &&!defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
srtp_helper_free(&srtp_helper);
|
srtp_helper_free(&srtp_helper);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -520,12 +520,10 @@ typedef struct callback_functions {
|
|||||||
unsigned char loadToSSL:1;
|
unsigned char loadToSSL:1;
|
||||||
} callback_functions;
|
} callback_functions;
|
||||||
|
|
||||||
#ifdef WOLFSSL_SRTP
|
#if defined(WOLFSSL_SRTP) && !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
typedef struct srtp_test_helper {
|
typedef struct srtp_test_helper {
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
#endif
|
|
||||||
uint8_t* server_srtp_ekm;
|
uint8_t* server_srtp_ekm;
|
||||||
size_t server_srtp_ekm_size;
|
size_t server_srtp_ekm_size;
|
||||||
} srtp_test_helper;
|
} srtp_test_helper;
|
||||||
@@ -537,7 +535,7 @@ typedef struct func_args {
|
|||||||
int return_code;
|
int return_code;
|
||||||
tcp_ready* signal;
|
tcp_ready* signal;
|
||||||
callback_functions *callbacks;
|
callback_functions *callbacks;
|
||||||
#ifdef WOLFSSL_SRTP
|
#if defined(WOLFSSL_SRTP) && !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
srtp_test_helper* srtp_helper;
|
srtp_test_helper* srtp_helper;
|
||||||
#endif
|
#endif
|
||||||
} func_args;
|
} func_args;
|
||||||
@@ -643,16 +641,15 @@ err_sys_with_errno(const char* msg)
|
|||||||
extern int myoptind;
|
extern int myoptind;
|
||||||
extern char* myoptarg;
|
extern char* myoptarg;
|
||||||
|
|
||||||
#ifdef WOLFSSL_SRTP
|
#if defined(WOLFSSL_SRTP) && !defined(SINGLE_THREADED) && defined(_POSIX_THREADS)
|
||||||
|
|
||||||
static WC_INLINE void srtp_helper_init(srtp_test_helper *srtp)
|
static WC_INLINE void srtp_helper_init(srtp_test_helper *srtp)
|
||||||
{
|
{
|
||||||
srtp->server_srtp_ekm_size = 0;
|
srtp->server_srtp_ekm_size = 0;
|
||||||
srtp->server_srtp_ekm = NULL;
|
srtp->server_srtp_ekm = NULL;
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
|
||||||
pthread_mutex_init(&srtp->mutex, 0);
|
pthread_mutex_init(&srtp->mutex, 0);
|
||||||
pthread_cond_init(&srtp->cond, 0);
|
pthread_cond_init(&srtp->cond, 0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -667,7 +664,6 @@ static WC_INLINE void srtp_helper_init(srtp_test_helper *srtp)
|
|||||||
static WC_INLINE void srtp_helper_get_ekm(srtp_test_helper *srtp,
|
static WC_INLINE void srtp_helper_get_ekm(srtp_test_helper *srtp,
|
||||||
uint8_t **ekm, size_t *size)
|
uint8_t **ekm, size_t *size)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
|
||||||
pthread_mutex_lock(&srtp->mutex);
|
pthread_mutex_lock(&srtp->mutex);
|
||||||
|
|
||||||
if (srtp->server_srtp_ekm == NULL)
|
if (srtp->server_srtp_ekm == NULL)
|
||||||
@@ -681,7 +677,6 @@ static WC_INLINE void srtp_helper_get_ekm(srtp_test_helper *srtp,
|
|||||||
srtp->server_srtp_ekm_size = 0;
|
srtp->server_srtp_ekm_size = 0;
|
||||||
|
|
||||||
pthread_mutex_unlock(&srtp->mutex);
|
pthread_mutex_unlock(&srtp->mutex);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -698,7 +693,6 @@ static WC_INLINE void srtp_helper_get_ekm(srtp_test_helper *srtp,
|
|||||||
static WC_INLINE void srtp_helper_set_ekm(srtp_test_helper *srtp,
|
static WC_INLINE void srtp_helper_set_ekm(srtp_test_helper *srtp,
|
||||||
uint8_t *ekm, size_t size)
|
uint8_t *ekm, size_t size)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
|
||||||
pthread_mutex_lock(&srtp->mutex);
|
pthread_mutex_lock(&srtp->mutex);
|
||||||
|
|
||||||
srtp->server_srtp_ekm_size = size;
|
srtp->server_srtp_ekm_size = size;
|
||||||
@@ -706,18 +700,15 @@ static WC_INLINE void srtp_helper_set_ekm(srtp_test_helper *srtp,
|
|||||||
pthread_cond_signal(&srtp->cond);
|
pthread_cond_signal(&srtp->cond);
|
||||||
|
|
||||||
pthread_mutex_unlock(&srtp->mutex);
|
pthread_mutex_unlock(&srtp->mutex);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WC_INLINE void srtp_helper_free(srtp_test_helper *srtp)
|
static WC_INLINE void srtp_helper_free(srtp_test_helper *srtp)
|
||||||
{
|
{
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
|
||||||
pthread_mutex_destroy(&srtp->mutex);
|
pthread_mutex_destroy(&srtp->mutex);
|
||||||
pthread_cond_destroy(&srtp->cond);
|
pthread_cond_destroy(&srtp->cond);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WOLFSSL_SRTP */
|
#endif /* WOLFSSL_SRTP && !SINGLE_THREADED && POSIX_THREADS */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user