Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
serpent_generic.c File Reference
#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.

Macros

#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)
 

Functions

int __serpent_setkey (struct serpent_ctx *ctx, const u8 *key, unsigned int keylen)
 
 EXPORT_SYMBOL_GPL (__serpent_setkey)
 
int serpent_setkey (struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
 
 EXPORT_SYMBOL_GPL (serpent_setkey)
 
void __serpent_encrypt (struct serpent_ctx *ctx, u8 *dst, const u8 *src)
 
 EXPORT_SYMBOL_GPL (__serpent_encrypt)
 
void __serpent_decrypt (struct serpent_ctx *ctx, u8 *dst, const u8 *src)
 
 EXPORT_SYMBOL_GPL (__serpent_decrypt)
 
 module_init (serpent_mod_init)
 
 module_exit (serpent_mod_fini)
 
 MODULE_LICENSE ("GPL")
 
 MODULE_DESCRIPTION ("Serpent and tnepres (kerneli compatible serpent reversed) Cipher Algorithm")
 
 MODULE_AUTHOR ("Dag Arne Osvik <osvik@ii.uib.no>")
 
 MODULE_ALIAS ("tnepres")
 
 MODULE_ALIAS ("serpent")
 

Macro Definition Documentation

#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 keyiter (   a,
  b,
  c,
  d,
  i,
  j 
)    ({ b ^= d; b ^= c; b ^= a; b ^= PHI ^ i; b = rol32(b, 11); k[j] = b; })

Definition at line 33 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]; })

Definition at line 36 of file serpent_generic.c.

#define PHI   0x9e3779b9UL

Definition at line 31 of file serpent_generic.c.

#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); })

Definition at line 42 of file serpent_generic.c.

#define storekeys (   x0,
  x1,
  x2,
  x3,
  i 
)    ({ k[i] = x0; k[i+1] = x1; k[i+2] = x2; k[i+3] = x3; })

Definition at line 39 of file serpent_generic.c.

Function Documentation

void __serpent_decrypt ( struct serpent_ctx ctx,
u8 dst,
const u8 src 
)

Definition at line 510 of file serpent_generic.c.

void __serpent_encrypt ( struct serpent_ctx ctx,
u8 dst,
const u8 src 
)

Definition at line 445 of file serpent_generic.c.

int __serpent_setkey ( struct serpent_ctx ctx,
const u8 key,
unsigned int  keylen 
)

Definition at line 232 of file serpent_generic.c.

EXPORT_SYMBOL_GPL ( __serpent_setkey  )
EXPORT_SYMBOL_GPL ( serpent_setkey  )
EXPORT_SYMBOL_GPL ( __serpent_encrypt  )
EXPORT_SYMBOL_GPL ( __serpent_decrypt  )
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  )
MODULE_LICENSE ( "GPL"  )
int serpent_setkey ( struct crypto_tfm tfm,
const u8 key,
unsigned int  keylen 
)

Definition at line 439 of file serpent_generic.c.