]> git.zerfleddert.de Git - proxmark3-svn/blob - armsrc/des.h
Merge pull request #278 from marshmellow42/graphwork
[proxmark3-svn] / armsrc / des.h
1 /* des.h */
2 /*
3 This file is part of the ARM-Crypto-Lib.
4 Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 /**
20 * \file des.h
21 * \author Daniel Otte
22 * \date 2007-06-16
23 * \brief des and tdes declarations
24 * \license GPLv3 or later
25 *
26 */
27 #ifndef DES_H_
28 #define DES_H_
29
30 /* the FIPS 46-3 (1999-10-25) name for triple DES is triple data encryption algorithm so TDEA.
31 * Also we only implement the three key mode */
32
33 /** \def tdea_enc
34 * \brief defining an alias for void tdes_enc(void* out, const void* in, const void* key)
35 */
36
37 /** \def tdea_dec
38 * \brief defining an alias for void tdes_dec(void* out, const void* in, const void* key)
39 */
40
41 #define tdea_enc tdes_enc
42 #define tdea_dec tdes_dec
43
44 /** \fn void des_enc(void* out, const void* in, const void* key)
45 * \brief encrypt a block with DES
46 *
47 * This function encrypts a block of 64 bits (8 bytes) with the DES algorithm.
48 * Key expansion is done automatically. The key is 64 bits long, but note that
49 * only 56 bits are used (the LSB of each byte is dropped). The input and output
50 * blocks may overlap.
51 *
52 * \param out pointer to the block (64 bit = 8 byte) where the ciphertext is written to
53 * \param in pointer to the block (64 bit = 8 byte) where the plaintext is read from
54 * \param key pointer to the key (64 bit = 8 byte)
55 */
56 void des_enc(void* out, const void* in, const void* key);
57
58 /** \fn void des_dec(void* out, const void* in, const void* key)
59 * \brief decrypt a block with DES
60 *
61 * This function decrypts a block of 64 bits (8 bytes) with the DES algorithm.
62 * Key expansion is done automatically. The key is 64 bits long, but note that
63 * only 56 bits are used (the LSB of each byte is dropped). The input and output
64 * blocks may overlap.
65 *
66 * \param out pointer to the block (64 bit = 8 byte) where the plaintext is written to
67 * \param in pointer to the block (64 bit = 8 byte) where the ciphertext is read from
68 * \param key pointer to the key (64 bit = 8 byte)
69 */
70 void des_dec(void* out, const void* in, const void* key);
71
72 /** \fn void tdes_enc(void* out, const void* in, const void* key)
73 * \brief encrypt a block with Tripple-DES
74 *
75 * This function encrypts a block of 64 bits (8 bytes) with the Tripple-DES (EDE)
76 * algorithm. Key expansion is done automatically. The key is 192 bits long, but
77 * note that only 178 bits are used (the LSB of each byte is dropped). The input
78 * and output blocks may overlap.
79 *
80 * \param out pointer to the block (64 bit = 8 byte) where the ciphertext is written to
81 * \param in pointer to the block (64 bit = 8 byte) where the plaintext is read from
82 * \param key pointer to the key (192 bit = 24 byte)
83 */
84 void tdes_enc(void* out, const void* in, const void* key);
85
86 /** \fn void tdes_dec(void* out, const void* in, const void* key)
87 * \brief decrypt a block with Tripple-DES
88 *
89 * This function decrypts a block of 64 bits (8 bytes) with the Tripple-DES (EDE)
90 * algorithm. Key expansion is done automatically. The key is 192 bits long, but
91 * note that only 178 bits are used (the LSB of each byte is dropped). The input
92 * and output blocks may overlap.
93 *
94 * \param out pointer to the block (64 bit = 8 byte) where the plaintext is written to
95 * \param in pointer to the block (64 bit = 8 byte) where the ciphertext is read from
96 * \param key pointer to the key (192 bit = 24 byte)
97 */
98 void tdes_dec(void* out, const void* in, const void* key);
99
100 void tdes_2key_enc(void* out, const void* in, size_t length, const void* key, unsigned char iv[8]);
101 void tdes_2key_dec(void* out, const void* in, size_t length, const void* key, unsigned char iv[8]);
102
103 #endif /*DES_H_*/
104
105 // Copied from des.h in desfire imp.
106 typedef unsigned long DES_KS[16][2]; /* Single-key DES key schedule */
107 typedef unsigned long DES3_KS[48][2]; /* Triple-DES key schedule */
108
109
110 extern int Asmversion; /* 1 if we're linked with an asm version, 0 if C */
Impressum, Datenschutz