/[openpgpmdrv]/trunk/OpenPGPminidriver/CardInitializationAndDeconstruct.c
ViewVC logotype

Annotation of /trunk/OpenPGPminidriver/CardInitializationAndDeconstruct.c

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 MIME type: text/plain
File size: 5622 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 <cardmod.h>
20     #include "Tracing.h"
21     #include "Context.h"
22     #include "SmartCard.h"
23    
24     // 4.1 Initialization and Deconstruct
25    
26    
27    
28     /** The CardAcquireContext function, defined by a smart card module,
29     initializes communication between the smart card module and either the
30     Microsoft Base Smart Card Cryptographic Service Provider (CSP) or smart
31     card key storage provider (KSP).
32     */
33     DWORD WINAPI CardAcquireContext(
34     __in PCARD_DATA pCardData,
35     __in DWORD dwFlags
36     )
37     {
38     DWORD dwReturn = 0;
39     __try
40     {
41     Trace(WINEVENT_LEVEL_VERBOSE, L"Enter");
42     if ( pCardData == NULL )
43     {
44     Trace(WINEVENT_LEVEL_ERROR, L"pCardData == NULL");
45     dwReturn = SCARD_E_INVALID_PARAMETER;
46     __leave;
47     }
48    
49     if ( dwFlags != 0 )
50     {
51     Trace(WINEVENT_LEVEL_ERROR, L"dwFlags != 0");
52     dwReturn = SCARD_E_INVALID_PARAMETER;
53     __leave;
54     }
55 vletoux 8 dwReturn = CreateContext(pCardData, dwFlags);
56 vletoux 1 if (dwReturn)
57     {
58     __leave;
59     }
60    
61    
62     /* CardInitializationAndDeconstruct.c */
63     pCardData->pfnCardDeleteContext = CardDeleteContext;
64    
65     /* CardPinOperation.c */
66     pCardData->pfnCardAuthenticatePin = CardAuthenticatePin;
67     pCardData->pfnCardGetChallenge = CardGetChallenge;
68     pCardData->pfnCardAuthenticateChallenge = CardAuthenticateChallenge;
69 vletoux 8
70 vletoux 1 pCardData->pfnCardDeauthenticate = CardDeauthenticate;
71     pCardData->pfnCardAuthenticateEx = CardAuthenticateEx;
72     pCardData->pfnCardGetChallengeEx = CardGetChallengeEx;
73     pCardData->pfnCardDeauthenticateEx = CardDeauthenticateEx;
74     pCardData->pfnCardChangeAuthenticatorEx = CardChangeAuthenticatorEx;
75     pCardData->pfnCardUnblockPin = CardUnblockPin;
76     pCardData->pfnCardChangeAuthenticator = CardChangeAuthenticator;
77    
78     /* CardPublicDataOperation.c */
79     pCardData->pfnCardCreateDirectory = CardCreateDirectory;
80     pCardData->pfnCardDeleteDirectory = CardDeleteDirectory;
81     pCardData->pfnCardReadFile = CardReadFile;
82     pCardData->pfnCardCreateFile = CardCreateFile;
83     pCardData->pfnCardGetFileInfo = CardGetFileInfo;
84     pCardData->pfnCardWriteFile = CardWriteFile;
85     pCardData->pfnCardDeleteFile = CardDeleteFile;
86     pCardData->pfnCardEnumFiles = CardEnumFiles;
87     pCardData->pfnCardQueryFreeSpace = CardQueryFreeSpace;
88    
89     /* CardCapabilities.c */
90     pCardData->pfnCardQueryCapabilities = CardQueryCapabilities;
91    
92     /* CardAndContainerProperties.c */
93     pCardData->pfnCardGetContainerProperty = CardGetContainerProperty;
94     pCardData->pfnCardSetContainerProperty = CardSetContainerProperty;
95     pCardData->pfnCardGetProperty = CardGetProperty;
96     pCardData->pfnCardSetProperty = CardSetProperty;
97    
98     /* CardKeyContainer.c */
99     pCardData->pfnCardCreateContainer = CardCreateContainer;
100     pCardData->pfnCardCreateContainerEx = CardCreateContainerEx;
101     pCardData->pfnCardDeleteContainer = CardDeleteContainer;
102     pCardData->pfnCardGetContainerInfo = CardGetContainerInfo;
103    
104     /* CardCryptographicOperations.c */
105     pCardData->pfnCardRSADecrypt = CardRSADecrypt;
106     pCardData->pfnCardSignData = CardSignData;
107    
108     // should be null for RSA only card
109     pCardData->pfnCardConstructDHAgreement = NULL; //CardConstructDHAgreement;
110     pCardData->pfnCardDeriveKey = NULL; //CardDeriveKey;
111     pCardData->pfnCardDestroyDHAgreement = NULL; //CardDestroyDHAgreement;
112    
113     pCardData->pfnCardSignData = CardSignData;
114     pCardData->pfnCardQueryKeySizes = CardQueryKeySizes;
115    
116     /* Not found :
117     The pfnCardDeriveKey, pfnCardDestroyDHAgreement, and pfnCspGetDHAgreement
118     members of the CARD_DATA structure are described in later sections.
119     Starting with Version 5 of this specification, the necessary modifications
120     to the pfnCardConstructDHAgreement function are handled through versioning
121     the structure that is associated with that function.
122     => what's the prototype for this function ?
123     */
124    
125     pCardData->pfnCspGetDHAgreement = NULL;
126     }
127     __finally
128     {
129     if (dwReturn)
130     {
131     CleanContext(pCardData);
132     }
133     }
134     Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
135     return dwReturn;
136     }
137    
138     /** The CardDeleteContext function reverses the effect of CardAcquireContext
139     and severs the communication between the Base CSP/KSP and the card minidriver.
140     This function also performs any needed deallocations and cleanup.
141     */
142    
143     DWORD WINAPI CardDeleteContext(
144     __inout PCARD_DATA pCardData
145     )
146     {
147 vletoux 8 DWORD dwReturn;
148 vletoux 1 Trace(WINEVENT_LEVEL_VERBOSE, L"Enter");
149 vletoux 8 dwReturn = CleanContext(pCardData);
150     Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
151     return dwReturn;
152 vletoux 1 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26