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

Side by Side Diff: Modules/_sha3/keccak/KeccakSponge.h

Issue 16113: Add SHA-3 (Keccak) support
Patch Set: Created 7 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:
View unified diff | Download patch
« no previous file with comments | « Modules/_sha3/keccak/KeccakSponge.c ('k') | Modules/_sha3/sha3module.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
3 Michaƫl Peeters and Gilles Van Assche. For more information, feedback or
4 questions, please refer to our website: http://keccak.noekeon.org/
5
6 Implementation by the designers,
7 hereby denoted as "the implementer".
8
9 To the extent possible under law, the implementer has waived all copyright
10 and related or neighboring rights to the source code in this file.
11 http://creativecommons.org/publicdomain/zero/1.0/
12 */
13
14 #ifndef _KeccakSponge_h_
15 #define _KeccakSponge_h_
16
17 #define KeccakPermutationSize 1600
18 #define KeccakPermutationSizeInBytes (KeccakPermutationSize/8)
19 #define KeccakMaximumRate 1536
20 #define KeccakMaximumRateInBytes (KeccakMaximumRate/8)
21
22 #if defined(__GNUC__)
23 #define ALIGN __attribute__ ((aligned(32)))
24 #elif defined(_MSC_VER)
25 #define ALIGN __declspec(align(32))
26 #else
27 #define ALIGN
28 #endif
29
30 ALIGN typedef struct spongeStateStruct {
31 ALIGN unsigned char state[KeccakPermutationSizeInBytes];
32 ALIGN unsigned char dataQueue[KeccakMaximumRateInBytes];
33 unsigned int rate;
34 unsigned int capacity;
35 unsigned int bitsInQueue;
36 unsigned int fixedOutputLength;
37 int squeezing;
38 unsigned int bitsAvailableForSqueezing;
39 } spongeState;
40
41 /**
42 * Function to initialize the state of the Keccak[r, c] sponge function.
43 * The sponge function is set to the absorbing phase.
44 * @param state Pointer to the state of the sponge function to be initia lized.
45 * @param rate The value of the rate r.
46 * @param capacity The value of the capacity c.
47 * @pre One must have r+c=1600 and the rate a multiple of 64 bits in this im plementation.
48 * @return Zero if successful, 1 otherwise.
49 */
50 static int InitSponge(spongeState *state, unsigned int rate, unsigned int capaci ty);
51 /**
52 * Function to give input data for the sponge function to absorb.
53 * @param state Pointer to the state of the sponge function initialized by InitSponge().
54 * @param data Pointer to the input data.
55 * When @a databitLen is not a multiple of 8, the last bits of data must be
56 * in the least significant bits of the last byte.
57 * @param databitLen The number of input bits provided in the input data.
58 * @pre In the previous call to Absorb(), databitLen was a multiple of 8.
59 * @pre The sponge function must be in the absorbing phase,
60 * i.e., Squeeze() must not have been called before.
61 * @return Zero if successful, 1 otherwise.
62 */
63 static int Absorb(spongeState *state, const unsigned char *data, unsigned long l ong databitlen);
64 /**
65 * Function to squeeze output data from the sponge function.
66 * If the sponge function was in the absorbing phase, this function
67 * switches it to the squeezing phase.
68 * @param state Pointer to the state of the sponge function initialized by InitSponge().
69 * @param output Pointer to the buffer where to store the output data.
70 * @param outputLength The number of output bits desired.
71 * It must be a multiple of 8.
72 * @return Zero if successful, 1 otherwise.
73 */
74 static int Squeeze(spongeState *state, unsigned char *output, unsigned long long outputLength);
75
76 #endif
OLDNEW
« no previous file with comments | « Modules/_sha3/keccak/KeccakSponge.c ('k') | Modules/_sha3/sha3module.c » ('j') | no next file with comments »

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