MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / sha1_done

Function sha1_done

Libraries/unrar/sha1.cpp:172–202  ·  view source on GitHub ↗

Add padding and return the message digest. */

Source from the content-addressed store, hash-verified

170
171/* Add padding and return the message digest. */
172void sha1_done( sha1_context* context, uint32 digest[5])
173{
174 uint32 workspace[16];
175 uint64 BitLength = context->count * 8;
176 uint BufPos = (uint)context->count & 0x3f;
177 context->buffer[BufPos++] = 0x80; // Padding the message with "1" bit.
178
179 if (BufPos!=56) // We need 56 bytes block followed by 8 byte length.
180 {
181 if (BufPos>56)
182 {
183 while (BufPos<64)
184 context->buffer[BufPos++] = 0;
185 BufPos=0;
186 }
187 if (BufPos==0)
188 SHA1Transform(context->state, workspace, context->buffer, true);
189 memset(context->buffer+BufPos,0,56-BufPos);
190 }
191
192 RawPutBE4((uint32)(BitLength>>32), context->buffer + 56);
193 RawPutBE4((uint32)(BitLength), context->buffer + 60);
194
195 SHA1Transform(context->state, workspace, context->buffer, true);
196
197 for (uint i = 0; i < 5; i++)
198 digest[i] = context->state[i];
199
200 /* Wipe variables */
201 sha1_init(context);
202}
203
204

Callers 1

SetKey30Method · 0.85

Calls 3

SHA1TransformFunction · 0.85
RawPutBE4Function · 0.85
sha1_initFunction · 0.85

Tested by

no test coverage detected