camellia.h
Go to the documentation of this file.
1 /**
2  * @file camellia.h
3  * @brief Camellia encryption algorithm
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _CAMELLIA_H
32 #define _CAMELLIA_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //Camellia block size
38 #define CAMELLIA_BLOCK_SIZE 16
39 //Common interface for encryption algorithms
40 #define CAMELLIA_CIPHER_ALGO (&camelliaCipherAlgo)
41 
42 //C++ guard
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 
48 /**
49  * @brief Structure describing subkey generation
50  **/
51 
52 typedef struct
53 {
54  uint8_t index;
55  uint8_t key;
56  uint8_t shift;
57  uint8_t position;
59 
60 
61 /**
62  * @brief Camellia algorithm context
63  **/
64 
65 typedef struct
66 {
68  uint32_t k[16];
69  uint32_t ks[68];
71 
72 
73 //Camellia related constants
74 extern const uint8_t CAMELLIA128_CBC_OID[11];
75 extern const uint8_t CAMELLIA192_CBC_OID[11];
76 extern const uint8_t CAMELLIA256_CBC_OID[11];
77 extern const CipherAlgo camelliaCipherAlgo;
78 
79 //Camellia related functions
80 error_t camelliaInit(CamelliaContext *context, const uint8_t *key,
81  size_t keyLen);
82 
83 void camelliaEncryptBlock(CamelliaContext *context, const uint8_t *input,
84  uint8_t *output);
85 
86 void camelliaDecryptBlock(CamelliaContext *context, const uint8_t *input,
87  uint8_t *output);
88 
89 void camelliaDeinit(CamelliaContext *context);
90 
91 //C++ guard
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif
const uint8_t CAMELLIA128_CBC_OID[11]
Definition: camellia.c:279
void camelliaDeinit(CamelliaContext *context)
Release Camellia context.
Definition: camellia.c:578
const uint8_t CAMELLIA256_CBC_OID[11]
Definition: camellia.c:283
Structure describing subkey generation.
Definition: camellia.h:53
error_t
Error codes.
Definition: error.h:43
void camelliaDecryptBlock(CamelliaContext *context, const uint8_t *input, uint8_t *output)
Decrypt a 16-byte block using Camellia algorithm.
Definition: camellia.c:512
General definitions for cryptographic algorithms.
uint8_t index
Definition: camellia.h:54
const uint8_t CAMELLIA192_CBC_OID[11]
Definition: camellia.c:281
error_t camelliaInit(CamelliaContext *context, const uint8_t *key, size_t keyLen)
Initialize a Camellia context using the supplied key.
Definition: camellia.c:309
uint8_t shift
Definition: camellia.h:56
uint8_t key
Definition: camellia.h:55
uint8_t position
Definition: camellia.h:57
const CipherAlgo camelliaCipherAlgo
Definition: camellia.c:286
void camelliaEncryptBlock(CamelliaContext *context, const uint8_t *input, uint8_t *output)
Encrypt a 16-byte block using Camellia algorithm.
Definition: camellia.c:444
Camellia algorithm context.
Definition: camellia.h:66
Common interface for encryption algorithms.
Definition: crypto.h:1068
unsigned int uint_t
Definition: compiler_port.h:50