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

Annotation of /trunk/OpenPGPminidriverTest/PINOperations.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations)
Thu Mar 11 20:32:26 2010 UTC (15 years, 1 month ago) by vletoux
File size: 2743 byte(s)
improvement of the quality of the project.
More test for the qualification of the driver success but not all ...

1 vletoux 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 vletoux 8 DWORD Authenticate(PSTR szPin, PWSTR wszUserId, PDWORD pcAttemptsRemaining)
24 vletoux 1 {
25 vletoux 8 DWORD cbPin = strlen(szPin);
26 vletoux 1 DWORD dwReturn;
27     __try
28     {
29     if (!pCardData)
30     {
31     dwReturn = SCARD_E_COMM_DATA_LOST;
32     __leave;
33     }
34    
35 vletoux 8 dwReturn = pCardData->pfnCardAuthenticatePin(
36     pCardData,
37     wszUserId,
38     (PBYTE) szPin,
39     cbPin - 1,
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     WORD cbPin = strlen(szPin);
52     DWORD cbPin2 = strlen(szPin2);
53     DWORD dwReturn;
54     __try
55     {
56     if (!pCardData)
57 vletoux 1 {
58 vletoux 8 dwReturn = SCARD_E_COMM_DATA_LOST;
59     __leave;
60 vletoux 1 }
61    
62 vletoux 8 dwReturn = pCardData->pfnCardChangeAuthenticator(
63 vletoux 1 pCardData,
64     wszUserId,
65     (PBYTE) szPin,
66 vletoux 8 cbPin,
67     (PBYTE) szPin2,
68     cbPin2,
69     0,CARD_AUTHENTICATE_PIN_PIN,
70 vletoux 1 pcAttemptsRemaining);
71     }
72     __finally
73     {
74     }
75    
76     return dwReturn;
77 vletoux 8 }
78     DWORD ResetPin(PSTR szPin, PSTR szPin2, BOOL fIsPUK, PDWORD pcAttemptsRemaining)
79     {
80     DWORD cbPin = strlen(szPin);
81     DWORD cbPin2 = strlen(szPin2);
82     DWORD dwReturn;
83     __try
84     {
85     if (!pCardData)
86     {
87     dwReturn = SCARD_E_COMM_DATA_LOST;
88     __leave;
89     }
90     if (fIsPUK)
91     {
92     dwReturn = pCardData->pfnCardChangeAuthenticatorEx(
93     pCardData,
94     PIN_CHANGE_FLAG_UNBLOCK, 5,
95     (PBYTE) szPin,cbPin,
96     ROLE_USER, (PBYTE)szPin2, cbPin2, 0,
97     pcAttemptsRemaining);
98     }
99     else
100     {
101     dwReturn = pCardData->pfnCardChangeAuthenticatorEx(
102     pCardData,
103     PIN_CHANGE_FLAG_UNBLOCK, ROLE_ADMIN,
104     (PBYTE) szPin,cbPin,
105     ROLE_USER, (PBYTE)szPin2, cbPin2, 0,
106     pcAttemptsRemaining);
107     }
108     }
109     __finally
110     {
111     }
112    
113     return dwReturn;
114 vletoux 1 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26