diff --git a/navicat-patcher/_tmain.cpp b/navicat-patcher/_tmain.cpp index d1dcc7d..56ccc1e 100644 --- a/navicat-patcher/_tmain.cpp +++ b/navicat-patcher/_tmain.cpp @@ -114,10 +114,18 @@ int _tmain(int argc, TCHAR* argv[]) { goto ON_tmain_ERROR; } } else { + _tprintf_s(TEXT("Generating new RSA private key, it may take long time.\n")); + do { cipher->GenerateKey(2048); - } while (patcher::Solution0::CheckKey(cipher) && patcher::Solution1::CheckKey(cipher)); - cipher->ExportKeyToFile("RegPrivateKey.pem"); + } while (!patcher::Solution0::CheckKey(cipher) || !patcher::Solution1::CheckKey(cipher)); // re-generate RSA key if one of CheckKey return FALSE + + if (!cipher->ExportKeyToFile("RegPrivateKey.pem")) { + _tprintf_s(TEXT("@%s LINE: %u\n"), TEXT(__FUNCTION__), __LINE__); + _tprintf_s(TEXT("ERROR: Failed to save RSA private key.\n")); + goto ON_tmain_ERROR; + } + _tprintf_s(TEXT("New RSA private key has been saved to RegPrivateKey.pem.\n")); } @@ -141,7 +149,9 @@ int _tmain(int argc, TCHAR* argv[]) { if (!patcher::Solution0::Do(cipher)) goto ON_tmain_ERROR; - + + _tprintf_s(TEXT("RSA public key has been replaced by\n")); + printf_s("%s\n", cipher->ExportKeyString().c_str()); _tprintf_s(TEXT("Solution0 has been done successfully.\n")); _tprintf_s(TEXT("\n"));