MD5Init(&s);
MD5Update(&s, (unsigned char const *)p, len);
MD5Final(output, &s);
+ smemclr(&s, sizeof(s));
}
/* ----------------------------------------------------------------------
* useful elsewhere (SOCKS5 CHAP authentication uses HMAC-MD5).
*/
-void *hmacmd5_make_context(void)
+void *hmacmd5_make_context(void *cipher_ctx)
{
return snewn(3, struct MD5Context);
}
void hmacmd5_free_context(void *handle)
{
+ smemclr(handle, 3*sizeof(struct MD5Context));
sfree(handle);
}
{
unsigned char correct[16];
hmacmd5_genresult(handle, correct);
- return !memcmp(correct, hmac, 16);
+ return smemeq(correct, hmac, 16);
}
static void hmacmd5_do_hmac_internal(void *handle,
{
unsigned char seqbuf[16];
- seqbuf[0] = (unsigned char) ((seq >> 24) & 0xFF);
- seqbuf[1] = (unsigned char) ((seq >> 16) & 0xFF);
- seqbuf[2] = (unsigned char) ((seq >> 8) & 0xFF);
- seqbuf[3] = (unsigned char) ((seq) & 0xFF);
-
+ PUT_32BIT_MSB_FIRST(seqbuf, seq);
hmacmd5_do_hmac_internal(handle, seqbuf, 4, blk, len, hmac);
}
{
unsigned char correct[16];
hmacmd5_do_hmac_ssh(handle, blk, len, seq, correct);
- return !memcmp(correct, blk + len, 16);
+ return smemeq(correct, blk + len, 16);
}
const struct ssh_mac ssh_hmac_md5 = {
hmacmd5_make_context, hmacmd5_free_context, hmacmd5_key_16,
hmacmd5_generate, hmacmd5_verify,
hmacmd5_start, hmacmd5_bytes, hmacmd5_genresult, hmacmd5_verresult,
- "hmac-md5",
- 16,
+ "hmac-md5", "hmac-md5-etm@openssh.com",
+ 16, 16,
"HMAC-MD5"
};