ATmega644 Smart-Card
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 
31 class Hiding
32 {
33 public:
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 
66 private:
67  #ifdef DUMMY_OPS
68  static constexpr uint8_t MAX_NUMBER_NO_OPS = 100;
69  static constexpr uint8_t NUMBER_OPS = 40;
70  uint8_t mNumbersDummyOps[NUMBER_OPS] = {};
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
Hiding::mNumbersDummyOps
uint8_t mNumbersDummyOps[NUMBER_OPS]
Array of random numbers, which specify the number of dummy ops per round.
Definition: hiding.h:70
Hiding::NUMBER_OPS
static constexpr uint8_t NUMBER_OPS
The number of operations before which the dummy ops are executed.
Definition: hiding.h:69
Hiding::DEFAULT_INV_SBOX_INDICES
static uint8_t DEFAULT_INV_SBOX_INDICES[STATE_BYTES]
Array that contains values from 0 to 15.
Definition: hiding.h:75
Hiding
Class that implements 2 hiding techniques: dummy-ops & shuffling.
Definition: hiding.h:31
Hiding::MAX_NUMBER_NO_OPS
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
RNG
Class that provides a random number generator. The RNG can be seeded by reading noise from an unused ...
Definition: rng.h:26
Hiding::Hiding
Hiding()=default
Construct a new Hiding object.
Hiding::shuffleSBoxAccess
void shuffleSBoxAccess(uint8_t indices[])
Shuffle the S-Box access.
Hiding::mRNG
RNG mRNG
Random number generator.
Definition: hiding.h:78
Hiding::dummyOp
void dummyOp()
Perform a dummy NOP operation a random number of times.
Hiding::mNoOpCounter
uint8_t mNoOpCounter
Counter for the number of dummy ops per round.
Definition: hiding.h:71
Hiding::init
void init()
Initialize AES hiding operations.
Hiding::shuffleArray
void shuffleArray(uint8_t array[], const uint8_t size)
Shuffle an array using the Fisher-Yates shuffle.