WOLFSSL_TEST_VIS: improved naming scheme based on peer review:

WOLFSSL_TEST_API->WOLFSSL_TEST_VIS,
  WOLFSSL_ALLOW_TEST_APIS->WOLFSSL_VIS_FOR_TESTS,
  WOLFSSL_LOCALIZE_TEST_APIS->WOLFSSL_PRIVATE_TEST_VIS.

support message argument to WC_DEPRECATED() on targets that support it

add MSVC support for WC_DEPRECATED().
This commit is contained in:
Daniel Pouzzner
2025-04-03 19:29:17 -05:00
parent cc223d1904
commit 96118b416d
4 changed files with 43 additions and 36 deletions

View File

@@ -23,7 +23,7 @@
#ifndef TESTS_UNIT_H
#define TESTS_UNIT_H
#define WOLFSSL_ALLOW_TEST_APIS
#define WOLFSSL_VIS_FOR_TESTS
#ifdef HAVE_CONFIG_H
#include <config.h>

View File

@@ -2435,8 +2435,7 @@ typedef struct CipherSuite {
#endif
} CipherSuite;
/* use wolfSSL_TEST_API visibility to be able to test in tests/api.c */
WOLFSSL_TEST_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_TEST_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_TEST_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_TEST_API to test it in tests/api.c */
WOLFSSL_TEST_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_TEST_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_TEST_API to enable src/api.c testing */
WOLFSSL_TEST_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_TEST_API to enable src/api.c testing */
WOLFSSL_TEST_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_TEST_API to enable src/api.c testing */
WOLFSSL_TEST_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_TEST_API to use this function in tests/api.c */
WOLFSSL_TEST_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_TEST_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_TEST_API to use this function in tests/api.c */
WOLFSSL_TEST_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_TEST_API extern CRYPTO_EX_cb_ctx* crypto_ex_cb_ctx_session;
WOLFSSL_TEST_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

@@ -51,10 +51,10 @@
#define WOLFSSL_LOCAL
#endif /* HAVE_VISIBILITY */
#ifdef WOLFSSL_LOCALIZE_TEST_APIS
#define WOLFSSL_TEST_API WOLFSSL_LOCAL
#ifdef WOLFSSL_PRIVATE_TEST_VIS
#define WOLFSSL_TEST_VIS WOLFSSL_LOCAL
#else
#define WOLFSSL_TEST_API WOLFSSL_API
#define WOLFSSL_TEST_VIS WOLFSSL_API
#endif
#else /* !BUILDING_WOLFSSL */
#if defined(__WATCOMC__)
@@ -77,12 +77,13 @@
#define WOLFSSL_LOCAL
#endif
#ifdef WOLFSSL_LOCALIZE_TEST_APIS
#define WOLFSSL_TEST_API WOLFSSL_LOCAL WC_DEPRECATED
#elif defined(WOLFSSL_ALLOW_TEST_APIS)
#define WOLFSSL_TEST_API WOLFSSL_API
#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_API WOLFSSL_API WC_DEPRECATED
#define WOLFSSL_TEST_VIS WOLFSSL_API WC_DEPRECATED("internal use only")
#endif
#endif /* !BUILDING_WOLFSSL */

View File

@@ -83,12 +83,21 @@
#endif /* !WC_MAYBE_UNUSED */
#ifndef WC_DEPRECATED
#if !defined(WOLFSSL_ZEPHYR) && \
((defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) || \
defined(__IAR_SYSTEMS_ICC__))
#define WC_DEPRECATED __attribute__((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
#define WC_DEPRECATED(msg) /* null expansion */
#endif
#endif /* !WC_MAYBE_UNUSED */