rc6.h
Go to the documentation of this file.
1 /**
2  * @file rc6.h
3  * @brief RC6-32/20 block cipher
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 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 1.9.6
29  **/
30 
31 #ifndef _RC6_H
32 #define _RC6_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //RC6 block size
38 #define RC6_BLOCK_SIZE 16
39 //Maximum length of the encryption key in bytes
40 #define RC6_MAX_KEY_SIZE 32
41 //Number of rounds
42 #define RC6_NB_ROUNDS 20
43 
44 //Common interface for encryption algorithms
45 #define RC6_CIPHER_ALGO (&rc6CipherAlgo)
46 
47 //C++ guard
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 
53 /**
54  * @brief RC6 algorithm context
55  **/
56 
57 typedef struct
58 {
59  uint32_t l[RC6_MAX_KEY_SIZE / 4];
60  uint32_t s[2 * RC6_NB_ROUNDS + 4];
61 } Rc6Context;
62 
63 
64 //RC6 related constants
65 extern const CipherAlgo rc6CipherAlgo;
66 
67 //RC6 related functions
68 error_t rc6Init(Rc6Context *context, const uint8_t *key, size_t keyLen);
69 void rc6EncryptBlock(Rc6Context *context, const uint8_t *input, uint8_t *output);
70 void rc6DecryptBlock(Rc6Context *context, const uint8_t *input, uint8_t *output);
71 
72 //C++ guard
73 #ifdef __cplusplus
74 }
75 #endif
76 
77 #endif
void rc6EncryptBlock(Rc6Context *context, const uint8_t *input, uint8_t *output)
Encrypt a 16-byte block using RC6 algorithm.
Definition: rc6.c:144
void rc6DecryptBlock(Rc6Context *context, const uint8_t *input, uint8_t *output)
Decrypt a 16-byte block using RC6 algorithm.
Definition: rc6.c:201
const CipherAlgo rc6CipherAlgo
Definition: rc6.c:50
#define RC6_MAX_KEY_SIZE
Definition: rc6.h:40
RC6 algorithm context.
Definition: rc6.h:57
error_t rc6Init(Rc6Context *context, const uint8_t *key, size_t keyLen)
Initialize a RC6 context using the supplied key.
Definition: rc6.c:72
error_t
Error codes.
Definition: error.h:42
General definitions for cryptographic algorithms.
#define RC6_NB_ROUNDS
Definition: rc6.h:42
uint8_t l
Definition: ndp.h:411
uint8_t s
Common interface for encryption algorithms.
Definition: crypto.h:1150