SIde-Channel Analysis toolKit (SICAK)
Software toolkit for side-channel analysis
oclcpa.h
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 OCLCPA_H
30 #define OCLCPA_H
31 
32 #include <QObject>
33 #include <QtPlugin>
34 #include "cpaengine.h"
35 #include "exceptions.hpp"
36 #include "ompcpa.hpp"
37 #include "oclcpaengine.hpp"
38 
39 #define CL_USE_DEPRECATED_OPENCL_1_1_APIS
40 #ifdef __APPLE__
41 #include <OpenCL/opencl.h>
42 #else
43 #include <CL/cl.h>
44 #endif
45 
53 class OclCPA : public QObject, CpaEngine {
54 
55  Q_OBJECT
56  Q_PLUGIN_METADATA(IID "cz.cvut.fit.Sicak.CpaEngineInterface/1.0" FILE "oclcpa.json")
57  Q_INTERFACES(CpaEngine)
58 
59 public:
60 
61  OclCPA();
62  virtual ~OclCPA() override;
63 
64  virtual QString getPluginName() override;
65  virtual QString getPluginInfo() override;
66 
67  virtual void init(int platform, int device, size_t noOfTraces, size_t samplesPerTrace, size_t noOfCandidates, const char * param) override;
68  virtual void deInit() override;
69 
70  virtual QString queryDevices() override;
71 
72  virtual void setConstTraces(bool constTraces = false) override;
73 
75  virtual UnivariateContext<double> createContext(const PowerTraces<int16_t> & powerTraces, const PowerPredictions<uint8_t> & powerPredictions) override;
76  virtual void mergeContexts(UnivariateContext<double> & firstAndOut, const UnivariateContext<double> & second) override;
77  virtual Matrix<double> finalizeContext(const UnivariateContext<double> & context) override;
78 
79 protected:
80 
82  bool m_constTraces;
83  bool m_tracesLoaded;
84 };
85 
86 #endif /* OCLCPA_H */
87 
virtual void setConstTraces(bool constTraces=false) override
When constTraces is set, the engine assumes the PowerTraces object is same in every call to createCon...
Definition: oclcpa.cpp:63
CPA computation plugin interface for use e.g. in stan.
virtual void mergeContexts(UnivariateContext< double > &firstAndOut, const UnivariateContext< double > &second) override
Merge the two CPA contexts, stores the result in the first of the contexts.
Definition: oclcpa.cpp:94
A class representing a Two-population Univariate Moment-based statistical context.
Definition: types_stat.hpp:43
virtual void deInit() override
Deinitialize the CPA engine.
Definition: oclcpa.cpp:53
This header file contains exceptions.
CPA computation engine QT plugin interface.
Definition: cpaengine.h:43
CPA context computation SICAK CpaEngine plugin, OpenCL implementation.
Definition: oclcpa.h:53
virtual QString getPluginName() override
Plugin name.
Definition: oclcpa.cpp:39
virtual UnivariateContext< double > createContext(const PowerTraces< int16_t > &powerTraces, const PowerPredictions< uint8_t > &powerPredictions) override
Creates context from traces and predictions using GPU. When constTraces=true, the traces are loaded t...
Definition: oclcpa.cpp:68
A class representing a matrix, stored in the machine's free space.
Definition: types_basic.hpp:305
OpenCL implementation of CPA statistical algorithms as function templates.
virtual void init(int platform, int device, size_t noOfTraces, size_t samplesPerTrace, size_t noOfCandidates, const char *param) override
Initialize the CPA computation engine with specified parameters.
Definition: oclcpa.cpp:47
Implementation of CPA statistical algorithms as function templates for various SICAK plugins.
A class representing a Matrix with 'noOfTraces' power predictions, with 'noOfCandidates' key candidat...
Definition: types_power.hpp:82
virtual QString queryDevices() override
Query for devices available.
Definition: oclcpa.cpp:59
virtual Matrix< double > finalizeContext(const UnivariateContext< double > &context) override
Compute correlation matrix based on given context.
Definition: oclcpa.cpp:99
virtual QString getPluginInfo() override
Plugin info.
Definition: oclcpa.cpp:43
A class representing a Matrix with 'noOfTraces' power traces, with 'samplesPerTrace' samples per powe...
Definition: types_power.hpp:44