1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-15 20:19:23 +00:00

chore(core/embed): fixup sha256 context type name

[no changelog]
This commit is contained in:
Roman Zeyde 2024-10-15 17:15:50 +03:00 committed by TychoVrahe
parent f1e01edfcb
commit da7ddd5c8c
5 changed files with 15 additions and 15 deletions

View File

@ -9,7 +9,7 @@
#define IMAGE_HASH_DIGEST_LENGTH SHA256_DIGEST_LENGTH #define IMAGE_HASH_DIGEST_LENGTH SHA256_DIGEST_LENGTH
#ifdef USE_HASH_PROCESSOR #ifdef USE_HASH_PROCESSOR
#include "hash_processor.h" #include "hash_processor.h"
#define IMAGE_HASH_CTX hash_sha265_context_t #define IMAGE_HASH_CTX hash_sha256_context_t
#define IMAGE_HASH_INIT(ctx) hash_processor_sha256_init(ctx) #define IMAGE_HASH_INIT(ctx) hash_processor_sha256_init(ctx)
#define IMAGE_HASH_UPDATE(ctx, data, len) \ #define IMAGE_HASH_UPDATE(ctx, data, len) \
hash_processor_sha256_update(ctx, data, len) hash_processor_sha256_update(ctx, data, len)

View File

@ -8,7 +8,7 @@
typedef struct { typedef struct {
uint32_t length; /*!< nb bytes in buffer */ uint32_t length; /*!< nb bytes in buffer */
uint8_t buffer[HASH_SHA256_BUFFER_SIZE]; /*!< data being processed */ uint8_t buffer[HASH_SHA256_BUFFER_SIZE]; /*!< data being processed */
} hash_sha265_context_t; } hash_sha256_context_t;
#ifdef KERNEL_MODE #ifdef KERNEL_MODE
@ -25,13 +25,13 @@ void hash_processor_sha256_calc(const uint8_t *data, uint32_t len,
// Initialize the hash context // Initialize the hash context
// This serves for calculating hashes of multiple data blocks // This serves for calculating hashes of multiple data blocks
void hash_processor_sha256_init(hash_sha265_context_t *ctx); void hash_processor_sha256_init(hash_sha256_context_t *ctx);
// Feed the hash next chunk of data // Feed the hash next chunk of data
void hash_processor_sha256_update(hash_sha265_context_t *ctx, void hash_processor_sha256_update(hash_sha256_context_t *ctx,
const uint8_t *data, uint32_t len); const uint8_t *data, uint32_t len);
// Finalize the hash calculation, retrieve the digest // Finalize the hash calculation, retrieve the digest
void hash_processor_sha256_final(hash_sha265_context_t *ctx, uint8_t *output); void hash_processor_sha256_final(hash_sha256_context_t *ctx, uint8_t *output);
#endif #endif

View File

@ -120,17 +120,17 @@ __attribute((no_stack_protector)) void syscall_handler(uint32_t *args,
#ifdef STM32U5 #ifdef STM32U5
case SYSCALL_SHA256_INIT: { case SYSCALL_SHA256_INIT: {
hash_sha265_context_t *ctx = (hash_sha265_context_t *)args[0]; hash_sha256_context_t *ctx = (hash_sha256_context_t *)args[0];
hash_processor_sha256_init(ctx); hash_processor_sha256_init(ctx);
} break; } break;
case SYSCALL_SHA256_UPDATE: { case SYSCALL_SHA256_UPDATE: {
hash_sha265_context_t *ctx = (hash_sha265_context_t *)args[0]; hash_sha256_context_t *ctx = (hash_sha256_context_t *)args[0];
const uint8_t *data = (const uint8_t *)args[1]; const uint8_t *data = (const uint8_t *)args[1];
uint32_t len = args[2]; uint32_t len = args[2];
hash_processor_sha256_update(ctx, data, len); hash_processor_sha256_update(ctx, data, len);
} break; } break;
case SYSCALL_SHA256_FINAL: { case SYSCALL_SHA256_FINAL: {
hash_sha265_context_t *ctx = (hash_sha265_context_t *)args[0]; hash_sha256_context_t *ctx = (hash_sha256_context_t *)args[0];
uint8_t *output = (uint8_t *)args[1]; uint8_t *output = (uint8_t *)args[1];
hash_processor_sha256_final(ctx, output); hash_processor_sha256_final(ctx, output);
} break; } break;

View File

@ -104,18 +104,18 @@ void reboot_device(void) {
#include "hash_processor.h" #include "hash_processor.h"
void hash_processor_sha256_init(hash_sha265_context_t *ctx) { void hash_processor_sha256_init(hash_sha256_context_t *ctx) {
syscall_invoke1((uint32_t)ctx, SYSCALL_SHA256_INIT); syscall_invoke1((uint32_t)ctx, SYSCALL_SHA256_INIT);
} }
// Feed the hash next chunk of data // Feed the hash next chunk of data
void hash_processor_sha256_update(hash_sha265_context_t *ctx, void hash_processor_sha256_update(hash_sha256_context_t *ctx,
const uint8_t *data, uint32_t len) { const uint8_t *data, uint32_t len) {
syscall_invoke3((uint32_t)ctx, (uint32_t)data, len, SYSCALL_SHA256_UPDATE); syscall_invoke3((uint32_t)ctx, (uint32_t)data, len, SYSCALL_SHA256_UPDATE);
} }
// Finalize the hash calculation, retrieve the digest // Finalize the hash calculation, retrieve the digest
void hash_processor_sha256_final(hash_sha265_context_t *ctx, uint8_t *output) { void hash_processor_sha256_final(hash_sha256_context_t *ctx, uint8_t *output) {
syscall_invoke2((uint32_t)ctx, (uint32_t)output, SYSCALL_SHA256_FINAL); syscall_invoke2((uint32_t)ctx, (uint32_t)output, SYSCALL_SHA256_FINAL);
} }

View File

@ -83,11 +83,11 @@ void hash_processor_sha256_calc(const uint8_t *data, uint32_t len,
} }
} }
void hash_processor_sha256_init(hash_sha265_context_t *ctx) { void hash_processor_sha256_init(hash_sha256_context_t *ctx) {
memzero(ctx, sizeof(hash_sha265_context_t)); memzero(ctx, sizeof(hash_sha256_context_t));
} }
void hash_processor_sha256_update(hash_sha265_context_t *ctx, void hash_processor_sha256_update(hash_sha256_context_t *ctx,
const uint8_t *data, uint32_t len) { const uint8_t *data, uint32_t len) {
if (ctx->length > 0) { if (ctx->length > 0) {
uint32_t chunk = HASH_SHA256_BUFFER_SIZE - ctx->length; uint32_t chunk = HASH_SHA256_BUFFER_SIZE - ctx->length;
@ -122,7 +122,7 @@ void hash_processor_sha256_update(hash_sha265_context_t *ctx,
} }
} }
void hash_processor_sha256_final(hash_sha265_context_t *ctx, uint8_t *output) { void hash_processor_sha256_final(hash_sha256_context_t *ctx, uint8_t *output) {
uint32_t tmp_out[SHA256_DIGEST_LENGTH / sizeof(uint32_t)] = {0}; uint32_t tmp_out[SHA256_DIGEST_LENGTH / sizeof(uint32_t)] = {0};
memzero(ctx->buffer + ctx->length, HASH_SHA256_BUFFER_SIZE - ctx->length); memzero(ctx->buffer + ctx->length, HASH_SHA256_BUFFER_SIZE - ctx->length);
HAL_HASHEx_SHA256_Accmlt_End(&hhash, (uint8_t *)ctx->buffer, ctx->length, HAL_HASHEx_SHA256_Accmlt_End(&hhash, (uint8_t *)ctx->buffer, ctx->length,