| /* $Id: nls.h 388 2005-04-28 21:04:09Z mwp $ */ |
/* $Id: nls.h 444 2006-05-17 07:41:23Z mwp $ */ |
| /* nls: NLS stream cipher and Mundja MAC header files */ |
/* nls: NLS stream cipher and Mundja MAC header files */ |
| |
|
| /* |
/* |
| #ifndef _NLS_DEFINED |
#ifndef _NLS_DEFINED |
| #define _NLS_DEFINED 1 |
#define _NLS_DEFINED 1 |
| |
|
| |
#ifndef ECRYPT_API |
| |
#include <limits.h> |
| |
#if __STDC_VERSION__ >= 199901 |
| |
#include <stdint.h> |
| |
#endif |
| |
#endif |
| |
|
| /* |
/* |
| * NLS maintains a counter that perturbs the state of the register |
* NLS maintains a counter that perturbs the state of the register |
| * at long intervals to ensure that short cycles are impossibile. |
* at long intervals to ensure that short cycles are impossibile. |
| #define WORD u32 |
#define WORD u32 |
| #define UCHAR u8 |
#define UCHAR u8 |
| #else |
#else |
| |
#if __STDC_VERSION__ >= 199901 |
| |
#define WORD uint32_t |
| |
#define WORD_MAX UINT32_MAX |
| |
#elif UINT_MAX >= 0xffffffff |
| |
#define WORD unsigned int |
| |
#define WORD_MAX UINT_MAX |
| |
#else |
| #define WORD unsigned long |
#define WORD unsigned long |
| |
#define WORD_MAX ULONG_MAX |
| |
#endif |
| #define UCHAR unsigned char |
#define UCHAR unsigned char |
| #endif |
#endif |
| |
|
| #endif /*NLS_LONG_OUTPUT*/ |
#endif /*NLS_LONG_OUTPUT*/ |
| #define MACKONST 8 |
#define MACKONST 8 |
| |
|
| |
#ifdef ECRYPT_API |
| |
#define ROTL ROTL32 |
| |
#define ROTR ROTR32 |
| |
#else |
| |
#if WORD_MAX == 0xffffffff |
| #define ROTL(w,x) (((w) << (x))|((w) >> (32 - (x)))) |
#define ROTL(w,x) (((w) << (x))|((w) >> (32 - (x)))) |
| #define ROTR(w,x) (((w) >> (x))|((w) << (32 - (x)))) |
#define ROTR(w,x) (((w) >> (x))|((w) << (32 - (x)))) |
| |
#else |
| |
#define ROTL(w,x) (((w) << (x))|(((w) & 0xffffffff) >> (32 - (x)))) |
| |
#define ROTR(w,x) ((((w) & 0xffffffff) >> (x))|((w) << (32 - (x)))) |
| |
#endif |
| |
#endif |
| |
|
| typedef struct { |
typedef struct { |
| WORD R[N]; /* Working storage for the shift register */ |
WORD R[N]; /* Working storage for the shift register */ |