MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */
| 144 | the message digest and zeroizing the context. |
| 145 | */ |
| 146 | void MD5Final(u8 digest[16], MD5_CTX *context) |
| 147 | /* digest: message digest */ |
| 148 | /* context: context */ |
| 149 | { |
| 150 | u8 bits[8]; |
| 151 | u32 index, padLen; |
| 152 | |
| 153 | /* Save number of bits */ |
| 154 | Encode (bits, context->count, 8); |
| 155 | |
| 156 | /* Pad out to 56 mod 64. */ |
| 157 | index = (u32)((context->count[0] >> 3) & 0x3f); |
| 158 | padLen = (index < 56) ? (56 - index) : (120 - index); |
| 159 | MD5Update (context, PADDING, padLen); |
| 160 | |
| 161 | /* Append length (before padding) */ |
| 162 | MD5Update (context, bits, 8); |
| 163 | |
| 164 | /* Store state in digest */ |
| 165 | Encode (digest, context->state, 16); |
| 166 | |
| 167 | /* Zeroize sensitive information. */ |
| 168 | memset(context, 0, sizeof(*context)); |
| 169 | } |
| 170 | |
| 171 | /* MD5 basic transformation. Transforms state based on block. |
| 172 | */ |
no test coverage detected