Eneboo - Documentación para desarrolladores
'defines' | Funciones
Referencia del Archivo src/libdigidoc/openssl/crypto/camellia/camellia.c
#include <string.h>
#include <stdlib.h>
#include "camellia.h"
#include "cmll_locl.h"

'defines'

#define CAMELLIA_SIGMA1L   (0xA09E667FL)
#define CAMELLIA_SIGMA1R   (0x3BCC908BL)
#define CAMELLIA_SIGMA2L   (0xB67AE858L)
#define CAMELLIA_SIGMA2R   (0x4CAA73B2L)
#define CAMELLIA_SIGMA3L   (0xC6EF372FL)
#define CAMELLIA_SIGMA3R   (0xE94F82BEL)
#define CAMELLIA_SIGMA4L   (0x54FF53A5L)
#define CAMELLIA_SIGMA4R   (0xF1D36F1CL)
#define CAMELLIA_SIGMA5L   (0x10E527FAL)
#define CAMELLIA_SIGMA5R   (0xDE682D1DL)
#define CAMELLIA_SIGMA6L   (0xB05688C2L)
#define CAMELLIA_SIGMA6R   (0xB3E6C1FDL)
#define CamelliaSubkeyL(INDEX)   (subkey[(INDEX)*2])
#define CamelliaSubkeyR(INDEX)   (subkey[(INDEX)*2 + 1])
#define CAMELLIA_RR8(x)   (((x) >> 8) + ((x) << 24))
#define CAMELLIA_RL1(x)   (((x) << 1) + ((x) >> 31))
#define CAMELLIA_RL8(x)   (((x) << 8) + ((x) >> 24))
#define CAMELLIA_ROLDQ(ll, lr, rl, rr, w0, w1, bits)
#define CAMELLIA_ROLDQo32(ll, lr, rl, rr, w0, w1, bits)
#define CAMELLIA_SP1110(INDEX)   (camellia_sp1110[(INDEX)])
#define CAMELLIA_SP0222(INDEX)   (camellia_sp0222[(INDEX)])
#define CAMELLIA_SP3033(INDEX)   (camellia_sp3033[(INDEX)])
#define CAMELLIA_SP4404(INDEX)   (camellia_sp4404[(INDEX)])
#define CAMELLIA_F(xl, xr, kl, kr, yl, yr, il, ir, t0, t1)
#define CAMELLIA_FLS(ll, lr, rl, rr, kll, klr, krl, krr, t0, t1, t2, t3)
#define CAMELLIA_ROUNDSM(xl, xr, kl, kr, yl, yr, il, ir, t0, t1)
#define subl(x)   subL[(x)]
#define subr(x)   subR[(x)]

Funciones

void camellia_setup128 (const u8 *key, u32 *subkey)
void camellia_setup256 (const u8 *key, u32 *subkey)
void camellia_setup192 (const u8 *key, u32 *subkey)
void camellia_encrypt128 (const u32 *subkey, u32 *io)
void camellia_decrypt128 (const u32 *subkey, u32 *io)
void camellia_encrypt256 (const u32 *subkey, u32 *io)
void camellia_decrypt256 (const u32 *subkey, u32 *io)

Documentación de los 'defines'

#define CAMELLIA_F (   xl,
  xr,
  kl,
  kr,
  yl,
  yr,
  il,
  ir,
  t0,
  t1 
)
Valor:
do                                                                      \
        {                                                               \
        il = xl ^ kl;                                                   \
        ir = xr ^ kr;                                                   \
        t0 = il >> 16;                                                  \
        t1 = ir >> 16;                                                  \
        yl = CAMELLIA_SP1110(ir & 0xff)                                 \
                ^ CAMELLIA_SP0222((t1 >> 8) & 0xff)                     \
                ^ CAMELLIA_SP3033(t1 & 0xff)                            \
                ^ CAMELLIA_SP4404((ir >> 8) & 0xff);                    \
        yr = CAMELLIA_SP1110((t0 >> 8) & 0xff)                          \
                ^ CAMELLIA_SP0222(t0 & 0xff)                            \
                ^ CAMELLIA_SP3033((il >> 8) & 0xff)                     \
                ^ CAMELLIA_SP4404(il & 0xff);                           \
        yl ^= yr;                                                       \
        yr = CAMELLIA_RR8(yr);                                          \
        yr ^= yl;                                                       \
        } while(0)
#define CAMELLIA_FLS (   ll,
  lr,
  rl,
  rr,
  kll,
  klr,
  krl,
  krr,
  t0,
  t1,
  t2,
  t3 
)
Valor:
do                                                                      \
        {                                                               \
        t0 = kll;                                                       \
        t0 &= ll;                                                       \
        lr ^= CAMELLIA_RL1(t0);                                         \
        t1 = klr;                                                       \
        t1 |= lr;                                                       \
        ll ^= t1;                                                       \
                                                                        \
        t2 = krr;                                                       \
        t2 |= rr;                                                       \
        rl ^= t2;                                                       \
        t3 = krl;                                                       \
        t3 &= rl;                                                       \
        rr ^= CAMELLIA_RL1(t3);                                         \
        } while(0)
#define CAMELLIA_RL1 (   x)    (((x) << 1) + ((x) >> 31))
#define CAMELLIA_RL8 (   x)    (((x) << 8) + ((x) >> 24))
#define CAMELLIA_ROLDQ (   ll,
  lr,
  rl,
  rr,
  w0,
  w1,
  bits 
)
Valor:
do                                                      \
        {                                               \
        w0 = ll;                                        \
        ll = (ll << bits) + (lr >> (32 - bits));        \
        lr = (lr << bits) + (rl >> (32 - bits));        \
        rl = (rl << bits) + (rr >> (32 - bits));        \
        rr = (rr << bits) + (w0 >> (32 - bits));        \
        } while(0)
#define CAMELLIA_ROLDQo32 (   ll,
  lr,
  rl,
  rr,
  w0,
  w1,
  bits 
)
Valor:
do                                                      \
        {                                               \
        w0 = ll;                                        \
        w1 = lr;                                        \
        ll = (lr << (bits - 32)) + (rl >> (64 - bits)); \
        lr = (rl << (bits - 32)) + (rr >> (64 - bits)); \
        rl = (rr << (bits - 32)) + (w0 >> (64 - bits)); \
        rr = (w0 << (bits - 32)) + (w1 >> (64 - bits)); \
        } while(0)
#define CAMELLIA_ROUNDSM (   xl,
  xr,
  kl,
  kr,
  yl,
  yr,
  il,
  ir,
  t0,
  t1 
)
Valor:
do                                                                      \
        {                                                               \
        il = xl;                                                        \
        ir = xr;                                                        \
        t0 = il >> 16;                                                  \
        t1 = ir >> 16;                                                  \
        ir = CAMELLIA_SP1110(ir & 0xff)                                 \
                ^ CAMELLIA_SP0222((t1 >> 8) & 0xff)                     \
                ^ CAMELLIA_SP3033(t1 & 0xff)                            \
                ^ CAMELLIA_SP4404((ir >> 8) & 0xff);                    \
        il = CAMELLIA_SP1110((t0 >> 8) & 0xff)                          \
                ^ CAMELLIA_SP0222(t0 & 0xff)                            \
                ^ CAMELLIA_SP3033((il >> 8) & 0xff)                     \
                ^ CAMELLIA_SP4404(il & 0xff);                           \
        il ^= kl;                                                       \
        ir ^= kr;                                                       \
        ir ^= il;                                                       \
        il = CAMELLIA_RR8(il);                                          \
        il ^= ir;                                                       \
        yl ^= ir;                                                       \
        yr ^= il;                                                       \
        } while(0)
#define CAMELLIA_RR8 (   x)    (((x) >> 8) + ((x) << 24))
#define CAMELLIA_SIGMA1L   (0xA09E667FL)
#define CAMELLIA_SIGMA1R   (0x3BCC908BL)
#define CAMELLIA_SIGMA2L   (0xB67AE858L)
#define CAMELLIA_SIGMA2R   (0x4CAA73B2L)
#define CAMELLIA_SIGMA3L   (0xC6EF372FL)
#define CAMELLIA_SIGMA3R   (0xE94F82BEL)
#define CAMELLIA_SIGMA4L   (0x54FF53A5L)
#define CAMELLIA_SIGMA4R   (0xF1D36F1CL)
#define CAMELLIA_SIGMA5L   (0x10E527FAL)
#define CAMELLIA_SIGMA5R   (0xDE682D1DL)
#define CAMELLIA_SIGMA6L   (0xB05688C2L)
#define CAMELLIA_SIGMA6R   (0xB3E6C1FDL)
#define CAMELLIA_SP0222 (   INDEX)    (camellia_sp0222[(INDEX)])
#define CAMELLIA_SP1110 (   INDEX)    (camellia_sp1110[(INDEX)])
#define CAMELLIA_SP3033 (   INDEX)    (camellia_sp3033[(INDEX)])
#define CAMELLIA_SP4404 (   INDEX)    (camellia_sp4404[(INDEX)])
#define CamelliaSubkeyL (   INDEX)    (subkey[(INDEX)*2])
#define CamelliaSubkeyR (   INDEX)    (subkey[(INDEX)*2 + 1])
#define subl (   x)    subL[(x)]

Stuff related to the Camellia key schedule

#define subr (   x)    subR[(x)]

Documentación de las funciones

void camellia_decrypt128 ( const u32 subkey,
u32 io 
)
void camellia_decrypt256 ( const u32 subkey,
u32 io 
)
void camellia_encrypt128 ( const u32 subkey,
u32 io 
)

Stuff related to camellia encryption/decryption

void camellia_encrypt256 ( const u32 subkey,
u32 io 
)

stuff for 192 and 256bit encryption/decryption

void camellia_setup128 ( const u8 key,
u32 subkey 
)

k == kll || klr || krl || krr (|| is concatination)

generate KL dependent subkeys

void camellia_setup192 ( const u8 key,
u32 subkey 
)
void camellia_setup256 ( const u8 key,
u32 subkey 
)

key = (kll || klr || krl || krr || krll || krlr || krrl || krrr) (|| is concatination)

 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'