Electroneum
groestl.h
Go to the documentation of this file.
1 // Copyrights(c) 2017-2021, The Electroneum Project
2 // Copyrights(c) 2014-2019, The Monero Project
3 //
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without modification, are
7 // permitted provided that the following conditions are met:
8 //
9 // 1. Redistributions of source code must retain the above copyright notice, this list of
10 // conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 // of conditions and the following disclaimer in the documentation and/or other
14 // materials provided with the distribution.
15 //
16 // 3. Neither the name of the copyright holder nor the names of its contributors may be
17 // used to endorse or promote products derived from this software without specific
18 // prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 #ifndef __hash_h
31 #define __hash_h
32 /*
33 #include "crypto_uint8.h"
34 #include "crypto_uint32.h"
35 #include "crypto_uint64.h"
36 #include "crypto_hash.h"
37 
38 typedef crypto_uint8 uint8_t;
39 typedef crypto_uint32 uint32_t;
40 typedef crypto_uint64 uint64_t;
41 */
42 #include <stdint.h>
43 
44 /* some sizes (number of bytes) */
45 #define ROWS 8
46 #define LENGTHFIELDLEN ROWS
47 #define COLS512 8
48 
49 #define SIZE512 (ROWS*COLS512)
50 
51 #define ROUNDS512 10
52 #define HASH_BIT_LEN 256
53 
54 #define ROTL32(v, n) ((((v)<<(n))|((v)>>(32-(n))))&li_32(ffffffff))
55 
56 
57 #define li_32(h) 0x##h##u
58 #define EXT_BYTE(var,n) ((uint8_t)((uint32_t)(var) >> (8*n)))
59 #define u32BIG(a) \
60  ((ROTL32(a,8) & li_32(00FF00FF)) | \
61  (ROTL32(a,24) & li_32(FF00FF00)))
62 
63 
64 /* NIST API begin */
65 typedef unsigned char BitSequence;
66 typedef unsigned long long DataLength;
67 typedef struct {
68  uint32_t chaining[SIZE512/sizeof(uint32_t)]; /* actual state */
69  uint32_t block_counter1,
70  block_counter2; /* message block counter(s) */
71  BitSequence buffer[SIZE512]; /* data buffer */
72  int buf_ptr; /* data buffer pointer */
73  int bits_in_last_byte; /* no. of message bits in last byte of
74  data buffer */
75 } hashState;
76 
77 /*void Init(hashState*);
78 void Update(hashState*, const BitSequence*, DataLength);
79 void Final(hashState*, BitSequence*); */
81 /* NIST API end */
82 
83 /*
84 int crypto_hash(unsigned char *out,
85  const unsigned char *in,
86  unsigned long long len);
87 */
88 
89 #endif /* __hash_h */
uint32_t block_counter2
Definition: groestl.h:69
void groestl(const BitSequence *, DataLength, BitSequence *)
unsigned char BitSequence
Definition: groestl.h:65
unsigned int uint32_t
Definition: stdint.h:126
int buf_ptr
Definition: groestl.h:72
#define SIZE512
Definition: groestl.h:49
unsigned long long DataLength
Definition: groestl.h:66
int bits_in_last_byte
Definition: groestl.h:73