From 3877d77b55d083fae004375684641c02f44afe9b Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 20 Oct 2018 16:00:59 +0200 Subject: [PATCH] Clean up SHA1Reset --- Source/sha.cpp | 19 ++++++++++++------- Source/sha.h | 5 +++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Source/sha.cpp b/Source/sha.cpp index 293f19bc5..86b45b1df 100644 --- a/Source/sha.cpp +++ b/Source/sha.cpp @@ -121,11 +121,16 @@ void __fastcall SHA1ProcessMessageBlock(SHA1Context *context) void __fastcall SHA1Reset(int n) { - sgSHA1[n].count[0] = 0; - sgSHA1[n].count[1] = 0; - sgSHA1[n].state[0] = 0x67452301; - sgSHA1[n].state[1] = 0xEFCDAB89; - sgSHA1[n].state[2] = 0x98BADCFE; - sgSHA1[n].state[3] = 0x10325476; - sgSHA1[n].state[4] = 0xC3D2E1F0; + SHA1Init(&sgSHA1[n]); +} + +void __fastcall SHA1Init(SHA1Context *context) +{ + context->count[0] = 0; + context->count[1] = 0; + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; } diff --git a/Source/sha.h b/Source/sha.h index 06c237584..c6e61d490 100644 --- a/Source/sha.h +++ b/Source/sha.h @@ -5,8 +5,8 @@ /* * Define the SHA1 circular left shift macro */ -#define SHA1CircularShift(bits,word) \ - (((word) << (bits)) | ((word) >> (32-(bits)))) +#define SHA1CircularShift(bits, word) \ + (((word) << (bits)) | ((word) >> (32 - (bits)))) #define SHA1HashSize 20 //sha @@ -18,5 +18,6 @@ void __fastcall SHA1Calculate(int n, const char *data, char Message_Digest[SHA1H void __fastcall SHA1Input(SHA1Context *context, const char *message_array, int len); void __fastcall SHA1ProcessMessageBlock(SHA1Context *context); void __fastcall SHA1Reset(int n); +void __fastcall SHA1Init(SHA1Context *context); #endif /* __SHA_H__ */