Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
4.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1995 - 1996
  6. //
  7. // File: nmpvkhlp.h
  8. //
  9. // History: 10-May-96 philh created
  10. //--------------------------------------------------------------------------
  11. #ifndef __NMPVKHLP_H__
  12. #define __NMPVKHLP_H__
  13. #include "wincrypt.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #ifndef PRIVATEKEYBLOB
  18. #define PRIVATEKEYBLOB 0x7
  19. #endif
  20. //+-------------------------------------------------------------------------
  21. // Creates a temporary container in the provider and loads the private key
  22. // from memory.
  23. // For success, returns a handle to a cryptographic provider for the private
  24. // key and the name of the temporary container. PrivateKeyReleaseContext must
  25. // be called to release the hCryptProv and delete the temporary container.
  26. //
  27. // PrivateKeyLoadFromMemory is called to load the private key into the
  28. // temporary container.
  29. //--------------------------------------------------------------------------
  30. BOOL WINAPI
  31. PvkPrivateKeyAcquireContextFromMemory(IN LPCWSTR pwszProvName,
  32. IN DWORD dwProvType,
  33. IN BYTE *pbData,
  34. IN DWORD cbData,
  35. IN HWND hwndOwner,
  36. IN LPCWSTR pwszKeyName,
  37. IN OUT OPTIONAL DWORD *pdwKeySpec,
  38. OUT HCRYPTPROV *phCryptProv);
  39. //+-------------------------------------------------------------------------
  40. // Releases the cryptographic provider and deletes the temporary container
  41. // created by PrivateKeyAcquireContext or PrivateKeyAcquireContextFromMemory.
  42. //--------------------------------------------------------------------------
  43. BOOL WINAPI
  44. PvkPrivateKeyReleaseContext(IN HCRYPTPROV hCryptProv,
  45. IN LPCWSTR pwszProvName,
  46. IN DWORD dwProvType,
  47. IN LPWSTR pwszTmpContainer);
  48. //+-------------------------------------------------------------------------
  49. // Acquiring hprovs, Trys the file first and then the KeyContainer. Use
  50. // PvkFreeCryptProv to release HCRYPTPROV and resources.
  51. //--------------------------------------------------------------------------
  52. HCRYPTPROV WINAPI
  53. PvkGetCryptProvU(IN HWND hwnd,
  54. IN LPCWSTR pwszCaption,
  55. IN LPCWSTR pwszCapiProvider,
  56. IN DWORD dwProviderType,
  57. IN LPCWSTR pwszPrivKey,
  58. OUT LPWSTR *ppwszTmpContainer);
  59. void WINAPI
  60. PvkFreeCryptProvU(IN HCRYPTPROV hProv,
  61. IN LPCWSTR pwszCapiProvider,
  62. IN DWORD dwProviderType,
  63. IN LPWSTR pwszTmpContainer);
  64. //+-----------------------------------------------------------------------
  65. //
  66. //
  67. // Parameters:
  68. // Return Values:
  69. // Error Codes:
  70. //
  71. //------------------------------------------------------------------------
  72. void WINAPI PvkFreeCryptProv(IN HCRYPTPROV hProv,
  73. IN LPCWSTR pwszCapiProvider,
  74. IN DWORD dwProviderType,
  75. IN LPWSTR pwszTmpContainer);
  76. //+-----------------------------------------------------------------------
  77. //
  78. //
  79. // Parameters:
  80. // Return Values:
  81. // Error Codes:
  82. //
  83. //------------------------------------------------------------------------
  84. HRESULT WINAPI PvkGetCryptProv( IN HWND hwnd,
  85. IN LPCWSTR pwszCaption,
  86. IN LPCWSTR pwszCapiProvider,
  87. IN DWORD dwProviderType,
  88. IN LPCWSTR pwszPvkFile,
  89. IN LPCWSTR pwszKeyContainerName,
  90. IN DWORD *pdwKeySpec,
  91. OUT LPWSTR *ppwszTmpContainer,
  92. OUT HCRYPTPROV *phCryptProv);
  93. #ifdef _M_IX86
  94. BOOL WINAPI CryptAcquireContextU(
  95. HCRYPTPROV *phProv,
  96. LPCWSTR lpContainer,
  97. LPCWSTR lpProvider,
  98. DWORD dwProvType,
  99. DWORD dwFlags
  100. );
  101. #else
  102. #define CryptAcquireContextU CryptAcquireContextW
  103. #endif
  104. //+-------------------------------------------------------------------------
  105. // Private Key helper error codes
  106. //--------------------------------------------------------------------------
  107. #define PVK_HELPER_BAD_PARAMETER 0x80097001
  108. #define PVK_HELPER_BAD_PVK_FILE 0x80097002
  109. #define PVK_HELPER_WRONG_KEY_TYPE 0x80097003
  110. #define PVK_HELPER_PASSWORD_CANCEL 0x80097004
  111. #ifdef __cplusplus
  112. } // Balance extern "C" above
  113. #endif
  114. #endif