37 lines
839 B
C++
37 lines
839 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-2018 Danny Robson <danny@nerdcruft.net>
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
|
|
#include <cruft/util/std.hpp>
|
|
#include <cruft/util/view.hpp>
|
|
|
|
|
|
namespace cruft::crypto::block {
|
|
/// An implementation of the "Corrected Block TEA" block cipher.
|
|
///
|
|
/// ref: http://en.wikipedia.org/wiki/XXTEA
|
|
class XXTEA {
|
|
public:
|
|
using key_t = std::array<u32,4>;
|
|
using word_t = u32;
|
|
|
|
explicit XXTEA (key_t);
|
|
|
|
void encrypt (cruft::view<word_t*> data);
|
|
void decrypt (cruft::view<word_t*> data);
|
|
|
|
private:
|
|
key_t m_key;
|
|
};
|
|
}
|