HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
sbox_lookup.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 
33 #include "hal_core/defines.h"
35 #include "hawkeye/sbox_database.h"
36 
37 #include <set>
38 #include <vector>
39 
40 namespace hal
41 {
42  class Gate;
43 
47  namespace hawkeye
48  {
49  class RoundCandidate;
50 
58  {
59  public:
63  SBoxCandidate() = default;
64 
68  ~SBoxCandidate() = default;
69 
74 
78  std::vector<Gate*> m_component;
79 
83  std::set<Gate*> m_input_gates;
84 
88  std::set<Gate*> m_output_gates;
89  };
90 
103 
111  Result<std::string> identify_sbox(const SBoxCandidate& sbox_candidate, const SBoxDatabase& db);
112  } // namespace hawkeye
113 } // namespace hal
A round candidate constructed from a previously discovered register candidate.
An S-box candidate discovered within the round function of a round candidate.
Definition: sbox_lookup.h:58
SBoxCandidate()=default
Default constructor for SBoxCandidate.
std::set< Gate * > m_output_gates
The output gates of the S-box candidate (usually combinational logic that is input to the linear laye...
Definition: sbox_lookup.h:88
const RoundCandidate * m_candidate
The RoundCandidate that the S-box candidate belongs to.
Definition: sbox_lookup.h:73
std::vector< Gate * > m_component
The gates of the component which the S-box candidate is part of.
Definition: sbox_lookup.h:78
std::set< Gate * > m_input_gates
The input gates of the S-box candidate (will be flip-flops).
Definition: sbox_lookup.h:83
~SBoxCandidate()=default
Default destructor for SBoxCandidate.
Database of known S-boxes.
Definition: sbox_database.h:50
Result< std::vector< SBoxCandidate > > locate_sboxes(const RoundCandidate *candidate)
Try to locate S-box candidates within the combinational next-state logic of the round function candid...
Definition: sbox_lookup.cpp:18
Result< std::string > identify_sbox(const SBoxCandidate &sbox_candidate, const SBoxDatabase &db)
Try to identify an S-box candidate by matching it against a database of known S-boxes under affine eq...
Definition: defines.h:45
This file contains the S-box database class that holds and manages known cryptographic S-boxes up to ...