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
11namespace Botan {
12
13/*
14* DESX Encryption
15*/
16void 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*/
32void 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*/
48void 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}
void decrypt_n(const byte in[], byte out[], size_t blocks) const
Definition desx.cpp:32
void encrypt_n(const byte in[], byte out[], size_t blocks) const
Definition desx.cpp:16
void copy(const T in[], size_t n)
Definition secmem.h:126
void set_key(const SymmetricKey &key)
Definition sym_algo.h:60
void xor_buf(byte out[], const byte in[], size_t length)
Definition xor_buf.h:21