Batch #909 by ragnarok-clanker: 0 byte-identical, 4 confirmed by peer review. - fn_18102 myGPack::EncodeBlock: logic confirmed by peer review - fn_18103 myGPack::FinalPermutation: logic confirmed by peer review - fn_18104 myGPack::InitialPermutation: logic confirmed by peer review - fn_18131 myGPack::DerivePakKey: logic confirmed by peer review Reviewed-by: ragnarok-clanker
29 lines
959 B
C++
29 lines
959 B
C++
#ifndef RAGNAROK_SOURCE_ARCHIVE_PAKCIPHER_H
|
|
#define RAGNAROK_SOURCE_ARCHIVE_PAKCIPHER_H
|
|
|
|
#include <cstdint>
|
|
|
|
namespace myGPack {
|
|
|
|
class PakCipher {
|
|
public:
|
|
PakCipher();
|
|
explicit PakCipher(const std::uint8_t* key);
|
|
~PakCipher();
|
|
int DecodeBlock(int rounds, const std::uint8_t* input, std::uint8_t* output) const;
|
|
int Decode(const std::uint8_t* input, int length, std::uint8_t* output, int* outputLength, int cycle) const;
|
|
int DecodePrefix(const std::uint8_t* input, int length, std::uint8_t* output, int* outputLength) const;
|
|
|
|
private:
|
|
std::uint8_t m_roundKeys[16][8];
|
|
};
|
|
|
|
static_assert(sizeof(PakCipher) == 128);
|
|
std::uint8_t* DerivePakKey(const char* name, std::uint8_t* key);
|
|
int InitialPermutation(std::uint8_t* block);
|
|
int FinalPermutation(std::uint8_t* block);
|
|
int EncodeBlock(int rounds, const std::uint8_t (*roundKeys)[8], std::uint32_t inputLow, std::uint32_t inputHigh, std::uint8_t* output);
|
|
|
|
}
|
|
|
|
#endif
|