123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102(**************************************************************************)(* This file is part of BINSEC. *)(* *)(* Copyright (C) 2016-2026 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)includeCli.Make_from_logger(Logger)(structletname="Constant time checker"letshortname="checkct"end)moduleLeakInfo=Builder.Variant_choice_assoc(structtypet=leak_infoletname="leak-info"letdoc="Select the information that is reported about leakage.\n"^"\t\t- halt: halts at first leak\n"^"\t\t- instr: reports leaky instructions (instructions are reported only \
once)\n"letdefault=InstrLeakletassoc_map=[("halt",HaltLeak);("instr",InstrLeak)]end)moduleTaint=Builder.No(structletname="taint"letdoc="Disable taint analysis (prove that instruction can not leak)"end)moduleChosenValues=Builder.No(structletname="cv"letdoc="Disable chosen value sampling (prove that instruction may leak)"end)moduleRelse=Builder.No(structletname="relse"letdoc="Disable relational symbolic engine to answer security queries"end)moduleStatsFile=Builder.String_option(structletname="stats-file"letdoc="set file for dumping staistics"end)moduleFeatures=Builder.Variant_list(structletname="features"letdoc="Set of CT check points : control-flow, memory-access, multiplication, \
dividend and divisor. Multiplication and division checks are \
experimental."letaccept_empty=truetypet=Kind.tletof_string=Kind.of_stringend)letmake_options:unit->(moduleOPTIONS)=fun():(moduleOPTIONS)->(modulestructletleak_info=LeakInfo.get()lettaint=Taint.get()letcv=ChosenValues.get()letrelse=Relse.get()letstats_file=StatsFile.get_opt()letfeatures=ifFeatures.is_set()thenFeatures.get()else[Control_flow;Memory_access]letcheck_branch=List.memqKind.Control_flowfeaturesletcheck_memory=List.memqKind.Memory_accessfeaturesletcheck_mult=List.memqKind.Multiplicationfeaturesletcheck_dividend=List.memqKind.Dividendfeaturesletcheck_divisor=List.memqKind.Divisorfeaturesend)let()=Sse.register_plugin~is_enabled(fun()->(modulePlugin((valmake_options()))))