[Openpgpmdrv-commits] r5 - in trunk: OpenPGPminidriver OpenPGPminidriverTest

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Mar 2 19:54:35 CET 2010


Author: vletoux
Date: 2010-03-02 19:54:34 +0100 (Tue, 02 Mar 2010)
New Revision: 5

Modified:
   trunk/OpenPGPminidriver/CardCryptographicOperations.c
   trunk/OpenPGPminidriver/CryptoOperations.c
   trunk/OpenPGPminidriver/CryptoOperations.h
   trunk/OpenPGPminidriverTest/CryptoOperations.cpp
   trunk/OpenPGPminidriverTest/Dialog.h
   trunk/OpenPGPminidriverTest/Dialog.rc
   trunk/OpenPGPminidriverTest/global.h
   trunk/OpenPGPminidriverTest/main.cpp
Log:
authentication working

Modified: trunk/OpenPGPminidriver/CardCryptographicOperations.c
===================================================================
--- trunk/OpenPGPminidriver/CardCryptographicOperations.c	2010-02-28 09:39:34 UTC (rev 4)
+++ trunk/OpenPGPminidriver/CardCryptographicOperations.c	2010-03-02 18:54:34 UTC (rev 5)
@@ -130,7 +130,19 @@
 		{
 			__leave;
 		}
-		dwReturn = SCardSign(pCardData, pInfo);
+		switch(pInfo->bContainerIndex)
+		{
+		case Authentication:
+			dwReturn = SCardAuthenticate(pCardData, pInfo);
+			break;
+		case Signature:
+			dwReturn = SCardSign(pCardData, pInfo);
+			break;
+		default:
+			dwReturn = SCARD_E_NO_KEY_CONTAINER;
+			Trace(WINEVENT_LEVEL_ERROR, L"SCARD_E_NO_KEY_CONTAINER %d", pInfo->bContainerIndex);
+			__leave;
+		}
 	}
 	__finally
 	{

Modified: trunk/OpenPGPminidriver/CryptoOperations.c
===================================================================
--- trunk/OpenPGPminidriver/CryptoOperations.c	2010-02-28 09:39:34 UTC (rev 4)
+++ trunk/OpenPGPminidriver/CryptoOperations.c	2010-03-02 18:54:34 UTC (rev 5)
@@ -188,6 +188,7 @@
 		if (pbData)
 			pCardData->pfnCspFree(pbData);
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 }
 
@@ -234,6 +235,7 @@
 	__finally
 	{
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 }
 
@@ -372,7 +374,6 @@
 		{
 			(*ppbTlv)[dwOffset+dwI] = pbPublicKeyData[(3*bitlen)/16 - 1 - dwI];
 		}
-		TraceDump(WINEVENT_LEVEL_VERBOSE, *ppbTlv + dwOffset, bitlen / 16);
 		dwOffset += bitlen / 16;
 		
 		// prime2
@@ -381,7 +382,6 @@
 			(*ppbTlv)[dwOffset+dwI] = pbPublicKeyData[(4*bitlen)/16 - 1 - dwI];
 		}
 		//memcpy(*ppbTlv + dwOffset, pbPublicKeyData + (3*bitlen)/16, bitlen / 16);
-		TraceDump(WINEVENT_LEVEL_VERBOSE, *ppbTlv + dwOffset, bitlen / 16);
 		dwOffset += bitlen / 16;
 		if (bFormat & 2)
 		{
@@ -416,11 +416,11 @@
 				(*ppbTlv)[dwOffset+dwI] = pbPublicKeyData[bitlen / 8 - 1 - dwI];
 			}
 		}
-		TraceDump(WINEVENT_LEVEL_VERBOSE, pbPublicKeyData, bitlen / 8);
 	}
 	__finally
 	{
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 }
 
@@ -461,6 +461,7 @@
 	__finally
 	{
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 }
 
@@ -567,6 +568,7 @@
 			CryptReleaseContext(hProv,0);
 
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 
 }
@@ -621,7 +623,6 @@
 		{
 			__leave;
 		}
-		//TraceDump(WINEVENT_LEVEL_INFO, pbData,dwSize);
 		if (!find_tlv(pbData,0x81,&pbModulus,&dwModulusSize))
 		{
 			dwReturn = SCARD_E_UNEXPECTED;
@@ -659,12 +660,12 @@
 			pbBlob->modulus[dwI] = pbModulus[dwModulusSize - 1 - dwI];
 		}
 		
-		//TraceDump(WINEVENT_LEVEL_VERBOSE, pbModulus, dwModulusSize);
 		dwReturn = 0;
 	}
 	__finally
 	{
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 }
 
@@ -766,6 +767,7 @@
 		if (pbData)
 			pCardData->pfnCspFree(pbData);
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 }
 
@@ -830,7 +832,6 @@
 		{
 			__leave;
 		}
-		//TraceDump(WINEVENT_LEVEL_VERBOSE, pbTlv, dwTlvSize);
 		if (dwTlvSize > 0xFF)
 		{
 			dwCommandSize = 7 + dwTlvSize;
@@ -890,6 +891,7 @@
 			pCardData->pfnCspFree(pbTlv);
 		}
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 }
 
@@ -910,14 +912,118 @@
 	__try
 	{
 		Trace(WINEVENT_LEVEL_VERBOSE, L"Enter dwContainer=%d",pInfo->bContainerIndex);
-		if (pInfo->bContainerIndex >= MaxContainer)
+		if (pInfo->bContainerIndex != Signature)
 		{
 			dwReturn = SCARD_E_NO_KEY_CONTAINER;
 			Trace(WINEVENT_LEVEL_ERROR, L"SCARD_E_NO_KEY_CONTAINER %d", pInfo->bContainerIndex);
 			__leave;
 		}
-		if (pInfo->bContainerIndex != Signature)
+		if (CARD_PADDING_PKCS1 & pInfo->dwPaddingType)
 		{
+			dwReturn = SCARD_E_UNSUPPORTED_FEATURE;
+			Trace(WINEVENT_LEVEL_ERROR, L"CARD_PADDING_PKCS1");
+			__leave;
+		}
+		else if (CARD_PADDING_PSS & pInfo->dwPaddingType)
+		{
+			dwReturn = SCARD_E_UNSUPPORTED_FEATURE;
+			Trace(WINEVENT_LEVEL_ERROR, L"CARD_PADDING_PSS");
+			__leave;
+		}
+		for(dwI = 0 ; dwI < dwSignatureAlgorithmCount ; dwI++)
+		{
+			if (SignatureAlgorithm[dwI].aiHashAlg == pInfo->aiHashAlg)
+			{
+				// found
+				break;
+			}
+		}
+		if (dwI >= dwSignatureAlgorithmCount)
+		{
+			Trace(WINEVENT_LEVEL_ERROR, L"alg not found %d", pInfo->aiHashAlg);
+			__leave;
+		}
+		if (SignatureAlgorithm[dwI].dwHashSize != pInfo->cbData)
+		{
+			Trace(WINEVENT_LEVEL_ERROR, L"wrong hash size %d", pInfo->cbData);
+			__leave;
+		}
+		pContext = (POPENPGP_CONTEXT) pCardData->pvVendorSpecific;
+
+		dwCmdSize = 5;
+		if (pContext->fExtentedLeLcFields)
+		{
+			dwCmdSize++;
+		}
+		pbCmd[dwCmdSize++] = (BYTE) (SignatureAlgorithm[dwI].dwEncodedOidSize + pInfo->cbData);
+		memcpy(pbCmd + dwCmdSize , SignatureAlgorithm[dwI].pbEncodedOid,SignatureAlgorithm[dwI].dwEncodedOidSize);
+		dwCmdSize += SignatureAlgorithm[dwI].dwEncodedOidSize;
+		/*for(dwI = 0 ; dwI < pInfo->cbData ; dwI++)
+		{
+			pbCmd[dwCmdSize + dwI] = pInfo->pbData[pInfo->cbData - dwI -1];
+		}*/
+		memcpy(pbCmd + dwCmdSize, pInfo->pbData,pInfo->cbData);
+		dwCmdSize += pInfo->cbData;
+
+		
+		if (pContext->fExtentedLeLcFields)
+		{
+			pbCmd[dwCmdSize++] = (BYTE)(pContext->dwMaxLength / 0x100);
+			pbCmd[dwCmdSize++] = (BYTE)(pContext->dwMaxLength % 0x100);
+		}
+		else
+		{
+			pbCmd[dwCmdSize++] = 0;
+		}
+		dwReturn = SCardGetData(pCardData, pbCmd, dwCmdSize, &(pInfo->pbSignedData), &(pInfo->cbSignedData));
+		if (dwReturn == SCARD_W_WRONG_CHV)
+		{
+			dwReturn = SCARD_W_SECURITY_VIOLATION;
+			__leave;
+		}
+		if (dwReturn)
+		{
+			__leave;
+		}
+		// revert the BYTES
+		for(dwI = 0 ; dwI < pInfo->cbSignedData / 2 ; dwI++)
+		{
+			BYTE bTemp = pInfo->pbSignedData[dwI];
+			pInfo->pbSignedData[dwI] = pInfo->pbSignedData[pInfo->cbSignedData - 1 - dwI];
+			pInfo->pbSignedData[pInfo->cbSignedData - 1 - dwI] = bTemp;
+		}
+	}
+	__finally
+	{
+		if (dwReturn)
+		{
+			if (pInfo->pbSignedData)
+				pCardData->pfnCspFree(pInfo->pbSignedData);
+		}
+	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
+	return dwReturn;
+}
+
+DWORD SCardAuthenticate(PCARD_DATA pCardData,
+				PCARD_SIGNING_INFO  pInfo)
+{
+	DWORD dwReturn;
+	PBYTE pbData = NULL;
+	DWORD dwCmdSize = 0, dwI;
+	POPENPGP_CONTEXT pContext;
+	BYTE pbCmd[6 + 256 + 256] = {0x00, 
+				    0x88,
+					0x00,
+					0x00,
+					0x00,
+					0x00,
+					};
+	__try
+	{
+		Trace(WINEVENT_LEVEL_VERBOSE, L"Enter dwContainer=%d",pInfo->bContainerIndex);
+		if (pInfo->bContainerIndex != Authentication)
+		{
 			dwReturn = SCARD_E_NO_KEY_CONTAINER;
 			Trace(WINEVENT_LEVEL_ERROR, L"SCARD_E_NO_KEY_CONTAINER %d", pInfo->bContainerIndex);
 			__leave;
@@ -996,7 +1102,6 @@
 			pInfo->pbSignedData[dwI] = pInfo->pbSignedData[pInfo->cbSignedData - 1 - dwI];
 			pInfo->pbSignedData[pInfo->cbSignedData - 1 - dwI] = bTemp;
 		}
-		//TraceDump(WINEVENT_LEVEL_ERROR,pInfo->pbSignedData,pInfo->cbSignedData);
 	}
 	__finally
 	{
@@ -1006,6 +1111,7 @@
 				pCardData->pfnCspFree(pInfo->pbSignedData);
 		}
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 }
 
@@ -1102,81 +1208,11 @@
 			pCardData->pfnCspFree(pbData);
 		}
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 }
 
-DWORD SCardAuthenticate(PCARD_DATA pCardData,
-							PCARD_SIGNING_INFO  pInfo)
-{
-	DWORD dwReturn;
-	PBYTE pbData = NULL;
-	DWORD dwSize = 0, dwI;
-	BYTE pbCmd[6 + 256 + 256] = {0x00, 
-				    0x88,
-					0x00,
-					0x00,
-					0x00,
-					};
-	__try
-	{
-		Trace(WINEVENT_LEVEL_VERBOSE, L"Enter dwContainer=%d",pInfo->bContainerIndex);
-		if (pInfo->bContainerIndex >= MaxContainer)
-		{
-			dwReturn = SCARD_E_NO_KEY_CONTAINER;
-			Trace(WINEVENT_LEVEL_ERROR, L"SCARD_E_NO_KEY_CONTAINER %d", pInfo->bContainerIndex);
-			__leave;
-		}
-		if (pInfo->bContainerIndex != Authentication)
-		{
-			dwReturn = SCARD_E_NO_KEY_CONTAINER;
-			Trace(WINEVENT_LEVEL_ERROR, L"SCARD_E_NO_KEY_CONTAINER %d", pInfo->bContainerIndex);
-			__leave;
-		}
-		if (CARD_PADDING_PKCS1 & pInfo->dwPaddingType)
-		{
-			dwReturn = SCARD_E_UNSUPPORTED_FEATURE;
-			Trace(WINEVENT_LEVEL_ERROR, L"CARD_PADDING_PKCS1");
-			__leave;
-		}
-		else if (CARD_PADDING_PSS & pInfo->dwPaddingType)
-		{
-			dwReturn = SCARD_E_UNSUPPORTED_FEATURE;
-			Trace(WINEVENT_LEVEL_ERROR, L"CARD_PADDING_PSS");
-			__leave;
-		}
-		for(dwI = 0 ; dwI < dwSignatureAlgorithmCount ; dwI++)
-		{
-			if (SignatureAlgorithm[dwI].aiHashAlg == pInfo->aiHashAlg)
-			{
-				// found
-				break;
-			}
-		}
-		if (dwI >= dwSignatureAlgorithmCount)
-		{
-			Trace(WINEVENT_LEVEL_ERROR, L"alg not found %d", pInfo->aiHashAlg);
-			__leave;
-		}
-		if (SignatureAlgorithm[dwI].dwHashSize != pInfo->cbData)
-		{
-			Trace(WINEVENT_LEVEL_ERROR, L"wrong hash size %d", pInfo->cbData);
-			__leave;
-		}
-		memcpy(pbCmd +5, SignatureAlgorithm[dwI].pbEncodedOid,SignatureAlgorithm[dwI].dwEncodedOidSize);
-		memcpy(pbCmd +5 + SignatureAlgorithm[dwI].dwEncodedOidSize, pInfo->pbData,pInfo->cbData);
 
-		dwReturn = SCardGetData(pCardData, pbCmd, ARRAYSIZE(pbCmd), &(pInfo->pbSignedData), &(pInfo->cbSignedData));
-		if (dwReturn)
-		{
-			__leave;
-		}
-	}
-	__finally
-	{
-	}
-	return dwReturn;
-}
-
 DWORD GetPinInfo(DWORD __in dwPinIndex, __inout PPIN_INFO pPinInfo)
 {
 	DWORD dwReturn=0;
@@ -1215,5 +1251,6 @@
 	__finally
 	{
 	}
+	Trace(WINEVENT_LEVEL_VERBOSE, L"dwReturn = 0x%08X",dwReturn);
 	return dwReturn;
 }
\ No newline at end of file

Modified: trunk/OpenPGPminidriver/CryptoOperations.h
===================================================================
--- trunk/OpenPGPminidriver/CryptoOperations.h	2010-02-28 09:39:34 UTC (rev 4)
+++ trunk/OpenPGPminidriver/CryptoOperations.h	2010-03-02 18:54:34 UTC (rev 5)
@@ -52,10 +52,10 @@
 DWORD SCardSign(PCARD_DATA  pCardData,
 				PCARD_SIGNING_INFO  pInfo);
 
+DWORD SCardAuthenticate(PCARD_DATA pCardData,
+				PCARD_SIGNING_INFO  pInfo);
+
 DWORD SCardDecrypt(PCARD_DATA  pCardData,
 				PCARD_RSA_DECRYPT_INFO  pInfo);
 
-DWORD SCardAuthenticate(PCARD_DATA  pCardData,
-							PCARD_SIGNING_INFO  pInfo);
-
 DWORD GetPinInfo(DWORD __in bContainerIndex, __inout PPIN_INFO pPinInfo);
\ No newline at end of file

Modified: trunk/OpenPGPminidriverTest/CryptoOperations.cpp
===================================================================
--- trunk/OpenPGPminidriverTest/CryptoOperations.cpp	2010-02-28 09:39:34 UTC (rev 4)
+++ trunk/OpenPGPminidriverTest/CryptoOperations.cpp	2010-03-02 18:54:34 UTC (rev 5)
@@ -76,6 +76,7 @@
 	HCRYPTKEY hKey = NULL;
 	TCHAR szContainerName[] = OPENPGP_TEST_CONTAINER;
 	BYTE pbData[4096];
+	BYTE pbDataControl[4096];
 	BYTE pbBlobRef[4096];
 	DWORD dwDataSize = ARRAYSIZE(pbData);
 	DWORD dwBlobRefSize = ARRAYSIZE(pbBlobRef);
@@ -134,6 +135,7 @@
 			dwReturn = GetLastError();
 			__leave;
 		}
+		memcpy(pbDataControl, pbData, ARRAYSIZE(pbData));
 		dwSize = sizeof(DWORD);
 		bStatus = CryptGetKeyParam(hKey, KP_KEYLEN, (PBYTE) &dwAglLen,&dwSize , 0);
 		dwReturn = pCardData->pfnCardCreateContainerEx(pCardData, (BYTE) dwIndex, 
@@ -143,6 +145,13 @@
 		{
 			__leave;
 		}
+		// check if the buffer has been altered
+		if (memcmp(pbDataControl,pbData, ARRAYSIZE(pbData)) != 0)
+		{
+			dwReturn = SCARD_E_UNEXPECTED;
+			__leave;
+		}
+
 		memset(&ContainerInfo,0,sizeof(CONTAINER_INFO));
 		ContainerInfo.dwVersion = 0;
 		dwReturn = pCardData->pfnCardGetContainerInfo(pCardData, (BYTE) dwIndex, 0, &ContainerInfo);
@@ -157,7 +166,7 @@
 			__leave;
 		}
 		pBlobRef = (PRSAPUBLICKEYBLOB) pbBlobRef;
-		pBlob = (PRSAPUBLICKEYBLOB) ContainerInfo.pbSigPublicKey;
+		pBlob = (PRSAPUBLICKEYBLOB) (dwKeySpec==AT_SIGNATURE ? ContainerInfo.pbSigPublicKey : ContainerInfo.pbKeyExPublicKey);
 		//if (memcmp(pBlobRef, pBlob, ContainerInfo.cbSigPublicKey) != 0)
 		for (DWORD dwI = 0; dwI < pBlobRef->rsapubkey.bitlen / 8; dwI++)
 		{
@@ -179,4 +188,131 @@
 			CryptReleaseContext(hProv,0);
 	}
 	return dwReturn;
+}
+
+DWORD SetTheSameKeyForAllContainers()
+{
+	DWORD dwReturn, dwKeySpec;
+	PIN_ID  PinId;
+	HCRYPTPROV hProv = NULL;
+	HCRYPTKEY hKey = NULL;
+	TCHAR szContainerName[] = OPENPGP_TEST_CONTAINER;
+	BYTE pbData[4096];
+	BYTE pbDataControl[4096];
+	BYTE pbBlobRef[4096];
+	DWORD dwDataSize = ARRAYSIZE(pbData);
+	DWORD dwBlobRefSize = ARRAYSIZE(pbBlobRef);
+	BOOL bStatus;
+	CONTAINER_INFO  ContainerInfo;
+	PRSAPUBLICKEYBLOB pBlob, pBlobRef;
+	DWORD dwAglLen, dwSize, dwIndex;
+	__try
+	{
+		 if (!pCardData)
+		{
+			dwReturn = SCARD_E_COMM_DATA_LOST;
+			__leave;
+		}
+		bStatus = CryptAcquireContext(&hProv, szContainerName, MS_ENHANCED_PROV, PROV_RSA_FULL, 0);
+		if (!bStatus) 
+		{
+			dwReturn = GetLastError();
+			if (dwReturn == NTE_BAD_KEYSET)
+			{
+				bStatus = CryptAcquireContext(&hProv, szContainerName, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET);
+			}
+			if (!bStatus) 
+			{
+				dwReturn = GetLastError();
+				__leave;
+			}
+		}
+		bStatus = CryptGenKey(hProv, AT_SIGNATURE, CRYPT_EXPORTABLE, &hKey);
+		if (!bStatus) 
+		{
+			dwReturn = GetLastError();
+			__leave;
+		}
+		bStatus = CryptExportKey(hKey,  NULL, PRIVATEKEYBLOB, 0, pbData, &dwDataSize);
+		if (!bStatus) 
+		{
+			dwReturn = GetLastError();
+			__leave;
+		}
+		memcpy(pbDataControl, pbData, ARRAYSIZE(pbData));
+		dwSize = sizeof(DWORD);
+		bStatus = CryptGetKeyParam(hKey, KP_KEYLEN, (PBYTE) &dwAglLen,&dwSize , 0);
+
+		for(dwIndex = 0; dwIndex < 3; dwIndex++)
+		{
+			switch(dwIndex)
+			{
+			case 0:	//Signature,
+				dwKeySpec = AT_SIGNATURE;
+				PinId = ROLE_USER;
+				break;
+			case 1: //Authentication,
+				dwKeySpec = AT_SIGNATURE;
+				PinId = 3;
+				break;
+			case 2: // Confidentiality,
+				dwKeySpec = AT_KEYEXCHANGE;
+				PinId = 4;
+				break;
+			default:
+				dwReturn = SCARD_E_UNEXPECTED;
+				__leave;
+			}
+
+			dwReturn = pCardData->pfnCardCreateContainerEx(pCardData, (BYTE) dwIndex, 
+												CARD_CREATE_CONTAINER_KEY_IMPORT, 
+												dwKeySpec, dwAglLen, pbData, PinId);
+			if (dwReturn)
+			{
+				__leave;
+			}
+			// check if the buffer has been altered
+			if (memcmp(pbDataControl,pbData, ARRAYSIZE(pbData)) != 0)
+			{
+				dwReturn = SCARD_E_UNEXPECTED;
+				__leave;
+			}
+
+			memset(&ContainerInfo,0,sizeof(CONTAINER_INFO));
+			ContainerInfo.dwVersion = 0;
+			dwReturn = pCardData->pfnCardGetContainerInfo(pCardData, (BYTE) dwIndex, 0, &ContainerInfo);
+			if (dwReturn)
+			{
+				__leave;
+			}
+			bStatus = CryptExportKey(hKey,  NULL, PUBLICKEYBLOB, 0, pbBlobRef, &dwBlobRefSize);
+			if (!bStatus) 
+			{
+				dwReturn = GetLastError();
+				__leave;
+			}
+			pBlobRef = (PRSAPUBLICKEYBLOB) pbBlobRef;
+			pBlob = (PRSAPUBLICKEYBLOB) (dwKeySpec==AT_SIGNATURE ? ContainerInfo.pbSigPublicKey : ContainerInfo.pbKeyExPublicKey);
+			//if (memcmp(pBlobRef, pBlob, ContainerInfo.cbSigPublicKey) != 0)
+			for (DWORD dwI = 0; dwI < pBlobRef->rsapubkey.bitlen / 8; dwI++)
+			{
+				if ( pBlobRef->modulus[dwI] != pBlob->modulus[dwI])
+				{
+					dwReturn = SCARD_E_UNEXPECTED;
+					__leave;
+				}
+			}
+		}
+		dwReturn = 0;
+
+	}
+	__finally
+	{
+		if (hKey)
+			CryptDestroyKey(hKey);
+		//CryptAcquireContext(&hProv, szContainerName, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
+		if (hProv)
+			CryptReleaseContext(hProv,0);
+	}
+	return dwReturn;
 }
\ No newline at end of file

Modified: trunk/OpenPGPminidriverTest/Dialog.h
===================================================================
--- trunk/OpenPGPminidriverTest/Dialog.h	2010-02-28 09:39:34 UTC (rev 4)
+++ trunk/OpenPGPminidriverTest/Dialog.h	2010-03-02 18:54:34 UTC (rev 5)
@@ -1,20 +1,3 @@
-/*	OpenPGP Smart Card Mini Driver
-    Copyright (C) 2009 Vincent Le Toux
-
-    This library is Free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License version 2.1 as published by the Free Software Foundation.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
 #define IDD_DLG 1000
 #define IDC_CONNECT 1001
 #define IDC_CurrentDll 1002
@@ -34,3 +17,4 @@
 #define IDC_CONTAINERINDEX 1016
 #define IDC_NEWKEY 1017
 #define IDC_IMPORTKEY 1018
+#define IDC_SAMEKEY 1019

Modified: trunk/OpenPGPminidriverTest/Dialog.rc
===================================================================
--- trunk/OpenPGPminidriverTest/Dialog.rc	2010-02-28 09:39:34 UTC (rev 4)
+++ trunk/OpenPGPminidriverTest/Dialog.rc	2010-03-02 18:54:34 UTC (rev 5)
@@ -24,5 +24,6 @@
   CONTROL "",IDC_CONTAINERINDEX,"ComboBox",WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_DROPDOWNLIST,15,126,90,15
   CONTROL "Generate new key",IDC_NEWKEY,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,129,123,72,21
   CONTROL "Import key",IDC_IMPORTKEY,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,129,147,72,21
+  CONTROL "Set same key",IDC_SAMEKEY,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,210,123,72,21
 END
 

Modified: trunk/OpenPGPminidriverTest/global.h
===================================================================
--- trunk/OpenPGPminidriverTest/global.h	2010-02-28 09:39:34 UTC (rev 4)
+++ trunk/OpenPGPminidriverTest/global.h	2010-03-02 18:54:34 UTC (rev 5)
@@ -26,4 +26,5 @@
 DWORD Decrypt(PTSTR szContainer, DWORD dwKeySpec);
 DWORD GenerateNewKey(DWORD dwIndex);
 DWORD ImportKey(DWORD dwIndex);
+DWORD SetTheSameKeyForAllContainers();
 #define OPENPGP_TEST_CONTAINER TEXT("Test_OPENPGPG")
\ No newline at end of file

Modified: trunk/OpenPGPminidriverTest/main.cpp
===================================================================
--- trunk/OpenPGPminidriverTest/main.cpp	2010-02-28 09:39:34 UTC (rev 4)
+++ trunk/OpenPGPminidriverTest/main.cpp	2010-03-02 18:54:34 UTC (rev 5)
@@ -149,6 +149,10 @@
 				dwReturn = ImportKey(SendDlgItemMessage(hMainWnd,IDC_CONTAINERINDEX, CB_GETCURSEL, 0, 0));
 				MessageBoxWin32(dwReturn);
 				break;
+			case IDC_SAMEKEY:
+				dwReturn = SetTheSameKeyForAllContainers();
+				MessageBoxWin32(dwReturn);
+				break;
 				////////// base CSP
 			case IDC_CONTAINER:
 				dwReturn = ListContainer();



More information about the Openpgpmdrv-commits mailing list