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.

108 lines
4.0 KiB

  1. // CryptoCard.h: interface for the CCryptoCard class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(CRYPTOCARD_H__INCLUDED_)
  5. #define CRYPTOCARD_H__INCLUDED_
  6. #include "NoWarning.h"
  7. #include "DllSymDefn.h"
  8. #include "SmartCard.h"
  9. namespace iop
  10. {
  11. struct CryptoACL
  12. {
  13. BYTE Level; // ranges from 0 to 15
  14. BYTE CHVnumber; // Number of the CHV is requested, equal to 0 by default
  15. BYTE AUTnumber; // Number of the AUT is requested, equal to 0 by default
  16. BYTE CHVcounter;
  17. BYTE AUTcounter;
  18. };
  19. class IOPDLL_API CCryptoCard : public CSmartCard
  20. {
  21. public:
  22. void GetACL(BYTE *bACL);
  23. CCryptoCard(const SCARDHANDLE hCardHandle, const char* szReaderName,
  24. const SCARDCONTEXT pContext, const DWORD dwMode);
  25. virtual ~CCryptoCard();
  26. virtual void DeleteFile(const WORD wFileID);
  27. virtual void CreateFile(const FILE_HEADER* pMyFile);
  28. virtual void SelectParent();
  29. virtual void Directory (const BYTE bFile_Nb, FILE_HEADER* pMyFile);
  30. virtual void Select (const char* szFileFullPath, FILE_HEADER* pMyFile = NULL, const bool fSelectAll = false);
  31. virtual void VerifyKey (const BYTE bKeyNumber, const BYTE bKeyLength, const BYTE* bKey);
  32. virtual void VerifyCHV (const BYTE bCHVNumber, const BYTE* bCHV);
  33. virtual void VerifyTransportKey(const BYTE *bKey);
  34. virtual void GetChallenge(const DWORD dwNumberLength, BYTE* bRandomNumber);
  35. virtual void ExternalAuth(const KeyType kt, const BYTE bKeyNb,
  36. const BYTE bDataLength, const BYTE* bData);
  37. virtual void InternalAuth(const KeyType kt, const BYTE bKeyNb,
  38. const BYTE bDataLength, const BYTE* bDataIn, BYTE* bDataOut);
  39. virtual void ReadPublicKey (CPublicKeyBlob *aKey, const BYTE bKeyNum);
  40. virtual void WritePublicKey (const CPublicKeyBlob aKey, const BYTE bKeyNum);
  41. virtual void WritePrivateKey(const CPrivateKeyBlob aKey, const BYTE bKeyNum);
  42. virtual CPublicKeyBlob GenerateKeyPair(const BYTE *bpPublExp, const WORD wPublExpLen,
  43. const BYTE bKeyNum, const KeyType kt);
  44. virtual void ChangeACL (const BYTE *bACL);
  45. virtual void ChangeCHV (const BYTE bKey_nb, const BYTE *bOldCHV, const BYTE *bNewCHV);
  46. virtual void ChangeCHV (const BYTE bKey_nb, const BYTE *bNewCHV);
  47. virtual void UnblockCHV (const BYTE bKey_nb, const BYTE *bUnblockPIN, const BYTE *bNewPin);
  48. virtual void ChangeUnblockKey (const BYTE bKey_nb, const BYTE *bNewPIN);
  49. virtual void ChangeTransportKey(const BYTE *bNewKey);
  50. virtual void GetSerial(BYTE* bSerial, size_t &SerialLength);
  51. virtual void LogoutAll();
  52. protected:
  53. virtual void
  54. DefaultDispatchError(ClassByte cb,
  55. Instruction ins,
  56. StatusWord sw) const;
  57. virtual void
  58. DispatchError(ClassByte cb,
  59. Instruction ins,
  60. StatusWord sw) const;
  61. virtual void
  62. DoReadBlock(WORD wOffset,
  63. BYTE *pbBuffer,
  64. BYTE bLength);
  65. virtual void
  66. DoWriteBlock(WORD wOffset,
  67. BYTE const *pbBuffer,
  68. BYTE cLength);
  69. virtual bool
  70. SupportLogout();
  71. virtual void Select(const WORD wFileID);
  72. void AccessToCryptoACL(bool* fAccessACL, CryptoACL* pCryptoACL);
  73. void CryptoToAccessACL(BYTE* bAccessACL, const BYTE bACLNibble,
  74. const BYTE bKeyNibble, const BYTE bShift);
  75. private:
  76. enum // Instruction
  77. {
  78. insChangeChv = 0x24,
  79. insUnblockChv = 0x2C,
  80. insKeyGeneration = 0x46,
  81. };
  82. BYTE m_bLastACL[4];
  83. };
  84. }
  85. #endif // !defined(AFX_CRYPTOCARD_H__INCLUDED_)