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
2 changes: 1 addition & 1 deletion doc/dox_comments/header_files-ja/wc_she.h
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ int wc_SHE_LoadKey_Verify_Label(
\brief ハードウェアから鍵をSHEのロード可能な形式(M1〜M5)でエクスポートします。一部のHSMでは特定の鍵スロット(例: RAM鍵)のエクスポートが許可されており、後からSHEの鍵更新プロトコルで再ロードできます。WOLF_CRYPTO_CBが有効で、かつNO_WC_SHE_EXPORTKEYが定義されていないことが必要です。出力バッファはいずれもNULLにでき、その場合そのメッセージはスキップされます。

\return 0 成功した場合に返されます
\return BAD_FUNC_ARG sheがNULLの場合に返されます
\return BAD_FUNC_ARG sheがNULLの場合、またはNULLでない出力バッファのサイズがそのメッセージのサイズより小さい場合に返されます
\return CRYPTOCB_UNAVAILABLE コールバックが登録されていない場合に返されます

\param she 初期化済みのSHEコンテキスト
Expand Down
3 changes: 2 additions & 1 deletion doc/dox_comments/header_files/wc_she.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,8 @@ int wc_SHE_LoadKey_Verify_Label(
output buffer may be NULL to skip that message.

\return 0 on success
\return BAD_FUNC_ARG if she is NULL
\return BAD_FUNC_ARG if she is NULL, or a non-NULL output buffer is
smaller than its message size
\return CRYPTOCB_UNAVAILABLE if no callback is registered

\param she initialized SHE context
Expand Down
30 changes: 30 additions & 0 deletions tests/api/test_she.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,36 @@ int test_wc_SHE_CryptoCb(void)
em3, WC_SHE_M3_SZ, em4, WC_SHE_M4_SZ,
em5, WC_SHE_M5_SZ, NULL),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
ExpectIntEQ(wc_SHE_ExportKey(&she,
em1, WC_SHE_M1_SZ - 1, em2, WC_SHE_M2_SZ,
em3, WC_SHE_M3_SZ, em4, WC_SHE_M4_SZ,
em5, WC_SHE_M5_SZ, NULL),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
ExpectIntEQ(wc_SHE_ExportKey(&she,
em1, WC_SHE_M1_SZ, em2, WC_SHE_M2_SZ - 1,
em3, WC_SHE_M3_SZ, em4, WC_SHE_M4_SZ,
em5, WC_SHE_M5_SZ, NULL),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
ExpectIntEQ(wc_SHE_ExportKey(&she,
em1, WC_SHE_M1_SZ, em2, WC_SHE_M2_SZ,
em3, WC_SHE_M3_SZ - 1, em4, WC_SHE_M4_SZ,
em5, WC_SHE_M5_SZ, NULL),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
ExpectIntEQ(wc_SHE_ExportKey(&she,
em1, WC_SHE_M1_SZ, em2, WC_SHE_M2_SZ,
em3, WC_SHE_M3_SZ, em4, WC_SHE_M4_SZ - 1,
em5, WC_SHE_M5_SZ, NULL),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
ExpectIntEQ(wc_SHE_ExportKey(&she,
em1, WC_SHE_M1_SZ, em2, WC_SHE_M2_SZ,
em3, WC_SHE_M3_SZ, em4, WC_SHE_M4_SZ,
em5, WC_SHE_M5_SZ - 1, NULL),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));

/* NULL buffers skip that message, so their size is not checked */
ExpectIntEQ(wc_SHE_ExportKey(&she,
NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL),
0);
}
#endif

Expand Down
10 changes: 7 additions & 3 deletions wolfcrypt/src/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ int wolfAsync_DevOpenThread(int *pDevId, void* threadId)
int ret = 0;
int devId = INVALID_DEVID;

if (pDevId == NULL)
return BAD_FUNC_ARG;

#ifdef HAVE_CAVIUM
ret = NitroxOpenDeviceDefault();
if (ret >= 0)
Expand All @@ -363,9 +366,7 @@ int wolfAsync_DevOpenThread(int *pDevId, void* threadId)

(void)threadId;

/* return devId if requested */
if (*pDevId)
*pDevId = devId;
*pDevId = devId;

return ret;
}
Expand Down Expand Up @@ -989,6 +990,9 @@ int wc_AsyncThreadCreate_ex(pthread_t *thread,
pthread_attr_t attr;
struct sched_param param;

if (thread == NULL || function == NULL)
return BAD_FUNC_ARG;

status = pthread_attr_init(&attr);
if (status !=0) {
fprintf(stderr, "pthread_attr_init error: %d\n", status);
Expand Down
7 changes: 6 additions & 1 deletion wolfcrypt/src/wc_she.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,12 @@ int wc_SHE_ExportKey(wc_SHE* she,
byte* m5, word32 m5Sz,
const void* ctx)
{
if (she == NULL) {
if (she == NULL ||
(m1 != NULL && m1Sz < WC_SHE_M1_SZ) ||
(m2 != NULL && m2Sz < WC_SHE_M2_SZ) ||
(m3 != NULL && m3Sz < WC_SHE_M3_SZ) ||
(m4 != NULL && m4Sz < WC_SHE_M4_SZ) ||
(m5 != NULL && m5Sz < WC_SHE_M5_SZ)) {
return BAD_FUNC_ARG;
}

Expand Down
Loading