mirror of https://github.com/wolfSSL/wolfBoot.git
F-12114: pkcs11: wipe the login PIN on all pre-handoff paths
pkcs11_crypto_deinit() - the only caller of pkcs11_pin_wipe() - was invoked from the update_flash path alone (src/update_flash.c:1715). On the RAMBOOT, hwswap and disk pre-handoff paths the PKCS#11 login credential stayed in retained bootloader memory after handoff. Add the same #ifdef ENCRYPT_PKCS11 deinit block after the WOLFHSM cleanup in src/update_ram.c, src/update_flash_hwswap.c and src/update_disk.c, in the same position as the existing update_flash call (before hal_flash_protect/hal_prepare_boot). update_ram.c and update_flash_hwswap.c did not include encrypt.h, where pkcs11_crypto_deinit() is declared - add the include (update_flash.c and update_disk.c already had it). The deinit is a no-op when crypto was never initialized, so the calls are safe on every build. Verification: full build with PKCS11 enabled (sim config + CFLAGS_EXTRA: ENCRYPT_PKCS11, EXT_ENCRYPTED, EXT_FLASH, WOLFCRYPT_SECURE_MODE, SECURE_PKCS11, WOLFPKCS11_USER_SETTINGS + mechanism/sizes/PIN) compiles all sources cleanly; the link stops on pre-existing externals (token library + secure-mode wolfssl objects that a real target's link config supplies) - a control build of the unpatched tree fails identically with the same undefined-symbol set. sim and kontron_vx3060_s2 builds green (PKCS11 disabled, hunks inactive). cstyle clean on the changed hunks.pull/880/head
parent
6dabdad01e
commit
b548341e9b
|
|
@ -928,6 +928,10 @@ void RAMFUNCTION wolfBoot_start(void)
|
|||
#elif defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER)
|
||||
(void)hal_hsm_server_cleanup();
|
||||
#endif
|
||||
|
||||
#ifdef ENCRYPT_PKCS11
|
||||
pkcs11_crypto_deinit();
|
||||
#endif
|
||||
#ifndef TZEN
|
||||
if (hal_flash_protect(WOLFBOOT_ORIGIN, BOOTLOADER_PARTITION_SIZE) < 0) {
|
||||
wolfBoot_printf("Error protecting bootloader flash region\r\n");
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "spi_flash.h"
|
||||
#include "wolfboot/wolfboot.h"
|
||||
#include "printf.h"
|
||||
#include "encrypt.h"
|
||||
#ifdef SECURE_PKCS11
|
||||
int WP11_Library_Init(void);
|
||||
#endif
|
||||
|
|
@ -125,6 +126,10 @@ void RAMFUNCTION wolfBoot_start(void)
|
|||
#elif defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER)
|
||||
(void)hal_hsm_server_cleanup();
|
||||
#endif
|
||||
|
||||
#ifdef ENCRYPT_PKCS11
|
||||
pkcs11_crypto_deinit();
|
||||
#endif
|
||||
#ifndef TZEN
|
||||
if (hal_flash_protect(WOLFBOOT_ORIGIN, BOOTLOADER_PARTITION_SIZE) < 0)
|
||||
boot_panic();
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "printf.h"
|
||||
#include "wolfboot/wolfboot.h"
|
||||
#include <string.h>
|
||||
#include "encrypt.h"
|
||||
|
||||
#ifdef WOLFBOOT_UBOOT_LEGACY
|
||||
#include "gpt.h" /* gpt_crc32_* helpers (reflected CRC-32, poly 0xEDB88320) */
|
||||
|
|
@ -807,6 +808,10 @@ backup_on_failure:
|
|||
(void)hal_hsm_server_cleanup();
|
||||
#endif
|
||||
|
||||
#ifdef ENCRYPT_PKCS11
|
||||
pkcs11_crypto_deinit();
|
||||
#endif
|
||||
|
||||
#ifndef TZEN
|
||||
if (hal_flash_protect(WOLFBOOT_ORIGIN, BOOTLOADER_PARTITION_SIZE) < 0) {
|
||||
wolfBoot_printf("Error protecting bootloader flash region\n");
|
||||
|
|
|
|||
Loading…
Reference in New Issue