]> cvs.zerfleddert.de Git - proxmark3-svn/blame - armsrc/des.h
Merge pull request #81 from mdp/fixguard
[proxmark3-svn] / armsrc / des.h
CommitLineData
f38a1528 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 */
53d5dc64 27#ifndef __DES_H_
28#define __DES_H_
29
30#include <stdint.h>
31#include <string.h>
f38a1528 32
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 */
35
36/** \def tdea_enc
37 * \brief defining an alias for void tdes_enc(void* out, const void* in, const void* key)
38 */
39
40/** \def tdea_dec
41 * \brief defining an alias for void tdes_dec(void* out, const void* in, const void* key)
42 */
43
44#define tdea_enc tdes_enc
45#define tdea_dec tdes_dec
46
47/** \fn void des_enc(void* out, const void* in, const void* key)
48 * \brief encrypt a block with DES
49 *
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
53 * blocks may overlap.
54 *
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)
58 */
59void des_enc(void* out, const void* in, const void* key);
60
61/** \fn void des_dec(void* out, const void* in, const void* key)
62 * \brief decrypt a block with DES
63 *
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
67 * blocks may overlap.
68 *
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)
72 */
53d5dc64 73//void des_dec(void* out, const void* in, const void* key);
74void des_dec(void* out, const void* in, const uint8_t* key);
f38a1528 75
76/** \fn void tdes_enc(void* out, const void* in, const void* key)
77 * \brief encrypt a block with Tripple-DES
78 *
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.
83 *
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)
87 */
53d5dc64 88//void tdes_enc(void* out, const void* in, const void* key);
89void tdes_enc(void* out, void* in, const void* key);
f38a1528 90
91/** \fn void tdes_dec(void* out, const void* in, const void* key)
92 * \brief decrypt a block with Tripple-DES
93 *
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.
98 *
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)
102 */
53d5dc64 103 //void tdes_dec(void* out, const void* in, const void* key);
104 void tdes_dec(void* out, void* in, const uint8_t* key);
aa60d156 105
062b7cb9 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]);
f38a1528 108
f38a1528 109// Copied from des.h in desfire imp.
110typedef unsigned long DES_KS[16][2]; /* Single-key DES key schedule */
111typedef unsigned long DES3_KS[48][2]; /* Triple-DES key schedule */
112
f38a1528 113extern int Asmversion; /* 1 if we're linked with an asm version, 0 if C */
53d5dc64 114
115#endif /*DES_H_*/
Impressum, Datenschutz