mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Move AES code to Common/Crypto
This commit is contained in:
@ -30,6 +30,7 @@ set(SRCS Analytics.cpp
|
||||
x64ABI.cpp
|
||||
x64Emitter.cpp
|
||||
MD5.cpp
|
||||
Crypto/AES.cpp
|
||||
Crypto/bn.cpp
|
||||
Crypto/ec.cpp
|
||||
Logging/LogManager.cpp)
|
||||
|
@ -139,6 +139,7 @@
|
||||
<ClInclude Include="x64ABI.h" />
|
||||
<ClInclude Include="x64Emitter.h" />
|
||||
<ClInclude Include="x64Reg.h" />
|
||||
<ClInclude Include="Crypto\AES.h" />
|
||||
<ClInclude Include="Crypto\bn.h" />
|
||||
<ClInclude Include="Crypto\ec.h" />
|
||||
<ClInclude Include="Logging\ConsoleListener.h" />
|
||||
@ -188,6 +189,7 @@
|
||||
<ClCompile Include="x64CPUDetect.cpp" />
|
||||
<ClCompile Include="x64Emitter.cpp" />
|
||||
<ClCompile Include="x64FPURoundMode.cpp" />
|
||||
<ClCompile Include="Crypto\AES.cpp" />
|
||||
<ClCompile Include="Crypto\bn.cpp" />
|
||||
<ClCompile Include="Crypto\ec.cpp" />
|
||||
<ClCompile Include="Logging\LogManager.cpp" />
|
||||
|
@ -75,6 +75,9 @@
|
||||
<ClInclude Include="Logging\LogManager.h">
|
||||
<Filter>Logging</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Crypto\AES.h">
|
||||
<Filter>Crypto</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Crypto\ec.h">
|
||||
<Filter>Crypto</Filter>
|
||||
</ClInclude>
|
||||
@ -259,6 +262,9 @@
|
||||
<ClCompile Include="x64CPUDetect.cpp" />
|
||||
<ClCompile Include="x64Emitter.cpp" />
|
||||
<ClCompile Include="x64FPURoundMode.cpp" />
|
||||
<ClCompile Include="Crypto\AES.cpp">
|
||||
<Filter>Crypto</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Crypto\bn.cpp">
|
||||
<Filter>Crypto</Filter>
|
||||
</ClCompile>
|
||||
|
24
Source/Core/Common/Crypto/AES.cpp
Normal file
24
Source/Core/Common/Crypto/AES.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <mbedtls/aes.h>
|
||||
|
||||
#include "Common/Crypto/AES.h"
|
||||
|
||||
namespace Common
|
||||
{
|
||||
namespace AES
|
||||
{
|
||||
std::vector<u8> Decrypt(const u8* key, u8* iv, const u8* src, size_t size)
|
||||
{
|
||||
mbedtls_aes_context aes_ctx;
|
||||
std::vector<u8> buffer(size);
|
||||
|
||||
mbedtls_aes_setkey_dec(&aes_ctx, key, 128);
|
||||
mbedtls_aes_crypt_cbc(&aes_ctx, MBEDTLS_AES_DECRYPT, size, iv, src, buffer.data());
|
||||
|
||||
return buffer;
|
||||
}
|
||||
} // namespace AES
|
||||
} // namespace Common
|
18
Source/Core/Common/Crypto/AES.h
Normal file
18
Source/Core/Common/Crypto/AES.h
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
namespace Common
|
||||
{
|
||||
namespace AES
|
||||
{
|
||||
std::vector<u8> Decrypt(const u8* key, u8* iv, const u8* src, size_t size);
|
||||
} // namespace AES
|
||||
} // namespace Common
|
Reference in New Issue
Block a user