Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tpruvot
GitHub Repository: tpruvot/cpuminer-multi
Path: blob/linux/sha3/sph_radiogatun.h
1201 views
1
/* $Id: sph_radiogatun.h 226 2010-06-16 17:28:08Z tp $ */
2
/**
3
* RadioGatun interface.
4
*
5
* RadioGatun has been published in: G. Bertoni, J. Daemen, M. Peeters
6
* and G. Van Assche, "RadioGatun, a belt-and-mill hash function",
7
* presented at the Second Cryptographic Hash Workshop, Santa Barbara,
8
* August 24-25, 2006. The main Web site, containing that article, the
9
* reference code and some test vectors, appears to be currently located
10
* at the following URL: http://radiogatun.noekeon.org/
11
*
12
* The presentation article does not specify endianness or padding. The
13
* reference code uses the following conventions, which we also apply
14
* here:
15
* <ul>
16
* <li>The input message is an integral number of sequences of three
17
* words. Each word is either a 32-bit of 64-bit word (depending on
18
* the version of RadioGatun).</li>
19
* <li>Input bytes are decoded into words using little-endian
20
* convention.</li>
21
* <li>Padding consists of a single bit of value 1, using little-endian
22
* convention within bytes (i.e. for a byte-oriented input, a single
23
* byte of value 0x01 is appended), then enough bits of value 0 to finish
24
* the current block.</li>
25
* <li>Output consists of 256 bits. Successive output words are encoded
26
* with little-endian convention.</li>
27
* </ul>
28
* These conventions are very close to those we use for PANAMA, which is
29
* a close ancestor or RadioGatun.
30
*
31
* RadioGatun is actually a family of functions, depending on some
32
* internal parameters. We implement here two functions, with a "belt
33
* length" of 13, a "belt width" of 3, and a "mill length" of 19. The
34
* RadioGatun[32] version uses 32-bit words, while the RadioGatun[64]
35
* variant uses 64-bit words.
36
*
37
* Strictly speaking, the name "RadioGatun" should use an acute accent
38
* on the "u", which we omitted here to keep strict ASCII-compatibility
39
* of this file.
40
*
41
* ==========================(LICENSE BEGIN)============================
42
*
43
* Copyright (c) 2007-2010 Projet RNRT SAPHIR
44
*
45
* Permission is hereby granted, free of charge, to any person obtaining
46
* a copy of this software and associated documentation files (the
47
* "Software"), to deal in the Software without restriction, including
48
* without limitation the rights to use, copy, modify, merge, publish,
49
* distribute, sublicense, and/or sell copies of the Software, and to
50
* permit persons to whom the Software is furnished to do so, subject to
51
* the following conditions:
52
*
53
* The above copyright notice and this permission notice shall be
54
* included in all copies or substantial portions of the Software.
55
*
56
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
57
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
58
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
59
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
60
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
61
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
62
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
63
*
64
* ===========================(LICENSE END)=============================
65
*
66
* @file sph_radiogatun.h
67
* @author Thomas Pornin <[email protected]>
68
*/
69
70
#ifndef SPH_RADIOGATUN_H__
71
#define SPH_RADIOGATUN_H__
72
73
#include <stddef.h>
74
#include "sph_types.h"
75
76
/**
77
* Output size (in bits) for RadioGatun[32].
78
*/
79
#define SPH_SIZE_radiogatun32 256
80
81
/**
82
* This structure is a context for RadioGatun[32] computations: it
83
* contains intermediate values and some data from the last entered
84
* block. Once a RadioGatun[32] computation has been performed, the
85
* context can be reused for another computation.
86
*
87
* The contents of this structure are private. A running RadioGatun[32]
88
* computation can be cloned by copying the context (e.g. with a
89
* simple <code>memcpy()</code>).
90
*/
91
typedef struct {
92
#ifndef DOXYGEN_IGNORE
93
unsigned char data[156]; /* first field, for alignment */
94
unsigned data_ptr;
95
sph_u32 a[19], b[39];
96
#endif
97
} sph_radiogatun32_context;
98
99
/**
100
* Initialize a RadioGatun[32] context. This process performs no
101
* memory allocation.
102
*
103
* @param cc the RadioGatun[32] context (pointer to a
104
* <code>sph_radiogatun32_context</code>)
105
*/
106
void sph_radiogatun32_init(void *cc);
107
108
/**
109
* Process some data bytes. It is acceptable that <code>len</code> is zero
110
* (in which case this function does nothing).
111
*
112
* @param cc the RadioGatun[32] context
113
* @param data the input data
114
* @param len the input data length (in bytes)
115
*/
116
void sph_radiogatun32(void *cc, const void *data, size_t len);
117
118
/**
119
* Terminate the current RadioGatun[32] computation and output the
120
* result into the provided buffer. The destination buffer must be wide
121
* enough to accomodate the result (32 bytes). The context is
122
* automatically reinitialized.
123
*
124
* @param cc the RadioGatun[32] context
125
* @param dst the destination buffer
126
*/
127
void sph_radiogatun32_close(void *cc, void *dst);
128
129
#if SPH_64
130
131
/**
132
* Output size (in bits) for RadioGatun[64].
133
*/
134
#define SPH_SIZE_radiogatun64 256
135
136
/**
137
* This structure is a context for RadioGatun[64] computations: it
138
* contains intermediate values and some data from the last entered
139
* block. Once a RadioGatun[64] computation has been performed, the
140
* context can be reused for another computation.
141
*
142
* The contents of this structure are private. A running RadioGatun[64]
143
* computation can be cloned by copying the context (e.g. with a
144
* simple <code>memcpy()</code>).
145
*/
146
typedef struct {
147
#ifndef DOXYGEN_IGNORE
148
unsigned char data[312]; /* first field, for alignment */
149
unsigned data_ptr;
150
sph_u64 a[19], b[39];
151
#endif
152
} sph_radiogatun64_context;
153
154
/**
155
* Initialize a RadioGatun[64] context. This process performs no
156
* memory allocation.
157
*
158
* @param cc the RadioGatun[64] context (pointer to a
159
* <code>sph_radiogatun64_context</code>)
160
*/
161
void sph_radiogatun64_init(void *cc);
162
163
/**
164
* Process some data bytes. It is acceptable that <code>len</code> is zero
165
* (in which case this function does nothing).
166
*
167
* @param cc the RadioGatun[64] context
168
* @param data the input data
169
* @param len the input data length (in bytes)
170
*/
171
void sph_radiogatun64(void *cc, const void *data, size_t len);
172
173
/**
174
* Terminate the current RadioGatun[64] computation and output the
175
* result into the provided buffer. The destination buffer must be wide
176
* enough to accomodate the result (32 bytes). The context is
177
* automatically reinitialized.
178
*
179
* @param cc the RadioGatun[64] context
180
* @param dst the destination buffer
181
*/
182
void sph_radiogatun64_close(void *cc, void *dst);
183
184
#endif
185
186
#endif
187