/* $Id: sph_panama.h 154 2010-04-26 17:00:24Z tp $ */1/**2* PANAMA interface.3*4* PANAMA has been published in: J. Daemen and C. Clapp, "Fast Hashing5* and Stream Encryption with PANAMA", Fast Software Encryption -6* FSE'98, LNCS 1372, Springer (1998), pp. 60--74.7*8* PANAMA is not fully defined with regards to endianness and related9* topics. This implementation follows strict little-endian conventions:10* <ul>11* <li>Each 32-byte input block is split into eight 32-bit words, the12* first (leftmost) word being numbered 0.</li>13* <li>Each such 32-bit word is decoded from memory in little-endian14* convention.</li>15* <li>The additional padding bit equal to "1" is added by considering16* the least significant bit in a byte to come first; practically, this17* means that a single byte of value 0x01 is appended to the (byte-oriented)18* message, and then 0 to 31 bytes of value 0x00.</li>19* <li>The output consists of eight 32-bit words; the word numbered 0 is20* written first (in leftmost position) and it is encoded in little-endian21* convention.22* </ul>23* With these conventions, PANAMA is sometimes known as "PANAMA-LE". The24* PANAMA reference implementation uses our conventions for input, but25* prescribes no convention for output.26*27* ==========================(LICENSE BEGIN)============================28*29* Copyright (c) 2007-2010 Projet RNRT SAPHIR30*31* Permission is hereby granted, free of charge, to any person obtaining32* a copy of this software and associated documentation files (the33* "Software"), to deal in the Software without restriction, including34* without limitation the rights to use, copy, modify, merge, publish,35* distribute, sublicense, and/or sell copies of the Software, and to36* permit persons to whom the Software is furnished to do so, subject to37* the following conditions:38*39* The above copyright notice and this permission notice shall be40* included in all copies or substantial portions of the Software.41*42* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,43* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF44* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.45* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY46* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,47* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE48* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.49*50* ===========================(LICENSE END)=============================51*52* @file sph_panama.h53* @author Thomas Pornin <[email protected]>54*/5556#ifndef SPH_PANAMA_H__57#define SPH_PANAMA_H__5859#include <stddef.h>60#include "sph_types.h"6162/**63* Output size (in bits) for PANAMA.64*/65#define SPH_SIZE_panama 2566667/**68* This structure is a context for PANAMA computations: it contains the69* intermediate values and some data from the last entered block. Once70* a PANAMA computation has been performed, the context can be reused for71* another computation.72*73* The contents of this structure are private. A running PANAMA computation74* can be cloned by copying the context (e.g. with a simple75* <code>memcpy()</code>).76*/77typedef struct {78#ifndef DOXYGEN_IGNORE79unsigned char data[32]; /* first field, for alignment */80unsigned data_ptr;8182sph_u32 buffer[32][8];83unsigned buffer_ptr;8485sph_u32 state[17];86#endif87} sph_panama_context;8889/**90* Initialize a PANAMA context. This process performs no memory allocation.91*92* @param cc the PANAMA context (pointer to a <code>sph_panama_context</code>)93*/94void sph_panama_init(void *cc);9596/**97* Process some data bytes. It is acceptable that <code>len</code> is zero98* (in which case this function does nothing).99*100* @param cc the PANAMA context101* @param data the input data102* @param len the input data length (in bytes)103*/104void sph_panama(void *cc, const void *data, size_t len);105106/**107* Terminate the current PANAMA computation and output the result into the108* provided buffer. The destination buffer must be wide enough to109* accomodate the result (32 bytes). The context is automatically110* reinitialized.111*112* @param cc the PANAMA context113* @param dst the destination buffer114*/115void sph_panama_close(void *cc, void *dst);116117#endif118119120