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
6 changes: 6 additions & 0 deletions include/wolfboot/wcs_pkcs11.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,5 +343,11 @@ CK_RV CSME_NSE_API C_GetFunctionStatus_nsc_call(CK_SESSION_HANDLE hSession);
CK_RV CSME_NSE_API C_CancelFunction_nsc_call(CK_SESSION_HANDLE hSession);
CK_RV CSME_NSE_API C_WaitForSlotEvent_nsc_call(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserved);

#ifdef PKCS11_STORE_STATS
CK_RV CSME_NSE_API C_StoreGetStats_nsc_call(uint32_t *pCommits,
uint32_t *pErases, uint32_t *pPrograms);
CK_RV CSME_NSE_API C_StoreResetStats_nsc_call(void);
#endif

#endif /* SECURE_PKCS11 */
#endif /* !WOLFBOOT_PKCS11_H */
4 changes: 4 additions & 0 deletions options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,10 @@ ifeq ($(WOLFBOOT_DICE_HW),1)
endif
endif

ifeq ($(PKCS11_STORE_STATS),1)
CFLAGS+=-DPKCS11_STORE_STATS
endif

ifeq ($(WOLFCRYPT_TZ_PKCS11),1)
CFLAGS+=-DSECURE_PKCS11
CFLAGS+=-DWOLFPKCS11_USER_SETTINGS
Expand Down
24 changes: 24 additions & 0 deletions src/pkcs11_callable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,30 @@ CK_RV CSME_NSE_API C_CancelFunction_nsc_call(CK_SESSION_HANDLE hSession)
return C_CancelFunction(hSession);
}

#ifdef PKCS11_STORE_STATS
/* Flash-activity counters, implemented in src/pkcs11_store.c (the wolfBoot
* store backend); declared here to keep the wolfPKCS11 submodule untouched. */
void wolfPKCS11_Store_GetStats(uint32_t *commits, uint32_t *erases,
uint32_t *programs);
void wolfPKCS11_Store_ResetStats(void);

CK_RV CSME_NSE_API C_StoreGetStats_nsc_call(uint32_t *pCommits,
uint32_t *pErases, uint32_t *pPrograms)
{
NSC_CHK(ns_ok(pCommits, sizeof(uint32_t)));
NSC_CHK(ns_ok(pErases, sizeof(uint32_t)));
NSC_CHK(ns_ok(pPrograms, sizeof(uint32_t)));
wolfPKCS11_Store_GetStats(pCommits, pErases, pPrograms);
return CKR_OK;
}

CK_RV CSME_NSE_API C_StoreResetStats_nsc_call(void)
{
wolfPKCS11_Store_ResetStats();
return CKR_OK;
}
#endif

CK_RV CSME_NSE_API C_WaitForSlotEvent_nsc_call(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserved)
{
/* pReserved must be NULL; the underlying call rejects anything else. */
Expand Down
Loading
Loading