2023-12-14 21:54:22 +01:00
|
|
|
#ifndef AES_CONTEXT_H
|
|
|
|
#define AES_CONTEXT_H
|
2023-12-17 15:39:29 +01:00
|
|
|
|
2023-12-14 21:54:22 +01:00
|
|
|
/* aes_context.h */
|
2023-12-17 15:39:29 +01:00
|
|
|
|
2023-12-14 21:54:22 +01:00
|
|
|
|
|
|
|
#include "core/crypto/crypto_core.h"
|
|
|
|
#include "core/object/reference.h"
|
|
|
|
|
|
|
|
class AESContext : public Reference {
|
|
|
|
GDCLASS(AESContext, Reference);
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Mode {
|
|
|
|
MODE_ECB_ENCRYPT,
|
|
|
|
MODE_ECB_DECRYPT,
|
|
|
|
MODE_CBC_ENCRYPT,
|
|
|
|
MODE_CBC_DECRYPT,
|
|
|
|
MODE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
Mode mode;
|
|
|
|
CryptoCore::AESContext ctx;
|
|
|
|
PoolByteArray iv;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
|
|
|
Error start(Mode p_mode, PoolByteArray p_key, PoolByteArray p_iv = PoolByteArray());
|
|
|
|
PoolByteArray update(PoolByteArray p_src);
|
|
|
|
PoolByteArray get_iv_state();
|
|
|
|
void finish();
|
|
|
|
|
|
|
|
AESContext();
|
|
|
|
};
|
|
|
|
|
|
|
|
VARIANT_ENUM_CAST(AESContext::Mode);
|
|
|
|
|
|
|
|
#endif // AES_CONTEXT_H
|