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  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneCrypto Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _RC6_H
30 #define _RC6_H
31 
32 //Dependencies
33 #include "core/crypto.h"
34 
35 //RC6 block size
36 #define RC6_BLOCK_SIZE 16
37 //Maximum length of the encryption key in bytes
38 #define RC6_MAX_KEY_SIZE 32
39 //Number of rounds
40 #define RC6_NB_ROUNDS 20
41 
42 //Common interface for encryption algorithms
43 #define RC6_CIPHER_ALGO (&rc6CipherAlgo)
44 
45 //C++ guard
46 #ifdef __cplusplus
47  extern "C" {
48 #endif
49 
50 
51 /**
52  * @brief RC6 algorithm context
53  **/
54 
55 typedef struct
56 {
57  uint32_t l[RC6_MAX_KEY_SIZE / 4];
58  uint32_t s[2 * RC6_NB_ROUNDS + 4];
59 } Rc6Context;
60 
61 
62 //RC6 related constants
63 extern const CipherAlgo rc6CipherAlgo;
64 
65 //RC6 related functions
66 error_t rc6Init(Rc6Context *context, const uint8_t *key, size_t keyLen);
67 void rc6EncryptBlock(Rc6Context *context, const uint8_t *input, uint8_t *output);
68 void rc6DecryptBlock(Rc6Context *context, const uint8_t *input, uint8_t *output);
69 
70 //C++ guard
71 #ifdef __cplusplus
72  }
73 #endif
74 
75 #endif
#define RC6_MAX_KEY_SIZE
Definition: rc6.h:38
RC6 algorithm context.
Definition: rc6.h:55
General definitions for cryptographic algorithms.
Common interface for encryption algorithms.
Definition: crypto.h:1073
const CipherAlgo rc6CipherAlgo
Definition: rc6.c:48
#define RC6_NB_ROUNDS
Definition: rc6.h:40
error_t rc6Init(Rc6Context *context, const uint8_t *key, size_t keyLen)
Initialize a RC6 context using the supplied key.
Definition: rc6.c:70
uint8_t s
error_t
Error codes.
Definition: error.h:40
void rc6DecryptBlock(Rc6Context *context, const uint8_t *input, uint8_t *output)
Decrypt a 16-byte block using RC6 algorithm.
Definition: rc6.c:193
uint8_t l
Definition: ndp.h:408
void rc6EncryptBlock(Rc6Context *context, const uint8_t *input, uint8_t *output)
Encrypt a 16-byte block using RC6 algorithm.
Definition: rc6.c:136