1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465(**************************************************************************)(* *)(* OCaml *)(* *)(* Florian Angeletti, projet Cambium, Inria *)(* *)(* Copyright 2022 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)letm=0xd1342543de82ef95Ltypestate=(Int64.t,Bigarray.int64_elt,Bigarray.c_layout)Bigarray.Array1.tmoduleIndices:sigtypet=privateintvala:tvals:tvalx0:tvalx1:tval(.!{}):state-> t->Int64.tval(.!{}<-):state->t->Int64.t->unitend=structtypet=intleta=0lets=1letx0=2letx1=3let(.!{})=Bigarray.Array1.unsafe_getlet(.!{}<-)=Bigarray.Array1.unsafe_setendopenIndicesopenstructlet(+)=Int64.addlet(*)=Int64.mullet(lxor )=Int64.logxorlet(lsl)=Int64.shift_leftlet(lsr)=Int64.shift_right_logicallet(lor)=Int64.logorendlet[@inlinealways]rotlxk=xlslklorxlsr(64-k)letnextst=(*Combining operation *)letz=st.!{s}+st.!{x0}in(* Mixing function *)letz=(zlxor(zlsr32))*0xdaba0b6eb09322e3Linletz=(zlxor(zlsr32))*0xdaba0b6eb09322e3Linletz=(zlxor(zlsr32))in(* LGC update *)st.!{s}<-st.!{s}*m+st.!{a};(* XBG update *)letq0=st.!{x0}andq1=st.!{x1}inletq1=q0lxorq1inletq0=rotlq024inletq0=q0lxorq1lxor(q1lsl16)inletq1=rotlq137inst.!{x0}<-q0;st.!{x1}<-q1;z