MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. unsigned char digest[16] - message digest MD5_CTX *context - context */
| 168 | MD5_CTX *context - context |
| 169 | */ |
| 170 | void MD5Final (char digest[16], MD5_CTX *context) |
| 171 | { |
| 172 | unsigned char bits[8]; |
| 173 | unsigned int index, padLen; |
| 174 | |
| 175 | /* Save number of bits */ |
| 176 | Encode (bits, context->count, 8); |
| 177 | |
| 178 | /* Pad out to 56 mod 64. |
| 179 | */ |
| 180 | index = (unsigned int)((context->count[0] >> 3) & 0x3f); |
| 181 | padLen = (index < 56) ? (56 - index) : (120 - index); |
| 182 | MD5Update (context, (const char *)PADDING, padLen); |
| 183 | |
| 184 | /* Append length (before padding) */ |
| 185 | MD5Update (context, (const char *)bits, 8); |
| 186 | |
| 187 | /* Store state in digest */ |
| 188 | Encode ((unsigned char *)digest, context->state, 16); |
| 189 | |
| 190 | /* Zeroize sensitive information. |
| 191 | */ |
| 192 | MD5_memset ((POINTER)context, 0, sizeof (*context)); |
| 193 | } |
| 194 | |
| 195 | /* MD5 basic transformation. Transforms state based on block. |
| 196 | */ |
no test coverage detected