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.

186 lines
4.5 KiB

  1. // CspProfile.h -- CSP Profile class declaration
  2. // (c) Copyright Schlumberger Technology Corp., unpublished work, created
  3. // 1998. 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_PROFILE_H)
  8. #define SLBCSP_PROFILE_H
  9. #if _UNICODE
  10. #if !defined(UNICODE)
  11. #define UNICODE
  12. #endif //!UNICODE
  13. #endif //_UNICODE
  14. #if defined(UNICODE)
  15. #if !defined(_UNICODE)
  16. #define _UNICODE
  17. #endif //!_UNICODE
  18. #endif //UNICODE
  19. #ifndef __AFXWIN_H__
  20. #error include 'stdafx.h' before including this file for PCH
  21. #endif
  22. #include <memory> // for auto_ptr
  23. #include <string>
  24. #include <vector>
  25. namespace ProviderProfile
  26. {
  27. class ATR
  28. {
  29. public:
  30. typedef unsigned char Length;
  31. enum Attribute
  32. {
  33. MaxLength = 33
  34. };
  35. explicit
  36. ATR();
  37. ATR(Length al, BYTE const abATR[], BYTE const abMask[]);
  38. BYTE const *String() const;
  39. BYTE const *Mask() const;
  40. ATR::Length ATRLength() const;
  41. size_t Size() const;
  42. ATR &operator=(ATR const &rhs);
  43. bool operator==(ATR const &rhs);
  44. bool operator!=(ATR const &rhs);
  45. private:
  46. typedef BYTE ATRString[MaxLength];
  47. Length m_al;
  48. ATRString m_atrstring;
  49. ATRString m_atrsMask;
  50. };
  51. class CardProfile
  52. {
  53. public:
  54. enum Attribute
  55. {
  56. attrNone = 0,
  57. // Card has the "Cryptoflex Most Significant Byte zero
  58. // private Key Defect."
  59. attrMsbKeyDefect = 0x01,
  60. };
  61. explicit
  62. CardProfile();
  63. CardProfile(ProviderProfile::ATR const &ratr,
  64. std::string const &rsFriendlyName,
  65. std::string const &rsRegistryName,
  66. GUID const &rgPrimaryProvider,
  67. Attribute attr = attrNone);
  68. CardProfile(ProviderProfile::ATR const &ratr,
  69. CString const &rcsFriendlyName,
  70. CString const &rcsRegistryName,
  71. GUID const &rgPrimaryProvider,
  72. Attribute attr = attrNone);
  73. ~CardProfile();
  74. ATR const &ATR() const;
  75. std::string FriendlyName() const;
  76. CString csFriendlyName() const;
  77. GUID const &PrimaryProvider() const;
  78. std::string RegistryName() const;
  79. CString csRegistryName() const;
  80. bool AtrMatches(ATR::Length cAtr,
  81. BYTE const *pbAtr) const;
  82. bool HasAttribute(Attribute attr) const;
  83. bool operator==(CardProfile const &rhs);
  84. bool operator!=(CardProfile const &rhs);
  85. private:
  86. ProviderProfile::ATR m_atr;
  87. std::string m_sFriendlyName;
  88. std::string m_sRegistryName;
  89. CString m_csFriendlyName;
  90. CString m_csRegistryName;
  91. GUID m_gPrimaryProvider;
  92. Attribute m_attr;
  93. };
  94. struct VersionInfo
  95. {
  96. explicit
  97. VersionInfo()
  98. : m_dwMajor(0),
  99. m_dwMinor(0)
  100. {}
  101. DWORD m_dwMajor;
  102. DWORD m_dwMinor;
  103. };
  104. class CspProfile
  105. {
  106. public:
  107. HINSTANCE
  108. DllInstance() const;
  109. static CspProfile const &
  110. Instance();
  111. const CString
  112. Name() const;
  113. HINSTANCE
  114. Resources() const;
  115. DWORD
  116. Type() const;
  117. VersionInfo
  118. Version() const;
  119. std::vector<CardProfile> const &
  120. Cards() const;
  121. static void
  122. Release();
  123. private:
  124. // client can not directly create a Profile
  125. // object, use Instance to get the handle
  126. CspProfile(DWORD Type,
  127. std::vector<CardProfile> const &rvcp);
  128. // not implemented, copy is not allowed
  129. CspProfile(CspProfile const &rhs);
  130. // client can not directly delete a profile, use Release to
  131. // delete one.
  132. ~CspProfile();
  133. // not implemented, assignment is not allowed
  134. CspProfile &
  135. operator=(CspProfile const &rProfile);
  136. HINSTANCE m_hDllInstance;
  137. DWORD const m_dwType;
  138. VersionInfo m_vi;
  139. std::vector<CardProfile> m_vcp;
  140. HINSTANCE m_hResInstance;
  141. AFX_EXTENSION_MODULE m_RsrcExtensionDLL;
  142. std::auto_ptr<CDynLinkLibrary> m_apExtDll;
  143. static CspProfile *m_pInstance;
  144. };
  145. }
  146. #endif // SLBCSP_PROFILE_H