#include <linux/init.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <asm/byteorder.h>
#include <linux/crypto.h>
#include <linux/types.h>
#include <crypto/serpent.h>
Go to the source code of this file.
|
#define | PHI 0x9e3779b9UL |
|
#define | keyiter(a, b, c, d, i, j) ({ b ^= d; b ^= c; b ^= a; b ^= PHI ^ i; b = rol32(b, 11); k[j] = b; }) |
|
#define | loadkeys(x0, x1, x2, x3, i) ({ x0 = k[i]; x1 = k[i+1]; x2 = k[i+2]; x3 = k[i+3]; }) |
|
#define | storekeys(x0, x1, x2, x3, i) ({ k[i] = x0; k[i+1] = x1; k[i+2] = x2; k[i+3] = x3; }) |
|
#define | store_and_load_keys(x0, x1, x2, x3, s, l) ({ storekeys(x0, x1, x2, x3, s); loadkeys(x0, x1, x2, x3, l); }) |
|
#define | K(x0, x1, x2, x3, i) |
|
#define | LK(x0, x1, x2, x3, x4, i) |
|
#define | KL(x0, x1, x2, x3, x4, i) |
|
#define | S0(x0, x1, x2, x3, x4) |
|
#define | S1(x0, x1, x2, x3, x4) |
|
#define | S2(x0, x1, x2, x3, x4) |
|
#define | S3(x0, x1, x2, x3, x4) |
|
#define | S4(x0, x1, x2, x3, x4) |
|
#define | S5(x0, x1, x2, x3, x4) |
|
#define | S6(x0, x1, x2, x3, x4) |
|
#define | S7(x0, x1, x2, x3, x4) |
|
#define | SI0(x0, x1, x2, x3, x4) |
|
#define | SI1(x0, x1, x2, x3, x4) |
|
#define | SI2(x0, x1, x2, x3, x4) |
|
#define | SI3(x0, x1, x2, x3, x4) |
|
#define | SI4(x0, x1, x2, x3, x4) |
|
#define | SI5(x0, x1, x2, x3, x4) |
|
#define | SI6(x0, x1, x2, x3, x4) |
|
#define | SI7(x0, x1, x2, x3, x4) |
|
#define K |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
i |
|
) |
| |
Value:({ \
x3 ^=
k[4*(
i)+3]; x2 ^=
k[4*(
i)+2]; \
x1 ^=
k[4*(
i)+1]; x0 ^=
k[4*(
i)+0]; \
})
Definition at line 45 of file serpent_generic.c.
#define KL |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4, |
|
|
|
i |
|
) |
| |
Value:({ \
x0 ^=
k[4*
i+0]; x1 ^=
k[4*
i+1]; x2 ^=
k[4*
i+2]; \
x3 ^=
k[4*
i+3]; x0 = ror32(x0, 5); x2 = ror32(x2, 22);\
x4 = x1; x2 ^= x3; x0 ^= x3; \
x4 <<= 7; x0 ^= x1; x1 = ror32(x1, 1); \
x2 ^= x4; x3 = ror32(x3, 7); x4 = x0 << 3; \
x1 ^= x0; x3 ^= x4; x0 = ror32(x0, 13);\
x1 ^= x2; x3 ^= x2; x2 = ror32(x2, 3); \
})
Definition at line 62 of file serpent_generic.c.
#define LK |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4, |
|
|
|
i |
|
) |
| |
Value:({ \
x0 = rol32(x0, 13);\
x2 = rol32(x2, 3); x1 ^= x0; x4 = x0 << 3; \
x3 ^= x2; x1 ^= x2; \
x1 = rol32(x1, 1); x3 ^= x4; \
x3 = rol32(x3, 7); x4 = x1; \
x0 ^= x1; x4 <<= 7; x2 ^= x3; \
x0 ^= x3; x2 ^= x4; x3 ^=
k[4*
i+3]; \
x1 ^=
k[4*
i+1]; x0 = rol32(x0, 5); x2 = rol32(x2, 22);\
x0 ^=
k[4*
i+0]; x2 ^=
k[4*
i+2]; \
})
Definition at line 50 of file serpent_generic.c.
#define loadkeys |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
i |
|
) |
| ({ x0 = k[i]; x1 = k[i+1]; x2 = k[i+2]; x3 = k[i+3]; }) |
#define S0 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x4 = x3; \
x3 |= x0; x0 ^= x4; x4 ^= x2; \
x4 = ~x4; x3 ^= x1; x1 &= x0; \
x1 ^= x4; x2 ^= x0; x0 ^= x3; \
x4 |= x0; x0 ^= x2; x2 &= x1; \
x3 ^= x2; x1 = ~x1; x2 ^= x4; \
x1 ^= x2; \
})
Definition at line 72 of file serpent_generic.c.
#define S1 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x4 = x1; \
x1 ^= x0; x0 ^= x3; x3 = ~x3; \
x4 &= x1; x0 |= x1; x3 ^= x2; \
x0 ^= x3; x1 ^= x3; x3 ^= x4; \
x1 |= x4; x4 ^= x2; x2 &= x0; \
x2 ^= x1; x1 |= x0; x0 = ~x0; \
x0 ^= x2; x4 ^= x1; \
})
Definition at line 82 of file serpent_generic.c.
#define S2 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x3 = ~x3; \
x1 ^= x0; x4 = x0; x0 &= x2; \
x0 ^= x3; x3 |= x4; x2 ^= x1; \
x3 ^= x1; x1 &= x0; x0 ^= x2; \
x2 &= x3; x3 |= x1; x0 = ~x0; \
x3 ^= x0; x4 ^= x0; x0 ^= x2; \
x1 |= x2; \
})
Definition at line 92 of file serpent_generic.c.
#define S3 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x4 = x1; \
x1 ^= x3; x3 |= x0; x4 &= x0; \
x0 ^= x2; x2 ^= x1; x1 &= x3; \
x2 ^= x3; x0 |= x4; x4 ^= x3; \
x1 ^= x0; x0 &= x3; x3 &= x4; \
x3 ^= x2; x4 |= x1; x2 &= x1; \
x4 ^= x3; x0 ^= x3; x3 ^= x2; \
})
Definition at line 102 of file serpent_generic.c.
#define S4 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x4 = x3; \
x3 &= x0; x0 ^= x4; \
x3 ^= x2; x2 |= x4; x0 ^= x1; \
x4 ^= x3; x2 |= x0; \
x2 ^= x1; x1 &= x0; \
x1 ^= x4; x4 &= x2; x2 ^= x3; \
x4 ^= x0; x3 |= x1; x1 = ~x1; \
x3 ^= x0; \
})
Definition at line 112 of file serpent_generic.c.
#define S5 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x4 = x1; x1 |= x0; \
x2 ^= x1; x3 = ~x3; x4 ^= x0; \
x0 ^= x2; x1 &= x4; x4 |= x3; \
x4 ^= x0; x0 &= x3; x1 ^= x3; \
x3 ^= x2; x0 ^= x1; x2 &= x4; \
x1 ^= x2; x2 &= x0; \
x3 ^= x2; \
})
Definition at line 123 of file serpent_generic.c.
#define S6 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x4 = x1; \
x3 ^= x0; x1 ^= x2; x2 ^= x0; \
x0 &= x3; x1 |= x3; x4 = ~x4; \
x0 ^= x1; x1 ^= x2; \
x3 ^= x4; x4 ^= x0; x2 &= x0; \
x4 ^= x1; x2 ^= x3; x3 &= x1; \
x3 ^= x0; x1 ^= x2; \
})
Definition at line 133 of file serpent_generic.c.
#define S7 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x1 = ~x1; \
x4 = x1; x0 = ~x0; x1 &= x2; \
x1 ^= x3; x3 |= x4; x4 ^= x2; \
x2 ^= x3; x3 ^= x0; x0 |= x1; \
x2 &= x0; x0 ^= x4; x4 ^= x3; \
x3 &= x0; x4 ^= x1; \
x2 ^= x4; x3 ^= x1; x4 |= x0; \
x4 ^= x1; \
})
Definition at line 143 of file serpent_generic.c.
#define SI0 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x4 = x3; x1 ^= x0; \
x3 |= x1; x4 ^= x1; x0 = ~x0; \
x2 ^= x3; x3 ^= x0; x0 &= x1; \
x0 ^= x2; x2 &= x3; x3 ^= x4; \
x2 ^= x3; x1 ^= x3; x3 &= x0; \
x1 ^= x0; x0 ^= x2; x4 ^= x3; \
})
Definition at line 154 of file serpent_generic.c.
#define SI1 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x1 ^= x3; x4 = x0; \
x0 ^= x2; x2 = ~x2; x4 |= x1; \
x4 ^= x3; x3 &= x1; x1 ^= x2; \
x2 &= x4; x4 ^= x1; x1 |= x3; \
x3 ^= x0; x2 ^= x0; x0 |= x4; \
x2 ^= x4; x1 ^= x0; \
x4 ^= x1; \
})
Definition at line 163 of file serpent_generic.c.
#define SI2 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x2 ^= x1; x4 = x3; x3 = ~x3; \
x3 |= x2; x2 ^= x4; x4 ^= x0; \
x3 ^= x1; x1 |= x2; x2 ^= x0; \
x1 ^= x4; x4 |= x3; x2 ^= x3; \
x4 ^= x2; x2 &= x1; \
x2 ^= x3; x3 ^= x4; x4 ^= x0; \
})
Definition at line 173 of file serpent_generic.c.
#define SI3 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x2 ^= x1; \
x4 = x1; x1 &= x2; \
x1 ^= x0; x0 |= x4; x4 ^= x3; \
x0 ^= x3; x3 |= x1; x1 ^= x2; \
x1 ^= x3; x0 ^= x2; x2 ^= x3; \
x3 &= x1; x1 ^= x0; x0 &= x2; \
x4 ^= x3; x3 ^= x0; x0 ^= x1; \
})
Definition at line 182 of file serpent_generic.c.
#define SI4 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x2 ^= x3; x4 = x0; x0 &= x1; \
x0 ^= x2; x2 |= x3; x4 = ~x4; \
x1 ^= x0; x0 ^= x2; x2 &= x4; \
x2 ^= x0; x0 |= x4; \
x0 ^= x3; x3 &= x2; \
x4 ^= x3; x3 ^= x1; x1 &= x0; \
x4 ^= x1; x0 ^= x3; \
})
Definition at line 192 of file serpent_generic.c.
#define SI5 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x4 = x1; x1 |= x2; \
x2 ^= x4; x1 ^= x3; x3 &= x4; \
x2 ^= x3; x3 |= x0; x0 = ~x0; \
x3 ^= x2; x2 |= x0; x4 ^= x1; \
x2 ^= x4; x4 &= x0; x0 ^= x1; \
x1 ^= x3; x0 &= x2; x2 ^= x3; \
x0 ^= x2; x2 ^= x4; x4 ^= x3; \
})
Definition at line 202 of file serpent_generic.c.
#define SI6 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x0 ^= x2; \
x4 = x0; x0 &= x3; x2 ^= x3; \
x0 ^= x2; x3 ^= x1; x2 |= x4; \
x2 ^= x3; x3 &= x0; x0 = ~x0; \
x3 ^= x1; x1 &= x2; x4 ^= x0; \
x3 ^= x4; x4 ^= x2; x0 ^= x1; \
x2 ^= x0; \
})
Definition at line 212 of file serpent_generic.c.
#define SI7 |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
x4 |
|
) |
| |
Value:({ \
x4 = x3; x3 &= x0; x0 ^= x2; \
x2 |= x4; x4 ^= x1; x0 = ~x0; \
x1 |= x3; x4 ^= x0; x0 &= x2; \
x0 ^= x1; x1 &= x2; x3 ^= x2; \
x4 ^= x3; x2 &= x3; x3 |= x0; \
x1 ^= x4; x3 ^= x4; x4 &= x0; \
x4 ^= x2; \
})
Definition at line 222 of file serpent_generic.c.
#define store_and_load_keys |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
s, |
|
|
|
l |
|
) |
| ({ storekeys(x0, x1, x2, x3, s); loadkeys(x0, x1, x2, x3, l); }) |
#define storekeys |
( |
|
x0, |
|
|
|
x1, |
|
|
|
x2, |
|
|
|
x3, |
|
|
|
i |
|
) |
| ({ k[i] = x0; k[i+1] = x1; k[i+2] = x2; k[i+3] = x3; }) |
MODULE_ALIAS |
( |
"tnepres" |
| ) |
|
MODULE_ALIAS |
( |
"serpent" |
| ) |
|
MODULE_AUTHOR |
( |
"Dag Arne Osvik <osvik@ii.uib.no>" |
| ) |
|
MODULE_DESCRIPTION |
( |
"Serpent and tnepres (kerneli compatible serpent reversed) Cipher Algorithm" |
| ) |
|
module_exit |
( |
serpent_mod_fini |
| ) |
|
module_init |
( |
serpent_mod_init |
| ) |
|