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.

129 lines
3.9 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. // FILE : swnt_pk.h //
  3. // DESCRIPTION : //
  4. // AUTHOR : //
  5. // HISTORY : //
  6. // Apr 19 1995 larrys Cleanup //
  7. // Oct 27 1995 rajeshk RandSeed Stuff added hUID to PKCS2Encrypt //
  8. // //
  9. // Copyright (C) 1993 Microsoft Corporation All Rights Reserved //
  10. /////////////////////////////////////////////////////////////////////////////
  11. #ifndef __SWNT_PK_H__
  12. #define __SWNT_PK_H__
  13. #include <delayimp.h>
  14. #include <pstore.h>
  15. #include <alloca.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #define GetNextAlignedValue(c, alignment) ((c + alignment) & ~(alignment - 1))
  20. #define GetPtrAlignedSize(cb) (GetNextAlignedValue(cb, sizeof(ULONG_PTR)))
  21. #define NTPK_USE_SIG 0
  22. #define NTPK_USE_EXCH 1
  23. #define PKCS_BLOCKTYPE_1 1
  24. #define PKCS_BLOCKTYPE_2 2
  25. //
  26. // Function : EncryptAndDecryptWithRSAKey
  27. //
  28. // Description : This function creates a buffer and then encrypts that with
  29. // the passed in private key and decrypts with the passed in
  30. // public key. The function is used for FIPS 140-1 compliance
  31. // to make sure that newly generated/imported keys work and
  32. // in the self test during DLL initialization.
  33. //
  34. extern DWORD
  35. EncryptAndDecryptWithRSAKey(
  36. IN BYTE *pbRSAPub,
  37. IN BYTE *pbRSAPriv,
  38. IN BOOL fSigKey,
  39. IN BOOL fEncryptCheck,
  40. IN BOOL fHardCodedKey);
  41. extern DWORD
  42. ReGenKey(
  43. HCRYPTPROV hUser,
  44. DWORD dwFlags,
  45. DWORD dwWhichKey,
  46. HCRYPTKEY *phKey,
  47. DWORD bits);
  48. extern BOOL
  49. CheckDataLenForRSAEncrypt(
  50. IN DWORD cbMod, // length of the modulus
  51. IN DWORD cbData, // length of the data
  52. IN DWORD dwFlags); // flags
  53. // do the modular exponentiation calculation M^PubKey mod N
  54. extern DWORD
  55. RSAPublicEncrypt(
  56. IN PEXPO_OFFLOAD_STRUCT pOffloadInfo,
  57. IN BSAFE_PUB_KEY *pBSPubKey,
  58. IN BYTE *pbInput,
  59. IN BYTE *pbOutput);
  60. // do the modular exponentiation calculation M^PrivKey Exponent mod N
  61. extern DWORD
  62. RSAPrivateDecrypt(
  63. IN PEXPO_OFFLOAD_STRUCT pOffloadInfo,
  64. IN BSAFE_PRV_KEY *pBSPrivKey,
  65. IN BYTE *pbInput,
  66. IN BYTE *pbOutput);
  67. /************************************************************************/
  68. /* RSAEncrypt performs a RSA encryption. */
  69. /************************************************************************/
  70. extern DWORD
  71. RSAEncrypt(
  72. IN PNTAGUserList pTmpUser,
  73. IN BSAFE_PUB_KEY *pBSPubKey,
  74. IN BYTE *pbPlaintext,
  75. IN DWORD cbPlaintext,
  76. IN BYTE *pbParams,
  77. IN DWORD cbParams,
  78. IN DWORD dwFlags,
  79. OUT BYTE *pbOut);
  80. /************************************************************************/
  81. /* RSADecrypt performs a RSA decryption. */
  82. /************************************************************************/
  83. extern DWORD
  84. RSADecrypt(
  85. IN PNTAGUserList pTmpUser,
  86. IN BSAFE_PRV_KEY *pBSPrivKey,
  87. IN CONST BYTE *pbBlob,
  88. IN DWORD cbBlob,
  89. IN BYTE *pbParams,
  90. IN DWORD cbParams,
  91. IN DWORD dwFlags,
  92. OUT BYTE **ppbPlaintext,
  93. OUT DWORD *pcbPlaintext);
  94. //
  95. // Routine : DerivePublicFromPrivate
  96. //
  97. // Description : Derive the public RSA key from the private RSA key. This is
  98. // done and the resulting public key is placed in the appropriate
  99. // place in the context pointer (pTmpUser).
  100. //
  101. extern DWORD
  102. DerivePublicFromPrivate(
  103. IN PNTAGUserList pUser,
  104. IN BOOL fSigKey);
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif // __SWNT_PK_H__