35 lines
786 B
C++
35 lines
786 B
C++
/*
|
|
* 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/.
|
|
*
|
|
* 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
|
|
|