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:
parent
f1e01edfcb
commit
da7ddd5c8c
@ -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)
|
||||
|
@ -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
|
||||
|
||||
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user