Merge pull request #8628 from douzzer/20250402-WOLFSSL_TEST_API

20250402-WOLFSSL_TEST_API
This commit is contained in:
JacobBarthelmeh
2025-04-04 09:37:56 -06:00
committed by GitHub
5 changed files with 59 additions and 25 deletions

View File

@@ -42578,7 +42578,7 @@ static int test_wolfSSL_TXT_DB(void)
/* Test index */
ExpectIntEQ(TXT_DB_create_index(db, 3, NULL,
(wolf_sk_hash_cb)(long unsigned int)TXT_DB_hash,
(wolf_sk_hash_cb)(wc_ptr_t)TXT_DB_hash,
(wolf_lh_compare_cb)TXT_DB_cmp), 1);
ExpectNotNull(TXT_DB_get_by_index(db, 3, (WOLFSSL_STRING*)fields));
fields[3] = "12DA";

View File

@@ -23,6 +23,8 @@
#ifndef TESTS_UNIT_H
#define TESTS_UNIT_H
#define WOLFSSL_VIS_FOR_TESTS
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

View File

@@ -2435,8 +2435,7 @@ typedef struct CipherSuite {
#endif
} CipherSuite;
/* use wolfSSL_API visibility to be able to test in tests/api.c */
WOLFSSL_API void InitSuitesHashSigAlgo(byte* hashSigAlgo, int have,
WOLFSSL_TEST_VIS void InitSuitesHashSigAlgo(byte* hashSigAlgo, int have,
int tls1_2, int keySz, word16* len);
WOLFSSL_LOCAL int AllocateCtxSuites(WOLFSSL_CTX* ctx);
WOLFSSL_LOCAL int AllocateSuites(WOLFSSL* ssl);
@@ -3396,7 +3395,7 @@ WOLFSSL_LOCAL int TLSX_CSR2_ForceRequest(WOLFSSL* ssl);
#if defined(WOLFSSL_PUBLIC_ASN) && defined(HAVE_PK_CALLBACKS)
/* Internal callback guarded by WOLFSSL_PUBLIC_ASN because of DecodedCert. */
typedef int (*CallbackProcessPeerCert)(WOLFSSL* ssl, DecodedCert* p_cert);
WOLFSSL_API void wolfSSL_CTX_SetProcessPeerCertCb(WOLFSSL_CTX* ctx,
WOLFSSL_TEST_VIS void wolfSSL_CTX_SetProcessPeerCertCb(WOLFSSL_CTX* ctx,
CallbackProcessPeerCert cb);
#endif /* DecodedCert && HAVE_PK_CALLBACKS */
@@ -4700,8 +4699,7 @@ WOLFSSL_LOCAL WOLFSSL_SESSION* wolfSSL_GetSession(
WOLFSSL* ssl, byte* masterSecret, byte restoreSessionCerts);
WOLFSSL_LOCAL void SetupSession(WOLFSSL* ssl);
WOLFSSL_LOCAL void AddSession(WOLFSSL* ssl);
/* use wolfSSL_API visibility to be able to test in tests/api.c */
WOLFSSL_API int AddSessionToCache(WOLFSSL_CTX* ctx,
WOLFSSL_TEST_VIS int AddSessionToCache(WOLFSSL_CTX* ctx,
WOLFSSL_SESSION* addSession, const byte* id, byte idSz, int* sessionIndex,
int side, word16 useTicket, ClientSession** clientCacheEntry);
#ifndef NO_CLIENT_CACHE
@@ -4717,8 +4715,8 @@ WOLFSSL_LOCAL int TlsSessionCacheGetAndRdLock(const byte *id,
WOLFSSL_LOCAL int TlsSessionCacheGetAndWrLock(const byte *id,
WOLFSSL_SESSION **sess, word32 *lockedRow, byte side);
WOLFSSL_LOCAL void EvictSessionFromCache(WOLFSSL_SESSION* session);
/* WOLFSSL_API to test it in tests/api.c */
WOLFSSL_API int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output);
/* WOLFSSL_TEST_VIS to test it in tests/api.c */
WOLFSSL_TEST_VIS int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output);
WOLFSSL_LOCAL int wolfSSL_SetSession(WOLFSSL* ssl, WOLFSSL_SESSION* session);
WOLFSSL_LOCAL void wolfSSL_FreeSession(WOLFSSL_CTX* ctx,
WOLFSSL_SESSION* session);
@@ -6382,7 +6380,7 @@ WOLFSSL_LOCAL int SetSSL_CTX(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup);
WOLFSSL_LOCAL int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup);
WOLFSSL_LOCAL int ReinitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup);
WOLFSSL_LOCAL void FreeSSL(WOLFSSL* ssl, void* heap);
WOLFSSL_API void wolfSSL_ResourceFree(WOLFSSL* ssl); /* Micrium uses */
WOLFSSL_TEST_VIS void wolfSSL_ResourceFree(WOLFSSL* ssl); /* Micrium uses */
#ifndef OPENSSL_COEXIST
#define SSL_ResourceFree wolfSSL_ResourceFree
#endif
@@ -6748,18 +6746,18 @@ WOLFSSL_LOCAL word32 MacSize(const WOLFSSL* ssl);
#ifdef WOLFSSL_DTLS
WOLFSSL_LOCAL DtlsMsg* DtlsMsgNew(word32 sz, byte tx, void* heap);
WOLFSSL_LOCAL void DtlsMsgDelete(DtlsMsg* item, void* heap);
/* Use WOLFSSL_API to enable src/api.c testing */
WOLFSSL_API void DtlsMsgListDelete(DtlsMsg* head, void* heap);
/* Use WOLFSSL_TEST_VIS to enable src/api.c testing */
WOLFSSL_TEST_VIS void DtlsMsgListDelete(DtlsMsg* head, void* heap);
WOLFSSL_LOCAL void DtlsTxMsgListClean(WOLFSSL* ssl);
WOLFSSL_LOCAL int DtlsMsgSet(DtlsMsg* msg, word32 seq, word16 epoch,
const byte* data, byte type,
word32 fragOffset, word32 fragSz, void* heap,
word32 totalLen, byte encrypted);
/* Use WOLFSSL_API to enable src/api.c testing */
WOLFSSL_API DtlsMsg* DtlsMsgFind(DtlsMsg* head, word16 epoch, word32 seq);
/* Use WOLFSSL_TEST_VIS to enable src/api.c testing */
WOLFSSL_TEST_VIS DtlsMsg* DtlsMsgFind(DtlsMsg* head, word16 epoch, word32 seq);
/* Use WOLFSSL_API to enable src/api.c testing */
WOLFSSL_API void DtlsMsgStore(WOLFSSL* ssl, word16 epoch, word32 seq,
/* Use WOLFSSL_TEST_VIS to enable src/api.c testing */
WOLFSSL_TEST_VIS void DtlsMsgStore(WOLFSSL* ssl, word16 epoch, word32 seq,
const byte* data, word32 dataSz, byte type,
word32 fragOffset, word32 fragSz,
void* heap);
@@ -6949,8 +6947,8 @@ WOLFSSL_LOCAL int BuildMessage(WOLFSSL* ssl, byte* output, int outSz,
int sizeOnly, int asyncOkay, int epochOrder);
#ifdef WOLFSSL_TLS13
/* Use WOLFSSL_API to use this function in tests/api.c */
WOLFSSL_API int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
/* Use WOLFSSL_TEST_VIS to use this function in tests/api.c */
WOLFSSL_TEST_VIS int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
int inSz, int type, int hashOutput, int sizeOnly, int asyncOkay);
WOLFSSL_LOCAL int Tls13UpdateKeys(WOLFSSL* ssl);
#endif
@@ -7007,7 +7005,7 @@ WOLFSSL_LOCAL word32 nid2oid(int nid, int grp);
#endif
#ifdef WOLFSSL_DTLS
WOLFSSL_API int wolfSSL_DtlsUpdateWindow(word16 cur_hi, word32 cur_lo,
WOLFSSL_TEST_VIS int wolfSSL_DtlsUpdateWindow(word16 cur_hi, word32 cur_lo,
word16* next_hi, word32* next_lo, word32 *window);
WOLFSSL_LOCAL int DtlsUpdateWindow(WOLFSSL* ssl);
WOLFSSL_LOCAL void DtlsResetState(WOLFSSL *ssl);
@@ -7017,8 +7015,8 @@ WOLFSSL_LOCAL void DtlsSetSeqNumForReply(WOLFSSL* ssl);
#ifdef WOLFSSL_DTLS13
/* Use WOLFSSL_API to use this function in tests/api.c */
WOLFSSL_API struct Dtls13Epoch* Dtls13GetEpoch(WOLFSSL* ssl,
/* Use WOLFSSL_TEST_VIS to use this function in tests/api.c */
WOLFSSL_TEST_VIS struct Dtls13Epoch* Dtls13GetEpoch(WOLFSSL* ssl,
w64wrapper epochNumber);
WOLFSSL_LOCAL void Dtls13SetOlderEpochSide(WOLFSSL* ssl, w64wrapper epochNumber,
int side);
@@ -7108,9 +7106,8 @@ typedef struct CRYPTO_EX_cb_ctx {
struct CRYPTO_EX_cb_ctx* next;
} CRYPTO_EX_cb_ctx;
/* use wolfSSL_API visibility to be able to clear in tests/api.c */
WOLFSSL_API extern CRYPTO_EX_cb_ctx* crypto_ex_cb_ctx_session;
WOLFSSL_API void crypto_ex_cb_free(CRYPTO_EX_cb_ctx* cb_ctx);
WOLFSSL_TEST_VIS extern CRYPTO_EX_cb_ctx* crypto_ex_cb_ctx_session;
WOLFSSL_TEST_VIS void crypto_ex_cb_free(CRYPTO_EX_cb_ctx* cb_ctx);
WOLFSSL_LOCAL void crypto_ex_cb_setup_new_data(void *new_obj,
CRYPTO_EX_cb_ctx* cb_ctx, WOLFSSL_CRYPTO_EX_DATA* ex_data);
WOLFSSL_LOCAL void crypto_ex_cb_free_data(void *obj, CRYPTO_EX_cb_ctx* cb_ctx,

View File

@@ -50,7 +50,13 @@
#define WOLFSSL_API
#define WOLFSSL_LOCAL
#endif /* HAVE_VISIBILITY */
#else /* BUILDING_WOLFSSL */
#ifdef WOLFSSL_PRIVATE_TEST_VIS
#define WOLFSSL_TEST_VIS WOLFSSL_LOCAL
#else
#define WOLFSSL_TEST_VIS WOLFSSL_API
#endif
#else /* !BUILDING_WOLFSSL */
#if defined(__WATCOMC__)
#if defined(WOLFSSL_DLL) && defined(__NT__)
#define WOLFSSL_API __declspec(dllimport)
@@ -70,7 +76,17 @@
#define WOLFSSL_API
#define WOLFSSL_LOCAL
#endif
#endif /* BUILDING_WOLFSSL */
#if defined(WOLFSSL_VIS_FOR_TESTS)
#ifdef WOLFSSL_PRIVATE_TEST_VIS
#error WOLFSSL_VIS_FOR_TESTS is unavailable in WOLFSSL_PRIVATE_TEST_VIS builds.
#endif
#define WOLFSSL_TEST_VIS WOLFSSL_API
#else
#define WOLFSSL_TEST_VIS WOLFSSL_API WC_DEPRECATED("internal use only")
#endif
#endif /* !BUILDING_WOLFSSL */
/* WOLFSSL_ABI is used for public API symbols that must not change
* their signature. This tag is used for all APIs that are a

View File

@@ -82,6 +82,25 @@
#endif
#endif /* !WC_MAYBE_UNUSED */
#ifndef WC_DEPRECATED
#ifdef WOLFSSL_ZEPHYR
#define WC_DEPRECATED(msg) /* null expansion */
#elif ((defined(__GNUC__) && \
((__GNUC__ >= 5) || \
((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))) || \
defined(__clang__)
#define WC_DEPRECATED(msg) __attribute__((deprecated(msg)))
#elif defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || \
defined(_WIN32_WCE) || defined(__WATCOMC__)
#define WC_DEPRECATED(msg) __declspec(deprecated(msg))
#elif (defined(__GNUC__) && (__GNUC__ >= 4)) || \
defined(__IAR_SYSTEMS_ICC__)
#define WC_DEPRECATED(msg) __attribute__((deprecated))
#else
#define WC_DEPRECATED(msg) /* null expansion */
#endif
#endif /* !WC_MAYBE_UNUSED */
/* use inlining if compiler allows */
#ifndef WC_INLINE
#ifndef NO_INLINE