]>
git.zerfleddert.de Git - proxmark3-svn/blob - armsrc/des.h
90f742464ba6d4ed41988c81f2cf33b8c4dc77ec
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/>.
23 * \brief des and tdes declarations
24 * \license GPLv3 or later
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 */
34 * \brief defining an alias for void tdes_enc(void* out, const void* in, const void* key)
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
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
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 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]);
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 */
110 extern int Asmversion
; /* 1 if we're linked with an asm version, 0 if C */