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.

131 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. cr.h
  5. Abstract:
  6. Local Security Authority - Encryption Routine Definitions
  7. NOTE: This file is included via lsacomp.h. It should
  8. not be included directly.
  9. Author:
  10. Scott Birrell (ScottBi) December 13, 1991
  11. Environment:
  12. Revision History:
  13. --*/
  14. //
  15. // Max encryption Key Length
  16. //
  17. #define LSAP_CR_MAX_CIPHER_KEY_LENGTH (0x00000010L)
  18. //
  19. // Cipher Key Structure
  20. //
  21. typedef struct _LSAP_CR_CIPHER_KEY {
  22. ULONG Length;
  23. ULONG MaximumLength;
  24. PUCHAR Buffer;
  25. } LSAP_CR_CIPHER_KEY, *PLSAP_CR_CIPHER_KEY;
  26. //
  27. // Clear value structure
  28. //
  29. typedef struct _LSAP_CR_CLEAR_VALUE {
  30. ULONG Length;
  31. ULONG MaximumLength;
  32. PUCHAR Buffer;
  33. } LSAP_CR_CLEAR_VALUE, *PLSAP_CR_CLEAR_VALUE;
  34. //
  35. // Two-way encrypted value structure in Self-relative form. This
  36. // is just like a String.
  37. //
  38. typedef struct _LSAP_CR_CIPHER_VALUE {
  39. ULONG Length;
  40. ULONG MaximumLength;
  41. PUCHAR Buffer;
  42. } LSAP_CR_CIPHER_VALUE, *PLSAP_CR_CIPHER_VALUE;
  43. NTSTATUS
  44. LsapCrClientGetSessionKey(
  45. IN LSA_HANDLE ObjectHandle,
  46. OUT PLSAP_CR_CIPHER_KEY *SessionKey
  47. );
  48. NTSTATUS
  49. LsapCrServerGetSessionKey(
  50. IN LSA_HANDLE ObjectHandle,
  51. OUT PLSAP_CR_CIPHER_KEY *SessionKey
  52. );
  53. NTSTATUS
  54. LsapCrEncryptValue(
  55. IN PLSAP_CR_CLEAR_VALUE ClearValue,
  56. IN PLSAP_CR_CIPHER_KEY CipherKey,
  57. OUT PLSAP_CR_CIPHER_VALUE *CipherValue
  58. );
  59. NTSTATUS
  60. LsapCrDecryptValue(
  61. IN PLSAP_CR_CIPHER_VALUE CipherValue,
  62. IN PLSAP_CR_CIPHER_KEY CipherKey,
  63. OUT PLSAP_CR_CLEAR_VALUE *ClearValue
  64. );
  65. VOID
  66. LsapCrFreeMemoryValue(
  67. IN PVOID MemoryValue
  68. );
  69. VOID
  70. LsapCrUnicodeToClearValue(
  71. IN PUNICODE_STRING UnicodeString,
  72. OUT PLSAP_CR_CLEAR_VALUE ClearValue
  73. );
  74. VOID
  75. LsapCrClearValueToUnicode(
  76. IN PLSAP_CR_CLEAR_VALUE ClearValue,
  77. OUT PUNICODE_STRING UnicodeString
  78. );
  79. #define LsapCrRtlEncryptData(ClearData, CipherKey, CipherData) \
  80. ( \
  81. RtlEncryptData( \
  82. (PCLEAR_DATA) ClearData, \
  83. (PDATA_KEY) CipherKey, \
  84. (PCYPHER_DATA) CipherData \
  85. ) \
  86. )
  87. #define LsapCrRtlDecryptData(ClearData, CipherKey, CipherData) \
  88. ( \
  89. RtlDecryptData( \
  90. (PCLEAR_DATA) ClearData, \
  91. (PDATA_KEY) CipherKey, \
  92. (PCYPHER_DATA) CipherData \
  93. ) \
  94. )