diff --git a/core/embed/lib/image_hash_conf.h b/core/embed/lib/image_hash_conf.h index 62756e84c9..e8108070c7 100644 --- a/core/embed/lib/image_hash_conf.h +++ b/core/embed/lib/image_hash_conf.h @@ -7,7 +7,7 @@ #ifdef IMAGE_HASH_SHA256 #include "sha2.h" #define IMAGE_HASH_DIGEST_LENGTH SHA256_DIGEST_LENGTH -#ifdef USE_HASH_PROCESSOR +#if defined(USE_HASH_PROCESSOR) && defined(KERNEL_MODE) #include "hash_processor.h" #define IMAGE_HASH_CTX hash_sha256_context_t #define IMAGE_HASH_INIT(ctx) hash_processor_sha256_init(ctx) diff --git a/core/embed/trezorhal/hash_processor.h b/core/embed/trezorhal/hash_processor.h index 59b6194b45..c7a84a4e68 100644 --- a/core/embed/trezorhal/hash_processor.h +++ b/core/embed/trezorhal/hash_processor.h @@ -3,6 +3,8 @@ #include +#ifdef KERNEL_MODE + #define HASH_SHA256_BUFFER_SIZE 4 typedef struct { @@ -34,4 +36,6 @@ void hash_processor_sha256_update(hash_sha256_context_t *ctx, // Finalize the hash calculation, retrieve the digest void hash_processor_sha256_final(hash_sha256_context_t *ctx, uint8_t *output); +#endif // KERNEL_MODE + #endif diff --git a/core/embed/trezorhal/stm32f4/syscall_dispatch.c b/core/embed/trezorhal/stm32f4/syscall_dispatch.c index a6fd697ec2..abd2839595 100644 --- a/core/embed/trezorhal/stm32f4/syscall_dispatch.c +++ b/core/embed/trezorhal/stm32f4/syscall_dispatch.c @@ -29,7 +29,6 @@ #include "entropy.h" #include "fwutils.h" #include "haptic.h" -#include "hash_processor.h" #include "irq.h" #include "mpu.h" #include "optiga.h" @@ -130,33 +129,6 @@ __attribute((no_stack_protector)) void syscall_handler(uint32_t *args, reboot_and_upgrade(hash); } break; -#ifdef STM32U5 - case SYSCALL_SHA256_INIT: { - hash_sha256_context_t *ctx = (hash_sha256_context_t *)args[0]; - hash_processor_sha256_init(ctx); - } break; - - case SYSCALL_SHA256_UPDATE: { - hash_sha256_context_t *ctx = (hash_sha256_context_t *)args[0]; - const uint8_t *data = (const uint8_t *)args[1]; - uint32_t len = args[2]; - hash_processor_sha256_update(ctx, data, len); - } break; - - case SYSCALL_SHA256_FINAL: { - hash_sha256_context_t *ctx = (hash_sha256_context_t *)args[0]; - uint8_t *output = (uint8_t *)args[1]; - hash_processor_sha256_final(ctx, output); - } break; - - case SYSCALL_SHA256_CALC: { - const uint8_t *data = (const uint8_t *)args[0]; - uint32_t len = args[1]; - uint8_t *hash = (uint8_t *)args[2]; - hash_processor_sha256_calc(data, len, hash); - } break; -#endif // STM32U5 - case SYSCALL_DISPLAY_SET_BACKLIGHT: { int level = (int)args[0]; args[0] = display_set_backlight(level); diff --git a/core/embed/trezorhal/stm32f4/syscall_numbers.h b/core/embed/trezorhal/stm32f4/syscall_numbers.h index 0e6138bc9d..17da29be1a 100644 --- a/core/embed/trezorhal/stm32f4/syscall_numbers.h +++ b/core/embed/trezorhal/stm32f4/syscall_numbers.h @@ -37,11 +37,6 @@ typedef enum { SYSCALL_REBOOT_TO_BOOTLOADER, SYSCALL_REBOOT_AND_UPGRADE, - SYSCALL_SHA256_INIT, - SYSCALL_SHA256_UPDATE, - SYSCALL_SHA256_FINAL, - SYSCALL_SHA256_CALC, - SYSCALL_DISPLAY_SET_BACKLIGHT, SYSCALL_DISPLAY_GET_BACKLIGHT, SYSCALL_DISPLAY_SET_ORIENTATION, diff --git a/core/embed/trezorhal/stm32f4/syscall_stubs.c b/core/embed/trezorhal/stm32f4/syscall_stubs.c index 792523f6df..5c756247e4 100644 --- a/core/embed/trezorhal/stm32f4/syscall_stubs.c +++ b/core/embed/trezorhal/stm32f4/syscall_stubs.c @@ -98,32 +98,6 @@ void reboot_device(void) { ; } -// ============================================================================= -// hash_processor.h -// ============================================================================= - -#include "hash_processor.h" - -void hash_processor_sha256_init(hash_sha256_context_t *ctx) { - syscall_invoke1((uint32_t)ctx, SYSCALL_SHA256_INIT); -} - -// Feed the hash next chunk of data -void hash_processor_sha256_update(hash_sha256_context_t *ctx, - const uint8_t *data, uint32_t len) { - syscall_invoke3((uint32_t)ctx, (uint32_t)data, len, SYSCALL_SHA256_UPDATE); -} - -// Finalize the hash calculation, retrieve the digest -void hash_processor_sha256_final(hash_sha256_context_t *ctx, uint8_t *output) { - syscall_invoke2((uint32_t)ctx, (uint32_t)output, SYSCALL_SHA256_FINAL); -} - -void hash_processor_sha256_calc(const uint8_t *data, uint32_t len, - uint8_t *hash) { - syscall_invoke3((uint32_t)data, len, (uint32_t)hash, SYSCALL_SHA256_CALC); -} - // ============================================================================= // xdisplay.h // =============================================================================