forked from Roman-Oliynykov/ciphers-speed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime_measure.hpp
58 lines (36 loc) · 1.75 KB
/
time_measure.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Declarations of constants and data types for ciphers speed comparison
Author: Roman Oliynykov
*/
#ifndef TIME_MEASURE
#define TIME_MEASURE
/* Block size constant definition for 64, 128, 256 and 512 bits */
const int Nb_64 = 1;
const int Nb_128 = 2;
const int Nb_256 = 4;
const int Nb_512 = 8;
// memory block for encryptions in RAM, in megabytes
const unsigned int memory_amount_for_encryption = 1024;
// encryption of 1 GB is too fast for measure; re-encrypt several times
const unsigned int number_of_reencryptions_in_memory = 8;
const unsigned int number_of_blocks_in_memory_64 = memory_amount_for_encryption * 1024 * 1024 / 8 / 1;
const unsigned int number_of_blocks_in_memory_128 = memory_amount_for_encryption * 1024 * 1024 / 8 / Nb_128;
const unsigned int number_of_blocks_in_memory_256 = memory_amount_for_encryption * 1024 * 1024 / 8 / Nb_256;
const unsigned int number_of_blocks_in_memory_512 = memory_amount_for_encryption * 1024 * 1024 / 8 / Nb_512;
/* types for data blocks */
typedef unsigned long long DATA_64;
typedef unsigned long long DATA_128[ Nb_128 ];
typedef unsigned long long DATA_256[ Nb_256 ];
typedef unsigned long long DATA_512[ Nb_512 ];
typedef union {
DATA_64 block64 [ number_of_blocks_in_memory_64 ];
DATA_128 block128[ number_of_blocks_in_memory_128 ];
DATA_256 block256[ number_of_blocks_in_memory_256 ];
DATA_512 block512[ number_of_blocks_in_memory_512 ];
} ENCRYPTED_MEMORY;
// Getting current processor number of ticks for time of call
void DetermineTime(struct timeval& ticks );
double CalculateEncryptionSpeedMemory(struct timeval& start_ticks, struct timeval& finish_ticks );
// fill memory with different constants
void InitMemoryEncryptionBlock();
#endif