Skip to content

Commit

Permalink
Do not cast to const type, when not required
Browse files Browse the repository at this point in the history
Signed-off-by: Anjan Roy <[email protected]>
  • Loading branch information
itzmeanjan committed Sep 2, 2024
1 parent 43aad07 commit 5ee7aba
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions include/ml_kem/internals/ml_kem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ decapsulate(std::span<const uint8_t, ml_kem_utils::get_kem_secret_key_len(k)> se
(void)k_pke::encrypt<k, eta1, eta2, du, dv>(pubkey, g_in_span0, g_out_span1, c_prime);

// line 9-12 of algorithm 17, in constant-time
using kdf_t = std::span<const uint8_t, shared_secret.size()>;
const uint32_t cond = ml_kem_utils::ct_memcmp(cipher, std::span<const uint8_t, ctlen>(c_prime));
ml_kem_utils::ct_cond_memcpy(cond, shared_secret, kdf_t(g_out_span0), kdf_t(z));
ml_kem_utils::ct_cond_memcpy(cond, shared_secret, std::span<const uint8_t, g_out_span0.size()>(g_out_span0), z);
}

}

0 comments on commit 5ee7aba

Please sign in to comment.