Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 6 additions & 4 deletions doc/dox_comments/header_files/ecc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3405,13 +3405,14 @@ int wc_ecc_set_custom_curve(ecc_key* key, const ecc_set_type* dp);
\return ecEncCtx pointer on success
\return NULL on failure

\param flags Context flags
\param flags Either REQ_RESP_CLIENT or REQ_RESP_SERVER; any other
value fails and NULL is returned
\param rng Random number generator

_Example_
\code
WC_RNG rng;
ecEncCtx* ctx = wc_ecc_ctx_new(0, &rng);
ecEncCtx* ctx = wc_ecc_ctx_new(REQ_RESP_CLIENT, &rng);
\endcode

\sa wc_ecc_ctx_free
Expand All @@ -3425,14 +3426,15 @@ ecEncCtx* wc_ecc_ctx_new(int flags, WC_RNG* rng);
\return ecEncCtx pointer on success
\return NULL on failure

\param flags Context flags
\param flags Either REQ_RESP_CLIENT or REQ_RESP_SERVER; any other
value fails and NULL is returned
\param rng Random number generator
\param heap Heap hint

_Example_
\code
WC_RNG rng;
ecEncCtx* ctx = wc_ecc_ctx_new_ex(0, &rng, NULL);
ecEncCtx* ctx = wc_ecc_ctx_new_ex(REQ_RESP_CLIENT, &rng, NULL);
\endcode

\sa wc_ecc_ctx_new
Expand Down
5 changes: 5 additions & 0 deletions tests/api/test_ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2121,7 +2121,12 @@ int test_wc_ecc_ctx_new(void)
/* Test bad args. */
/* wc_ecc_ctx_new_ex() will free if returned NULL. */
ExpectNull(cli = wc_ecc_ctx_new(0, &rng));
ExpectNull(cli = wc_ecc_ctx_new(100, &rng));
ExpectNull(cli = wc_ecc_ctx_new(-3, &rng));
/* Must not be truncated to a valid (byte) flag value. */
ExpectNull(cli = wc_ecc_ctx_new(REQ_RESP_CLIENT + 256, &rng));
ExpectNull(cli = wc_ecc_ctx_new(REQ_RESP_CLIENT, NULL));
ExpectNull(cli = wc_ecc_ctx_new(REQ_RESP_CLIENT | REQ_RESP_SERVER, &rng));

DoExpectIntEQ(wc_FreeRng(&rng), 0);
wc_ecc_ctx_free(cli);
Expand Down
9 changes: 7 additions & 2 deletions wolfcrypt/src/ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15710,9 +15710,14 @@ int wc_ecc_ctx_reset(ecEncCtx* ctx, WC_RNG* rng)
ecEncCtx* wc_ecc_ctx_new_ex(int flags, WC_RNG* rng, void* heap)
{
int ret = 0;
ecEncCtx* ctx = (ecEncCtx*)XMALLOC(sizeof(ecEncCtx), heap,
DYNAMIC_TYPE_ECC);
ecEncCtx* ctx;

if (flags != REQ_RESP_SERVER && flags != REQ_RESP_CLIENT) {
WOLFSSL_MSG("Bad flag passed to wc_ecc_ctx_new_ex");
return NULL;
}

ctx = (ecEncCtx*)XMALLOC(sizeof(ecEncCtx), heap, DYNAMIC_TYPE_ECC);
if (ctx) {
ctx->protocol = (byte)flags;
ctx->heap = heap;
Expand Down
Loading