Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tpruvot
GitHub Repository: tpruvot/cpuminer-multi
Path: blob/linux/sha3/sph_panama.h
1201 views
1
/* $Id: sph_panama.h 154 2010-04-26 17:00:24Z tp $ */
2
/**
3
* PANAMA interface.
4
*
5
* PANAMA has been published in: J. Daemen and C. Clapp, "Fast Hashing
6
* and Stream Encryption with PANAMA", Fast Software Encryption -
7
* FSE'98, LNCS 1372, Springer (1998), pp. 60--74.
8
*
9
* PANAMA is not fully defined with regards to endianness and related
10
* topics. This implementation follows strict little-endian conventions:
11
* <ul>
12
* <li>Each 32-byte input block is split into eight 32-bit words, the
13
* first (leftmost) word being numbered 0.</li>
14
* <li>Each such 32-bit word is decoded from memory in little-endian
15
* convention.</li>
16
* <li>The additional padding bit equal to "1" is added by considering
17
* the least significant bit in a byte to come first; practically, this
18
* means that a single byte of value 0x01 is appended to the (byte-oriented)
19
* message, and then 0 to 31 bytes of value 0x00.</li>
20
* <li>The output consists of eight 32-bit words; the word numbered 0 is
21
* written first (in leftmost position) and it is encoded in little-endian
22
* convention.
23
* </ul>
24
* With these conventions, PANAMA is sometimes known as "PANAMA-LE". The
25
* PANAMA reference implementation uses our conventions for input, but
26
* prescribes no convention for output.
27
*
28
* ==========================(LICENSE BEGIN)============================
29
*
30
* Copyright (c) 2007-2010 Projet RNRT SAPHIR
31
*
32
* Permission is hereby granted, free of charge, to any person obtaining
33
* a copy of this software and associated documentation files (the
34
* "Software"), to deal in the Software without restriction, including
35
* without limitation the rights to use, copy, modify, merge, publish,
36
* distribute, sublicense, and/or sell copies of the Software, and to
37
* permit persons to whom the Software is furnished to do so, subject to
38
* the following conditions:
39
*
40
* The above copyright notice and this permission notice shall be
41
* included in all copies or substantial portions of the Software.
42
*
43
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
44
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
47
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
48
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
49
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50
*
51
* ===========================(LICENSE END)=============================
52
*
53
* @file sph_panama.h
54
* @author Thomas Pornin <[email protected]>
55
*/
56
57
#ifndef SPH_PANAMA_H__
58
#define SPH_PANAMA_H__
59
60
#include <stddef.h>
61
#include "sph_types.h"
62
63
/**
64
* Output size (in bits) for PANAMA.
65
*/
66
#define SPH_SIZE_panama 256
67
68
/**
69
* This structure is a context for PANAMA computations: it contains the
70
* intermediate values and some data from the last entered block. Once
71
* a PANAMA computation has been performed, the context can be reused for
72
* another computation.
73
*
74
* The contents of this structure are private. A running PANAMA computation
75
* can be cloned by copying the context (e.g. with a simple
76
* <code>memcpy()</code>).
77
*/
78
typedef struct {
79
#ifndef DOXYGEN_IGNORE
80
unsigned char data[32]; /* first field, for alignment */
81
unsigned data_ptr;
82
83
sph_u32 buffer[32][8];
84
unsigned buffer_ptr;
85
86
sph_u32 state[17];
87
#endif
88
} sph_panama_context;
89
90
/**
91
* Initialize a PANAMA context. This process performs no memory allocation.
92
*
93
* @param cc the PANAMA context (pointer to a <code>sph_panama_context</code>)
94
*/
95
void sph_panama_init(void *cc);
96
97
/**
98
* Process some data bytes. It is acceptable that <code>len</code> is zero
99
* (in which case this function does nothing).
100
*
101
* @param cc the PANAMA context
102
* @param data the input data
103
* @param len the input data length (in bytes)
104
*/
105
void sph_panama(void *cc, const void *data, size_t len);
106
107
/**
108
* Terminate the current PANAMA computation and output the result into the
109
* provided buffer. The destination buffer must be wide enough to
110
* accomodate the result (32 bytes). The context is automatically
111
* reinitialized.
112
*
113
* @param cc the PANAMA context
114
* @param dst the destination buffer
115
*/
116
void sph_panama_close(void *cc, void *dst);
117
118
#endif
119
120