| /* ------------------------------------------------------------------------- */ |
/* ------------------------------------------------------------------------- */ |
| /* Data Types used in coding */ |
/* Data Types used in coding */ |
| /* ------------------------------------------------------------------------- */ |
/* ------------------------------------------------------------------------- */ |
| typedef unsigned long long ull; |
typedef u64 ull; |
| typedef u32 ul; |
typedef u32 ul; |
| typedef u8 uc; |
typedef u8 uc; |
| |
|
| typedef Int |
#if defined(ECRYPT_LITTLE_ENDIAN) |
| |
typedef union |
| { struct _b |
{ struct _b |
| { uc b0, b1, b2, b3, b4, b5, b6, b7; |
{ uc b0, b1, b2, b3, b4, b5, b6, b7; |
| } b; /* 8 -bit access */ |
} b; /* 8 -bit access */ |
| { ul w0, w1; |
{ ul w0, w1; |
| } w; /* 32-bit access */ |
} w; /* 32-bit access */ |
| ull v; /* 64-bit access */ |
ull v; /* 64-bit access */ |
| }; |
} Int; |
| |
#elif defined(ECRYPT_BIG_ENDIAN) |
| |
typedef union |
| |
{ struct _b |
| |
{ uc b7, b6, b5, b4, b3, b2, b1, b0; |
| |
} b; /* 8 -bit access */ |
| |
struct _w |
| |
{ ul w1, w0; |
| |
} w; /* 32-bit access */ |
| |
ull v; /* 64-bit access */ |
| |
} Int; |
| |
#else |
| |
#error Could not detect endianness |
| |
#endif |
| |
|
| /* ------------------------------------------------------------------------- */ |
/* ------------------------------------------------------------------------- */ |
| /* Data structures */ |
/* Data structures */ |
| Int a, b, x0, x1, x2, x3; /* Internal State */ |
Int a, b, x0, x1, x2, x3; /* Internal State */ |
| uc S[256]; /* secret S-box */ |
uc S[256]; /* secret S-box */ |
| |
|
| |
u8 key[16]; |
| |
|
| } ECRYPT_ctx; |
} ECRYPT_ctx; |
| |
|
| #endif |
#endif |
| * The name of your cipher. |
* The name of your cipher. |
| */ |
*/ |
| #define ECRYPT_NAME "Mir-1" /* [edit] */ |
#define ECRYPT_NAME "Mir-1" /* [edit] */ |
| |
#define ECRYPT_PROFILE "SW" |
| |
|
| /* |
/* |
| * Specify which key and IV sizes are supported by your cipher. A user |
* Specify which key and IV sizes are supported by your cipher. A user |
| * declared below. |
* declared below. |
| */ |
*/ |
| |
|
| #define ECRYPT_BLOCKLENGTH 4 /* [edit] */ |
#define ECRYPT_BLOCKLENGTH 8 /* [edit] */ |
| |
|
| #define ECRYPT_USES_DEFAULT_BLOCK_MACROS /* [edit] */ |
#define ECRYPT_USES_DEFAULT_BLOCK_MACROS /* [edit] */ |
| #ifdef ECRYPT_USES_DEFAULT_BLOCK_MACROS |
#ifdef ECRYPT_USES_DEFAULT_BLOCK_MACROS |
| |
|
| #endif |
#endif |
| |
|
| |
/* |
| |
* If your cipher can be implemented in different ways, you can use |
| |
* the ECRYPT_VARIANT parameter to allow the user to choose between |
| |
* them at compile time (e.g., gcc -DECRYPT_VARIANT=3 ...). Please |
| |
* only use this possibility if you really think it could make a |
| |
* significant difference and keep the number of variants |
| |
* (ECRYPT_MAXVARIANT) as small as possible (definitely not more than |
| |
* 10). Note also that all variants should have exactly the same |
| |
* external interface (i.e., the same ECRYPT_BLOCKLENGTH, etc.). |
| |
*/ |
| |
#define ECRYPT_MAXVARIANT 1 /* [edit] */ |
| |
|
| |
#ifndef ECRYPT_VARIANT |
| |
#define ECRYPT_VARIANT 1 |
| |
#endif |
| |
|
| |
#if (ECRYPT_VARIANT > ECRYPT_MAXVARIANT) |
| |
#error this variant does not exist |
| |
#endif |
| |
|
| /* ------------------------------------------------------------------------- */ |
/* ------------------------------------------------------------------------- */ |
| |
|
| #endif |
#endif |