SIde-Channel Analysis toolKit (SICAK)
Software toolkit for side-channel analysis
types_power.hpp
Go to the documentation of this file.
1 /*
2 * SICAK - SIde-Channel Analysis toolKit
3 * Copyright (C) 2018 Petr Socha, FIT, CTU in Prague
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18 
29 #ifndef TYPES_POWER_HPP
30 #define TYPES_POWER_HPP
31 
32 #include "types_basic.hpp"
33 
34 
35 
43 template <class T>
44 class PowerTraces : public Matrix<T> {
45 
46 public:
52  PowerTraces(size_t samplesPerTrace, size_t noOfTraces, T initVal) : Matrix<T>(samplesPerTrace, noOfTraces, initVal) {}
53 
55  PowerTraces(PowerTraces&& other) : Matrix<T>(std::move(other)) { }
57  PowerTraces& operator=(PowerTraces&& other) { return static_cast<PowerTraces&>(Matrix<T>::operator=(std::move(other))); }
58 
60  virtual ~PowerTraces() {}
61 
62  virtual void init(size_t samplesPerTrace, size_t noOfTraces) { return Matrix<T>::init(samplesPerTrace, noOfTraces); }
63 
65  virtual size_t samplesPerTrace() const { return (*this).cols(); }
67  virtual size_t noOfTraces() const { return (*this).rows(); }
68 
69  virtual T & operator() (size_t sample, size_t trace) { return Matrix<T>::operator()(sample, trace); }
70  virtual const T & operator() (size_t sample, size_t trace) const { return Matrix<T>::operator()(sample, trace); }
71 };
72 
73 
81 template <class T>
82 class PowerPredictions : public Matrix<T> {
83 
84 public:
90  PowerPredictions(size_t noOfCandidates, size_t noOfTraces, T initVal) : Matrix<T>(noOfCandidates, noOfTraces, initVal) {}
91 
93  PowerPredictions(PowerPredictions&& other) : Matrix<T>(std::move(other)) { }
95  PowerPredictions& operator=(PowerPredictions&& other) { return static_cast<PowerPredictions&>(Matrix<T>::operator=(std::move(other))); }
96 
99 
100  virtual void init(size_t noOfCandidates, size_t noOfTraces) { return Matrix<T>::init(noOfCandidates, noOfTraces); }
101 
103  virtual size_t noOfCandidates() const { return (*this).cols(); }
105  virtual size_t noOfTraces() const { return (*this).rows(); }
106 
107  virtual T & operator() (size_t keyCandidate, size_t trace) { return Matrix<T>::operator()(keyCandidate, trace); }
108  virtual const T & operator() (size_t keyCandidate, size_t trace) const { return Matrix<T>::operator()(keyCandidate, trace); }
109 };
110 
111 
112 #endif /* TYPES_POWER_HPP */
113 
virtual T & operator()(size_t sample, size_t trace)
Accesses an element in the matrix. Doesn't check for bounds.
Definition: types_power.hpp:69
PowerTraces(size_t samplesPerTrace, size_t noOfTraces)
Constructs a Matrix with 'samplesPerTrace' * 'noOfTraces' elements.
Definition: types_power.hpp:50
virtual size_t noOfTraces() const
Returns number of power traces.
Definition: types_power.hpp:67
PowerPredictions()
Constructs an empty Matrix with no elements. Needs to be initialized first (init).
Definition: types_power.hpp:86
PowerTraces()
Constructs an empty Matrix with no elements. Needs to be initialized first (init).
Definition: types_power.hpp:48
PowerTraces & operator=(PowerTraces &&other)
Move assignment operator.
Definition: types_power.hpp:57
virtual void init(size_t noOfCandidates, size_t noOfTraces)
Initializes the matrix with a specified number of cols and rows.
Definition: types_power.hpp:100
PowerTraces(PowerTraces &&other)
Move constructor.
Definition: types_power.hpp:55
PowerPredictions(size_t noOfCandidates, size_t noOfTraces)
Constructs a Matrix with 'noOfCandidates' * 'noOfTraces' elements.
Definition: types_power.hpp:88
PowerTraces(size_t samplesPerTrace, size_t noOfTraces, T initVal)
Constructs a Matrix with 'samplesPerTrace' * 'noOfTraces' elements and fills it with 'initVal'.
Definition: types_power.hpp:52
virtual T & operator()(size_t col, size_t row)
Accesses an element in the matrix. Doesn't check for bounds.
Definition: types_basic.hpp:353
This header file contains class templates of basic data containers.
virtual size_t noOfTraces() const
Returns number of power predictions.
Definition: types_power.hpp:105
A class representing a matrix, stored in the machine's free space.
Definition: types_basic.hpp:305
PowerPredictions & operator=(PowerPredictions &&other)
Move assignment operator.
Definition: types_power.hpp:95
~PowerPredictions()
Empty destructor.
Definition: types_power.hpp:98
virtual size_t samplesPerTrace() const
Returns number of samples per trace.
Definition: types_power.hpp:65
A class representing a Matrix with 'noOfTraces' power predictions, with 'noOfCandidates' key candidat...
Definition: types_power.hpp:82
virtual T & operator()(size_t keyCandidate, size_t trace)
Accesses an element in the matrix. Doesn't check for bounds.
Definition: types_power.hpp:107
virtual void init(size_t samplesPerTrace, size_t noOfTraces)
Initializes the matrix with a specified number of cols and rows.
Definition: types_power.hpp:62
PowerPredictions(size_t noOfCandidates, size_t noOfTraces, T initVal)
Constructs a Matrix with 'noOfCandidates' * 'noOfTraces' elements and fills it with 'initVal'.
Definition: types_power.hpp:90
virtual void init(size_t cols, size_t rows)
Initializes the matrix with a specified number of cols and rows.
Definition: types_basic.hpp:332
virtual size_t noOfCandidates() const
Returns number of key candidates per power prediction.
Definition: types_power.hpp:103
PowerPredictions(PowerPredictions &&other)
Move constructor.
Definition: types_power.hpp:93
A class representing a Matrix with 'noOfTraces' power traces, with 'samplesPerTrace' samples per powe...
Definition: types_power.hpp:44
virtual ~PowerTraces()
Empty destructor.
Definition: types_power.hpp:60