From 38bde3aaaa2faaf07263721139f5ed42bd2f6238 Mon Sep 17 00:00:00 2001 From: Calascibetta Romain Date: Tue, 23 Apr 2024 19:11:01 +0200 Subject: [PATCH] mirage-crypto-ec: Set bytes used for "zero" to '\000' (#226) Cstruct.create does this. If we don't initialize bytes with '\000', Field_element.zero can be something else than '\000'. It's a fix for mirleft/ocaml-x509#167. Co-authored-by: Hannes Mehnert --- ec/mirage_crypto_ec.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ec/mirage_crypto_ec.ml b/ec/mirage_crypto_ec.ml index 5c1e47ed..05f346e4 100644 --- a/ec/mirage_crypto_ec.ml +++ b/ec/mirage_crypto_ec.ml @@ -158,7 +158,8 @@ module Make_field_element (P : Parameters) (F : Foreign) : Field_element = struc b_uts tmp let zero = - b_uts (create ()) + let b = Bytes.make P.fe_length '\000' in + b_uts b let one = let fe = create () in