From 11777554bd63b16bb13aa3b7358d8e7809f17523 Mon Sep 17 00:00:00 2001 From: dmitry dulesov Date: Thu, 30 Jan 2020 03:50:54 +0300 Subject: [PATCH] gosthash2012: Simplify `pad' `pad' does not need this complicated memory movements using stack buffer. Committed-by: Vitaly Chikunov --- gosthash2012.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/gosthash2012.c b/gosthash2012.c index 0233d0a..201fe31 100644 --- a/gosthash2012.c +++ b/gosthash2012.c @@ -48,13 +48,9 @@ void init_gost2012_hash_ctx(gost2012_hash_ctx * CTX, static INLINE void pad(gost2012_hash_ctx * CTX) { - unsigned char buf[64]; + memset(&(CTX->buffer[CTX->bufsize]), 0, sizeof(CTX->buffer) - CTX->bufsize); + CTX->buffer[CTX->bufsize] = 1; - memset(&buf, 0x00, sizeof buf); - memcpy(&buf, CTX->buffer, CTX->bufsize); - - buf[CTX->bufsize] = 0x01; - memcpy(CTX->buffer, &buf, sizeof buf); } static INLINE void add512(const union uint512_u *x, -- 2.39.2