Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect Crypspr initialisation with a mutex #2425

Merged
merged 5 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions haicrypt/cryspr-gnutls.c → haicrypt/cryspr-gnutls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ written by
*****************************************************************************/

#include "hcrypt.h"
#include "sync.h"

#include <string.h>

Expand Down Expand Up @@ -173,6 +174,9 @@ static CRYSPR_methods crysprGnuTLS_methods;

CRYSPR_methods *crysprGnuTLS(void)
{
static srt::sync::Mutex s_mtxCrysprInit;
srt::sync::ScopedLock lck(s_mtxCrysprInit);

if(NULL == crysprGnuTLS_methods.open) {
crysprInit(&crysprGnuTLS_methods); /* Set default methods */

Expand Down
4 changes: 4 additions & 0 deletions haicrypt/cryspr-mbedtls.c → haicrypt/cryspr-mbedtls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ written by
*****************************************************************************/

#include "hcrypt.h"
#include "sync.h"

#include <string.h>

Expand Down Expand Up @@ -231,6 +232,9 @@ static CRYSPR_methods crysprMbedtls_methods;

CRYSPR_methods *crysprMbedtls(void)
{
static srt::sync::Mutex s_mtxCrysprInit;
srt::sync::ScopedLock lck(s_mtxCrysprInit);

if (crysprMbedtls_methods.open)
return(&crysprMbedtls_methods);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ written by
*****************************************************************************/

#include "hcrypt.h"
#include "sync.h"

#include <string.h>

Expand Down Expand Up @@ -290,6 +291,9 @@ static CRYSPR_methods crysprOpenSSL_EVP_methods;

CRYSPR_methods* crysprOpenSSL_EVP(void)
{
static srt::sync::Mutex s_mtxCrysprInit;
srt::sync::ScopedLock lck(s_mtxCrysprInit);

if (NULL == crysprOpenSSL_EVP_methods.open)
{
crysprInit(&crysprOpenSSL_EVP_methods); // Default/fallback methods
Expand Down
4 changes: 4 additions & 0 deletions haicrypt/cryspr-openssl.c → haicrypt/cryspr-openssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ written by
*****************************************************************************/

#include "hcrypt.h"
#include "sync.h"

#include <string.h>

Expand Down Expand Up @@ -195,6 +196,9 @@ static CRYSPR_methods crysprOpenSSL_methods;

CRYSPR_methods *crysprOpenSSL(void)
{
static srt::sync::Mutex s_mtxCrysprInit;
srt::sync::ScopedLock lck(s_mtxCrysprInit);

if(NULL == crysprOpenSSL_methods.open) {
crysprInit(&crysprOpenSSL_methods); //Default/fallback methods

Expand Down
2 changes: 1 addition & 1 deletion haicrypt/filelist-gnutls.maf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ haicrypt_log.h

SOURCES
cryspr.c
cryspr-gnutls.c
cryspr-gnutls.cpp
hcrypt.c
hcrypt_ctx_rx.c
hcrypt_ctx_tx.c
Expand Down
2 changes: 1 addition & 1 deletion haicrypt/filelist-mbedtls.maf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ haicrypt_log.h

SOURCES
cryspr.c
cryspr-mbedtls.c
cryspr-mbedtls.cpp
hcrypt.c
hcrypt_ctx_rx.c
hcrypt_ctx_tx.c
Expand Down
2 changes: 1 addition & 1 deletion haicrypt/filelist-openssl-evp.maf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ haicrypt_log.h

SOURCES
cryspr.c
cryspr-openssl-evp.c
cryspr-openssl-evp.cpp
hcrypt.c
hcrypt_ctx_rx.c
hcrypt_ctx_tx.c
Expand Down
2 changes: 1 addition & 1 deletion haicrypt/filelist-openssl.maf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ haicrypt_log.h

SOURCES
cryspr.c
cryspr-openssl.c
cryspr-openssl.cpp
hcrypt.c
hcrypt_ctx_rx.c
hcrypt_ctx_tx.c
Expand Down