Source code of Windows XP (NT5)
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.

125 lines
3.6 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 NTPK_USE_SIG 0
  20. #define NTPK_USE_EXCH 1
  21. #define PKCS_BLOCKTYPE_1 1
  22. #define PKCS_BLOCKTYPE_2 2
  23. //
  24. // Function : EncryptAndDecryptWithRSAKey
  25. //
  26. // Description : This function creates a buffer and then encrypts that with
  27. // the passed in private key and decrypts with the passed in
  28. // public key. The function is used for FIPS 140-1 compliance
  29. // to make sure that newly generated/imported keys work and
  30. // in the self test during DLL initialization.
  31. //
  32. extern DWORD
  33. EncryptAndDecryptWithRSAKey(
  34. IN BYTE *pbRSAPub,
  35. IN BYTE *pbRSAPriv,
  36. IN BOOL fSigKey,
  37. IN BOOL fEncryptCheck,
  38. IN BOOL fHardCodedKey);
  39. extern DWORD
  40. ReGenKey(
  41. HCRYPTPROV hUser,
  42. DWORD dwFlags,
  43. DWORD dwWhichKey,
  44. HCRYPTKEY *phKey,
  45. DWORD bits);
  46. extern BOOL
  47. CheckDataLenForRSAEncrypt(
  48. IN DWORD cbMod, // length of the modulus
  49. IN DWORD cbData, // length of the data
  50. IN DWORD dwFlags); // flags
  51. // do the modular exponentiation calculation M^PubKey mod N
  52. extern DWORD
  53. RSAPublicEncrypt(
  54. IN PEXPO_OFFLOAD_STRUCT pOffloadInfo,
  55. IN BSAFE_PUB_KEY *pBSPubKey,
  56. IN BYTE *pbInput,
  57. IN BYTE *pbOutput);
  58. // do the modular exponentiation calculation M^PrivKey Exponent mod N
  59. extern DWORD
  60. RSAPrivateDecrypt(
  61. IN PEXPO_OFFLOAD_STRUCT pOffloadInfo,
  62. IN BSAFE_PRV_KEY *pBSPrivKey,
  63. IN BYTE *pbInput,
  64. IN BYTE *pbOutput);
  65. /************************************************************************/
  66. /* RSAEncrypt performs a RSA encryption. */
  67. /************************************************************************/
  68. extern DWORD
  69. RSAEncrypt(
  70. IN PNTAGUserList pTmpUser,
  71. IN BSAFE_PUB_KEY *pBSPubKey,
  72. IN BYTE *pbPlaintext,
  73. IN DWORD cbPlaintext,
  74. IN BYTE *pbParams,
  75. IN DWORD cbParams,
  76. IN DWORD dwFlags,
  77. OUT BYTE *pbOut);
  78. /************************************************************************/
  79. /* RSADecrypt performs a RSA decryption. */
  80. /************************************************************************/
  81. extern DWORD
  82. RSADecrypt(
  83. IN PNTAGUserList pTmpUser,
  84. IN BSAFE_PRV_KEY *pBSPrivKey,
  85. IN CONST BYTE *pbBlob,
  86. IN DWORD cbBlob,
  87. IN BYTE *pbParams,
  88. IN DWORD cbParams,
  89. IN DWORD dwFlags,
  90. OUT BYTE **ppbPlaintext,
  91. OUT DWORD *pcbPlaintext);
  92. //
  93. // Routine : DerivePublicFromPrivate
  94. //
  95. // Description : Derive the public RSA key from the private RSA key. This is
  96. // done and the resulting public key is placed in the appropriate
  97. // place in the context pointer (pTmpUser).
  98. //
  99. extern DWORD
  100. DerivePublicFromPrivate(
  101. IN PNTAGUserList pUser,
  102. IN BOOL fSigKey);
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif // __SWNT_PK_H__