From 32a4874abfbaff8cb4ee2d31fe71bcc3499e52dc Mon Sep 17 00:00:00 2001 From: J08nY Date: Wed, 27 Nov 2019 20:34:58 +0100 Subject: Reorganize files, implement proper main. --- pyecsca/codegen/hash/hash.h | 2 ++ pyecsca/codegen/hash/none.c | 4 ++++ pyecsca/codegen/hash/sha1.c | 4 ++++ pyecsca/codegen/hash/sha2.c | 4 ++++ 4 files changed, 14 insertions(+) (limited to 'pyecsca/codegen/hash') diff --git a/pyecsca/codegen/hash/hash.h b/pyecsca/codegen/hash/hash.h index 9e79b61..7121cd4 100644 --- a/pyecsca/codegen/hash/hash.h +++ b/pyecsca/codegen/hash/hash.h @@ -18,4 +18,6 @@ void hash_init(void *ctx); void hash_final(void *ctx, int size, const uint8_t *msg, uint8_t *digest); +void hash_free_ctx(void *ctx); + #endif //HASH_H_ \ No newline at end of file diff --git a/pyecsca/codegen/hash/none.c b/pyecsca/codegen/hash/none.c index 79690e8..b40adc3 100644 --- a/pyecsca/codegen/hash/none.c +++ b/pyecsca/codegen/hash/none.c @@ -17,4 +17,8 @@ void hash_init(void *ctx) { void hash_final(void *ctx, int size, const uint8_t *msg, uint8_t *digest) { memcpy(digest, msg, size); +} + +void hash_free_ctx(void *ctx) { + } \ No newline at end of file diff --git a/pyecsca/codegen/hash/sha1.c b/pyecsca/codegen/hash/sha1.c index cf6ca3e..213ed11 100644 --- a/pyecsca/codegen/hash/sha1.c +++ b/pyecsca/codegen/hash/sha1.c @@ -187,3 +187,7 @@ void hash_final(void *ctx, int size, const uint8_t *msg, uint8_t *digest) { sha1_lastBlock(ctx, msg, length); sha1_ctx2hash(digest, ctx); } + +void hash_free_ctx(void *ctx) { + free(ctx); +} diff --git a/pyecsca/codegen/hash/sha2.c b/pyecsca/codegen/hash/sha2.c index d2ddf6f..2b7f11d 100644 --- a/pyecsca/codegen/hash/sha2.c +++ b/pyecsca/codegen/hash/sha2.c @@ -334,4 +334,8 @@ void hash_final(void* ctx, int size, const uint8_t* msg, uint8_t* digest) { } sha2_lastBlock(ctx, msg, length_b); sha2_ctx2hash(digest, ctx); +} + +void hash_free_ctx(void *ctx) { + free(ctx); } \ No newline at end of file -- cgit v1.3.1