ATmega644 Smart-Card
Loading...
Searching...
No Matches
hiding.h
1
11#ifndef HIDING_H
12#define HIDING_H
13
14#include "defs.h"
15#include "rng.h"
16#include "aesMath.h"
17#include <string.h>
18
31class Hiding
32{
33public:
37 Hiding() = default;
38
47 void init();
48
55 #ifdef SHUFFLING
56 void shuffleSBoxAccess(uint8_t indices[]);
57 #endif
58
62 #ifdef DUMMY_OPS
63 void dummyOp();
64 #endif
65
66private:
67 #ifdef DUMMY_OPS
68 static constexpr uint8_t MAX_NUMBER_NO_OPS = 100;
69 static constexpr uint8_t NUMBER_OPS = 40;
71 uint8_t mNoOpCounter = 0;
72 #endif
73
74 #ifdef SHUFFLING
75 static uint8_t DEFAULT_INV_SBOX_INDICES[STATE_BYTES];
76 #endif
77
79
85 void shuffleArray(uint8_t array[], const uint8_t size);
86};
87
88#endif // HIDING_H
Class that implements 2 hiding techniques: dummy-ops & shuffling.
Definition hiding.h:32
void dummyOp()
Perform a dummy NOP operation a random number of times.
RNG mRNG
Random number generator.
Definition hiding.h:78
void init()
Initialize AES hiding operations.
static constexpr uint8_t NUMBER_OPS
The number of operations before which the dummy ops are executed.
Definition hiding.h:69
void shuffleSBoxAccess(uint8_t indices[])
Shuffle the S-Box access.
uint8_t mNoOpCounter
Counter for the number of dummy ops per round.
Definition hiding.h:71
Hiding()=default
Construct a new Hiding object.
static uint8_t DEFAULT_INV_SBOX_INDICES[STATE_BYTES]
Array that contains values from 0 to 15.
Definition hiding.h:75
uint8_t mNumbersDummyOps[NUMBER_OPS]
Array of random numbers, which specify the number of dummy ops per round.
Definition hiding.h:70
void shuffleArray(uint8_t array[], const uint8_t size)
Shuffle an array using the Fisher-Yates shuffle.
static constexpr uint8_t MAX_NUMBER_NO_OPS
The maximum number of NOPs per AES execution. It is important that this number stays the same for eve...
Definition hiding.h:68
Class that provides a random number generator. The RNG can be seeded by reading noise from an unused ...
Definition rng.h:27