1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-15 19:08:07 +00:00

refactor(core): remove hash_processor syscalls

[no changelog]
This commit is contained in:
cepetr 2024-09-30 08:39:38 +02:00 committed by cepetr
parent 0312158aa1
commit be59a09a4c
5 changed files with 5 additions and 60 deletions

View File

@ -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)

View File

@ -3,6 +3,8 @@
#include <stdint.h>
#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

View File

@ -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);

View File

@ -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,

View File

@ -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
// =============================================================================