OpenSSL  1.0.1c
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Functions
camellia.c File Reference
#include "camellia.h"
#include "cmll_locl.h"
#include <string.h>
#include <stdlib.h>

Go to the source code of this file.

Macros

#define RightRotate(x, s)   ( ((x) >> (s)) + ((x) << (32 - s)) )
 
#define LeftRotate(x, s)   ( ((x) << (s)) + ((x) >> (32 - s)) )
 
#define GETU32(p)   (((u32)(p)[0] << 24) ^ ((u32)(p)[1] << 16) ^ ((u32)(p)[2] << 8) ^ ((u32)(p)[3]))
 
#define PUTU32(p, v)   ((p)[0] = (u8)((v) >> 24), (p)[1] = (u8)((v) >> 16), (p)[2] = (u8)((v) >> 8), (p)[3] = (u8)(v))
 
#define SBOX1_1110   Camellia_SBOX[0]
 
#define SBOX4_4404   Camellia_SBOX[1]
 
#define SBOX2_0222   Camellia_SBOX[2]
 
#define SBOX3_3033   Camellia_SBOX[3]
 
#define Camellia_Feistel(_s0, _s1, _s2, _s3, _key)
 
#define RotLeft128(_s0, _s1, _s2, _s3, _n)
 

Functions

int Camellia_Ekeygen (int keyBitLength, const u8 *rawKey, KEY_TABLE_TYPE k)
 
void Camellia_EncryptBlock_Rounds (int grandRounds, const u8 plaintext[], const KEY_TABLE_TYPE keyTable, u8 ciphertext[])
 
void Camellia_EncryptBlock (int keyBitLength, const u8 plaintext[], const KEY_TABLE_TYPE keyTable, u8 ciphertext[])
 
void Camellia_DecryptBlock_Rounds (int grandRounds, const u8 ciphertext[], const KEY_TABLE_TYPE keyTable, u8 plaintext[])
 
void Camellia_DecryptBlock (int keyBitLength, const u8 plaintext[], const KEY_TABLE_TYPE keyTable, u8 ciphertext[])
 

Macro Definition Documentation

#define Camellia_Feistel (   _s0,
  _s1,
  _s2,
  _s3,
  _key 
)
Value:
do {\
register u32 _t0,_t1,_t2,_t3;\
\
_t0 = _s0 ^ (_key)[0];\
_t3 = SBOX4_4404[_t0&0xff];\
_t1 = _s1 ^ (_key)[1];\
_t3 ^= SBOX3_3033[(_t0 >> 8)&0xff];\
_t2 = SBOX1_1110[_t1&0xff];\
_t3 ^= SBOX2_0222[(_t0 >> 16)&0xff];\
_t2 ^= SBOX4_4404[(_t1 >> 8)&0xff];\
_t3 ^= SBOX1_1110[(_t0 >> 24)];\
_t2 ^= _t3;\
_t3 = RightRotate(_t3,8);\
_t2 ^= SBOX3_3033[(_t1 >> 16)&0xff];\
_s3 ^= _t3;\
_t2 ^= SBOX2_0222[(_t1 >> 24)];\
_s2 ^= _t2; \
_s3 ^= _t2;\
} while(0)

Definition at line 329 of file camellia.c.

#define GETU32 (   p)    (((u32)(p)[0] << 24) ^ ((u32)(p)[1] << 16) ^ ((u32)(p)[2] << 8) ^ ((u32)(p)[3]))

Definition at line 131 of file camellia.c.

#define LeftRotate (   x,
 
)    ( ((x) << (s)) + ((x) >> (32 - s)) )

Definition at line 127 of file camellia.c.

#define PUTU32 (   p,
 
)    ((p)[0] = (u8)((v) >> 24), (p)[1] = (u8)((v) >> 16), (p)[2] = (u8)((v) >> 8), (p)[3] = (u8)(v))

Definition at line 132 of file camellia.c.

#define RightRotate (   x,
 
)    ( ((x) >> (s)) + ((x) << (32 - s)) )

Definition at line 126 of file camellia.c.

#define RotLeft128 (   _s0,
  _s1,
  _s2,
  _s3,
  _n 
)
Value:
do {\
u32 _t0=_s0>>(32-_n);\
_s0 = (_s0<<_n) | (_s1>>(32-_n));\
_s1 = (_s1<<_n) | (_s2>>(32-_n));\
_s2 = (_s2<<_n) | (_s3>>(32-_n));\
_s3 = (_s3<<_n) | _t0;\
} while (0)

Definition at line 354 of file camellia.c.

#define SBOX1_1110   Camellia_SBOX[0]

Definition at line 136 of file camellia.c.

#define SBOX2_0222   Camellia_SBOX[2]

Definition at line 138 of file camellia.c.

#define SBOX3_3033   Camellia_SBOX[3]

Definition at line 139 of file camellia.c.

#define SBOX4_4404   Camellia_SBOX[1]

Definition at line 137 of file camellia.c.

Function Documentation

void Camellia_DecryptBlock ( int  keyBitLength,
const u8  plaintext[],
const KEY_TABLE_TYPE  keyTable,
u8  ciphertext[] 
)

Definition at line 577 of file camellia.c.

void Camellia_DecryptBlock_Rounds ( int  grandRounds,
const u8  ciphertext[],
const KEY_TABLE_TYPE  keyTable,
u8  plaintext[] 
)

Definition at line 535 of file camellia.c.

int Camellia_Ekeygen ( int  keyBitLength,
const u8 rawKey,
KEY_TABLE_TYPE  k 
)

Definition at line 362 of file camellia.c.

void Camellia_EncryptBlock ( int  keyBitLength,
const u8  plaintext[],
const KEY_TABLE_TYPE  keyTable,
u8  ciphertext[] 
)

Definition at line 528 of file camellia.c.

void Camellia_EncryptBlock_Rounds ( int  grandRounds,
const u8  plaintext[],
const KEY_TABLE_TYPE  keyTable,
u8  ciphertext[] 
)

Definition at line 486 of file camellia.c.