des3.h
Go to the documentation of this file.
1 /**
2  * @file des3.h
3  * @brief Triple DES (Triple Data 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.0
29  **/
30 
31 #ifndef _DES3_H
32 #define _DES3_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "cipher/des.h"
37 
38 //Application specific context
39 #ifndef DES3_PRIVATE_CONTEXT
40  #define DES3_PRIVATE_CONTEXT
41 #endif
42 
43 //Triple DES block size
44 #define DES3_BLOCK_SIZE 8
45 //Common interface for encryption algorithms
46 #define DES3_CIPHER_ALGO (&des3CipherAlgo)
47 
48 //C++ guard
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 
54 /**
55  * @brief Triple DES algorithm context
56  **/
57 
58 typedef struct
59 {
64 } Des3Context;
65 
66 
67 //Triple DES related constants
68 extern const uint8_t DES_EDE3_CBC_OID[8];
69 extern const CipherAlgo des3CipherAlgo;
70 
71 //Triple DES related functions
72 error_t des3Init(Des3Context *context, const uint8_t *key, size_t keyLen);
73 
74 void des3EncryptBlock(Des3Context *context, const uint8_t *input,
75  uint8_t *output);
76 
77 void des3DecryptBlock(Des3Context *context, const uint8_t *input,
78  uint8_t *output);
79 
80 void des3Deinit(Des3Context *context);
81 
82 //C++ guard
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif
General definitions for cryptographic algorithms.
#define DES3_PRIVATE_CONTEXT
Definition: des3.h:40
void des3DecryptBlock(Des3Context *context, const uint8_t *input, uint8_t *output)
Decrypt a 8-byte block using Triple DES algorithm.
Definition: des3.c:144
const uint8_t DES_EDE3_CBC_OID[8]
Definition: des3.c:48
error_t des3Init(Des3Context *context, const uint8_t *key, size_t keyLen)
Initialize a Triple DES context using the supplied key.
Definition: des3.c:74
const CipherAlgo des3CipherAlgo
Definition: des3.c:51
void des3EncryptBlock(Des3Context *context, const uint8_t *input, uint8_t *output)
Encrypt a 8-byte block using Triple DES algorithm.
Definition: des3.c:125
void des3Deinit(Des3Context *context)
Release Triple DES context.
Definition: des3.c:161
DES (Data Encryption Standard)
error_t
Error codes.
Definition: error.h:43
Common interface for encryption algorithms.
Definition: crypto.h:1036
Triple DES algorithm context.
Definition: des3.h:59
DesContext k2
Definition: des3.h:61
DesContext k3
Definition: des3.h:62
DesContext k1
Definition: des3.h:60
DES algorithm context.
Definition: des.h:58