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

Contents of /trunk/OpenPGPminidriverTest/PINOperations.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (show annotations)
Thu Mar 18 16:03:39 2010 UTC (15 years, 1 month ago) by vletoux
File size: 3397 byte(s)
first working & stable version
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(PSTR szPin, PWSTR wszUserId, PDWORD pcAttemptsRemaining)
24 {
25 DWORD cbPin = (DWORD) strlen(szPin);
26 DWORD dwReturn;
27 __try
28 {
29 if (!pCardData)
30 {
31 dwReturn = SCARD_E_COMM_DATA_LOST;
32 __leave;
33 }
34
35 dwReturn = pCardData->pfnCardAuthenticatePin(
36 pCardData,
37 wszUserId,
38 (PBYTE) szPin,
39 cbPin,
40 pcAttemptsRemaining);
41 }
42 __finally
43 {
44 }
45
46 return dwReturn;
47 }
48
49 DWORD ChangePin(PSTR szPin, PSTR szPin2, PWSTR wszUserId, PDWORD pcAttemptsRemaining)
50 {
51 DWORD cbPin = (DWORD) strlen(szPin);
52 DWORD cbPin2 = (DWORD) strlen(szPin2);
53 DWORD dwReturn;
54 __try
55 {
56 if (!pCardData)
57 {
58 dwReturn = SCARD_E_COMM_DATA_LOST;
59 __leave;
60 }
61
62 dwReturn = pCardData->pfnCardChangeAuthenticator(
63 pCardData,
64 wszUserId,
65 (PBYTE) szPin,
66 cbPin,
67 (PBYTE) szPin2,
68 cbPin2,
69 0,CARD_AUTHENTICATE_PIN_PIN,
70 pcAttemptsRemaining);
71 }
72 __finally
73 {
74 }
75
76 return dwReturn;
77 }
78
79 DWORD SetPuk(PSTR szPin, PSTR szPin2, PDWORD pcAttemptsRemaining)
80 {
81 DWORD cbPin = (DWORD) strlen(szPin);
82 DWORD cbPin2 = (DWORD) strlen(szPin2);
83 DWORD dwReturn;
84 __try
85 {
86 if (!pCardData)
87 {
88 dwReturn = SCARD_E_COMM_DATA_LOST;
89 __leave;
90 }
91
92 dwReturn = pCardData->pfnCardChangeAuthenticatorEx(
93 pCardData,
94 PIN_CHANGE_FLAG_CHANGEPIN, ROLE_ADMIN,
95 (PBYTE) szPin,
96 cbPin,
97 4,
98 (PBYTE) szPin2,
99 cbPin2,
100 0,
101 pcAttemptsRemaining);
102 }
103 __finally
104 {
105 }
106
107 return dwReturn;
108 }
109
110 DWORD ResetPin(PSTR szPin, PSTR szPin2, BOOL fIsPUK, PDWORD pcAttemptsRemaining)
111 {
112 DWORD cbPin = (DWORD) strlen(szPin);
113 DWORD cbPin2 = (DWORD) strlen(szPin2);
114 DWORD dwReturn;
115 __try
116 {
117 if (!pCardData)
118 {
119 dwReturn = SCARD_E_COMM_DATA_LOST;
120 __leave;
121 }
122 if (fIsPUK)
123 {
124 dwReturn = pCardData->pfnCardChangeAuthenticatorEx(
125 pCardData,
126 PIN_CHANGE_FLAG_UNBLOCK, 5,
127 (PBYTE) szPin,cbPin,
128 ROLE_USER, (PBYTE)szPin2, cbPin2, 0,
129 pcAttemptsRemaining);
130 }
131 else
132 {
133 dwReturn = pCardData->pfnCardChangeAuthenticatorEx(
134 pCardData,
135 PIN_CHANGE_FLAG_UNBLOCK, ROLE_ADMIN,
136 (PBYTE) szPin,cbPin,
137 ROLE_USER, (PBYTE)szPin2, cbPin2, 0,
138 pcAttemptsRemaining);
139 }
140 }
141 __finally
142 {
143 }
144
145 return dwReturn;
146 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26