From 91f91762796c5f0c8efde875d2da8840cf5dae95 Mon Sep 17 00:00:00 2001 From: Lucas Gabriel Vuotto Date: Fri, 28 Jun 2024 17:08:23 +0000 Subject: [PATCH] ct/cmp: make it generic by taking void pointers --- ct.c | 7 +++++-- lilcrypto.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ct.c b/ct.c index 3dd6e43..047a448 100644 --- a/ct.c +++ b/ct.c @@ -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++; diff --git a/lilcrypto.h b/lilcrypto.h index b68d8fe..f811e2d 100644 --- a/lilcrypto.h +++ b/lilcrypto.h @@ -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);