]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - armsrc/des.h
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
33 /* the FIPS 46-3 (1999-10-25) name for triple DES is triple data encryption algorithm so TDEA.
34 * Also we only implement the three key mode */
37 * \brief defining an alias for void tdes_enc(void* out, const void* in, const void* key)
41 * \brief defining an alias for void tdes_dec(void* out, const void* in, const void* key)
44 #define tdea_enc tdes_enc
45 #define tdea_dec tdes_dec
47 /** \fn void des_enc(void* out, const void* in, const void* key)
48 * \brief encrypt a block with DES
50 * This function encrypts a block of 64 bits (8 bytes) with the DES algorithm.
51 * Key expansion is done automatically. The key is 64 bits long, but note that
52 * only 56 bits are used (the LSB of each byte is dropped). The input and output
55 * \param out pointer to the block (64 bit = 8 byte) where the ciphertext is written to
56 * \param in pointer to the block (64 bit = 8 byte) where the plaintext is read from
57 * \param key pointer to the key (64 bit = 8 byte)
59 void des_enc(void* out
, const void* in
, const void* key
);
61 /** \fn void des_dec(void* out, const void* in, const void* key)
62 * \brief decrypt a block with DES
64 * This function decrypts a block of 64 bits (8 bytes) with the DES algorithm.
65 * Key expansion is done automatically. The key is 64 bits long, but note that
66 * only 56 bits are used (the LSB of each byte is dropped). The input and output
69 * \param out pointer to the block (64 bit = 8 byte) where the plaintext is written to
70 * \param in pointer to the block (64 bit = 8 byte) where the ciphertext is read from
71 * \param key pointer to the key (64 bit = 8 byte)
73 //void des_dec(void* out, const void* in, const void* key);
74 void des_dec(void* out
, const void* in
, const uint8_t* key
);
76 /** \fn void tdes_enc(void* out, const void* in, const void* key)
77 * \brief encrypt a block with Tripple-DES
79 * This function encrypts a block of 64 bits (8 bytes) with the Tripple-DES (EDE)
80 * algorithm. Key expansion is done automatically. The key is 192 bits long, but
81 * note that only 178 bits are used (the LSB of each byte is dropped). The input
82 * and output blocks may overlap.
84 * \param out pointer to the block (64 bit = 8 byte) where the ciphertext is written to
85 * \param in pointer to the block (64 bit = 8 byte) where the plaintext is read from
86 * \param key pointer to the key (192 bit = 24 byte)
88 //void tdes_enc(void* out, const void* in, const void* key);
89 void tdes_enc(void* out
, void* in
, const void* key
);
91 /** \fn void tdes_dec(void* out, const void* in, const void* key)
92 * \brief decrypt a block with Tripple-DES
94 * This function decrypts a block of 64 bits (8 bytes) with the Tripple-DES (EDE)
95 * algorithm. Key expansion is done automatically. The key is 192 bits long, but
96 * note that only 178 bits are used (the LSB of each byte is dropped). The input
97 * and output blocks may overlap.
99 * \param out pointer to the block (64 bit = 8 byte) where the plaintext is written to
100 * \param in pointer to the block (64 bit = 8 byte) where the ciphertext is read from
101 * \param key pointer to the key (192 bit = 24 byte)
103 //void tdes_dec(void* out, const void* in, const void* key);
104 void tdes_dec(void* out
, void* in
, const uint8_t* key
);
106 void tdes_2key_enc(void* out
, const void* in
, size_t length
, const void* key
, unsigned char iv
[8]);
107 void tdes_2key_dec(void* out
, const void* in
, size_t length
, const void* key
, unsigned char iv
[8]);
109 // Copied from des.h in desfire imp.
110 typedef unsigned long DES_KS
[16][2]; /* Single-key DES key schedule */
111 typedef unsigned long DES3_KS
[48][2]; /* Triple-DES key schedule */
113 extern int Asmversion
; /* 1 if we're linked with an asm version, 0 if C */