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.

201 lines
5.2 KiB

  1. // PubKeyCtx.h -- declaration of CPublicKeyContext
  2. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  3. // 2000. This computer program includes Confidential, Proprietary
  4. // Information and is a Trade Secret of Schlumberger Technology Corp. All
  5. // use, disclosure, and/or reproduction is prohibited unless authorized
  6. // in writing. All Rights Reserved.
  7. #if !defined(SLBCSP_PUBKEYCTX_H)
  8. #define SLBCSP_PUBKEYCTX_H
  9. #include <cciCont.h>
  10. #include <cciCert.h>
  11. #include "KeyContext.h"
  12. #include "MsRsaPriKB.h"
  13. #include "MsRsaPubKB.h"
  14. class CryptContext;
  15. class CHashContext;
  16. class Pkcs11Attributes;
  17. class CPublicKeyContext
  18. : public CKeyContext
  19. {
  20. public:
  21. // Types
  22. // C'tors/D'tors
  23. CPublicKeyContext(HCRYPTPROV hProv,
  24. CryptContext &rcryptctx,
  25. ALG_ID algid = 0,
  26. bool fVerifyKeyExists = true);
  27. ~CPublicKeyContext();
  28. // Operators
  29. // Operations
  30. virtual std::auto_ptr<CKeyContext>
  31. Clone(DWORD const *pdwReserved,
  32. DWORD dwFlags) const;
  33. virtual void
  34. AuxPublicKey(AlignedBlob const &rabMsPublicKey);
  35. void
  36. ClearAuxPublicKey();
  37. virtual void
  38. Certificate(BYTE *pbData);
  39. virtual Blob
  40. Decrypt(Blob const &rblbCipher);
  41. virtual void
  42. Decrypt(HCRYPTHASH hAuxHash,
  43. BOOL Final,
  44. DWORD dwFlags,
  45. BYTE *pbData,
  46. DWORD *pdwDataLen);
  47. virtual void
  48. Generate(ALG_ID AlgoId,
  49. DWORD dwFlags);
  50. virtual void
  51. ImportPrivateKey(MsRsaPrivateKeyBlob const &rmsprikb,
  52. bool fExportable);
  53. virtual void
  54. ImportPublicKey(MsRsaPublicKeyBlob const &rmspubkb);
  55. virtual void
  56. Permissions(BYTE bPermissions);
  57. virtual Blob
  58. Sign(CHashContext *pHash,
  59. bool fNoHashOid);
  60. // Auxiliary CSP communication
  61. virtual
  62. void ImportToAuxCSP(void);
  63. void
  64. VerifyKeyExists() const;
  65. void
  66. VerifySignature(HCRYPTHASH hHash,
  67. BYTE const *pbSignature,
  68. DWORD dwSigLen,
  69. LPCTSTR sDescription,
  70. DWORD dwFlags);
  71. // Access
  72. virtual AlignedBlob
  73. AsAlignedBlob(HCRYPTKEY hDummy,
  74. DWORD dwBlobType) const;
  75. virtual DWORD
  76. KeySpec() const;
  77. virtual StrengthType
  78. MaxStrength() const;
  79. virtual StrengthType
  80. MinStrength() const;
  81. virtual BYTE
  82. Permissions() const;
  83. virtual StrengthType
  84. Strength() const;
  85. virtual Blob
  86. Certificate();
  87. // Predicates
  88. bool
  89. AuxKeyLoaded() const;
  90. protected:
  91. // Types
  92. // C'tors/D'tors
  93. // Duplicate key context and its current state
  94. CPublicKeyContext(CPublicKeyContext const &rhs,
  95. DWORD const *pdwReserved,
  96. DWORD dwFlags);
  97. // Operators
  98. // Operations
  99. // Access
  100. // Predicates
  101. // Variables
  102. private:
  103. // Types
  104. enum
  105. {
  106. // These constants are defined as enums since VC 6.0 doesn't
  107. // support use of initializer specified in const declarations.
  108. MaxKeyStrength = 1024, // US Export
  109. // restricted, do
  110. // not change
  111. MinKeyStrength = 1024, // Only support one
  112. // strength
  113. };
  114. // C'tors/D'tors
  115. // Operators
  116. // Operations
  117. void
  118. ClearCertificate(cci::CCertificate &rhcert) const;
  119. void
  120. OkReplacingCredentials() const;
  121. void
  122. PrepToStoreKey(cci::CKeyPair &rkp) const;
  123. void
  124. SetAttributes(cci::CPublicKey &rhpubkey, // always non-zero
  125. cci::CPrivateKey &rhprikey,
  126. bool fLocal,
  127. bool fExportable) const;
  128. void
  129. SetCertDerivedPkcs11Attributes(cci::CKeyPair const &rkp,
  130. Pkcs11Attributes &rPkcsAttr) const;
  131. void
  132. SetPkcs11Attributes(cci::CPublicKey &rpubkey,
  133. cci::CPrivateKey &rprikey) const;
  134. // Access
  135. cci::CKeyPair
  136. KeyPair() const;
  137. Blob
  138. Pkcs11Id(Blob const &rbModulus) const;
  139. Blob
  140. Pkcs11CredentialId(Blob const &rbModulus) const;
  141. // Predicates
  142. bool
  143. AreLogonCredentials() const;
  144. // Variables
  145. CryptContext &m_rcryptctx;
  146. cci::KeySpec m_ks;
  147. };
  148. #endif // SLBCSP_PUBKEYCTX_H