Skip to content

Commit

Permalink
don't use as function name
Browse files Browse the repository at this point in the history
This conflicts with a function in the C stdlib
  • Loading branch information
franziskuskiefer committed Jul 2, 2024
1 parent db5a91e commit e565afe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions libcrux-ml-kem/c/libcrux_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ uint8_t libcrux_ml_kem_constant_time_ops_compare_ciphertexts_in_constant_time(
return compare(lhs, rhs);
}

static void select(Eurydice_slice lhs, Eurydice_slice rhs, uint8_t selector,
uint8_t ret[32U]) {
static void select_ct(Eurydice_slice lhs, Eurydice_slice rhs, uint8_t selector,
uint8_t ret[32U]) {
uint8_t mask = core_num__u8_6__wrapping_sub(is_non_zero(selector), 1U);
uint8_t out[32U] = {0U};
for (size_t i = (size_t)0U; i < LIBCRUX_ML_KEM_CONSTANTS_SHARED_SECRET_SIZE;
Expand All @@ -60,7 +60,7 @@ void libcrux_ml_kem_constant_time_ops_select_shared_secret_in_constant_time(
Eurydice_slice lhs, Eurydice_slice rhs, uint8_t selector,
uint8_t ret[32U]) {
uint8_t ret0[32U];
select(lhs, rhs, selector, ret0);
select_ct(lhs, rhs, selector, ret0);
memcpy(ret, ret0, (size_t)32U * sizeof(uint8_t));
}

Expand Down
6 changes: 3 additions & 3 deletions libcrux-ml-kem/src/constant_time_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn compare(lhs: &[u8], rhs: &[u8]) -> u8 {
hax_lib::implies(selector == 0, || result == lhs) &&
hax_lib::implies(selector != 0, || result == rhs)
))]
pub(crate) fn select(lhs: &[u8], rhs: &[u8], selector: u8) -> [u8; SHARED_SECRET_SIZE] {
fn select_ct(lhs: &[u8], rhs: &[u8], selector: u8) -> [u8; SHARED_SECRET_SIZE] {
hax_debug_assert!(lhs.len() == rhs.len());
hax_debug_assert!(lhs.len() == SHARED_SECRET_SIZE);

Expand Down Expand Up @@ -84,8 +84,8 @@ pub(crate) fn select_shared_secret_in_constant_time(
selector: u8,
) -> [u8; SHARED_SECRET_SIZE] {
#[cfg(eurydice)]
return select(lhs, rhs, selector);
return select_ct(lhs, rhs, selector);

#[cfg(not(eurydice))]
core::hint::black_box(select(lhs, rhs, selector))
core::hint::black_box(select_ct(lhs, rhs, selector))
}

0 comments on commit e565afe

Please sign in to comment.