Classes | Defines | Typedefs | Functions

Whirlpool.hpp File Reference

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

Go to the source code of this file.

Classes

struct  NESSIEstruct

Defines

#define ONE32   0xffffffffU
#define ONE8   0xffU
#define ONE16   0xffffU
#define T8(x)   ((x) & ONE8)
#define T16(x)   ((x) & ONE16)
#define T32(x)   ((x) & ONE32)
#define LL(v)   (v##ULL)
#define ONE64   LL(0xffffffffffffffff)
#define T64(x)   ((x) & ONE64)
#define ROTR64(v, n)   (((v) >> (n)) | T64((v) << (64 - (n))))
#define U8TO32_BIG(c)   (((u32)T8(*(c)) << 24) | ((u32)T8(*((c) + 1)) << 16) | ((u32)T8(*((c) + 2)) << 8) | ((u32)T8(*((c) + 3))))
#define U8TO32_LITTLE(c)   (((u32)T8(*(c))) | ((u32)T8(*((c) + 1)) << 8) | (u32)T8(*((c) + 2)) << 16) | ((u32)T8(*((c) + 3)) << 24))
#define U32TO8_BIG(c, v)   do { u32 x = (v); u8 *d = (c); d[0] = T8(x >> 24); d[1] = T8(x >> 16); d[2] = T8(x >> 8); d[3] = T8(x); } while (0)
#define U32TO8_LITTLE(c, v)   do { u32 x = (v); u8 *d = (c); d[0] = T8(x); d[1] = T8(x >> 8); d[2] = T8(x >> 16); d[3] = T8(x >> 24); } while (0)
#define ROTL32(v, n)   (T32((v) << (n)) | ((v) >> (32 - (n))))
#define DIGESTBYTES   64
#define DIGESTBITS   (8*DIGESTBYTES)
#define WBLOCKBYTES   64
#define WBLOCKBITS   (8*WBLOCKBYTES)
#define LENGTHBYTES   32
#define LENGTHBITS   (8*LENGTHBYTES)
#define R   10

Typedefs

typedef signed char s8
typedef unsigned char u8
typedef signed short s16
typedef signed int s32
typedef unsigned short u16
typedef unsigned int u32
typedef unsigned long long u64
typedef signed long long s64
typedef struct NESSIEstruct NESSIEstruct

Functions

void NESSIEinit (struct NESSIEstruct *const structpointer)
void NESSIEadd (const unsigned char *const source, unsigned long sourceBits, struct NESSIEstruct *const structpointer)
void NESSIEfinalize (struct NESSIEstruct *const structpointer, unsigned char *const result)

Define Documentation

#define DIGESTBITS   (8*DIGESTBYTES)
#define DIGESTBYTES   64
#define LENGTHBITS   (8*LENGTHBYTES)
#define LENGTHBYTES   32
#define LL (   v )    (v##ULL)
#define ONE16   0xffffU
#define ONE32   0xffffffffU
#define ONE64   LL(0xffffffffffffffff)
#define ONE8   0xffU
#define R   10
#define ROTL32 (   v,
 
)    (T32((v) << (n)) | ((v) >> (32 - (n))))
#define ROTR64 (   v,
 
)    (((v) >> (n)) | T64((v) << (64 - (n))))
#define T16 (   x )    ((x) & ONE16)
#define T32 (   x )    ((x) & ONE32)
#define T64 (   x )    ((x) & ONE64)
#define T8 (   x )    ((x) & ONE8)
#define U32TO8_BIG (   c,
 
)    do { u32 x = (v); u8 *d = (c); d[0] = T8(x >> 24); d[1] = T8(x >> 16); d[2] = T8(x >> 8); d[3] = T8(x); } while (0)
#define U32TO8_LITTLE (   c,
 
)    do { u32 x = (v); u8 *d = (c); d[0] = T8(x); d[1] = T8(x >> 8); d[2] = T8(x >> 16); d[3] = T8(x >> 24); } while (0)
#define U8TO32_BIG (   c )    (((u32)T8(*(c)) << 24) | ((u32)T8(*((c) + 1)) << 16) | ((u32)T8(*((c) + 2)) << 8) | ((u32)T8(*((c) + 3))))
#define U8TO32_LITTLE (   c )    (((u32)T8(*(c))) | ((u32)T8(*((c) + 1)) << 8) | (u32)T8(*((c) + 2)) << 16) | ((u32)T8(*((c) + 3)) << 24))
#define WBLOCKBITS   (8*WBLOCKBYTES)
#define WBLOCKBYTES   64

Typedef Documentation

typedef struct NESSIEstruct NESSIEstruct
typedef signed short s16
typedef signed int s32
typedef signed long long s64
typedef signed char s8

The Whirlpool hashing function.

References

The Whirlpool algorithm was developed by Paulo S. L. M. Barreto and Vincent Rijmen.

See P.S.L.M. Barreto, V. Rijmen, ``The Whirlpool hashing function,'' NESSIE submission, 2000 (tweaked version, 2001), <https://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/whirlpool.zip>

Author:
Paulo S.L.M. Barreto
Vincent Rijmen.
Version:
3.0 (2003.03.12)

=============================================================================

Differences from version 2.1:

  • Suboptimal diffusion matrix replaced by cir(1, 1, 4, 1, 8, 5, 2, 9).

=============================================================================

Differences from version 2.0:

  • Generation of ISO/IEC 10118-3 test vectors.
  • Bug fix: nonzero carry was ignored when tallying the data length (this bug apparently only manifested itself when feeding data in pieces rather than in a single chunk at once).
  • Support for MS Visual C++ 64-bit integer arithmetic.

Differences from version 1.0:

  • Original S-box replaced by the tweaked, hardware-efficient version.

=============================================================================

THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

typedef unsigned short u16
typedef unsigned int u32
typedef unsigned long long u64
typedef unsigned char u8

Function Documentation

void NESSIEadd ( const unsigned char *const   source,
unsigned long  sourceBits,
struct NESSIEstruct *const   structpointer 
)

Delivers input data to the hashing algorithm.

Parameters:
sourceplaintext data to hash.
sourceBitshow many bits of plaintext to process.
structpointerpointer This method maintains the invariant: bufferBits < DIGESTBITS
void NESSIEfinalize ( struct NESSIEstruct *const   structpointer,
unsigned char *const   result 
)

Get the hash value from the hashing state.

This method uses the invariant: bufferBits < DIGESTBITS

void NESSIEinit ( struct NESSIEstruct *const   structpointer )

Initialize the hashing state.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Sun Jan 22 2012 15:28:21