Skip to content

Commit 96118b4

Browse files
committed
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().
1 parent cc223d1 commit 96118b4

4 files changed

Lines changed: 43 additions & 36 deletions

File tree

tests/unit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#ifndef TESTS_UNIT_H
2424
#define TESTS_UNIT_H
2525

26-
#define WOLFSSL_ALLOW_TEST_APIS
26+
#define WOLFSSL_VIS_FOR_TESTS
2727

2828
#ifdef HAVE_CONFIG_H
2929
#include <config.h>

wolfssl/internal.h

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,8 +2435,7 @@ typedef struct CipherSuite {
24352435
#endif
24362436
} CipherSuite;
24372437

2438-
/* use wolfSSL_TEST_API visibility to be able to test in tests/api.c */
2439-
WOLFSSL_TEST_API void InitSuitesHashSigAlgo(byte* hashSigAlgo, int have,
2438+
WOLFSSL_TEST_VIS void InitSuitesHashSigAlgo(byte* hashSigAlgo, int have,
24402439
int tls1_2, int keySz, word16* len);
24412440
WOLFSSL_LOCAL int AllocateCtxSuites(WOLFSSL_CTX* ctx);
24422441
WOLFSSL_LOCAL int AllocateSuites(WOLFSSL* ssl);
@@ -3396,7 +3395,7 @@ WOLFSSL_LOCAL int TLSX_CSR2_ForceRequest(WOLFSSL* ssl);
33963395
#if defined(WOLFSSL_PUBLIC_ASN) && defined(HAVE_PK_CALLBACKS)
33973396
/* Internal callback guarded by WOLFSSL_PUBLIC_ASN because of DecodedCert. */
33983397
typedef int (*CallbackProcessPeerCert)(WOLFSSL* ssl, DecodedCert* p_cert);
3399-
WOLFSSL_TEST_API void wolfSSL_CTX_SetProcessPeerCertCb(WOLFSSL_CTX* ctx,
3398+
WOLFSSL_TEST_VIS void wolfSSL_CTX_SetProcessPeerCertCb(WOLFSSL_CTX* ctx,
34003399
CallbackProcessPeerCert cb);
34013400
#endif /* DecodedCert && HAVE_PK_CALLBACKS */
34023401

@@ -4700,8 +4699,7 @@ WOLFSSL_LOCAL WOLFSSL_SESSION* wolfSSL_GetSession(
47004699
WOLFSSL* ssl, byte* masterSecret, byte restoreSessionCerts);
47014700
WOLFSSL_LOCAL void SetupSession(WOLFSSL* ssl);
47024701
WOLFSSL_LOCAL void AddSession(WOLFSSL* ssl);
4703-
/* use wolfSSL_API visibility to be able to test in tests/api.c */
4704-
WOLFSSL_TEST_API int AddSessionToCache(WOLFSSL_CTX* ctx,
4702+
WOLFSSL_TEST_VIS int AddSessionToCache(WOLFSSL_CTX* ctx,
47054703
WOLFSSL_SESSION* addSession, const byte* id, byte idSz, int* sessionIndex,
47064704
int side, word16 useTicket, ClientSession** clientCacheEntry);
47074705
#ifndef NO_CLIENT_CACHE
@@ -4717,8 +4715,8 @@ WOLFSSL_LOCAL int TlsSessionCacheGetAndRdLock(const byte *id,
47174715
WOLFSSL_LOCAL int TlsSessionCacheGetAndWrLock(const byte *id,
47184716
WOLFSSL_SESSION **sess, word32 *lockedRow, byte side);
47194717
WOLFSSL_LOCAL void EvictSessionFromCache(WOLFSSL_SESSION* session);
4720-
/* WOLFSSL_TEST_API to test it in tests/api.c */
4721-
WOLFSSL_TEST_API int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output);
4718+
/* WOLFSSL_TEST_VIS to test it in tests/api.c */
4719+
WOLFSSL_TEST_VIS int wolfSSL_GetSessionFromCache(WOLFSSL* ssl, WOLFSSL_SESSION* output);
47224720
WOLFSSL_LOCAL int wolfSSL_SetSession(WOLFSSL* ssl, WOLFSSL_SESSION* session);
47234721
WOLFSSL_LOCAL void wolfSSL_FreeSession(WOLFSSL_CTX* ctx,
47244722
WOLFSSL_SESSION* session);
@@ -6382,7 +6380,7 @@ WOLFSSL_LOCAL int SetSSL_CTX(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup);
63826380
WOLFSSL_LOCAL int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup);
63836381
WOLFSSL_LOCAL int ReinitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup);
63846382
WOLFSSL_LOCAL void FreeSSL(WOLFSSL* ssl, void* heap);
6385-
WOLFSSL_TEST_API void wolfSSL_ResourceFree(WOLFSSL* ssl); /* Micrium uses */
6383+
WOLFSSL_TEST_VIS void wolfSSL_ResourceFree(WOLFSSL* ssl); /* Micrium uses */
63866384
#ifndef OPENSSL_COEXIST
63876385
#define SSL_ResourceFree wolfSSL_ResourceFree
63886386
#endif
@@ -6748,18 +6746,18 @@ WOLFSSL_LOCAL word32 MacSize(const WOLFSSL* ssl);
67486746
#ifdef WOLFSSL_DTLS
67496747
WOLFSSL_LOCAL DtlsMsg* DtlsMsgNew(word32 sz, byte tx, void* heap);
67506748
WOLFSSL_LOCAL void DtlsMsgDelete(DtlsMsg* item, void* heap);
6751-
/* Use WOLFSSL_TEST_API to enable src/api.c testing */
6752-
WOLFSSL_TEST_API void DtlsMsgListDelete(DtlsMsg* head, void* heap);
6749+
/* Use WOLFSSL_TEST_VIS to enable src/api.c testing */
6750+
WOLFSSL_TEST_VIS void DtlsMsgListDelete(DtlsMsg* head, void* heap);
67536751
WOLFSSL_LOCAL void DtlsTxMsgListClean(WOLFSSL* ssl);
67546752
WOLFSSL_LOCAL int DtlsMsgSet(DtlsMsg* msg, word32 seq, word16 epoch,
67556753
const byte* data, byte type,
67566754
word32 fragOffset, word32 fragSz, void* heap,
67576755
word32 totalLen, byte encrypted);
6758-
/* Use WOLFSSL_TEST_API to enable src/api.c testing */
6759-
WOLFSSL_TEST_API DtlsMsg* DtlsMsgFind(DtlsMsg* head, word16 epoch, word32 seq);
6756+
/* Use WOLFSSL_TEST_VIS to enable src/api.c testing */
6757+
WOLFSSL_TEST_VIS DtlsMsg* DtlsMsgFind(DtlsMsg* head, word16 epoch, word32 seq);
67606758

6761-
/* Use WOLFSSL_TEST_API to enable src/api.c testing */
6762-
WOLFSSL_TEST_API void DtlsMsgStore(WOLFSSL* ssl, word16 epoch, word32 seq,
6759+
/* Use WOLFSSL_TEST_VIS to enable src/api.c testing */
6760+
WOLFSSL_TEST_VIS void DtlsMsgStore(WOLFSSL* ssl, word16 epoch, word32 seq,
67636761
const byte* data, word32 dataSz, byte type,
67646762
word32 fragOffset, word32 fragSz,
67656763
void* heap);
@@ -6949,8 +6947,8 @@ WOLFSSL_LOCAL int BuildMessage(WOLFSSL* ssl, byte* output, int outSz,
69496947
int sizeOnly, int asyncOkay, int epochOrder);
69506948

69516949
#ifdef WOLFSSL_TLS13
6952-
/* Use WOLFSSL_TEST_API to use this function in tests/api.c */
6953-
WOLFSSL_TEST_API int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
6950+
/* Use WOLFSSL_TEST_VIS to use this function in tests/api.c */
6951+
WOLFSSL_TEST_VIS int BuildTls13Message(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
69546952
int inSz, int type, int hashOutput, int sizeOnly, int asyncOkay);
69556953
WOLFSSL_LOCAL int Tls13UpdateKeys(WOLFSSL* ssl);
69566954
#endif
@@ -7007,7 +7005,7 @@ WOLFSSL_LOCAL word32 nid2oid(int nid, int grp);
70077005
#endif
70087006

70097007
#ifdef WOLFSSL_DTLS
7010-
WOLFSSL_TEST_API int wolfSSL_DtlsUpdateWindow(word16 cur_hi, word32 cur_lo,
7008+
WOLFSSL_TEST_VIS int wolfSSL_DtlsUpdateWindow(word16 cur_hi, word32 cur_lo,
70117009
word16* next_hi, word32* next_lo, word32 *window);
70127010
WOLFSSL_LOCAL int DtlsUpdateWindow(WOLFSSL* ssl);
70137011
WOLFSSL_LOCAL void DtlsResetState(WOLFSSL *ssl);
@@ -7017,8 +7015,8 @@ WOLFSSL_LOCAL void DtlsSetSeqNumForReply(WOLFSSL* ssl);
70177015

70187016
#ifdef WOLFSSL_DTLS13
70197017

7020-
/* Use WOLFSSL_TEST_API to use this function in tests/api.c */
7021-
WOLFSSL_TEST_API struct Dtls13Epoch* Dtls13GetEpoch(WOLFSSL* ssl,
7018+
/* Use WOLFSSL_TEST_VIS to use this function in tests/api.c */
7019+
WOLFSSL_TEST_VIS struct Dtls13Epoch* Dtls13GetEpoch(WOLFSSL* ssl,
70227020
w64wrapper epochNumber);
70237021
WOLFSSL_LOCAL void Dtls13SetOlderEpochSide(WOLFSSL* ssl, w64wrapper epochNumber,
70247022
int side);
@@ -7108,9 +7106,8 @@ typedef struct CRYPTO_EX_cb_ctx {
71087106
struct CRYPTO_EX_cb_ctx* next;
71097107
} CRYPTO_EX_cb_ctx;
71107108

7111-
/* use wolfSSL_API visibility to be able to clear in tests/api.c */
7112-
WOLFSSL_TEST_API extern CRYPTO_EX_cb_ctx* crypto_ex_cb_ctx_session;
7113-
WOLFSSL_TEST_API void crypto_ex_cb_free(CRYPTO_EX_cb_ctx* cb_ctx);
7109+
WOLFSSL_TEST_VIS extern CRYPTO_EX_cb_ctx* crypto_ex_cb_ctx_session;
7110+
WOLFSSL_TEST_VIS void crypto_ex_cb_free(CRYPTO_EX_cb_ctx* cb_ctx);
71147111
WOLFSSL_LOCAL void crypto_ex_cb_setup_new_data(void *new_obj,
71157112
CRYPTO_EX_cb_ctx* cb_ctx, WOLFSSL_CRYPTO_EX_DATA* ex_data);
71167113
WOLFSSL_LOCAL void crypto_ex_cb_free_data(void *obj, CRYPTO_EX_cb_ctx* cb_ctx,

wolfssl/wolfcrypt/visibility.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
#define WOLFSSL_LOCAL
5252
#endif /* HAVE_VISIBILITY */
5353

54-
#ifdef WOLFSSL_LOCALIZE_TEST_APIS
55-
#define WOLFSSL_TEST_API WOLFSSL_LOCAL
54+
#ifdef WOLFSSL_PRIVATE_TEST_VIS
55+
#define WOLFSSL_TEST_VIS WOLFSSL_LOCAL
5656
#else
57-
#define WOLFSSL_TEST_API WOLFSSL_API
57+
#define WOLFSSL_TEST_VIS WOLFSSL_API
5858
#endif
5959
#else /* !BUILDING_WOLFSSL */
6060
#if defined(__WATCOMC__)
@@ -77,12 +77,13 @@
7777
#define WOLFSSL_LOCAL
7878
#endif
7979

80-
#ifdef WOLFSSL_LOCALIZE_TEST_APIS
81-
#define WOLFSSL_TEST_API WOLFSSL_LOCAL WC_DEPRECATED
82-
#elif defined(WOLFSSL_ALLOW_TEST_APIS)
83-
#define WOLFSSL_TEST_API WOLFSSL_API
80+
#if defined(WOLFSSL_VIS_FOR_TESTS)
81+
#ifdef WOLFSSL_PRIVATE_TEST_VIS
82+
#error WOLFSSL_VIS_FOR_TESTS is unavailable in WOLFSSL_PRIVATE_TEST_VIS builds.
83+
#endif
84+
#define WOLFSSL_TEST_VIS WOLFSSL_API
8485
#else
85-
#define WOLFSSL_TEST_API WOLFSSL_API WC_DEPRECATED
86+
#define WOLFSSL_TEST_VIS WOLFSSL_API WC_DEPRECATED("internal use only")
8687
#endif
8788

8889
#endif /* !BUILDING_WOLFSSL */

wolfssl/wolfcrypt/wc_port.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,21 @@
8383
#endif /* !WC_MAYBE_UNUSED */
8484

8585
#ifndef WC_DEPRECATED
86-
#if !defined(WOLFSSL_ZEPHYR) && \
87-
((defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) || \
88-
defined(__IAR_SYSTEMS_ICC__))
89-
#define WC_DEPRECATED __attribute__((deprecated))
86+
#ifdef WOLFSSL_ZEPHYR
87+
#define WC_DEPRECATED(msg) /* null expansion */
88+
#elif ((defined(__GNUC__) && \
89+
((__GNUC__ >= 5) || \
90+
((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))) || \
91+
defined(__clang__)
92+
#define WC_DEPRECATED(msg) __attribute__((deprecated(msg)))
93+
#elif defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__) || \
94+
defined(_WIN32_WCE) || defined(__WATCOMC__)
95+
#define WC_DEPRECATED(msg) __declspec(deprecated(msg))
96+
#elif (defined(__GNUC__) && (__GNUC__ >= 4)) || \
97+
defined(__IAR_SYSTEMS_ICC__)
98+
#define WC_DEPRECATED(msg) __attribute__((deprecated))
9099
#else
91-
#define WC_DEPRECATED
100+
#define WC_DEPRECATED(msg) /* null expansion */
92101
#endif
93102
#endif /* !WC_MAYBE_UNUSED */
94103

0 commit comments

Comments
 (0)