From c7417593521a2a96442e97508354e32f502bd931 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Wed, 27 Oct 2010 06:31:24 +0300 Subject: random key generation --- main.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 108 insertions(+), 4 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 27ed44e..898b672 100644 --- a/main.cpp +++ b/main.cpp @@ -218,7 +218,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM DBWriteContactSettingByte(NULL, szGPGModuleName, "FirstRun", 0); { wstring keyinfo = _T("Current private key id: "); - keyinfo += (_tcslen(fp) > 0)?fp:_T("not set"); + keyinfo += (fp[0])?fp:_T("not set"); extern HWND hwndCurKey_p; SetWindowText(hwndCurKey_p, keyinfo.c_str()); } @@ -379,9 +379,113 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM DBDeleteContactSetting(NULL, szGPGModuleName, "KeyType"); ListView_DeleteItem(hwndList, itemnum); break; - } - break; - } + case IDC_GENERATE_RANDOM: + { + wstring path; + { //generating key file + TCHAR *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); + path = tmp; + mir_free(tmp); + path.append(_T("\\new_key")); + wfstream f(path.c_str(), std::ios::out); + if(!f.is_open()) + { + MessageBox(0, _T("Failed to open file"), _T("Error"), MB_OK); + break; + } + f<<"Key-Type: RSA"; + f<<"\n"; + f<<"Key-Length: 2048"; + f<<"\n"; + f<<"Subkey-Type: RSA"; + f<<"\n"; + f<<"Name-Real: "; + f<