aboutsummaryrefslogtreecommitdiff
path: root/src/hash/sha2-256.c
diff options
context:
space:
mode:
authorame <[email protected]>2024-05-01 23:52:54 -0500
committerame <[email protected]>2024-05-01 23:52:54 -0500
commit8740f3685e959d6477230cf4e8f33c7c93f9ea2b (patch)
treefeb939eadc804dfbdcf148c70fa235c36912476b /src/hash/sha2-256.c
parente59344f2d3903b9643ff8d77064147dfabced117 (diff)
fix some hash ub
Diffstat (limited to 'src/hash/sha2-256.c')
-rw-r--r--src/hash/sha2-256.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/hash/sha2-256.c b/src/hash/sha2-256.c
index 7e37da9..d4a685a 100644
--- a/src/hash/sha2-256.c
+++ b/src/hash/sha2-256.c
@@ -175,14 +175,14 @@ void sha512_final(struct sha512_hash* hash, char* out_stream){
_sha512_t_final(hash);
- sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h0);
- sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h1);
+ sprintf((char*)out_stream, "%016llx%016llx%016llx%016llx%016llx%016llx%016llx%016llx", hash->h0, hash->h1, hash->h2, hash->h3, hash->h4, hash->h5, hash->h6, hash->h7);
+ /*sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h1);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h2);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h3);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h4);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h5);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h6);
- sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h7);
+ sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h7);*/
memcpy(hash, &old_hash, sizeof * hash);
memcpy(hash->buffer, old, bs);
@@ -196,12 +196,12 @@ void sha384_final(struct sha512_hash* hash, char* out_stream){
_sha512_t_final(hash);
- sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h0);
- sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h1);
+ sprintf((char*)out_stream, "%016llx%016llx%016llx%016llx%016llx%016llx", hash->h0, hash->h1, hash->h2, hash->h3, hash->h4, hash->h5);
+ /*sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h1);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h2);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h3);
sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h4);
- sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h5);
+ sprintf((char*)out_stream, "%s%016llx", out_stream, hash->h5);*/
memcpy(hash, &old_hash, sizeof * hash);
memcpy(hash->buffer, old, bs);
@@ -236,7 +236,7 @@ struct iv sha_iv_gen(int i){
uint8_t nh[512] = {0};
uint8_t in[12];
- sprintf((char*)in, "SHA-512/%i",i);
+ sprintf((char*)in, "SHA-512/%i", i);
struct sha512_hash a = sha512_t_init(oh);
sha512_update(in, strlen((char*)in), &a);
_sha512_t_final(&a);