SafeInfoPage.cpp
上传用户:dengkfang
上传日期:2008-12-30
资源大小:5233k
文件大小:16k
源码类别:

CA认证

开发平台:

Visual C++

  1. // SafeInfoPage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "minica.h"
  5. #include "SafeInfoPage.h"
  6. #include "MiniMainDlg.h"
  7. #include "Evp.h"
  8. #include ".GenericClassLanguage.h"
  9. #include "minict.h"
  10. //系统默认堆栈为1M,超过1M的数组定义会失败
  11. const int dMaxMem = 1024*100;
  12. const UINT uMsgLen = MAX_PATH + 100;
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CSafeInfoPage property page
  20. IMPLEMENT_DYNCREATE(CSafeInfoPage, CPropertyPage)
  21. CSafeInfoPage::CSafeInfoPage() : CPropertyPage(CSafeInfoPage::IDD)
  22. {
  23. //{{AFX_DATA_INIT(CSafeInfoPage)
  24. // NOTE: the ClassWizard will add member initialization here
  25. //}}AFX_DATA_INIT
  26. m_pPageCdb = NULL;
  27. }
  28. CSafeInfoPage::~CSafeInfoPage()
  29. {
  30. }
  31. void CSafeInfoPage::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CPropertyPage::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(CSafeInfoPage)
  35. // DDX_Control(pDX, IDC_EDIT_PWD, m_XpEditPwd);
  36. // DDX_Control(pDX, IDC_EDIT_OUTFILE, m_XpEditOutFile);
  37. // DDX_Control(pDX, IDC_EDIT_INFILE, m_XpEditInfile);
  38. DDX_Control(pDX, IDC_BVSIGN, m_Bvsign);
  39. DDX_Control(pDX, IDC_BSIGN, m_Bsign);
  40. DDX_Control(pDX, IDC_BRSAKEY2, m_Brsakey2);
  41. DDX_Control(pDX, IDC_BRSAKEY, m_Brsakey);
  42. DDX_Control(pDX, IDC_BRSACERT2, m_Brsacert2);
  43. DDX_Control(pDX, IDC_BRSACERT, m_Brsacert);
  44. DDX_Control(pDX, IDC_BENC, m_Benc);
  45. DDX_Control(pDX, IDC_BDIGEST, m_Bdigest);
  46. DDX_Control(pDX, IDC_BDEC, m_Bdec);
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CSafeInfoPage, CPropertyPage)
  50. //{{AFX_MSG_MAP(CSafeInfoPage)
  51. ON_BN_CLICKED(IDC_BENC, OnBenc)
  52. ON_BN_CLICKED(IDC_BDEC, OnBdec)
  53. ON_BN_CLICKED(IDC_BDIGEST, OnBdigest)
  54. ON_BN_CLICKED(IDC_BSIGN, OnBsign)
  55. ON_BN_CLICKED(IDC_BVSIGN, OnBvsign)
  56. ON_BN_CLICKED(IDC_BRSACERT, OnBrsacert)
  57. ON_BN_CLICKED(IDC_BRSAKEY, OnBrsakey)
  58. ON_BN_CLICKED(IDC_BRSAKEY2, OnBrsakey2)
  59. ON_BN_CLICKED(IDC_BRSACERT2, OnBrsacert2)
  60. //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62. /////////////////////////////////////////////////////////////////////////////
  63. // CSafeInfoPage message handlers
  64. void CSafeInfoPage::AddMsg(CString info, DWORD type)
  65. {
  66. ((CMiniMainDlg *)AfxGetMainWnd())->AddMsg(MiniCT_0002, info, type);
  67. }
  68. BOOL CSafeInfoPage::OnInitDialog() 
  69. {
  70. CPropertyPage::OnInitDialog();
  71. // TODO: Add extra initialization here
  72. CXPStyleButtonST::SetAllThemeHelper(this, ((CMiniCaApp *)AfxGetApp())->GetThemeHelperST());
  73. m_Bvsign.SetIcon(IDI_ICON_DEC);
  74. m_Bvsign.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
  75. m_Bsign.SetIcon(IDI_ICON_ENC);
  76. m_Bsign.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
  77. m_Brsakey2.SetIcon(IDI_ICON_ENC);
  78. m_Brsakey2.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
  79. m_Brsakey.SetIcon(IDI_ICON_DEC);
  80. m_Brsakey.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
  81. m_Brsacert2.SetIcon(IDI_ICON_DEC);
  82. m_Brsacert2.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
  83. m_Brsacert.SetIcon(IDI_ICON_ENC);
  84. m_Brsacert.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
  85. m_Benc.SetIcon(IDI_ICON_ENC);
  86. m_Benc.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
  87. m_Bdigest.SetIcon(IDI_ICON_DEC);
  88. m_Bdigest.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
  89. m_Bdec.SetIcon(IDI_ICON_DEC);
  90. m_Bdec.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, 30);
  91. SetDlgItemText(IDC_COMBO_CRYPT,"idea-cbc");
  92. SetDlgItemText(IDC_COMBO_DIGEST,"sha1");
  93. SetDlgItemText(IDC_EDIT_PWD,"MiniCA");
  94. ((CComboBox *)GetDlgItem(IDC_COMBO_CRYPT))->SetCurSel(16);
  95. ((CComboBox *)GetDlgItem(IDC_COMBO_DIGEST))->SetCurSel(4);
  96. if(!((CMiniCaApp *)AfxGetApp())->IsXpStyle())
  97. {
  98. ClassXP(GetDlgItem(IDC_COMBO_CRYPT)->m_hWnd,TRUE);
  99. ClassXP(GetDlgItem(IDC_COMBO_DIGEST)->m_hWnd,TRUE);
  100. ClassXP(GetDlgItem(IDC_EDIT_PWD)->m_hWnd,TRUE);
  101. ClassXP(GetDlgItem(IDC_EDIT_OUTFILE)->m_hWnd,TRUE);
  102. ClassXP(GetDlgItem(IDC_EDIT_INFILE)->m_hWnd,TRUE);
  103. }
  104. SetDlgItemText(IDC_EDIT_INFILE, "多年前有个俄国的无神论的学者。"
  105. "一天,他在某大会场向人们讲上帝绝对不可能存在。当听众感觉他言之有理时,"
  106. "他便高声向上帝挑战说:“上帝,假如你果真有灵,请你下来,"
  107. "在这广大的群众面前把我杀死,我们便相信你是存在的了!”"
  108. "他故意静静地等候了几分钟,当然上帝没有下来杀死他。"
  109. "他便左顾右盼地向听众说:“你们都看见了,上帝根本不存在!” "
  110. "怎知有一位妇人,头上裹着一条盘巾,站起来对他说:“先生,你的理论很高明,"
  111. "你是个饱学之士。我只是一个农村妇人,不能向你反驳,"
  112. "只想请你回答我心中的一个问题:我信奉耶稣多年以来,"
  113. "心中有了主的救恩,十分快乐;我更爱读《圣经》,越读越有味,"
  114. "我心中充满耶稣给我的安慰;因为信奉耶稣,人生有了最大的快乐。"
  115. "请问:假如我死时发现上帝根本不存在,耶稣不是上帝的儿子,圣经全不可靠,"
  116. "我这一辈子信奉耶稣,损失了什么?” 无神论学者想了好一会儿,"
  117. "全场寂静无声,听众也很同意农村妇人的推理,"
  118. "连学者也惊叹好单纯的逻辑,他低声回答:“女士,我想你一点儿损失也没有。”"
  119. "农村妇人又向学者说道:“谢谢你这样好的回答。"
  120. "我心中还有一个问题:当你死的时候,假如你发现果真有上帝,"
  121. "圣经是千真万确,耶稣果然是神的儿子,也有天堂和地狱的存在,"
  122. "我想请问,你损失了什么?”学者想了许久,竟无言以对。");
  123. CMiniMainDlg * pMain = (CMiniMainDlg *)AfxGetMainWnd();
  124. if(pMain)
  125. {
  126. CWinEvpSheet * pSheet = (CWinEvpSheet *)(pMain->GetPage("CWinEvpSheet"));
  127. if(pSheet)
  128. m_pPageCdb = (CSafeDataCdbPage*)pSheet->GetPage("CSafeDataCdbPage");
  129. }
  130. {
  131. // Create the ToolTip control.
  132. m_toolTip.Create(this);
  133. m_toolTip.AddTool(GetDlgItem(IDC_COMBO_CRYPT), CMiniCaApp::NormalCode("操作使用的加密算法"));
  134. m_toolTip.AddTool(GetDlgItem(IDC_EDIT_PWD), CMiniCaApp::NormalCode("操作使用的密钥"));
  135. m_toolTip.AddTool(GetDlgItem(IDC_EDIT_INFILE), "原始信息");
  136. m_toolTip.AddTool(GetDlgItem(IDC_EDIT_OUTFILE), "操作结果");
  137. m_toolTip.AddTool(GetDlgItem(IDC_BENC), CMiniCaApp::NormalCode("加密信息"));
  138. m_toolTip.AddTool(GetDlgItem(IDC_BDEC), CMiniCaApp::NormalCode("解密信息"));
  139. m_toolTip.AddTool(GetDlgItem(IDC_COMBO_DIGEST), "操作使用的签名算法");
  140. m_toolTip.AddTool(GetDlgItem(IDC_BDIGEST), "对指定消息进行摘要操作");
  141. m_toolTip.AddTool(GetDlgItem(IDC_BSIGN), "对指定消息进行数字签名操作");
  142. m_toolTip.AddTool(GetDlgItem(IDC_BVSIGN), "对指定消息和签名结果进行验证");
  143. m_toolTip.AddTool(GetDlgItem(IDC_BRSACERT), "用公钥对对指定消息进行加密r 密钥长度决定加密时间");
  144. m_toolTip.AddTool(GetDlgItem(IDC_BRSAKEY), "用私钥对对指定消息进行解密r 密钥长度决定解密时间");
  145. m_toolTip.AddTool(GetDlgItem(IDC_BRSAKEY2), "用私钥对对指定消息进行加密r 密钥长度决定加密时间");
  146. m_toolTip.AddTool(GetDlgItem(IDC_BRSACERT2), "用公钥对对指定消息进行解密r 密钥长度决定解密时间");
  147. }
  148. return TRUE;  // return TRUE unless you set the focus to a control
  149. // EXCEPTION: OCX Property Pages should return FALSE
  150. }
  151. void CSafeInfoPage::OnBenc() 
  152. {
  153. // TODO: Add your control notification handler code here
  154. CString strIn;
  155. GetDlgItemText(IDC_EDIT_INFILE,strIn);
  156. UINT len = strIn.GetLength();
  157. if(len == 0)
  158. {
  159. AddMsg(MiniCT_0800,M_ERROR); //MiniCT_0800 "请输入要加密信息"
  160. return;
  161. }
  162. unsigned char outbuf[dMaxMem] = "";
  163. CString cpname,pwd;
  164. char outMsg[uMsgLen] = "";
  165. UINT templen = dMaxMem;
  166. GetDlgItemText(IDC_COMBO_CRYPT,cpname);
  167. GetDlgItemText(IDC_EDIT_PWD,pwd);
  168. if(pwd.IsEmpty())
  169. {
  170. AddMsg(MiniCT_0801,M_ERROR); //MiniCT_0801 "请输入加密密钥"
  171. return;
  172. }
  173. if(!CEvp::Crypt(cpname.GetBuffer(0),strIn.GetBuffer(0),len,(char *)outbuf,templen,
  174. pwd.GetBuffer(0),1,outMsg))
  175. AddMsg(outMsg,M_ERROR);
  176. else
  177. {
  178. CString out = CMiniCaApp::LmToHText(outbuf,templen);
  179. SetDlgItemText(IDC_EDIT_INFILE, out);
  180. // SetDlgItemText(IDC_EDIT_OUTFILE, strIn);
  181. Disply();
  182. AddMsg(MiniCT_0802); //MiniCT_0802 "加密信息成功"
  183. }
  184. }
  185. void CSafeInfoPage::OnBdec() 
  186. {
  187. // TODO: Add your control notification handler code here
  188. CString strIn;
  189. GetDlgItemText(IDC_EDIT_INFILE,strIn);
  190. UINT len = strIn.GetLength();
  191. if(len == 0)
  192. {
  193. AddMsg(MiniCT_0803,M_ERROR); //MiniCT_0803 "请输入要解信息"
  194. return;
  195. }
  196. unsigned char outbuf[dMaxMem] = "";//所有算法最长的块长度。
  197. CString cpname,pwd;
  198. char outMsg[uMsgLen] = "";
  199. UINT templen = dMaxMem;
  200. GetDlgItemText(IDC_COMBO_CRYPT,cpname);
  201. GetDlgItemText(IDC_EDIT_PWD,pwd);
  202. if(pwd.IsEmpty())
  203. {
  204. AddMsg(MiniCT_0804,M_ERROR); //MiniCT_0804 "请输入解密密钥"
  205. return;
  206. }
  207. char strLm[2*dMaxMem] = {0};
  208. UINT uLm = CMiniCaApp::HTextToLm(strIn.GetBuffer(0),strLm);
  209. if(uLm == 0)
  210. return;
  211. if(!CEvp::Crypt(cpname.GetBuffer(0),strLm,uLm,(char *)outbuf,templen,
  212. pwd.GetBuffer(0),0,outMsg))
  213. {
  214. // m_XpEditInfile.SetTextColor(RGB(128,0,0));
  215. //SetDlgItemText(IDC_EDIT_INFILE,(char *)outbuf);
  216. AddMsg(outMsg,M_ERROR);
  217. }
  218. else
  219. {
  220. SetDlgItemText(IDC_EDIT_INFILE,(char *)outbuf);
  221. // SetDlgItemText(IDC_EDIT_OUTFILE, strIn);
  222. Disply();
  223. AddMsg(MiniCT_0805); //MiniCT_0805 "解密信息成功"
  224. }
  225. }
  226. void CSafeInfoPage::OnBdigest() 
  227. {
  228. // TODO: Add your control notification handler code here
  229. CString strIn;
  230. GetDlgItemText(IDC_EDIT_INFILE,strIn);
  231. if(strIn.IsEmpty())
  232. {
  233. AddMsg(MiniCT_0806,M_ERROR);//MiniCT_0806 "请输入要摘要信息"
  234. return;
  235. }
  236. CString mdname;
  237. char outMsg[uMsgLen]="";
  238. unsigned char md_value[MAX_MD_SIZE]="";
  239. char buf[MAX_MD_SIZE*2] = "";
  240. unsigned int md_len;
  241. GetDlgItemText(IDC_COMBO_DIGEST,mdname);
  242. if(!CEvp::Digest(mdname.GetBuffer(0),strIn.GetBuffer(0),strlen(strIn),md_value,
  243. &md_len, outMsg))
  244. {
  245. AddMsg(outMsg,M_ERROR);
  246. }
  247. else
  248. {
  249. SetDlgItemText(IDC_EDIT_OUTFILE,CMiniCaApp::LmToHText(md_value,md_len));
  250. SetDlgItemText(IDC_EDIT_INFILE, strIn);
  251. Disply(TRUE); 
  252. AddMsg(MiniCT_0807); //MiniCT_0807 "信息摘要成功"
  253. }
  254. }
  255. void CSafeInfoPage::OnBsign() 
  256. {
  257. // TODO: Add your control notification handler code here
  258. CString mdname,strIn;
  259. char outMsg[uMsgLen]="";
  260. char strOut[dMaxMem] = {0};
  261. GetDlgItemText(IDC_COMBO_DIGEST,mdname);
  262. GetDlgItemText(IDC_EDIT_INFILE,strIn);
  263. if(strIn.IsEmpty())
  264. {
  265. AddMsg(MiniCT_0808,M_ERROR); //MiniCT_0808 "请输入要签名信息"
  266. return;
  267. }
  268. UINT outlen=0;
  269. if(m_pPageCdb->GetCertPair(CSafeDataCdbPage::SIGN, FALSE, m_strKey,m_lenKey,m_p12Pwd))//得到私钥
  270. {
  271. if(!CEvp::Sign(m_strKey,m_lenKey,m_p12Pwd.GetBuffer(0),mdname.GetBuffer(0),
  272. strIn.GetBuffer(0),strlen(strIn),
  273. strOut,outlen,outMsg))
  274. {
  275. AddMsg(outMsg,M_ERROR);
  276. }
  277. else
  278. {
  279. SetDlgItemText(IDC_EDIT_OUTFILE,CMiniCaApp::LmToHText((UCHAR *)strOut,outlen));
  280. SetDlgItemText(IDC_EDIT_INFILE, strIn);
  281. Disply(TRUE);
  282. AddMsg(MiniCT_0809); //MiniCT_0809 "信息签名成功"
  283. }
  284. }
  285. else
  286. AddMsg(MiniCT_0810,M_ERROR); //MiniCT_0810
  287. }
  288. void CSafeInfoPage::OnBvsign() 
  289. {
  290. // TODO: Add your control notification handler code here
  291. CString mdname,filein,fileout;
  292. char outMsg[uMsgLen]="";
  293. GetDlgItemText(IDC_COMBO_DIGEST,mdname);
  294. GetDlgItemText(IDC_EDIT_INFILE,filein);
  295. GetDlgItemText(IDC_EDIT_OUTFILE,fileout);
  296. if(filein.IsEmpty())
  297. {
  298. AddMsg(MiniCT_0811,M_ERROR); //MiniCT_0811
  299. return;
  300. }
  301. if(m_pPageCdb->GetCertPair(CSafeDataCdbPage::SIGN, TRUE, m_strKey,m_lenKey,m_p12Pwd))//得到公钥
  302. {
  303. char strLm[dMaxMem] = {0};
  304. UINT uLm = CMiniCaApp::HTextToLm(fileout.GetBuffer(0),strLm);
  305. if(!CEvp::VerifySign(m_strKey,m_lenKey,m_p12Pwd.GetBuffer(0),
  306. mdname.GetBuffer(0),filein.GetBuffer(0),strlen(filein),
  307. strLm,outMsg))
  308. {
  309. AddMsg(outMsg,M_ERROR);
  310. }
  311. else
  312. {
  313. AddMsg(MiniCT_0812);//MiniCT_0812
  314. Disply(TRUE);
  315. // SetDlgItemText(IDC_EDIT_OUTFILE, fileout);
  316. // SetDlgItemText(IDC_EDIT_INFILE, filein);
  317. }
  318. }
  319. else
  320. AddMsg(MiniCT_0810,M_ERROR); //MiniCT_0810 "取得密钥失败"
  321. }
  322. void CSafeInfoPage::OnBrsacert() 
  323. {
  324. // TODO: Add your control notification handler code here
  325. CString cert,filein,fileout;
  326. char outMsg[uMsgLen]="";
  327. char strOut[dMaxMem] ={0};
  328. GetDlgItemText(IDC_EDIT_INFILE,filein);
  329. if(filein.IsEmpty())
  330. {
  331. AddMsg(MiniCT_0800,M_ERROR); //MiniCT_0800 "请输入要加密信息"
  332. return;
  333. }
  334. DWORD len = dMaxMem;
  335. if(m_pPageCdb->GetCertPair(CSafeDataCdbPage::PubEnc, TRUE, m_strKey,m_lenKey,m_p12Pwd))//得到公钥
  336. {
  337. if(!CEvp::RSAPubEnc((BYTE *)m_strKey,m_lenKey,m_p12Pwd.GetBuffer(0),
  338. (BYTE *)filein.GetBuffer(0),strlen(filein),(BYTE *)strOut,len,outMsg))
  339. {
  340. AddMsg(outMsg,M_ERROR);
  341. }
  342. else
  343. {
  344. AddMsg(MiniCT_0813); //MiniCT_0813 "公钥加密信息成功"
  345. // m_XpEditInfile.SetTextColor(RGB(0,0,0));
  346. SetDlgItemText(IDC_EDIT_INFILE, CMiniCaApp::LmToHText((UCHAR *)strOut,len));
  347. Disply();
  348. }
  349. }
  350. else
  351. AddMsg(MiniCT_0810,M_ERROR);
  352. }
  353. void CSafeInfoPage::OnBrsakey() 
  354. {
  355. // TODO: Add your control notification handler code here
  356. CString key,filein,fileout;
  357. char outMsg[uMsgLen]="";
  358. char strOut[dMaxMem] = {0};
  359. GetDlgItemText(IDC_EDIT_INFILE,filein);
  360. DWORD len = dMaxMem;
  361. if(filein.IsEmpty())
  362. {
  363. AddMsg(MiniCT_0814,M_ERROR);
  364. return;
  365. }
  366. if(m_pPageCdb->GetCertPair(CSafeDataCdbPage::PrivEnc, FALSE, m_strKey,m_lenKey,m_p12Pwd))//得到私钥
  367. {
  368. char strLm[dMaxMem] = {0};
  369. UINT uLm = CMiniCaApp::HTextToLm(filein.GetBuffer(0),strLm);
  370. if(!CEvp::RSAPrivDec((BYTE *)m_strKey,m_lenKey,m_p12Pwd.GetBuffer(0),(BYTE *)strLm, 
  371. uLm, (BYTE *)strOut,len ,outMsg))
  372. {
  373. // m_XpEditInfile.SetTextColor(RGB(128,0,0));
  374. AddMsg(outMsg,M_ERROR);
  375. }
  376. else
  377. {
  378. // m_XpEditInfile.SetTextColor(RGB(0,128,0));
  379. SetDlgItemText(IDC_EDIT_INFILE,(char *)strOut);
  380. Disply();
  381. AddMsg(MiniCT_0815);
  382. }
  383. }
  384. else
  385. AddMsg(MiniCT_0810,M_ERROR);
  386. }
  387. void CSafeInfoPage::OnBrsakey2() 
  388. {
  389. // TODO: Add your control notification handler code here
  390. CString key,filein,fileout;
  391. char outMsg[uMsgLen]="";
  392. GetDlgItemText(IDC_EDIT_INFILE,filein);
  393. if(filein.IsEmpty())
  394. {
  395. AddMsg(MiniCT_0800,M_ERROR);
  396. return;
  397. }
  398. if(m_pPageCdb->GetCertPair(CSafeDataCdbPage::PrivEnc, FALSE, m_strKey,m_lenKey,m_p12Pwd))//得到私钥
  399. {
  400. char strLm[dMaxMem] = {0};
  401. DWORD len = dMaxMem;
  402. if(!CEvp::RSAPrivEnc((BYTE *)m_strKey,m_lenKey,m_p12Pwd.GetBuffer(0),(BYTE *)filein.GetBuffer(0), 
  403. filein.GetLength(),(BYTE *)strLm,len,outMsg))
  404. {
  405. AddMsg(outMsg,M_ERROR);
  406. }
  407. else
  408. {
  409. // m_XpEditInfile.SetTextColor(RGB(0,0,0));
  410. SetDlgItemText(IDC_EDIT_INFILE, CMiniCaApp::LmToHText((UCHAR *)strLm,len));
  411. Disply();
  412. AddMsg(MiniCT_0816);
  413. }
  414. }
  415. else
  416. AddMsg(MiniCT_0810,M_ERROR);
  417. }
  418. void CSafeInfoPage::OnBrsacert2() 
  419. {
  420. // TODO: Add your control notification handler code here
  421. CString key,filein,fileout;
  422. char outMsg[uMsgLen]="";
  423. char strOut[dMaxMem] = {0};
  424. GetDlgItemText(IDC_EDIT_INFILE,filein);
  425. DWORD len = dMaxMem;
  426. if(filein.IsEmpty())
  427. {
  428. AddMsg(MiniCT_0814,M_ERROR);
  429. return;
  430. }
  431. if(m_pPageCdb->GetCertPair(CSafeDataCdbPage::PubEnc, TRUE, m_strKey,m_lenKey,m_p12Pwd))//得到公钥
  432. {
  433. char strLm[dMaxMem] = {0};
  434. DWORD uLm = CMiniCaApp::HTextToLm(filein.GetBuffer(0),strLm);
  435. if(!CEvp::RSAPubDec((BYTE *)m_strKey,m_lenKey,m_p12Pwd.GetBuffer(0),(BYTE *)strLm, 
  436. uLm,(BYTE *)strOut,len,outMsg))
  437. {
  438. // m_XpEditInfile.SetTextColor(RGB(128,0,0));
  439. AddMsg(outMsg,M_ERROR);
  440. }
  441. else
  442. {
  443. // m_XpEditInfile.SetTextColor(RGB(0,128,0));
  444. SetDlgItemText(IDC_EDIT_INFILE,(char *)strOut);
  445. Disply();
  446. AddMsg(MiniCT_0817);
  447. }
  448. }
  449. else
  450. AddMsg(MiniCT_0810,M_ERROR);
  451. }
  452. void CSafeInfoPage::Disply(BOOL bDisply)
  453. {
  454. CWnd * pInWnd = GetDlgItem(IDC_EDIT_INFILE);
  455. CWnd * pOutWnd = GetDlgItem(IDC_EDIT_OUTFILE);
  456. CRect Rect;
  457. if(bDisply)
  458. {
  459. GetDlgItem(IDC_STATIC_SHORT)->GetWindowRect(Rect);
  460. pOutWnd->ShowWindow(SW_SHOW);
  461. }
  462. else
  463. {
  464. GetDlgItem(IDC_STATIC_LONG)->GetWindowRect(Rect);
  465. pOutWnd->ShowWindow(SW_HIDE);
  466. }
  467. pInWnd->SetWindowPos(NULL, 0, 0, Rect.Width(), Rect.Height(),
  468. SWP_NOMOVE|SWP_NOZORDER | SWP_NOACTIVATE|SWP_SHOWWINDOW);
  469. }
  470. void CSafeInfoPage::TranslateCT()
  471. {
  472. SetDlgItemText(IDC_STATIC_EVP5 ,MiniCT_11601);
  473. SetDlgItemText(IDC_STATIC_EVP6 ,MiniCT_11602);
  474. SetDlgItemText(IDC_STATIC_EVP7 ,MiniCT_11603);
  475. SetDlgItemText(IDC_STATIC_EVP8 ,MiniCT_11604);
  476. SetDlgItemText(IDC_STATIC_EVP9 ,MiniCT_11605);
  477. SetDlgItemText(IDC_BENC ,MiniCT_11606);
  478. SetDlgItemText(IDC_BDEC ,MiniCT_11607);
  479. SetDlgItemText(IDC_BDIGEST ,MiniCT_11608);
  480. SetDlgItemText(IDC_BSIGN ,MiniCT_11609);
  481. SetDlgItemText(IDC_BVSIGN ,MiniCT_11610);
  482. SetDlgItemText(IDC_BRSACERT ,MiniCT_11611);
  483. SetDlgItemText(IDC_BRSAKEY ,MiniCT_11612);
  484. SetDlgItemText(IDC_BRSAKEY2 ,MiniCT_11613);
  485. SetDlgItemText(IDC_BRSACERT2 ,MiniCT_11614);
  486. }
  487. BOOL CSafeInfoPage::PreTranslateMessage(MSG* pMsg) 
  488. {
  489. // TODO: Add your specialized code here and/or call the base class
  490. {
  491. // Let the ToolTip process this message.
  492. m_toolTip.RelayEvent(pMsg);
  493. }
  494. return CPropertyPage::PreTranslateMessage(pMsg);
  495. }