Skip to content

Commit

Permalink
chore(core/embed): fixup sha256 context type name
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
romanz authored and TychoVrahe committed Oct 21, 2024
1 parent f1e01ed commit da7ddd5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion core/embed/lib/image_hash_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define IMAGE_HASH_DIGEST_LENGTH SHA256_DIGEST_LENGTH
#ifdef USE_HASH_PROCESSOR
#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_UPDATE(ctx, data, len) \
hash_processor_sha256_update(ctx, data, len)
Expand Down
8 changes: 4 additions & 4 deletions core/embed/trezorhal/hash_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
typedef struct {
uint32_t length; /*!< nb bytes in buffer */
uint8_t buffer[HASH_SHA256_BUFFER_SIZE]; /*!< data being processed */
} hash_sha265_context_t;
} hash_sha256_context_t;

#ifdef KERNEL_MODE

Expand All @@ -25,13 +25,13 @@ void hash_processor_sha256_calc(const uint8_t *data, uint32_t len,

// Initialize the hash context
// 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
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);

// 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
6 changes: 3 additions & 3 deletions core/embed/trezorhal/stm32f4/syscall_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ __attribute((no_stack_protector)) void syscall_handler(uint32_t *args,

#ifdef STM32U5
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);
} break;
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];
uint32_t len = args[2];
hash_processor_sha256_update(ctx, data, len);
} break;
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];
hash_processor_sha256_final(ctx, output);
} break;
Expand Down
6 changes: 3 additions & 3 deletions core/embed/trezorhal/stm32f4/syscall_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@ void reboot_device(void) {

#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);
}

// 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) {
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_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);
}

Expand Down
8 changes: 4 additions & 4 deletions core/embed/trezorhal/stm32u5/hash_processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
memzero(ctx, sizeof(hash_sha265_context_t));
void hash_processor_sha256_init(hash_sha256_context_t *ctx) {
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) {
if (ctx->length > 0) {
uint32_t chunk = HASH_SHA256_BUFFER_SIZE - ctx->length;
Expand Down Expand Up @@ -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};
memzero(ctx->buffer + ctx->length, HASH_SHA256_BUFFER_SIZE - ctx->length);
HAL_HASHEx_SHA256_Accmlt_End(&hhash, (uint8_t *)ctx->buffer, ctx->length,
Expand Down

0 comments on commit da7ddd5

Please sign in to comment.