Add padding and return the message digest. */
| 170 | |
| 171 | /* Add padding and return the message digest. */ |
| 172 | void 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 |
no test coverage detected