camellia.c File Reference

Camellia encryption algorithm. More...

#include "core/crypto.h"
#include "cipher/camellia.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 
#define CAMELLIA_ROUND(left1, left2, right1, right2, k1, k2)
 
#define CAMELLIA_F(xl, xr, kl, kr)
 
#define CAMELLIA_FL(xl, xr, kl, kr)
 
#define CAMELLIA_INV_FL(yl, yr, kl, kr)
 
#define CAMELLIA_S(zl, zr)
 
#define CAMELLIA_P(zl, zr)
 
#define KL   0
 
#define KR   4
 
#define KA   8
 
#define KB   12
 
#define L   0
 
#define R   64
 

Functions

error_t camelliaInit (CamelliaContext *context, const uint8_t *key, size_t keyLen)
 Initialize a Camellia context using the supplied key. More...
 
void camelliaEncryptBlock (CamelliaContext *context, const uint8_t *input, uint8_t *output)
 Encrypt a 16-byte block using Camellia algorithm. More...
 
void camelliaDecryptBlock (CamelliaContext *context, const uint8_t *input, uint8_t *output)
 Decrypt a 16-byte block using Camellia algorithm. More...
 

Variables

const CipherAlgo camelliaCipherAlgo
 

Detailed Description

Camellia encryption algorithm.

License

Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneCrypto Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Description

Camellia is an encryption algorithm designed to encipher and decipher blocks of 128 bits under control of a 128/192/256-bit secret key

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file camellia.c.

Macro Definition Documentation

◆ CAMELLIA_F

#define CAMELLIA_F (   xl,
  xr,
  kl,
  kr 
)
Value:
{ \
xl = xl ^ kl; \
xl = xr ^ kr; \
CAMELLIA_S(xl, xr); \
CAMELLIA_P(xl, xr); \
}

Definition at line 61 of file camellia.c.

◆ CAMELLIA_FL

#define CAMELLIA_FL (   xl,
  xr,
  kl,
  kr 
)
Value:
{ \
temp1 = (xl & kl); \
xr ^= ROL32(temp1, 1); \
xl ^= (xr | kr); \
}
#define ROL32(a, n)
Definition: crypto.h:849

Definition at line 70 of file camellia.c.

◆ CAMELLIA_INV_FL

#define CAMELLIA_INV_FL (   yl,
  yr,
  kl,
  kr 
)
Value:
{ \
yl ^= (yr | kr); \
temp1 = (yl & kl); \
yr ^= ROL32(temp1, 1); \
}
#define ROL32(a, n)
Definition: crypto.h:849

Definition at line 78 of file camellia.c.

◆ CAMELLIA_P

#define CAMELLIA_P (   zl,
  zr 
)
Value:
{ \
zl ^= ROL32(zr, 8); \
zr ^= ROL32(zl, 16); \
zl ^= ROR32(zr, 8); \
zr ^= ROR32(zl, 8); \
}
#define ROL32(a, n)
Definition: crypto.h:849
#define ROR32(a, n)
Definition: crypto.h:855

Definition at line 95 of file camellia.c.

◆ CAMELLIA_ROUND

#define CAMELLIA_ROUND (   left1,
  left2,
  right1,
  right2,
  k1,
  k2 
)
Value:
{ \
temp1 = left1 ^ k1; \
temp2 = left2 ^ k2; \
CAMELLIA_S(temp1, temp2); \
CAMELLIA_P(temp1, temp2); \
temp1 ^= right2; \
temp2 ^= right1; \
right1 = left1; \
right2 = left2; \
left1 = temp2; \
left2 = temp1; \
}

Definition at line 46 of file camellia.c.

◆ CAMELLIA_S

#define CAMELLIA_S (   zl,
  zr 
)
Value:
{ \
zl = (sbox1[(zl >> 24) & 0xFF] << 24) | (sbox2[(zl >> 16) & 0xFF] << 16) | \
(sbox3[(zl >> 8) & 0xFF] << 8) | sbox4[zl & 0xFF]; \
zr = (sbox2[(zr >> 24) & 0xFF] << 24) | (sbox3[(zr >> 16) & 0xFF] << 16) | \
(sbox4[(zr >> 8) & 0xFF] << 8) | sbox1[zr & 0xFF]; \
}

Definition at line 86 of file camellia.c.

◆ KA

#define KA   8

Definition at line 106 of file camellia.c.

◆ KB

#define KB   12

Definition at line 107 of file camellia.c.

◆ KL

#define KL   0

Definition at line 104 of file camellia.c.

◆ KR

#define KR   4

Definition at line 105 of file camellia.c.

◆ L

#define L   0

Definition at line 108 of file camellia.c.

◆ R

#define R   64

Definition at line 109 of file camellia.c.

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 35 of file camellia.c.

Function Documentation

◆ camelliaDecryptBlock()

void camelliaDecryptBlock ( CamelliaContext context,
const uint8_t *  input,
uint8_t *  output 
)

Decrypt a 16-byte block using Camellia algorithm.

Parameters
[in]contextPointer to the Camellia context
[in]inputCiphertext block to decrypt
[out]outputPlaintext block resulting from decryption

Definition at line 492 of file camellia.c.

◆ camelliaEncryptBlock()

void camelliaEncryptBlock ( CamelliaContext context,
const uint8_t *  input,
uint8_t *  output 
)

Encrypt a 16-byte block using Camellia algorithm.

Parameters
[in]contextPointer to the Camellia context
[in]inputPlaintext block to encrypt
[out]outputCiphertext block resulting from encryption

Definition at line 427 of file camellia.c.

◆ camelliaInit()

error_t camelliaInit ( CamelliaContext context,
const uint8_t *  key,
size_t  keyLen 
)

Initialize a Camellia context using the supplied key.

Parameters
[in]contextPointer to the Camellia context to initialize
[in]keyPointer to the key
[in]keyLenLength of the key
Returns
Error code

Definition at line 299 of file camellia.c.

Variable Documentation

◆ camelliaCipherAlgo

const CipherAlgo camelliaCipherAlgo
Initial value:
=
{
"CAMELLIA",
sizeof(CamelliaContext),
NULL,
NULL,
}
void(* CipherAlgoDecryptBlock)(void *context, const uint8_t *input, uint8_t *output)
Definition: crypto.h:1030
void camelliaDecryptBlock(CamelliaContext *context, const uint8_t *input, uint8_t *output)
Decrypt a 16-byte block using Camellia algorithm.
Definition: camellia.c:492
error_t(* CipherAlgoInit)(void *context, const uint8_t *key, size_t keyLen)
Definition: crypto.h:1026
#define CAMELLIA_BLOCK_SIZE
Definition: camellia.h:36
void(* CipherAlgoEncryptBlock)(void *context, const uint8_t *input, uint8_t *output)
Definition: crypto.h:1029
error_t camelliaInit(CamelliaContext *context, const uint8_t *key, size_t keyLen)
Initialize a Camellia context using the supplied key.
Definition: camellia.c:299
void camelliaEncryptBlock(CamelliaContext *context, const uint8_t *input, uint8_t *output)
Encrypt a 16-byte block using Camellia algorithm.
Definition: camellia.c:427
Camellia algorithm context.
Definition: camellia.h:63

Definition at line 277 of file camellia.c.