diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-08-15 13:53:28 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-08-15 13:53:28 +0200 |
commit | db9837fa6c9401e898ac8e7492081a6e21c71790 (patch) | |
tree | d542a089711257402ac4fe70813fa0e7de825f2e /src/libs/3rdparty/botan/src/lib/block/des/desx.cpp | |
parent | 7bc14bf3498ea6b1c19abacf85a5103772da26bc (diff) | |
parent | 58747b2de107e8f6ac00daeb431ecbf3e603fd34 (diff) |
Merge remote-tracking branch 'origin/4.7'
Conflicts:
src/plugins/clangtools/clangtoolruncontrol.cpp
src/plugins/cpptools/compileroptionsbuilder.cpp
Change-Id: Ib1e8abf066898b50c90fc1ccba4697fe983e8a8f
Diffstat (limited to 'src/libs/3rdparty/botan/src/lib/block/des/desx.cpp')
-rw-r--r-- | src/libs/3rdparty/botan/src/lib/block/des/desx.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/libs/3rdparty/botan/src/lib/block/des/desx.cpp b/src/libs/3rdparty/botan/src/lib/block/des/desx.cpp new file mode 100644 index 00000000000..e869b3ebf85 --- /dev/null +++ b/src/libs/3rdparty/botan/src/lib/block/des/desx.cpp @@ -0,0 +1,65 @@ +/* +* DES +* (C) 1999-2007 Jack Lloyd +* +* Botan is released under the Simplified BSD License (see license.txt) +*/ + +#include <botan/desx.h> + +namespace Botan { + +/* +* DESX Encryption +*/ +void DESX::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const + { + verify_key_set(m_K1.empty() == false); + + for(size_t i = 0; i != blocks; ++i) + { + xor_buf(out, in, m_K1.data(), BLOCK_SIZE); + m_des.encrypt(out); + xor_buf(out, m_K2.data(), BLOCK_SIZE); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } + } + +/* +* DESX Decryption +*/ +void DESX::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const + { + verify_key_set(m_K1.empty() == false); + + for(size_t i = 0; i != blocks; ++i) + { + xor_buf(out, in, m_K2.data(), BLOCK_SIZE); + m_des.decrypt(out); + xor_buf(out, m_K1.data(), BLOCK_SIZE); + + in += BLOCK_SIZE; + out += BLOCK_SIZE; + } + } + +/* +* DESX Key Schedule +*/ +void DESX::key_schedule(const uint8_t key[], size_t) + { + m_K1.assign(key, key + 8); + m_des.set_key(key + 8, 8); + m_K2.assign(key + 16, key + 24); + } + +void DESX::clear() + { + m_des.clear(); + zap(m_K1); + zap(m_K2); + } + +} |