From e2ed3a802770dad9c46586e3f4f415d443dc7c41 Mon Sep 17 00:00:00 2001 From: Huntereb Date: Sun, 17 Nov 2019 12:00:18 -0500 Subject: [PATCH] Make error throws not lock up the software --- source/nx/nca_writer.cpp | 6 +++--- source/util/crypto.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) mode change 100644 => 100755 source/util/crypto.cpp diff --git a/source/nx/nca_writer.cpp b/source/nx/nca_writer.cpp index 0e2ac9e..6698c0d 100755 --- a/source/nx/nca_writer.cpp +++ b/source/nx/nca_writer.cpp @@ -413,7 +413,7 @@ u64 NcaWriter::write(const u8* ptr, u64 sz) crypto.decrypt(&header, &header, sizeof(header), 0, 0x200); if (header.magic != MAGIC_NCA3) - throw "Invalid NCA magic"; + throw std::runtime_error("Invalid NCA magic"); if(isOpen()) { @@ -440,7 +440,7 @@ u64 NcaWriter::write(const u8* ptr, u64 sz) } else { - throw "not enough data to read ncz header"; + throw std::runtime_error("not enough data to read ncz header"); } } @@ -450,7 +450,7 @@ u64 NcaWriter::write(const u8* ptr, u64 sz) } else { - throw "null writer"; + throw std::runtime_error("null writer"); } } diff --git a/source/util/crypto.cpp b/source/util/crypto.cpp old mode 100644 new mode 100755 index 02af148..657e11a --- a/source/util/crypto.cpp +++ b/source/util/crypto.cpp @@ -1,6 +1,7 @@ #include "util/crypto.hpp" #include #include +#include void Crypto::calculateMGF1andXOR(unsigned char* data, size_t data_size, const void* source, size_t source_size) { unsigned char h_buf[RSA_2048_BYTES] = {0}; @@ -44,7 +45,7 @@ bool Crypto::rsa2048PssVerify(const void *data, size_t len, const unsigned char mbedtls_mpi_exp_mod(&message_mpi, &signature_mpi, &e_mpi, &modulus_mpi, NULL); if (mbedtls_mpi_write_binary(&message_mpi, m_buf, RSA_2048_BYTES) != 0) { - throw "Failed to export exponentiated RSA message!"; + throw std::runtime_error("Failed to export exponentiated RSA message!"); } mbedtls_mpi_free(&signature_mpi);