/* $Id: sph_radiogatun.h 226 2010-06-16 17:28:08Z tp $ */1/**2* RadioGatun interface.3*4* RadioGatun has been published in: G. Bertoni, J. Daemen, M. Peeters5* and G. Van Assche, "RadioGatun, a belt-and-mill hash function",6* presented at the Second Cryptographic Hash Workshop, Santa Barbara,7* August 24-25, 2006. The main Web site, containing that article, the8* reference code and some test vectors, appears to be currently located9* at the following URL: http://radiogatun.noekeon.org/10*11* The presentation article does not specify endianness or padding. The12* reference code uses the following conventions, which we also apply13* here:14* <ul>15* <li>The input message is an integral number of sequences of three16* words. Each word is either a 32-bit of 64-bit word (depending on17* the version of RadioGatun).</li>18* <li>Input bytes are decoded into words using little-endian19* convention.</li>20* <li>Padding consists of a single bit of value 1, using little-endian21* convention within bytes (i.e. for a byte-oriented input, a single22* byte of value 0x01 is appended), then enough bits of value 0 to finish23* the current block.</li>24* <li>Output consists of 256 bits. Successive output words are encoded25* with little-endian convention.</li>26* </ul>27* These conventions are very close to those we use for PANAMA, which is28* a close ancestor or RadioGatun.29*30* RadioGatun is actually a family of functions, depending on some31* internal parameters. We implement here two functions, with a "belt32* length" of 13, a "belt width" of 3, and a "mill length" of 19. The33* RadioGatun[32] version uses 32-bit words, while the RadioGatun[64]34* variant uses 64-bit words.35*36* Strictly speaking, the name "RadioGatun" should use an acute accent37* on the "u", which we omitted here to keep strict ASCII-compatibility38* of this file.39*40* ==========================(LICENSE BEGIN)============================41*42* Copyright (c) 2007-2010 Projet RNRT SAPHIR43*44* Permission is hereby granted, free of charge, to any person obtaining45* a copy of this software and associated documentation files (the46* "Software"), to deal in the Software without restriction, including47* without limitation the rights to use, copy, modify, merge, publish,48* distribute, sublicense, and/or sell copies of the Software, and to49* permit persons to whom the Software is furnished to do so, subject to50* the following conditions:51*52* The above copyright notice and this permission notice shall be53* included in all copies or substantial portions of the Software.54*55* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,56* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF57* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.58* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY59* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,60* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE61* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.62*63* ===========================(LICENSE END)=============================64*65* @file sph_radiogatun.h66* @author Thomas Pornin <[email protected]>67*/6869#ifndef SPH_RADIOGATUN_H__70#define SPH_RADIOGATUN_H__7172#include <stddef.h>73#include "sph_types.h"7475/**76* Output size (in bits) for RadioGatun[32].77*/78#define SPH_SIZE_radiogatun32 2567980/**81* This structure is a context for RadioGatun[32] computations: it82* contains intermediate values and some data from the last entered83* block. Once a RadioGatun[32] computation has been performed, the84* context can be reused for another computation.85*86* The contents of this structure are private. A running RadioGatun[32]87* computation can be cloned by copying the context (e.g. with a88* simple <code>memcpy()</code>).89*/90typedef struct {91#ifndef DOXYGEN_IGNORE92unsigned char data[156]; /* first field, for alignment */93unsigned data_ptr;94sph_u32 a[19], b[39];95#endif96} sph_radiogatun32_context;9798/**99* Initialize a RadioGatun[32] context. This process performs no100* memory allocation.101*102* @param cc the RadioGatun[32] context (pointer to a103* <code>sph_radiogatun32_context</code>)104*/105void sph_radiogatun32_init(void *cc);106107/**108* Process some data bytes. It is acceptable that <code>len</code> is zero109* (in which case this function does nothing).110*111* @param cc the RadioGatun[32] context112* @param data the input data113* @param len the input data length (in bytes)114*/115void sph_radiogatun32(void *cc, const void *data, size_t len);116117/**118* Terminate the current RadioGatun[32] computation and output the119* result into the provided buffer. The destination buffer must be wide120* enough to accomodate the result (32 bytes). The context is121* automatically reinitialized.122*123* @param cc the RadioGatun[32] context124* @param dst the destination buffer125*/126void sph_radiogatun32_close(void *cc, void *dst);127128#if SPH_64129130/**131* Output size (in bits) for RadioGatun[64].132*/133#define SPH_SIZE_radiogatun64 256134135/**136* This structure is a context for RadioGatun[64] computations: it137* contains intermediate values and some data from the last entered138* block. Once a RadioGatun[64] computation has been performed, the139* context can be reused for another computation.140*141* The contents of this structure are private. A running RadioGatun[64]142* computation can be cloned by copying the context (e.g. with a143* simple <code>memcpy()</code>).144*/145typedef struct {146#ifndef DOXYGEN_IGNORE147unsigned char data[312]; /* first field, for alignment */148unsigned data_ptr;149sph_u64 a[19], b[39];150#endif151} sph_radiogatun64_context;152153/**154* Initialize a RadioGatun[64] context. This process performs no155* memory allocation.156*157* @param cc the RadioGatun[64] context (pointer to a158* <code>sph_radiogatun64_context</code>)159*/160void sph_radiogatun64_init(void *cc);161162/**163* Process some data bytes. It is acceptable that <code>len</code> is zero164* (in which case this function does nothing).165*166* @param cc the RadioGatun[64] context167* @param data the input data168* @param len the input data length (in bytes)169*/170void sph_radiogatun64(void *cc, const void *data, size_t len);171172/**173* Terminate the current RadioGatun[64] computation and output the174* result into the provided buffer. The destination buffer must be wide175* enough to accomodate the result (32 bytes). The context is176* automatically reinitialized.177*178* @param cc the RadioGatun[64] context179* @param dst the destination buffer180*/181void sph_radiogatun64_close(void *cc, void *dst);182183#endif184185#endif186187