2018-01-14 17:17:34 +11:00
|
|
|
/*
|
2018-08-04 15:18:16 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2018-01-14 17:17:34 +11:00
|
|
|
*
|
|
|
|
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CRUFT_CRYPTO_BLOCKXXTEA_HPP
|
|
|
|
#define CRUFT_CRYPTO_BLOCKXXTEA_HPP
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstddef>
|
|
|
|
|
|
|
|
namespace cruft::crypto::block {
|
|
|
|
// http://en.wikipedia.org/wiki/XXTEA
|
|
|
|
// 'corrected' block TEA
|
|
|
|
class XXTEA {
|
|
|
|
public:
|
|
|
|
using key_t = std::array<uint32_t,4>;
|
|
|
|
|
|
|
|
explicit XXTEA (key_t);
|
|
|
|
|
|
|
|
void encrypt (uint32_t *restrict data, size_t count);
|
|
|
|
void decrypt (uint32_t *restrict data, size_t count);
|
|
|
|
|
|
|
|
private:
|
|
|
|
key_t m_key;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|