-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeccaklib.fs
50 lines (43 loc) · 1.82 KB
/
keccaklib.fs
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
\ keccak wrapper
\ Copyright © 2012-2015 Bernd Paysan
\ This program is free software: you can redistribute it and/or modify
\ it under the terms of the GNU Affero General Public License as published by
\ the Free Software Foundation, either version 3 of the License, or
\ (at your option) any later version.
\ This program is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\ GNU Affero General Public License for more details.
\ You should have received a copy of the GNU Affero General Public License
\ along with this program. If not, see <http://www.gnu.org/licenses/>.
\c #include <KeccakF-1600.h>
\c UINT64* KeccakEncryptLoop(keccak_state state, UINT64 * data, size_t n, int rounds)
\c {
\c while(n!=0) {
\c size_t p = (n >= 128) ? 128 : n;
\c KeccakF(state, rounds);
\c KeccakEncrypt(state, data, p);
\c data = (UINT64*)(((char*)data)+p); n-=p;
\c }
\c return data;
\c }
\c UINT64* KeccakDecryptLoop(keccak_state state, UINT64 * data, size_t n, int rounds)
\c {
\c while(n!=0) {
\c size_t p = (n >= 128) ? 128 : n;
\c KeccakF(state, rounds);
\c KeccakDecrypt(state, data, p);
\c data = (UINT64*)(((char*)data)+p); n-=p;
\c }
\c return data;
\c }
\ ------===< functions >===-------
c-function KeccakInitialize KeccakInitialize -- void
c-function KeccakF KeccakF a n -- void
c-function KeccakInitializeState KeccakInitializeState a -- void
c-function KeccakExtract KeccakExtract a a n -- void
c-function KeccakAbsorb KeccakAbsorb a a n -- void
c-function KeccakEncrypt KeccakEncrypt a a n -- void
c-function KeccakDecrypt KeccakDecrypt a a n -- void
c-function KeccakEncryptLoop KeccakEncryptLoop a a u n -- a
c-function KeccakDecryptLoop KeccakDecryptLoop a a u n -- a