summaryrefslogtreecommitdiffstats
path: root/src/core/hw
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-01-13 01:36:41 +0100
committerbunnei <bunneidev@gmail.com>2018-01-13 01:36:41 +0100
commit8e51c61dbce925e0992e27c2c33311583645bd6f (patch)
tree2e868c243b15eaa63b953696775e0b84bab2fd22 /src/core/hw
parentdynarmic: Update to 83afe435 (diff)
downloadyuzu-8e51c61dbce925e0992e27c2c33311583645bd6f.tar
yuzu-8e51c61dbce925e0992e27c2c33311583645bd6f.tar.gz
yuzu-8e51c61dbce925e0992e27c2c33311583645bd6f.tar.bz2
yuzu-8e51c61dbce925e0992e27c2c33311583645bd6f.tar.lz
yuzu-8e51c61dbce925e0992e27c2c33311583645bd6f.tar.xz
yuzu-8e51c61dbce925e0992e27c2c33311583645bd6f.tar.zst
yuzu-8e51c61dbce925e0992e27c2c33311583645bd6f.zip
Diffstat (limited to 'src/core/hw')
-rw-r--r--src/core/hw/aes/ccm.cpp77
1 files changed, 5 insertions, 72 deletions
diff --git a/src/core/hw/aes/ccm.cpp b/src/core/hw/aes/ccm.cpp
index dc7035ab6..1ee37aaa4 100644
--- a/src/core/hw/aes/ccm.cpp
+++ b/src/core/hw/aes/ccm.cpp
@@ -3,11 +3,8 @@
// Refer to the license.txt file included.
#include <algorithm>
-#include <cryptopp/aes.h>
-#include <cryptopp/ccm.h>
-#include <cryptopp/cryptlib.h>
-#include <cryptopp/filters.h>
#include "common/alignment.h"
+#include "common/assert.h"
#include "common/logging/log.h"
#include "core/hw/aes/ccm.h"
#include "core/hw/aes/key.h"
@@ -15,80 +12,16 @@
namespace HW {
namespace AES {
-namespace {
-
-// 3DS uses a non-standard AES-CCM algorithm, so we need to derive a sub class from the standard one
-// and override with the non-standard part.
-using CryptoPP::lword;
-using CryptoPP::AES;
-using CryptoPP::CCM_Final;
-using CryptoPP::CCM_Base;
-template <bool T_IsEncryption>
-class CCM_3DSVariant_Final : public CCM_Final<AES, CCM_MAC_SIZE, T_IsEncryption> {
-public:
- void UncheckedSpecifyDataLengths(lword header_length, lword message_length,
- lword footer_length) override {
- // 3DS uses the aligned size to generate B0 for authentication, instead of the original size
- lword aligned_message_length = Common::AlignUp(message_length, AES_BLOCK_SIZE);
- CCM_Base::UncheckedSpecifyDataLengths(header_length, aligned_message_length, footer_length);
- CCM_Base::m_messageLength = message_length; // restore the actual message size
- }
-};
-
-class CCM_3DSVariant {
-public:
- using Encryption = CCM_3DSVariant_Final<true>;
- using Decryption = CCM_3DSVariant_Final<false>;
-};
-
-} // namespace
-
std::vector<u8> EncryptSignCCM(const std::vector<u8>& pdata, const CCMNonce& nonce,
size_t slot_id) {
- if (!IsNormalKeyAvailable(slot_id)) {
- LOG_ERROR(HW_AES, "Key slot %d not available. Will use zero key.", slot_id);
- }
- const AESKey normal = GetNormalKey(slot_id);
- std::vector<u8> cipher(pdata.size() + CCM_MAC_SIZE);
-
- try {
- CCM_3DSVariant::Encryption e;
- e.SetKeyWithIV(normal.data(), AES_BLOCK_SIZE, nonce.data(), CCM_NONCE_SIZE);
- e.SpecifyDataLengths(0, pdata.size(), 0);
- CryptoPP::ArraySource as(pdata.data(), pdata.size(), true,
- new CryptoPP::AuthenticatedEncryptionFilter(
- e, new CryptoPP::ArraySink(cipher.data(), cipher.size())));
- } catch (const CryptoPP::Exception& e) {
- LOG_ERROR(HW_AES, "FAILED with: %s", e.what());
- }
- return cipher;
+ UNIMPLEMENTED();
+ return {};
}
std::vector<u8> DecryptVerifyCCM(const std::vector<u8>& cipher, const CCMNonce& nonce,
size_t slot_id) {
- if (!IsNormalKeyAvailable(slot_id)) {
- LOG_ERROR(HW_AES, "Key slot %d not available. Will use zero key.", slot_id);
- }
- const AESKey normal = GetNormalKey(slot_id);
- const std::size_t pdata_size = cipher.size() - CCM_MAC_SIZE;
- std::vector<u8> pdata(pdata_size);
-
- try {
- CCM_3DSVariant::Decryption d;
- d.SetKeyWithIV(normal.data(), AES_BLOCK_SIZE, nonce.data(), CCM_NONCE_SIZE);
- d.SpecifyDataLengths(0, pdata_size, 0);
- CryptoPP::AuthenticatedDecryptionFilter df(
- d, new CryptoPP::ArraySink(pdata.data(), pdata_size));
- CryptoPP::ArraySource as(cipher.data(), cipher.size(), true, new CryptoPP::Redirector(df));
- if (!df.GetLastResult()) {
- LOG_ERROR(HW_AES, "FAILED");
- return {};
- }
- } catch (const CryptoPP::Exception& e) {
- LOG_ERROR(HW_AES, "FAILED with: %s", e.what());
- return {};
- }
- return pdata;
+ UNIMPLEMENTED();
+ return {};
}
} // namespace AES