Make error throws not lock up the software

This commit is contained in:
Huntereb 2019-11-17 12:00:18 -05:00
parent 4746a52edc
commit e2ed3a8027
2 changed files with 5 additions and 4 deletions

View file

@ -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");
}
}

3
source/util/crypto.cpp Normal file → Executable file
View file

@ -1,6 +1,7 @@
#include "util/crypto.hpp"
#include <string.h>
#include <mbedtls/bignum.h>
#include <stdexcept>
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);