mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
add X509_STORE_get/set_ex_data
This commit is contained in:
42
src/ssl.c
42
src/ssl.c
@ -26017,7 +26017,47 @@ void wolfSSL_X509_STORE_free(WOLFSSL_X509_STORE* store)
|
||||
XFREE(store, NULL, DYNAMIC_TYPE_X509_STORE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ex_data in WOLFSSL_STORE at given index
|
||||
* @param store a pointer to WOLFSSL_X509_STORE structure
|
||||
* @param idx Index of ex_data to get data from
|
||||
* @return void pointer to ex_data on success or NLL on failure
|
||||
*/
|
||||
void* wolfSSL_X509_STORE_get_ex_data(WOLFSSL_X509_STORE* store, int idx)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_X509_STORE_get_ex_data");
|
||||
#ifdef HAVE_EX_DATA
|
||||
if (store != NULL && idx < MAX_EX_DATA && idx >= 0) {
|
||||
return wolfSSL_CRYPTO_get_ex_data(&store->ex_data, idx);
|
||||
}
|
||||
#else
|
||||
(void)store;
|
||||
(void)idx;
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
/**
|
||||
* Set ex_data for WOLFSSL_STORE
|
||||
* @param store a pointer to WOLFSSL_X509_STORE structure
|
||||
* @param idx Index of ex data to set
|
||||
* @param data Data to set in ex data
|
||||
* @return WOLFSSL_SUCCESS on success or WOLFSSL_FAILURE on failure
|
||||
*/
|
||||
int wolfSSL_X509_STORE_set_ex_data(WOLFSSL_X509_STORE* store, int idx,
|
||||
void *data)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_X509_STORE_set_ex_data");
|
||||
#ifdef HAVE_EX_DATA
|
||||
if (store != NULL && idx < MAX_EX_DATA) {
|
||||
return wolfSSL_CRYPTO_set_ex_data(&store->ex_data, idx, data);
|
||||
}
|
||||
#else
|
||||
(void)store;
|
||||
(void)idx;
|
||||
(void)data;
|
||||
#endif
|
||||
return WOLFSSL_FAILURE;
|
||||
}
|
||||
#endif /* OPENSSL_EXTRA || WOLFSSL_WPAS_SMALL */
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
|
22
tests/api.c
22
tests/api.c
@ -28455,6 +28455,28 @@ static void test_wolfSSL_X509_STORE_CTX(void)
|
||||
X509_STORE_CTX_free(ctx);
|
||||
}
|
||||
|
||||
/* test X509_STORE_get/set_ex_data */
|
||||
{
|
||||
int i = 0, tmpData = 99;
|
||||
void* tmpDataRet;
|
||||
AssertNotNull(str = X509_STORE_new());
|
||||
#if defined(HAVE_EX_DATA)
|
||||
for (i = 0; i < MAX_EX_DATA; i++) {
|
||||
AssertIntEQ(X509_STORE_set_ex_data(str, i, &tmpData),
|
||||
WOLFSSL_SUCCESS);
|
||||
tmpDataRet = (int*)X509_STORE_get_ex_data(str, i);
|
||||
AssertNotNull(tmpDataRet);
|
||||
AssertIntEQ(tmpData, *(int*)tmpDataRet);
|
||||
}
|
||||
#else
|
||||
AssertIntEQ(X509_STORE_set_ex_data(str, i, &tmpData),
|
||||
WOLFSSL_FAILURE);
|
||||
tmpDataRet = (int*)X509_STORE_get_ex_data(str, i);
|
||||
AssertNull(tmpDataRet);
|
||||
#endif
|
||||
X509_STORE_free(str);
|
||||
}
|
||||
|
||||
printf(resultFmt, passed);
|
||||
#endif /* defined(OPENSSL_EXTRA) && !defined(NO_CERTS) && \
|
||||
!defined(NO_FILESYSTEM) && !defined(NO_RSA) */
|
||||
|
@ -602,6 +602,8 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_
|
||||
#define X509_STORE_set_flags wolfSSL_X509_STORE_set_flags
|
||||
#define X509_STORE_get1_certs wolfSSL_X509_STORE_get1_certs
|
||||
#define X509_STORE_get_by_subject wolfSSL_X509_STORE_get_by_subject
|
||||
#define X509_STORE_set_ex_data wolfSSL_X509_STORE_set_ex_data
|
||||
#define X509_STORE_get_ex_data wolfSSL_X509_STORE_get_ex_data
|
||||
#define X509_STORE_CTX_get1_issuer wolfSSL_X509_STORE_CTX_get1_issuer
|
||||
#define X509_STORE_CTX_set_time wolfSSL_X509_STORE_CTX_set_time
|
||||
#define X509_VERIFY_PARAM_new wolfSSL_X509_VERIFY_PARAM_new
|
||||
|
@ -1667,6 +1667,10 @@ WOLFSSL_API void* wolfSSL_X509_STORE_CTX_get_ex_data(
|
||||
WOLFSSL_X509_STORE_CTX* ctx, int idx);
|
||||
WOLFSSL_API int wolfSSL_X509_STORE_CTX_set_ex_data(WOLFSSL_X509_STORE_CTX* ctx,
|
||||
int idx, void *data);
|
||||
WOLFSSL_API void* wolfSSL_X509_STORE_get_ex_data(
|
||||
WOLFSSL_X509_STORE* store, int idx);
|
||||
WOLFSSL_API int wolfSSL_X509_STORE_set_ex_data(WOLFSSL_X509_STORE* store,
|
||||
int idx, void *data);
|
||||
WOLFSSL_API void wolfSSL_X509_STORE_CTX_set_depth(WOLFSSL_X509_STORE_CTX* ctx,
|
||||
int depth);
|
||||
WOLFSSL_API WOLFSSL_X509* wolfSSL_X509_STORE_CTX_get0_current_issuer(
|
||||
|
Reference in New Issue
Block a user