Botan 1.10.17

desx.cpp
Go to the documentation of this file.
1 /*
2 * DES
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #include <botan/desx.h>
9 #include <botan/internal/xor_buf.h>
10
11 namespace Botan {
12
13 /*
14 * DESX Encryption
15 */
16 void DESX::encrypt_n(const byte in[], byte out[], size_t blocks) const
17 {
18 for(size_t i = 0; i != blocks; ++i)
19 {
20 xor_buf(out, in, &K1[0], BLOCK_SIZE);
21 des.encrypt(out);
22 xor_buf(out, &K2[0], BLOCK_SIZE);
23
24 in += BLOCK_SIZE;
25 out += BLOCK_SIZE;
26 }
27 }
28
29 /*
30 * DESX Decryption
31 */
32 void DESX::decrypt_n(const byte in[], byte out[], size_t blocks) const
33 {
34 for(size_t i = 0; i != blocks; ++i)
35 {
36 xor_buf(out, in, &K2[0], BLOCK_SIZE);
37 des.decrypt(out);
38 xor_buf(out, &K1[0], BLOCK_SIZE);
39
40 in += BLOCK_SIZE;
41 out += BLOCK_SIZE;
42 }
43 }
44
45 /*
46 * DESX Key Schedule
47 */
48 void DESX::key_schedule(const byte key[], size_t)
49 {
50 K1.copy(key, 8);
51 des.set_key(key + 8, 8);
52 K2.copy(key + 16, 8);
53 }
54
55 }
Botan::Block_Cipher_Fixed_Params< 8, 24 >::BLOCK_SIZE
Definition: block_cipher.h:107
Botan::MemoryRegion::copy
void copy(const T in[], size_t n)
Definition: secmem.h:126
Botan::byte
unsigned char byte
Definition: types.h:22
Botan::BlockCipher::decrypt
void decrypt(const byte in[], byte out[]) const
Definition: block_cipher.h:57
Botan::BlockCipher::encrypt
void encrypt(const byte in[], byte out[]) const
Definition: block_cipher.h:47
Botan::SymmetricAlgorithm::set_key
void set_key(const SymmetricKey &key)
Definition: sym_algo.h:60
Botan::DESX::decrypt_n
void decrypt_n(const byte in[], byte out[], size_t blocks) const
Definition: desx.cpp:32
Botan
Definition: algo_base.h:14
Botan::DESX::encrypt_n
void encrypt_n(const byte in[], byte out[], size_t blocks) const
Definition: desx.cpp:16
Botan::xor_buf
void xor_buf(byte out[], const byte in[], size_t length)
Definition: xor_buf.h:21