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.

177 lines
4.3 KiB

  1. // V1ContRec.h -- declaration of CV1ContainerRecord
  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(SLBCCI_V1CONTREC_H)
  8. #define SLBCCI_V1CONTREC_H
  9. #include <string>
  10. #include <windows.h>
  11. #include "V1Card.h"
  12. namespace
  13. {
  14. struct ContainerBuffer;
  15. }
  16. namespace cci
  17. {
  18. class CV1ContainerRecord
  19. {
  20. public:
  21. // Types
  22. enum CreateMode
  23. {
  24. cmAlways,
  25. cmConditionally,
  26. cmNever,
  27. cmNoCheck,
  28. };
  29. // C'tors/D'tors
  30. explicit
  31. CV1ContainerRecord(CV1Card const &rv1card,
  32. std::string const &rsCntrType,
  33. CreateMode mode);
  34. ~CV1ContainerRecord();
  35. // Operators
  36. // Operations
  37. std::string
  38. ComputeSignature(KeySpec ks,
  39. std::string const &rsCipher) const;
  40. void
  41. Delete() const;
  42. void
  43. Name(std::string const &rsNewName);
  44. void
  45. Read(KeySpec ks,
  46. iop::CPublicKeyBlob &rKeyBlob) const;
  47. void
  48. Read(KeySpec ks,
  49. std::string &rsBlob) const;
  50. void
  51. Write(KeySpec ks,
  52. CPrivateKeyBlob const &rblob);
  53. void
  54. Write(KeySpec ks,
  55. iop::CPublicKeyBlob const &rKeyBlob);
  56. void
  57. Write(KeySpec ks,
  58. std::string const &rsBlob) const;
  59. // Access
  60. static std::string
  61. CertName();
  62. static std::string
  63. DefaultName();
  64. std::string
  65. Name() const;
  66. // Predicates
  67. bool
  68. Exists() const;
  69. bool
  70. KeyExists(KeySpec ks) const;
  71. protected:
  72. // Types
  73. // C'tors/D'tors
  74. // Operators
  75. // Operations
  76. // Access
  77. // Predicates
  78. // Variables
  79. private:
  80. // Types
  81. // ContainerBuffer is written to the card one byte after the next,
  82. // no padding between the bytes. Therefore the pack pragma is
  83. // necessary to prevent the compiler from aligning the members on
  84. // n-byte boundaries.
  85. #pragma pack(push, 1)
  86. struct ContainerBuffer
  87. {
  88. enum
  89. {
  90. cMaxContainerNameLength = 10,
  91. };
  92. WORD Size;
  93. BYTE Name[cMaxContainerNameLength];
  94. DWORD XK_dwExp;
  95. WORD XK_wLen;
  96. DWORD SK_dwExp;
  97. WORD SK_wLen;
  98. };
  99. #pragma pack(pop)
  100. // C'tors/D'tors
  101. // Operators
  102. // Operations
  103. void
  104. Create() const;
  105. DWORD
  106. FindOffset(DWORD &rdwOffset) const;
  107. void
  108. GetContainer(DWORD dwOffset,
  109. ContainerBuffer &rcontainer) const;
  110. bool
  111. GetContainerContent(KeySpec ks,
  112. std::string &rsBuffer,
  113. DWORD &rdwExponent) const;
  114. DWORD
  115. OpenContainer() const;
  116. DWORD
  117. SetContainer(DWORD dwOffset) const;
  118. void
  119. Write(KeySpec ks,
  120. BYTE const *pbModulus,
  121. WORD wModulusLength,
  122. DWORD dwExponent) const;
  123. // Access
  124. // Predicates
  125. bool
  126. IsDefault() const;
  127. // Variables
  128. CV1Card const &m_rcard;
  129. std::string const m_sCntrType;
  130. char const *m_szKeyPath;
  131. };
  132. } // namespace cci
  133. #endif // SLBCCI_V1CONTREC_H