ct/cmp: make it generic by taking void pointers

This commit is contained in:
Lucas Gabriel Vuotto 2024-06-28 17:08:23 +00:00
parent 546649da1d
commit 91f9176279
2 changed files with 6 additions and 3 deletions

7
ct.c
View File

@ -18,10 +18,13 @@
uint32_t
lc_ct_cmp(const uint8_t *x, const uint8_t *y, size_t l)
lc_ct_cmp(const void *px, const void *py, size_t l)
{
uint32_t r = 0;
const unsigned char *x, *y;
unsigned char r = 0;
x = px;
y = py;
for (; l > 0; l--)
r |= *x++ ^ *y++;

View File

@ -146,7 +146,7 @@ struct lc_hkdf_params {
/* Constant-time operations */
uint32_t lc_ct_cmp(const uint8_t *, const uint8_t *, size_t);
uint32_t lc_ct_cmp(const void *, const void *, size_t);
uint32_t lc_ct_mask32(uint32_t);