Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(43487)

Delta Between Two Patch Sets: Modules/_sha3/kcp/SnP-Relaned.h

Issue 16113: Add SHA-3 (Keccak) support
Left Patch Set: Created 6 years, 11 months ago
Right Patch Set: Created 3 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « Modules/_sha3/kcp/PlSnP-Fallback.inc ('k') | Modules/_sha3/README.txt » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /*
2 Implementation by the Keccak, Keyak and Ketje Teams, namely, Guido Bertoni,
3 Joan Daemen, Michaƫl Peeters, Gilles Van Assche and Ronny Van Keer, hereby
4 denoted as "the implementer".
5
6 For more information, feedback or questions, please refer to our websites:
7 http://keccak.noekeon.org/
8 http://keyak.noekeon.org/
9 http://ketje.noekeon.org/
10
11 To the extent possible under law, the implementer has waived all copyright
12 and related or neighboring rights to the source code in this file.
13 http://creativecommons.org/publicdomain/zero/1.0/
14 */
15
16 #ifndef _SnP_Relaned_h_
17 #define _SnP_Relaned_h_
18
19 #define SnP_AddBytes(state, data, offset, length, SnP_AddLanes, SnP_AddBytesInLa ne, SnP_laneLengthInBytes) \
20 { \
21 if ((offset) == 0) { \
22 SnP_AddLanes(state, data, (length)/SnP_laneLengthInBytes); \
23 SnP_AddBytesInLane(state, \
24 (length)/SnP_laneLengthInBytes, \
25 (data)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
26 0, \
27 (length)%SnP_laneLengthInBytes); \
28 } \
29 else { \
30 unsigned int _sizeLeft = (length); \
31 unsigned int _lanePosition = (offset)/SnP_laneLengthInBytes; \
32 unsigned int _offsetInLane = (offset)%SnP_laneLengthInBytes; \
33 const unsigned char *_curData = (data); \
34 while(_sizeLeft > 0) { \
35 unsigned int _bytesInLane = SnP_laneLengthInBytes - _offsetInLan e; \
36 if (_bytesInLane > _sizeLeft) \
37 _bytesInLane = _sizeLeft; \
38 SnP_AddBytesInLane(state, _lanePosition, _curData, _offsetInLane , _bytesInLane); \
39 _sizeLeft -= _bytesInLane; \
40 _lanePosition++; \
41 _offsetInLane = 0; \
42 _curData += _bytesInLane; \
43 } \
44 } \
45 }
46
47 #define SnP_OverwriteBytes(state, data, offset, length, SnP_OverwriteLanes, SnP_ OverwriteBytesInLane, SnP_laneLengthInBytes) \
48 { \
49 if ((offset) == 0) { \
50 SnP_OverwriteLanes(state, data, (length)/SnP_laneLengthInBytes); \
51 SnP_OverwriteBytesInLane(state, \
52 (length)/SnP_laneLengthInBytes, \
53 (data)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
54 0, \
55 (length)%SnP_laneLengthInBytes); \
56 } \
57 else { \
58 unsigned int _sizeLeft = (length); \
59 unsigned int _lanePosition = (offset)/SnP_laneLengthInBytes; \
60 unsigned int _offsetInLane = (offset)%SnP_laneLengthInBytes; \
61 const unsigned char *_curData = (data); \
62 while(_sizeLeft > 0) { \
63 unsigned int _bytesInLane = SnP_laneLengthInBytes - _offsetInLan e; \
64 if (_bytesInLane > _sizeLeft) \
65 _bytesInLane = _sizeLeft; \
66 SnP_OverwriteBytesInLane(state, _lanePosition, _curData, _offset InLane, _bytesInLane); \
67 _sizeLeft -= _bytesInLane; \
68 _lanePosition++; \
69 _offsetInLane = 0; \
70 _curData += _bytesInLane; \
71 } \
72 } \
73 }
74
75 #define SnP_ExtractBytes(state, data, offset, length, SnP_ExtractLanes, SnP_Extr actBytesInLane, SnP_laneLengthInBytes) \
76 { \
77 if ((offset) == 0) { \
78 SnP_ExtractLanes(state, data, (length)/SnP_laneLengthInBytes); \
79 SnP_ExtractBytesInLane(state, \
80 (length)/SnP_laneLengthInBytes, \
81 (data)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
82 0, \
83 (length)%SnP_laneLengthInBytes); \
84 } \
85 else { \
86 unsigned int _sizeLeft = (length); \
87 unsigned int _lanePosition = (offset)/SnP_laneLengthInBytes; \
88 unsigned int _offsetInLane = (offset)%SnP_laneLengthInBytes; \
89 unsigned char *_curData = (data); \
90 while(_sizeLeft > 0) { \
91 unsigned int _bytesInLane = SnP_laneLengthInBytes - _offsetInLan e; \
92 if (_bytesInLane > _sizeLeft) \
93 _bytesInLane = _sizeLeft; \
94 SnP_ExtractBytesInLane(state, _lanePosition, _curData, _offsetIn Lane, _bytesInLane); \
95 _sizeLeft -= _bytesInLane; \
96 _lanePosition++; \
97 _offsetInLane = 0; \
98 _curData += _bytesInLane; \
99 } \
100 } \
101 }
102
103 #define SnP_ExtractAndAddBytes(state, input, output, offset, length, SnP_Extract AndAddLanes, SnP_ExtractAndAddBytesInLane, SnP_laneLengthInBytes) \
104 { \
105 if ((offset) == 0) { \
106 SnP_ExtractAndAddLanes(state, input, output, (length)/SnP_laneLength InBytes); \
107 SnP_ExtractAndAddBytesInLane(state, \
108 (length)/SnP_laneLengthInBytes, \
109 (input)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
110 (output)+((length)/SnP_laneLengthInBytes)*SnP_laneLengthInBytes, \
111 0, \
112 (length)%SnP_laneLengthInBytes); \
113 } \
114 else { \
115 unsigned int _sizeLeft = (length); \
116 unsigned int _lanePosition = (offset)/SnP_laneLengthInBytes; \
117 unsigned int _offsetInLane = (offset)%SnP_laneLengthInBytes; \
118 const unsigned char *_curInput = (input); \
119 unsigned char *_curOutput = (output); \
120 while(_sizeLeft > 0) { \
121 unsigned int _bytesInLane = SnP_laneLengthInBytes - _offsetInLan e; \
122 if (_bytesInLane > _sizeLeft) \
123 _bytesInLane = _sizeLeft; \
124 SnP_ExtractAndAddBytesInLane(state, _lanePosition, _curInput, _c urOutput, _offsetInLane, _bytesInLane); \
125 _sizeLeft -= _bytesInLane; \
126 _lanePosition++; \
127 _offsetInLane = 0; \
128 _curInput += _bytesInLane; \
129 _curOutput += _bytesInLane; \
130 } \
131 } \
132 }
133
134 #endif
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+