1 /*=============================================================================
\r
5 ===============================================================================
\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.
\r
8 / Redistribution and use in source and binary forms, with or without
\r
9 / modification, are permitted provided that the following conditions
\r
12 / 1. Redistributions of source code must retain the above copyright
\r
13 / notice, this list of conditions and the following disclaimer.
\r
14 / 2. Redistributions in binary form must reproduce the above copyright
\r
15 / notice, this list of conditions and the following disclaimer in the
\r
16 / documentation and/or other materials provided with the distribution.
\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
\r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
\r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
\r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
\r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
\r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
\r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
\r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
28 /============================================================================*/
\r
31 #include <windows.h>
\r
35 #include <commctrl.h>
\r
36 #include <windowsx.h>
\r
39 #include "resource.h"
\r
41 #include <htmlhelp.h>
\r
45 #undef __MBSWRAPPER_H__
\r
46 #include "mbswrapper.h"
\r
49 /*=====
\83v
\83\8d\83g
\83^
\83C
\83v =====*/
\r
51 static BOOL CALLBACK OtpCalcWinProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
\r
54 /*=====
\8aO
\95\94\8eQ
\8fÆ =====*/
\r
56 extern HWND hHelpWin;
\r
59 /*-----
\83\8f\83\93\83^
\83C
\83\80\83p
\83X
\83\8f\81[
\83h
\8cv
\8eZ ----------------------------------------------
\r
66 *----------------------------------------------------------------------------*/
\r
68 void OtpCalcTool(void)
\r
70 DialogBox(GetFtpInst(), MAKEINTRESOURCE(otp_calc_dlg), GetMainHwnd(), OtpCalcWinProc);
\r
75 /*-----
\83\8f\83\93\83^
\83C
\83\80\83p
\83X
\83\8f\81[
\83h
\8cv
\8eZ
\83E
\83C
\83\93\83h
\83E
\82Ì
\83R
\81[
\83\8b\83o
\83b
\83N ----------------------
\r
78 * HWND hDlg :
\83E
\83C
\83\93\83h
\83E
\83n
\83\93\83h
\83\8b\r
79 * UINT message :
\83\81\83b
\83Z
\81[
\83W
\94Ô
\8d\86\r
80 * WPARAM wParam :
\83\81\83b
\83Z
\81[
\83W
\82Ì WPARAM
\88ø
\90\94\r
81 * LPARAM lParam :
\83\81\83b
\83Z
\81[
\83W
\82Ì LPARAM
\88ø
\90\94\r
85 *----------------------------------------------------------------------------*/
\r
87 static BOOL CALLBACK OtpCalcWinProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
\r
93 char Seed[MAX_SEED_LEN+1];
\r
94 char Pass[PASSWORD_LEN+1];
\r
96 static const RADIOBUTTON AlgoButton[] = {
\r
97 { OTPCALC_MD4, MD4 },
\r
98 { OTPCALC_MD5, MD5 },
\r
99 { OTPCALC_SHA1, SHA1 }
\r
101 #define ALGOBUTTONS (sizeof(AlgoButton)/sizeof(RADIOBUTTON))
\r
105 case WM_INITDIALOG :
\r
106 SendDlgItemMessage(hDlg, OTPCALC_KEY, EM_LIMITTEXT, 40, 0);
\r
107 SendDlgItemMessage(hDlg, OTPCALC_PASS, EM_LIMITTEXT, PASSWORD_LEN, 0);
\r
108 SetRadioButtonByValue(hDlg, MD4, AlgoButton, ALGOBUTTONS);
\r
112 switch(GET_WM_COMMAND_ID(wParam, lParam))
\r
115 SendDlgItemMessage(hDlg, OTPCALC_KEY, WM_GETTEXT, 41, (LPARAM)Tmp);
\r
116 SendDlgItemMessage(hDlg, OTPCALC_PASS, WM_GETTEXT, PASSWORD_LEN+1, (LPARAM)Pass);
\r
117 Type = AskRadioButtonValue(hDlg, AlgoButton, ALGOBUTTONS);
\r
127 if((Pos = GetNextField(Pos)) != NULL)
\r
129 if(GetOneField(Pos, Seed, MAX_SEED_LEN) == SUCCESS)
\r
131 Make6WordPass(Seq, Seed, Pass, Type, Tmp);
\r
134 strcpy(Tmp, MSGJPN251);
\r
137 strcpy(Tmp, MSGJPN252);
\r
140 strcpy(Tmp, MSGJPN253);
\r
142 SendDlgItemMessage(hDlg, OTPCALC_RES, WM_SETTEXT, 0, (LPARAM)Tmp);
\r
146 EndDialog(hDlg, NO);
\r
150 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000037);
\r