FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Modules/_sha3/kcp/PlSnP-Fallback.inc at pythoncapi · pythoncapi/cpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
pythoncapi
/
cpython
Public
forked from
python/cpython
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Modules
/
_sha3
/
kcp
/
PlSnP-Fallback.inc
Copy path
More file actions
More file actions
Latest commit
History
History
History
257 lines (224 loc) · 9.31 KB
Breadcrumbs
cpython
/
Modules
/
_sha3
/
kcp
/
PlSnP-Fallback.inc
Copy path
File metadata and controls
257 lines (224 loc) · 9.31 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
/*
Implementation by the Keccak, Keyak and Ketje Teams, namely, Guido Bertoni,
Joan Daemen, Michaël Peeters, Gilles Van Assche and Ronny Van Keer, hereby
denoted as "the implementer".
For more information, feedback or questions, please refer to our websites:
http://keccak.noekeon.org/
http://keyak.noekeon.org/
http://ketje.noekeon.org/
To the extent possible under law, the implementer has waived all copyright
and related or neighboring rights to the source code in this file.
http://creativecommons.org/publicdomain/zero/1.0/
*/
/*
expect PlSnP_baseParallelism, PlSnP_targetParallelism
*/
/*
expect SnP_stateSizeInBytes, SnP_stateAlignment
*/
/*
expect prefix
*/
/*
expect SnP_*
*/
#
define
JOIN0
(
a, b
) a ## b
#
define
JOIN
(
a, b
)
JOIN0
(a, b)
#
define
PlSnP_StaticInitialize
JOIN
(prefix, _StaticInitialize)
#
define
PlSnP_InitializeAll
JOIN
(prefix, _InitializeAll)
#
define
PlSnP_AddByte
JOIN
(prefix, _AddByte)
#
define
PlSnP_AddBytes
JOIN
(prefix, _AddBytes)
#
define
PlSnP_AddLanesAll
JOIN
(prefix, _AddLanesAll)
#
define
PlSnP_OverwriteBytes
JOIN
(prefix, _OverwriteBytes)
#
define
PlSnP_OverwriteLanesAll
JOIN
(prefix, _OverwriteLanesAll)
#
define
PlSnP_OverwriteWithZeroes
JOIN
(prefix, _OverwriteWithZeroes)
#
define
PlSnP_ExtractBytes
JOIN
(prefix, _ExtractBytes)
#
define
PlSnP_ExtractLanesAll
JOIN
(prefix, _ExtractLanesAll)
#
define
PlSnP_ExtractAndAddBytes
JOIN
(prefix, _ExtractAndAddBytes)
#
define
PlSnP_ExtractAndAddLanesAll
JOIN
(prefix, _ExtractAndAddLanesAll)
#
if
(PlSnP_baseParallelism == 1)
#
define
SnP_stateSizeInBytes
JOIN
(SnP, _stateSizeInBytes)
#define SnP_stateAlignment
JOIN
(SnP, _stateAlignment)
#
else
#
define
SnP_stateSizeInBytes
JOIN
(SnP, _statesSizeInBytes)
#define SnP_stateAlignment
JOIN
(SnP, _statesAlignment)
#endif
#
define
PlSnP_factor
((PlSnP_targetParallelism)/(PlSnP_baseParallelism))
#
define
SnP_stateOffset
(((SnP_stateSizeInBytes+(SnP_stateAlignment-
1
))/SnP_stateAlignment)*SnP_stateAlignment)
#
define
stateWithIndex
(
i
) ((
unsigned
char
*)states+((i)*SnP_stateOffset))
#
define
SnP_StaticInitialize
JOIN
(SnP, _StaticInitialize)
#
define
SnP_Initialize
JOIN
(SnP, _Initialize)
#
define
SnP_InitializeAll
JOIN
(SnP, _InitializeAll)
#
define
SnP_AddByte
JOIN
(SnP, _AddByte)
#
define
SnP_AddBytes
JOIN
(SnP, _AddBytes)
#
define
SnP_AddLanesAll
JOIN
(SnP, _AddLanesAll)
#
define
SnP_OverwriteBytes
JOIN
(SnP, _OverwriteBytes)
#
define
SnP_OverwriteLanesAll
JOIN
(SnP, _OverwriteLanesAll)
#
define
SnP_OverwriteWithZeroes
JOIN
(SnP, _OverwriteWithZeroes)
#
define
SnP_ExtractBytes
JOIN
(SnP, _ExtractBytes)
#
define
SnP_ExtractLanesAll
JOIN
(SnP, _ExtractLanesAll)
#
define
SnP_ExtractAndAddBytes
JOIN
(SnP, _ExtractAndAddBytes)
#
define
SnP_ExtractAndAddLanesAll
JOIN
(SnP, _ExtractAndAddLanesAll)
void PlSnP_StaticInitialize(
void
)
{
SnP_StaticInitialize
();
}
void
PlSnP_InitializeAll
(
void
*states)
{
unsigned
int
i;
for
(i=
0
; i<PlSnP_factor; i++)
#
if
(PlSnP_baseParallelism == 1)
SnP_Initialize
(
stateWithIndex
(i));
#
else
SnP_InitializeAll
(
stateWithIndex
(i));
#
endif
}
void
PlSnP_AddByte
(
void
*states,
unsigned
int
instanceIndex,
unsigned
char
byte,
unsigned
int
offset)
{
#
if
(PlSnP_baseParallelism == 1)
SnP_AddByte
(
stateWithIndex
(instanceIndex), byte, offset);
#
else
SnP_AddByte
(
stateWithIndex
(instanceIndex/PlSnP_baseParallelism), instanceIndex%PlSnP_baseParallelism, byte, offset);
#
endif
}
void
PlSnP_AddBytes
(
void
*states,
unsigned
int
instanceIndex,
const
unsigned
char
*data,
unsigned
int
offset,
unsigned
int
length)
{
#
if
(PlSnP_baseParallelism == 1)
SnP_AddBytes
(
stateWithIndex
(instanceIndex), data, offset, length);
#
else
SnP_AddBytes
(
stateWithIndex
(instanceIndex/PlSnP_baseParallelism), instanceIndex%PlSnP_baseParallelism, data, offset, length);
#
endif
}
void
PlSnP_AddLanesAll
(
void
*states,
const
unsigned
char
*data,
unsigned
int
laneCount,
unsigned
int
laneOffset)
{
unsigned
int
i;
for
(i=
0
; i<PlSnP_factor; i++) {
#
if
(PlSnP_baseParallelism == 1)
SnP_AddBytes
(
stateWithIndex
(i), data,
0
, laneCount*SnP_laneLengthInBytes);
#
else
SnP_AddLanesAll
(
stateWithIndex
(i), data, laneCount, laneOffset);
#
endif
data += PlSnP_baseParallelism*laneOffset*SnP_laneLengthInBytes;
}
}
void
PlSnP_OverwriteBytes
(
void
*states,
unsigned
int
instanceIndex,
const
unsigned
char
*data,
unsigned
int
offset,
unsigned
int
length)
{
#
if
(PlSnP_baseParallelism == 1)
SnP_OverwriteBytes
(
stateWithIndex
(instanceIndex), data, offset, length);
#
else
SnP_OverwriteBytes
(
stateWithIndex
(instanceIndex/PlSnP_baseParallelism), instanceIndex%PlSnP_baseParallelism, data, offset, length);
#
endif
}
void
PlSnP_OverwriteLanesAll
(
void
*states,
const
unsigned
char
*data,
unsigned
int
laneCount,
unsigned
int
laneOffset)
{
unsigned
int
i;
for
(i=
0
; i<PlSnP_factor; i++) {
#
if
(PlSnP_baseParallelism == 1)
SnP_OverwriteBytes
(
stateWithIndex
(i), data,
0
, laneCount*SnP_laneLengthInBytes);
#
else
SnP_OverwriteLanesAll
(
stateWithIndex
(i), data, laneCount, laneOffset);
#
endif
data += PlSnP_baseParallelism*laneOffset*SnP_laneLengthInBytes;
}
}
void
PlSnP_OverwriteWithZeroes
(
void
*states,
unsigned
int
instanceIndex,
unsigned
int
byteCount)
{
#
if
(PlSnP_baseParallelism == 1)
SnP_OverwriteWithZeroes
(
stateWithIndex
(instanceIndex), byteCount);
#
else
SnP_OverwriteWithZeroes
(
stateWithIndex
(instanceIndex/PlSnP_baseParallelism), instanceIndex%PlSnP_baseParallelism, byteCount);
#
endif
}
void
PlSnP_PermuteAll
(
void
*states)
{
unsigned
int
i;
for
(i=
0
; i<PlSnP_factor; i++) {
#
if
(PlSnP_baseParallelism == 1)
SnP_Permute
(
stateWithIndex
(i));
#
else
SnP_PermuteAll
(
stateWithIndex
(i));
#
endif
}
}
#
if
(defined(SnP_Permute_12rounds) || defined(SnP_PermuteAll_12rounds))
void
PlSnP_PermuteAll_12rounds
(
void
*states)
{
unsigned
int
i;
for
(i=
0
; i<PlSnP_factor; i++) {
#
if
(PlSnP_baseParallelism == 1)
SnP_Permute_12rounds
(
stateWithIndex
(i));
#
else
SnP_PermuteAll_12rounds
(
stateWithIndex
(i));
#
endif
}
}
#
endif
void
PlSnP_ExtractBytes
(
void
*states,
unsigned
int
instanceIndex,
unsigned
char
*data,
unsigned
int
offset,
unsigned
int
length)
{
#
if
(PlSnP_baseParallelism == 1)
SnP_ExtractBytes
(
stateWithIndex
(instanceIndex), data, offset, length);
#
else
SnP_ExtractBytes
(
stateWithIndex
(instanceIndex/PlSnP_baseParallelism), instanceIndex%PlSnP_baseParallelism, data, offset, length);
#
endif
}
void
PlSnP_ExtractLanesAll
(
const
void
*states,
unsigned
char
*data,
unsigned
int
laneCount,
unsigned
int
laneOffset)
{
unsigned
int
i;
for
(i=
0
; i<PlSnP_factor; i++) {
#
if
(PlSnP_baseParallelism == 1)
SnP_ExtractBytes
(
stateWithIndex
(i), data,
0
, laneCount*SnP_laneLengthInBytes);
#
else
SnP_ExtractLanesAll
(
stateWithIndex
(i), data, laneCount, laneOffset);
#
endif
data += laneOffset*SnP_laneLengthInBytes*PlSnP_baseParallelism;
}
}
void
PlSnP_ExtractAndAddBytes
(
void
*states,
unsigned
int
instanceIndex,
const
unsigned
char
*input,
unsigned
char
*output,
unsigned
int
offset,
unsigned
int
length)
{
#
if
(PlSnP_baseParallelism == 1)
SnP_ExtractAndAddBytes
(
stateWithIndex
(instanceIndex), input, output, offset, length);
#
else
SnP_ExtractAndAddBytes
(
stateWithIndex
(instanceIndex/PlSnP_baseParallelism), instanceIndex%PlSnP_baseParallelism, input, output, offset, length);
#
endif
}
void
PlSnP_ExtractAndAddLanesAll
(
const
void
*states,
const
unsigned
char
*input,
unsigned
char
*output,
unsigned
int
laneCount,
unsigned
int
laneOffset)
{
unsigned
int
i;
for
(i=
0
; i<PlSnP_factor; i++) {
#
if
(PlSnP_baseParallelism == 1)
SnP_ExtractAndAddBytes
(
stateWithIndex
(i), input, output,
0
, laneCount*SnP_laneLengthInBytes);
#
else
SnP_ExtractAndAddLanesAll
(
stateWithIndex
(i), input, output, laneCount, laneOffset);
#
endif
input += laneOffset*SnP_laneLengthInBytes*PlSnP_baseParallelism;
output += laneOffset*SnP_laneLengthInBytes*PlSnP_baseParallelism;
}
}
#
undef
PlSnP_factor
#
undef
SnP_stateOffset
#
undef
stateWithIndex
#
undef
JOIN0
#
undef
JOIN
#
undef
PlSnP_StaticInitialize
#
undef
PlSnP_InitializeAll
#
undef
PlSnP_AddByte
#
undef
PlSnP_AddBytes
#
undef
PlSnP_AddLanesAll
#
undef
PlSnP_OverwriteBytes
#
undef
PlSnP_OverwriteLanesAll
#
undef
PlSnP_OverwriteWithZeroes
#
undef
PlSnP_PermuteAll
#
undef
PlSnP_ExtractBytes
#
undef
PlSnP_ExtractLanesAll
#
undef
PlSnP_ExtractAndAddBytes
#
undef
PlSnP_ExtractAndAddLanesAll
#
undef
SnP_stateAlignment
#
undef
SnP_stateSizeInBytes
#
undef
PlSnP_factor
#
undef
SnP_stateOffset
#
undef
stateWithIndex
#
undef
SnP_StaticInitialize
#
undef
SnP_Initialize
#
undef
SnP_InitializeAll
#
undef
SnP_AddByte
#
undef
SnP_AddBytes
#
undef
SnP_AddLanesAll
#
undef
SnP_OverwriteBytes
#
undef
SnP_OverwriteWithZeroes
#
undef
SnP_OverwriteLanesAll
#
undef
SnP_ExtractBytes
#
undef
SnP_ExtractLanesAll
#
undef
SnP_ExtractAndAddBytes
#
undef
SnP_ExtractAndAddLanesAll
Back
|
FazBrowse Home
|
New Git URL