mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 10:40:52 +02:00
swdev: pair internal wolfCrypt_Init() with wolfCrypt_Cleanup()
This commit is contained in:
@@ -116,10 +116,12 @@ $(BUILDDIR)/swdev.o: $(BUILDDIR)/swdev.partial.o
|
||||
@# visibility("default") and overrides the command-line
|
||||
@# -fvisibility=hidden. --keep-global-symbol sidesteps that by matching
|
||||
@# on symbol name directly.
|
||||
$(OBJCOPY) --keep-global-symbol=wc_SwDev_Callback $< $@
|
||||
@# Sanity-check: only wc_SwDev_Callback may be externally visible.
|
||||
$(OBJCOPY) --keep-global-symbol=wc_SwDev_Callback \
|
||||
--keep-global-symbol=wc_SwDev_InternalCleanup $< $@
|
||||
@# Sanity-check: only the two swdev entry points may be externally visible.
|
||||
@visible=$$( $(NM) --extern-only --defined-only $@ | awk '{print $$3}' \
|
||||
| grep -v '^wc_SwDev_Callback$$' || true); \
|
||||
| grep -v '^wc_SwDev_Callback$$' \
|
||||
| grep -v '^wc_SwDev_InternalCleanup$$' || true); \
|
||||
if [ -n "$$visible" ]; then \
|
||||
echo "error: unexpected externally-visible symbols in $@:"; \
|
||||
echo "$$visible"; \
|
||||
|
||||
@@ -54,6 +54,14 @@ static int swdev_ensure_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
WC_SWDEV_EXPORT void wc_SwDev_InternalCleanup(void)
|
||||
{
|
||||
if (swdev_initialized) {
|
||||
wolfCrypt_Cleanup();
|
||||
swdev_initialized = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NO_RSA
|
||||
static int swdev_rsa(wc_CryptoInfo* info)
|
||||
{
|
||||
|
||||
+2
-1
@@ -38,8 +38,9 @@ extern "C" {
|
||||
#define WC_SWDEV_EXPORT
|
||||
#endif
|
||||
|
||||
WC_SWDEV_EXPORT int wc_SwDev_Callback(int devId, wc_CryptoInfo* info,
|
||||
WC_SWDEV_EXPORT int wc_SwDev_Callback(int devId, wc_CryptoInfo* info,
|
||||
void* ctx);
|
||||
WC_SWDEV_EXPORT void wc_SwDev_InternalCleanup(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
#endif
|
||||
|
||||
/* resolved at link time from swdev.o */
|
||||
extern int wc_SwDev_Callback(int devId, wc_CryptoInfo* info, void* ctx);
|
||||
extern int wc_SwDev_Callback(int devId, wc_CryptoInfo* info, void* ctx);
|
||||
extern void wc_SwDev_InternalCleanup(void);
|
||||
|
||||
/* Init always (re)registers because wolfCrypt_Cleanup wipes the cryptocb
|
||||
* table; only the final Cleanup unregisters. */
|
||||
@@ -61,6 +62,7 @@ void wc_SwDev_Cleanup(void)
|
||||
wc_CryptoCb_SetDeviceFindCb(NULL);
|
||||
#endif
|
||||
wc_CryptoCb_UnRegisterDevice(WC_SWDEV_ID);
|
||||
wc_SwDev_InternalCleanup();
|
||||
}
|
||||
else if (my_refCount < 0) {
|
||||
/* called more times than Init; restore floor */
|
||||
|
||||
Reference in New Issue
Block a user