/[openpgpmdrv]/trunk/OpenPGPminidriverTest/PINOperations.cpp
ViewVC logotype

Contents of /trunk/OpenPGPminidriverTest/PINOperations.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Tue Feb 23 19:18:59 2010 UTC (15 years, 2 months ago) by vletoux
File size: 2013 byte(s)


1 /* OpenPGP Smart Card Mini Driver
2 Copyright (C) 2009 Vincent Le Toux
3
4 This library is Free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License version 2.1 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Lesser General Public License for more details.
12
13 You should have received a copy of the GNU Lesser General Public
14 License along with this library; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18 #include <windows.h>
19 #include <tchar.h>
20 #include <cardmod.h>
21 #include "global.h"
22
23 DWORD Authenticate(PWSTR wszPin, PWSTR wszUserId, PDWORD pcAttemptsRemaining)
24 {
25 LPSTR szPin = NULL;
26 DWORD cbPin = 0;
27 DWORD dwReturn;
28 __try
29 {
30 if (!pCardData)
31 {
32 dwReturn = SCARD_E_COMM_DATA_LOST;
33 __leave;
34 }
35 //
36 // Convert the PIN to ANSI
37 //
38 if (0 == (cbPin = WideCharToMultiByte(CP_ACP,0,wszPin,-1,NULL,0,NULL,NULL)))
39 {
40 dwReturn = GetLastError();
41 __leave;
42 }
43
44 szPin = (LPSTR) LocalAlloc(0,cbPin);
45 if (szPin == NULL)
46 {
47 dwReturn = GetLastError();
48 __leave;
49 }
50
51 if (0 == (cbPin = WideCharToMultiByte(CP_ACP,0,wszPin,-1,szPin,cbPin,NULL,NULL)))
52 {
53 dwReturn = GetLastError();
54 __leave;
55 }
56
57 //
58 // Call the card module
59 //
60
61 dwReturn = pCardData->pfnCardAuthenticatePin(
62 pCardData,
63 wszUserId,
64 (PBYTE) szPin,
65 cbPin - 1,
66 pcAttemptsRemaining);
67 }
68 __finally
69 {
70 if (NULL != szPin)
71 LocalFree(szPin);
72 }
73
74 return dwReturn;
75 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26