rodecomp/Source/Utility/AES.h
ragnarok-clanker 2727c12fea Decompile 6 functions in Source/Utility/AES.cpp, Source/Utility/AES.h, ...
Batch #16181 by Yommy: 2 byte-identical, 4 confirmed by peer review.

- fn_04419 AES::Initialize: logic confirmed by peer review
- fn_04420 AES::Initialize: logic confirmed by peer review
- fn_04421 AES::SetIV: byte-identical
- fn_04422 AES::SetMode: byte-identical
- fn_05068 PakVerifier_655A30::Verify: logic confirmed by peer review
- fn_05112 PakAuxiliaryState::DecodeHeader: logic confirmed by peer review

Peer-reviewed-by: alisonrag, youko
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-10 14:44:58 +00:00

39 lines
1,003 B
C++

#ifndef RAGNAROK_SOURCE_UTILITY_AES_H
#define RAGNAROK_SOURCE_UTILITY_AES_H
#include <windows.h>
#include <bcrypt.h>
#include <VersionHelpers.h>
#include <span>
#include <vector>
class AES {
public:
enum Mode : int { ECB = 0, CBC = 1, CFB = 2 };
private:
/* 0000 */ BCRYPT_ALG_HANDLE m_algorithm;
/* 0004 */ BCRYPT_KEY_HANDLE m_key;
/* 0008 */ std::vector<UCHAR> m_keyObject;
/* 0014 */ std::vector<UCHAR> m_iv;
/* 0020 */ int m_mode;
public:
// INLINED
AES() : m_algorithm(nullptr), m_key(nullptr), m_mode(CBC) {
}
~AES();
ULONG Decrypt(PUCHAR input, ULONG inputSize, PUCHAR output, ULONG outputSize, UCHAR flags);
bool Initialize(PUCHAR secret, ULONG secretSize, std::span<const UCHAR> iv, int mode);
bool Initialize(PUCHAR secret, ULONG secretSize, int mode);
bool SetIV(std::span<const UCHAR> iv);
bool SetMode(int mode);
};
#if defined(_WIN32) && !defined(_WIN64)
static_assert(sizeof(std::vector<UCHAR>) == 12);
static_assert(sizeof(AES) == 36);
#endif
#endif