handlecontainer.h
上传用户:filter2008
上传日期:2013-02-01
资源大小:101k
文件大小:5k
源码类别:

CA认证

开发平台:

C/C++

  1. /****************************************************************************
  2. * library : pkcs_csp.dll
  3. * Purpose : It is a cryptographic service provider which is an independent 
  4. * software module that actually performs cryptography algorithms for 
  5. * authentication, encoding, and encryption.
  6. * This DLL can be interfaced on any PKCS#11 module.  
  7. *
  8. * Copyright (C) 2003 Ilex Syst鑝es Informatiques
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. *
  24. * Contact :
  25. * Ilex 
  26. * 51 boulevard Voltaire
  27. * 92600 Asni鑢es-sur-Seine
  28. * pkizy@ilex.fr
  29. *
  30. * Author: Delouvrier Antoine
  31. *
  32. *******************************************************************************/
  33. /*
  34. %----------------------------------------------------------------------------
  35. % PROJECT : CSP_PKCS
  36. %
  37. % MODULE : HandleContainer
  38. %
  39. % VERSION : 1.00
  40. %
  41. % FILE : HandleContainer.h
  42. %
  43. % this Class allows to manage a container. When an application obtains a context
  44. % on a container it is this class which deals with thereafter all the entrance
  45. % points of the DLL for this specific container
  46. %----------------------------------------------------------------------------
  47. % Version 1.00
  48. % CPX-31/03/2003-Creation
  49. %----------------------------------------------------------------------------
  50. % You can find wincrypt.h and cspdk in the CSPDK which is downloadable at the adress :
  51. % http://www.microsoft.com/downloads/details.aspx?FamilyId=0F436C75-2304-42BB-B81A-BA0C2C47BAC2&displaylang=en
  52. */ 
  53. #ifndef INCL_HANDLECONTAINER_H
  54. #define INCL_HANDLECONTAINER_H
  55. #include <windows.h>
  56. #include <wincrypt.h>
  57. #include "table.h"
  58. #include "cspdk.h"
  59. #include "pkcs.h"
  60. #include "pkcscontainer.h"
  61. #pragma once
  62. class HandleContainer
  63. {
  64. public:
  65. HandleContainer();
  66. ~HandleContainer();
  67. BOOL CreatePrivateExponentOneKey(LPTSTR szProvider,DWORD dwProvType,LPTSTR szContainer,DWORD dwKeySpec,HCRYPTPROV *hProv, HCRYPTKEY *hPrivateKey);
  68. BOOL ImportPlainSessionBlob(HCRYPTPROV hProv,HCRYPTKEY hPrivateKey,ALG_ID dwAlgId,LPBYTE pbKeyMaterial ,DWORD dwKeyMaterial ,HCRYPTKEY *hSessionKey);
  69. BOOL ExportPlainSessionBlob(HCRYPTKEY hPublicKey,HCRYPTKEY hSessionKey,LPBYTE *pbKeyMaterial ,DWORD *dwKeyMaterial );
  70. BOOL AcquireMicrosoftContext();
  71. BOOL CreateHandleContainer(const CHAR IN * const pszContainer,const DWORD IN dwFlags, PVTableProvStruc IN pVTable);
  72. BOOL CreateHash(ALG_ID Algid, HCRYPTKEY hCryptKey, DWORD dwFlags, HCRYPTHASH* phHash);
  73. BOOL DestroyHash(HCRYPTHASH hHash);
  74. BOOL GetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE* pbData, DWORD*pdwDataLen, DWORD dwFlags);
  75. BOOL HashData(HCRYPTHASH hHash, CONST BYTE* pbData, DWORD dwDatalen, DWORD dwFlags);
  76. BOOL SetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE*pbData, DWORD dwFlags);
  77. BOOL HandleContainer::GetProvParam(DWORD dwParam, BYTE* pbData, DWORD* pdwDataLen, DWORD dwFlags);
  78. BOOL Encrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE* pbData, DWORD*pdwDataLen, DWORD dwBufLen);
  79. BOOL Decrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE*pbData, DWORD*pdwDataLen);
  80. BOOL SignHash(HCRYPTHASH hHash, DWORD dwKeySpec, LPCWSTR sDescription, DWORD dwFlags, BYTE*pbSignature, DWORD* pdwSigLen);
  81. BOOL VerifySignature(HCRYPTHASH hHash, CONST BYTE* pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCTSTR sDescription, DWORD dwFlags);
  82. BOOL DestroyKey(HCRYPTKEY hKey);
  83. BOOL ImportKey(BYTE* pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY* phKey);
  84. BOOL GetKeyParam(HCRYPTKEY hKey, DWORD dwParam, BYTE* pbData, DWORD* pdwDataLen, DWORD dwFlags);
  85. BOOL SetKeyParam(HCRYPTKEY hKey, DWORD dwParam,CONST BYTE*pbData, DWORD dwFlags);
  86. BOOL GetUserKey(DWORD dwKeySpec, HCRYPTKEY* phUserKey);
  87. PKCSContainer* GetCurrentContainer(){return currentPContainer;}
  88. static bool VerifyHandleContainer(HandleContainer* handleContainer);
  89. static TableOfHandle handles_Container;
  90. private:
  91. PKCSContainer* currentPContainer;
  92. HCRYPTPROV microsoft_Provider;
  93. };
  94. #endif