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.

158 lines
4.5 KiB

  1. /*++
  2. KEYTAB.H
  3. Unix Keytab routines and data structures
  4. Copyright(C) 1997 Microsoft Corporation
  5. Created, 01-10-1997 DavidCHR
  6. --*/
  7. typedef unsigned char krb5_octet, K5_OCTET, *PK5_OCTET;
  8. typedef unsigned short krb5_int16, K5_INT16, *PK5_INT16;
  9. typedef unsigned long krb5_timestamp, K5_TIMESTAMP, *PK5_TIMESTAMP;
  10. typedef unsigned long krb5_int32, K5_INT32, *PK5_INT32;
  11. typedef struct _raw_ktcomp {
  12. K5_INT16 szComponentData; /* string length (including NULL) of component */
  13. PCHAR Component; /* key component name, like "host" */
  14. } KTCOMPONENT, *PKTCOMPONENT;
  15. /* this is the structure of a single kerberos service key entry */
  16. typedef struct _raw_ktent {
  17. K5_INT32 keySize; /* I am guessing that this is the keysize */
  18. K5_INT16 cEntries; /* number of KTCOMPONENTs */
  19. K5_INT16 szRealm; /* string length of Realm (including null) */
  20. PCHAR Realm; /* Kerberos realm in question */
  21. PKTCOMPONENT Components; /* kerberos key components. For example:
  22. host/davidchr_unix1.microsoft.com -->
  23. host and davidchr_unix1.microsoft.com are
  24. separate key components. */
  25. K5_INT32 PrincType; /* Principal type-- not sure what this is */
  26. K5_TIMESTAMP TimeStamp; /* Timestamp (seconds since the epoch) */
  27. K5_OCTET Version; /* key version number */
  28. K5_INT16 KeyType; /* Key Type -- not sure what this is either */
  29. #if 0 /* For some reason, the documentation I was reading
  30. erroneously listed this as a 32-bit value. */
  31. K5_INT32 KeyLength; /* size of key data (next field) */
  32. #else
  33. K5_INT16 KeyLength; /* size of key data (next field) */
  34. K5_INT16 foo_padding; // padding for alpha compilers.
  35. #endif
  36. PK5_OCTET KeyData; /* raw key data-- might as well be an LPBYTE */
  37. struct _raw_ktent *nextEntry;
  38. } KTENT, *PKTENT;
  39. /* this is the rough structure of the keytab file */
  40. typedef struct _raw_keytab {
  41. K5_INT16 Version;
  42. #if 0
  43. ULONG cEntries; /* this is not actually stored. It's the number of
  44. pktents we have in memory (below) */
  45. PKTENT KeyEntries;
  46. #else
  47. PKTENT FirstKeyEntry; /* This is a pointer to the first key in the
  48. linked list. In the file, they're just there,
  49. in no particular order though. */
  50. PKTENT LastKeyEntry; /* This is the list tail. */
  51. #endif
  52. } KTFILE, *PKTFILE;
  53. VOID
  54. FreeKeyTab( PKTFILE pktfile_to_free );
  55. BOOL
  56. ReadKeytabFromFile( PKTFILE *ppktfile, // free with FreeKeyTab when done
  57. PCHAR filename );
  58. BOOL
  59. WriteKeytabToFile( PKTFILE ktfile,
  60. PCHAR filename );
  61. /* These are the values to use for the OPTION_MASK to DisplayKeytab : */
  62. #define KT_COMPONENTS 0x001 /* key components (key's name) */
  63. #define KT_REALM 0x002 /* key realm-- useful */
  64. #define KT_PRINCTYPE 0x004 /* Principal type */
  65. #define KT_VNO 0x008 /* Key version number */
  66. #define KT_KTVNO 0x010 /* Keytab version number */
  67. #define KT_KEYTYPE 0x020 /* type of key (encryption type) */
  68. #define KT_KEYLENGTH 0x040 /* length of key-- not useful */
  69. #define KT_KEYDATA 0x080 /* key data -- not generally useful */
  70. #define KT_TIMESTAMP 0x100 /* timestamp (unix timestamp) */
  71. #define KT_RESERVED 0x200 /* wierd ULONG at the beginning of every key */
  72. #define KT_ENCTYPE KT_KEYTYPE
  73. #define KT_EVERYTHING 0x3ff
  74. #define KT_DEFAULT (KT_COMPONENTS | KT_REALM | KT_VNO | KT_KTVNO | KT_KEYTYPE | KT_PRINCTYPE )
  75. #ifdef __cplusplus
  76. #define OPTIONAL_PARAMETER( param, default_value ) param=default_value
  77. #else
  78. #define OPTIONAL_PARAMETER( param, default_value ) param
  79. #endif
  80. VOID
  81. DisplayKeytab( FILE *stream,
  82. PKTFILE ktfile,
  83. OPTIONAL_PARAMETER( ULONG options, KT_DEFAULT) );
  84. PVOID
  85. KEYTAB_ALLOC ( ULONG numBytes );
  86. VOID
  87. KEYTAB_FREE ( PVOID toFree );
  88. K5_INT32
  89. ComputeKeytabLength ( PKTENT thisKeyEntry );
  90. /* base linklist operations */
  91. BOOL
  92. AddEntryToKeytab( PKTFILE Keytab,
  93. PKTENT Entry,
  94. OPTIONAL_PARAMETER( BOOL copy, FALSE ));
  95. BOOL
  96. RemoveEntryFromKeytab( PKTFILE Keytab,
  97. PKTENT Entry,
  98. OPTIONAL_PARAMETER( BOOL dealloc, FALSE ) );
  99. VOID
  100. FreeKeyEntry( PKTENT pEntry );
  101. PKTENT
  102. CloneKeyEntry( PKTENT pEntry );
  103. BOOL
  104. KtCreateKey( PKTENT *ppKeyEntry,
  105. PCHAR principal,
  106. PCHAR password,
  107. PCHAR realmname,
  108. K5_OCTET keyVersionNumber,
  109. ULONG principalType,
  110. ULONG keyType,
  111. ULONG cryptosystem );