-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIV.h
108 lines (71 loc) · 2.28 KB
/
IV.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
IV.h
Joshua Cobb, Luke Engle, Everett Gally
*/
#ifndef COSC370_PROJECT_IV_H
#define COSC370_PROJECT_IV_H
#include <cstdint>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
using namespace std;
#define DEVURANDOM "/dev/urandom"
typedef unsigned char TYPE;
class IV {
public:
/*
return value: none (constructor)
parameters:
unsigned char array containing the IV you want to use
unsigned 64-bit integer containing the length of the IV in bytes
description:
This function will create an IV object from the given data and length.
*/
IV(const unsigned char *, uint64_t);
/*
return value: none (constructor)
parameters:
unsigned 64-bit integer containing the length of the IV you want to generate in bytes
description:
This function will generate an IV object with the given length in bytes.
*/
IV(uint64_t);
/*
return value: none (destructor)
parameters: none
description:
This function will destroy the IV object and free the memory it is using.
*/
~IV();
/*
return value: pointer to the IV data (const so the data cannot be modified)
parameters: none
description:
This function will return a pointer to the data contained within the IV. It is const so that the user cannot accidentally
modify the data. Since the user passes in the length of the IV, they are responsible for making sure they do not read
beyond the end of the data, however the iv objects do allow seeing how many bytes are in the IV with getlength().
*/
const unsigned char * getData() const;
/*
return value: unsigned 64-bit integer
parameters: none
description:
This function will return an integer representing how long the data in the IV is in bytes.
*/
uint64_t getLength() const;
private:
// actual data within the IV
unsigned char * data = nullptr;
// length of the data in the iv in bytes
uint64_t length;
/*
return value: unsigned char
parameters: none
description:
This function will return a cryptographically secure random byte by reading from the urandom device.
static because it does not change based on which object it is called on.
*/
static TYPE getRandU8();
};
#endif //COSC370_PROJECT_IV_H