2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: AES.hpp
|
|
|
|
Date: 2021-6-11
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Aurora::Crypto::AES
|
|
|
|
{
|
2022-11-06 12:30:06 +00:00
|
|
|
/**
|
|
|
|
* @brief
|
|
|
|
* @param pContext
|
|
|
|
* @param memoryView
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
AUKN_SYM bool CBCEncrypt(const AuSPtr<CBC::ICBCContext> pContext,
|
|
|
|
const Memory::MemoryViewWrite &memoryView);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief
|
|
|
|
* @param pContext
|
|
|
|
* @param memoryView
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
AUKN_SYM bool CBCDecrypt(const AuSPtr<CBC::ICBCContext> pContext,
|
|
|
|
const Memory::MemoryViewWrite &memoryView);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief
|
|
|
|
* @param plainText
|
|
|
|
* @return
|
|
|
|
*/
|
2021-09-18 20:10:25 +00:00
|
|
|
AUKN_SYM AuUInt GetSafeCipherPadding(const Memory::MemoryViewRead &plainText);
|
2021-06-27 21:25:29 +00:00
|
|
|
|
|
|
|
// Remember: AES works in chunks of 128 bits
|
|
|
|
// IVS are 16 bytes long
|
|
|
|
// Chunks are 16 bytes long
|
|
|
|
// Keys are 16, 24, or 32 bytes long
|
|
|
|
// Initialization vectors must never be constant
|
|
|
|
// Initialization vectors should be determined by a handshaake
|
|
|
|
// It is not the end of the world if an IV is made public by design
|
|
|
|
// Keys must be random
|
|
|
|
// Initialization vectors could be derived from SHA1, Tiger, or SHA2 digests
|
2021-09-18 20:10:25 +00:00
|
|
|
AUKN_SYM bool Encrypt(const Memory::MemoryViewRead &plainText,
|
|
|
|
const Memory::MemoryViewRead &inIv,
|
2022-01-29 11:49:11 +00:00
|
|
|
const Memory::MemoryViewWrite &outIv, // optional
|
2021-09-18 20:10:25 +00:00
|
|
|
const Memory::MemoryViewRead &inKey,
|
2022-01-20 16:04:53 +00:00
|
|
|
Memory::ByteBuffer &out,
|
2021-09-06 10:58:08 +00:00
|
|
|
bool auCoolCodePadding);
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-09-18 20:10:25 +00:00
|
|
|
AUKN_SYM bool Decrypt(const Memory::MemoryViewRead &cipherText,
|
|
|
|
const Memory::MemoryViewRead &inIv,
|
2022-01-29 11:49:11 +00:00
|
|
|
const Memory::MemoryViewWrite &outIv, // optional
|
2021-09-18 20:10:25 +00:00
|
|
|
const Memory::MemoryViewRead &inKey,
|
2022-01-20 16:04:53 +00:00
|
|
|
Memory::ByteBuffer &plainText,
|
2021-09-06 10:58:08 +00:00
|
|
|
bool auCoolCodePadding);
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|