-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandmaps.cpp
More file actions
150 lines (133 loc) · 4.74 KB
/
Copy pathrandmaps.cpp
File metadata and controls
150 lines (133 loc) · 4.74 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include "globalvars.h"
data_t f1(data_t x)
{
functionCall++;
IppStatus status;
int srclen;
srclen = 16;
Ipp8u pSrc[16];
Ipp8u pDst[16];
x &= mask;
data_t y;
for (size_t i = 0; i < 16; i++)
{
pSrc[i] = 0;
pDst[i] = 0;
}
memcpy(pSrc, &x, sizeof(data_t));
status = ippsAESEncryptECB(pSrc, pDst, srclen, pCtx1);
switch (status)
{
case ippStsNoErr: /*cout << "ippStsNoErr: Indicates no error." << endl;*/ break;
case ippStsNullPtrErr: cout << "ippStsNullPtrErr: Indicates an error condition if the specified pointer is NULL." << endl; break;
case ippStsLengthErr: cout << "ippStsLengthErr: Indicates an error condition if the input data stream length is less than or equal to zero." << endl; break;
case ippStsUnderRunErr: cout << "ippStsUnderRunErr: Indicates an error condition if srclen is not divisible by cipher block size." << endl; break;
case ippStsContextMatchErr: cout << "ippStsContextMatchErr: Indicates an error condition if the context parameter does not match the operation." << endl; break;
default: break;
}
memcpy(&y, pDst, sizeof(data_t));
return (y & mask);
}
data_t f2(data_t x)
{
functionCall++;
IppStatus status;
Ipp8u pSrc[16];
Ipp8u pDst[16];
int srclen;
srclen = 16;
x &= mask;
data_t y;
for (size_t i = 0; i < 16; i++)
{
pSrc[i] = 0;
pDst[i] = 0;
}
memcpy(pSrc, &x, sizeof(data_t));
status = ippsSMS4DecryptECB(pSrc, pDst, srclen, pCtx2);
switch (status)
{
case ippStsNoErr: /*cout << "ippStsNoErr: Indicates no error." << endl;*/ break;
case ippStsNullPtrErr: cout << "ippStsNullPtrErr: Indicates an error condition if the specified pointer is NULL." << endl; break;
case ippStsLengthErr: cout << "ippStsLengthErr: Indicates an error condition if the input data stream length is less than or equal to zero." << endl; break;
case ippStsUnderRunErr: cout << "ippStsUnderRunErr: Indicates an error condition if srclen is not divisible by cipher block size." << endl; break;
case ippStsContextMatchErr: cout << "ippStsContextMatchErr: Indicates an error condition if the context parameter does not match the operation." << endl; break;
default: break;
}
memcpy(&y, pDst, sizeof(data_t));
return (y & mask);
}
data_t h1(data_t x, u8 mblock[16])
{
functionCall++;
IppStatus status;
int keylen;
int ctxSize;
Ipp8u pKey[16];
IppsAESSpec * pCtx;
memcpy(pKey, mblock, sizeof(pKey));
keylen = 16;
initfunc(AES, pCtx);
int srclen;
srclen = 16;
Ipp8u pSrc[16];
Ipp8u pDst[16];
x &= mask;
data_t y;
for (size_t i = 0; i < 16; i++)
{
pSrc[i] = 0;
pDst[i] = 0;
}
memcpy(pSrc, &x, sizeof(data_t));
status = ippsAESEncryptECB(pSrc, pDst, srclen, pCtx);
switch (status)
{
case ippStsNoErr: /*cout << "ippStsNoErr: Indicates no error." << endl;*/ break;
case ippStsNullPtrErr: cout << "ippStsNullPtrErr: Indicates an error condition if the specified pointer is NULL." << endl; break;
case ippStsLengthErr: cout << "ippStsLengthErr: Indicates an error condition if the input data stream length is less than or equal to zero." << endl; break;
case ippStsUnderRunErr: cout << "ippStsUnderRunErr: Indicates an error condition if srclen is not divisible by cipher block size." << endl; break;
case ippStsContextMatchErr: cout << "ippStsContextMatchErr: Indicates an error condition if the context parameter does not match the operation." << endl; break;
default: break;
}
memcpy(&y, pDst, sizeof(data_t));
endfunc(pCtx);
return (y & mask);
}
data_t h2(data_t x, u8 mblock[16])
{
functionCall++;
IppStatus status;
int keylen;
int ctxSize;
Ipp8u pKey[16];
IppsSMS4Spec * pCtx;
memcpy(pKey, mblock, sizeof(pKey));
keylen = 16;
initfunc(SMS4, pCtx);
Ipp8u pSrc[16];
Ipp8u pDst[16];
int srclen;
srclen = 16;
x &= mask;
data_t y;
for (size_t i = 0; i < 16; i++)
{
pSrc[i] = 0;
pDst[i] = 0;
}
memcpy(pSrc, &x, sizeof(data_t));
status = ippsSMS4DecryptECB(pSrc, pDst, srclen, pCtx);
switch (status)
{
case ippStsNoErr: /*cout << "ippStsNoErr: Indicates no error." << endl;*/ break;
case ippStsNullPtrErr: cout << "ippStsNullPtrErr: Indicates an error condition if the specified pointer is NULL." << endl; break;
case ippStsLengthErr: cout << "ippStsLengthErr: Indicates an error condition if the input data stream length is less than or equal to zero." << endl; break;
case ippStsUnderRunErr: cout << "ippStsUnderRunErr: Indicates an error condition if srclen is not divisible by cipher block size." << endl; break;
case ippStsContextMatchErr: cout << "ippStsContextMatchErr: Indicates an error condition if the context parameter does not match the operation." << endl; break;
default: break;
}
memcpy(&y, pDst, sizeof(data_t));
endfunc(pCtx);
return (y & mask);
}