Mercurial > dropbear
diff dbutil.c @ 817:a625f9e135a4
Constant time memcmp for the hmac and password crypt
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 03 Oct 2013 22:25:30 +0800 |
parents | d63ef1e211ea |
children | 4095b6d7c9fc |
line wrap: on
line diff
--- a/dbutil.c Sat Sep 21 00:34:36 2013 +0800 +++ b/dbutil.c Thu Oct 03 22:25:30 2013 +0800 @@ -884,3 +884,16 @@ return DROPBEAR_SUCCESS; } } + +int constant_time_memcmp(const void* a, const void *b, size_t n) +{ + const char *xa = a, *xb = b; + uint8_t c = 0; + size_t i; + for (i = 0; i < n; i++) + { + c |= (xa[i] ^ xb[i]); + } + return c; +} +