comparison 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
comparison
equal deleted inserted replaced
816:84e4259dae3e 817:a625f9e135a4
882 return DROPBEAR_FAILURE; 882 return DROPBEAR_FAILURE;
883 } else { 883 } else {
884 return DROPBEAR_SUCCESS; 884 return DROPBEAR_SUCCESS;
885 } 885 }
886 } 886 }
887
888 int constant_time_memcmp(const void* a, const void *b, size_t n)
889 {
890 const char *xa = a, *xb = b;
891 uint8_t c = 0;
892 size_t i;
893 for (i = 0; i < n; i++)
894 {
895 c |= (xa[i] ^ xb[i]);
896 }
897 return c;
898 }
899