libcruft-crypto/block/tea.hpp

33 lines
770 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_BLOCK_TEA_HPP
#define CRUFT_CRYPTO_BLOCK_TEA_HPP
#include <array>
#include <cstdint>
#include <cstddef>
namespace cruft::crypto::block {
// http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm
class TEA {
public:
using key_t = std::array<uint32_t,4>;
explicit TEA (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