Some documentation and formatting to LogTraceHitag
[legacy-proxmark3.git] / armsrc / des.h
blob652886fd7a523d9aeab176057ac7003d8fd0ba2e
1 /* des.h */
2 /*
3 This file is part of the ARM-Crypto-Lib.
4 Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
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.
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.
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/>.
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
27 #ifndef DES_H_
28 #define DES_H_
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 */
33 /** \def tdea_enc
34 * \brief defining an alias for void tdes_enc(void* out, const void* in, const void* key)
37 /** \def tdea_dec
38 * \brief defining an alias for void tdes_dec(void* out, const void* in, const void* key)
41 #define tdea_enc tdes_enc
42 #define tdea_dec tdes_dec
44 /** \fn void des_enc(void* out, const void* in, const void* key)
45 * \brief encrypt a block with DES
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.
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)
56 void des_enc(void* out, const void* in, const void* key);
58 /** \fn void des_dec(void* out, const void* in, const void* key)
59 * \brief decrypt a block with DES
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.
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)
70 void des_dec(void* out, const void* in, const void* key);
72 /** \fn void tdes_enc(void* out, const void* in, const void* key)
73 * \brief encrypt a block with Tripple-DES
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.
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)
84 void tdes_enc(void* out, const void* in, const void* key);
86 /** \fn void tdes_dec(void* out, const void* in, const void* key)
87 * \brief decrypt a block with Tripple-DES
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.
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)
98 void tdes_dec(void* out, const void* in, const void* key);
100 #endif /*DES_H_*/
102 // Copied from des.h in desfire imp.
103 typedef unsigned long DES_KS[16][2]; /* Single-key DES key schedule */
104 typedef unsigned long DES3_KS[48][2]; /* Triple-DES key schedule */
107 extern int Asmversion; /* 1 if we're linked with an asm version, 0 if C */