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