HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
round_candidate.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
31 #pragma once
32 
34 #include "hal_core/defines.h"
36 
37 #include <map>
38 #include <set>
39 
40 namespace hal
41 {
42  namespace hawkeye
43  {
53  {
54  public:
58  RoundCandidate() = default;
59 
63  ~RoundCandidate() = default;
64 
76 
82  Netlist* get_netlist() const;
83 
90 
96  u32 get_size() const;
97 
103  const std::set<Gate*>& get_input_reg() const;
104 
110  const std::set<Gate*>& get_output_reg() const;
111 
117  const std::set<Gate*>& get_state_logic() const;
118 
124  const std::set<Net*>& get_state_inputs() const;
125 
131  const std::set<Net*>& get_control_inputs() const;
132 
138  const std::set<Net*>& get_other_inputs() const;
139 
145  const std::set<Net*>& get_state_outputs() const;
146 
152  const std::map<Gate*, std::set<Gate*>>& get_input_ffs_of_gate() const;
153 
159  const std::map<u32, std::set<Gate*>>& get_longest_distance_to_gate() const;
160 
161  private:
165  std::unique_ptr<Netlist> m_netlist;
166 
170  std::unique_ptr<graph_algorithm::NetlistGraph> m_graph;
171 
175  u32 m_size;
176 
180  std::set<Gate*> m_in_reg;
181 
185  std::set<Gate*> m_out_reg;
186 
190  std::set<Gate*> m_state_logic;
191 
195  std::set<Net*> m_state_inputs;
196 
200  std::set<Net*> m_control_inputs;
201 
205  std::set<Net*> m_other_inputs;
206 
210  std::set<Net*> m_state_outputs;
211 
215  std::map<Gate*, std::set<Gate*>> m_input_ffs_of_gate;
216 
220  std::map<u32, std::set<Gate*>> m_longest_distance_to_gate;
221  };
222  } // namespace hawkeye
223 } // namespace hal
A directed graph corresponding to a netlist.
Definition: netlist_graph.h:60
A register candidate discovered by HAWKEYE.
A round candidate constructed from a previously discovered register candidate.
const std::set< Gate * > & get_state_logic() const
Get the candidate's combinational logic computing the next state.
const std::set< Net * > & get_other_inputs() const
Get the candidate's other inputs to the logic computing the next state.
const std::set< Net * > & get_control_inputs() const
Get the candidate's control inputs to the logic computing the next state.
u32 get_size() const
Get the size of the candidate, i.e., the width of its registers.
const std::map< Gate *, std::set< Gate * > > & get_input_ffs_of_gate() const
Get a map from each combinational gate of the round function to all the input flip-flops it depends o...
const std::set< Net * > & get_state_outputs() const
Get the candidate's state outputs from the logic computing the next state.
static Result< std::unique_ptr< RoundCandidate > > from_register_candidate(RegisterCandidate *candidate)
Compute a round candidate from a previously identified register candidate.
const std::map< u32, std::set< Gate * > > & get_longest_distance_to_gate() const
Get a map from an integer distance to all gates that are reachable within at most that distance when ...
const std::set< Gate * > & get_output_reg() const
Get the candidate's output register.
Netlist * get_netlist() const
Get the netlist of the round candidate. The netlist is a partial copy of the netlist of the register ...
RoundCandidate()=default
Default constructor for RoundCandidate.
~RoundCandidate()=default
Default destructor for RoundCandidate.
graph_algorithm::NetlistGraph * get_graph() const
Get the netlist graph of the round candidate.
const std::set< Gate * > & get_input_reg() const
Get the candidate's input register.
const std::set< Net * > & get_state_inputs() const
Get the candidate's state inputs to the logic computing the next state.
uint32_t u32
Definition: defines.h:41
Definition: defines.h:45
This file contains the class that holds a netlist graph.
This file contains the class that holds all information on a register candidate.