aboutsummaryrefslogtreecommitdiff
path: root/src/hash/sha2-256.c
diff options
context:
space:
mode:
authorame <[email protected]>2024-09-30 02:17:37 -0500
committerame <[email protected]>2024-09-30 02:17:37 -0500
commitc18a2ac9469ddc7488834a81e49150ebb5506ed4 (patch)
tree2a9fafd40359419d36504b55e6041a9fdda23bc6 /src/hash/sha2-256.c
parent2a7f5c95a5406b6de215dbc24a733e29d609d20f (diff)
parente29d3ea86551380ace8e2c86c9f1f63e901941e1 (diff)
what
Diffstat (limited to 'src/hash/sha2-256.c')
-rw-r--r--src/hash/sha2-256.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/hash/sha2-256.c b/src/hash/sha2-256.c
index 7e37d9d..42f6a81 100644
--- a/src/hash/sha2-256.c
+++ b/src/hash/sha2-256.c
@@ -245,7 +245,13 @@ struct iv sha_iv_gen(int i){
return (struct iv){.h0 = a.h0, .h1 = a.h1, .h2 = a.h2, .h3 = a.h3, .h4 = a.h4, .h5 = a.h5, .h6 = a.h6, .h7 = a.h7};
}
-common_hash_clone(sha512);
+//common_hash_clone(sha512);
+lua_common_hash_clone_oargs(sha512, sha512, l_sha512_init(L), {
+ uint8_t* old = b->buffer;
+ *b = *a;
+ b->buffer = old;
+ memcpy(b->buffer, a->buffer, bs * sizeof * b->buffer);
+});
lua_common_hash_init_ni(sha512, sha512, sha512_t_init_l(sha512_iv, L));
lua_common_hash_update(sha512, sha512);
@@ -259,7 +265,13 @@ int l_sha512_final(lua_State* L){
return 1;
}
-common_hash_clone(sha384);
+//common_hash_clone(sha384);
+lua_common_hash_clone_oargs(sha384, sha384, l_sha384_init(L), {
+ uint8_t* old = b->buffer;
+ *b = *a;
+ b->buffer = old;
+ memcpy(b->buffer, a->buffer, bs * sizeof * b->buffer);
+});
lua_common_hash_init_ni(sha384, sha384, sha512_t_init_l(sha384_iv, L));
lua_common_hash_update(sha384, sha384);
@@ -278,7 +290,11 @@ int l_sha512_t_clone(lua_State* L){
lua_pushinteger(L, a->t);
l_sha512_t_init(L);
struct sha512_hash* b = (struct sha512_hash*)lua_touserdata(L, -1);
+
+ uint8_t* old = b->buffer;
*b = *a;
+ b->buffer = old;
+ memcpy(b->buffer, a->buffer, bs * sizeof * b->buffer);
return 1;
}