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.

132 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. ah.h
  5. Abstract:
  6. Contains AH specific structures
  7. Author:
  8. Sanjay Anand (SanjayAn) 2-January-1997
  9. ChunYe
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. #ifndef _AH_
  15. #define _AH_
  16. #define MD5DIGESTLEN 16
  17. #define SHADIGESTLEN 20
  18. #define AH_SIZE (sizeof(AH) + MD5DIGESTLEN * sizeof(UCHAR))
  19. //
  20. // State buffers for the individual algorithms
  21. //
  22. typedef struct _AlgoState {
  23. union { // internal algo state
  24. MD5_CTX as_md5ctx;
  25. A_SHA_CTX as_shactx;
  26. };
  27. PSA_TABLE_ENTRY as_sa;
  28. } ALGO_STATE, *PALGO_STATE;
  29. typedef NTSTATUS
  30. (*PALGO_INIT) (
  31. PALGO_STATE pEntry,
  32. ULONG Index
  33. );
  34. typedef NTSTATUS
  35. (*PALGO_UPDATE) (
  36. PALGO_STATE State,
  37. PUCHAR Data,
  38. ULONG Length
  39. );
  40. typedef NTSTATUS
  41. (*PALGO_FINISH) (
  42. PALGO_STATE State,
  43. PUCHAR Data,
  44. ULONG Index
  45. );
  46. //
  47. // Array of function ptrs for the AH authentication algorithms
  48. //
  49. typedef struct _auth_algorithm {
  50. PALGO_INIT init; // ptr to init fn for alg.
  51. PALGO_UPDATE update; // ptr to update fn for alg
  52. PALGO_FINISH finish; // ptr to finish fn for alg
  53. ULONG OutputLen; // Length (in u_int8s) of output
  54. // data. MUST be a multiple of 4
  55. } AUTH_ALGO, *PAUTH_ALGO;
  56. #define NUM_AUTH_ALGOS (sizeof(auth_algorithms)/sizeof(AUTH_ALGO)-1)
  57. //
  58. // The IPSEC AH payload
  59. //
  60. typedef struct _AH {
  61. UCHAR ah_next;
  62. UCHAR ah_len;
  63. USHORT ah_reserved;
  64. tSPI ah_spi;
  65. ULONG ah_replay;
  66. } AH, *PAH;
  67. NTSTATUS
  68. IPSecCreateAH(
  69. IN PUCHAR pIPHeader,
  70. IN PVOID pData,
  71. IN PSA_TABLE_ENTRY pSA,
  72. IN ULONG Index,
  73. OUT PVOID *ppNewData,
  74. OUT PVOID *ppSCContext,
  75. OUT PULONG pExtraBytes,
  76. IN ULONG HdrSpace,
  77. IN BOOLEAN fSrcRoute,
  78. IN BOOLEAN fCryptoOnly
  79. );
  80. NTSTATUS
  81. IPSecVerifyAH(
  82. IN PUCHAR *pIPHeader,
  83. IN PVOID pData,
  84. IN PSA_TABLE_ENTRY pSA,
  85. IN ULONG Index,
  86. OUT PULONG pExtraBytes,
  87. IN BOOLEAN fSrcRoute,
  88. IN BOOLEAN fCryptoDone,
  89. IN BOOLEAN fFastRcv
  90. );
  91. NTSTATUS
  92. IPSecGenerateHash(
  93. IN PUCHAR pIPHeader,
  94. IN PVOID pData,
  95. IN PSA_TABLE_ENTRY pSA,
  96. IN PUCHAR pAHData,
  97. IN BOOLEAN fMuteDest,
  98. IN BOOLEAN fIncoming,
  99. IN PAUTH_ALGO pAlgo,
  100. IN ULONG Index
  101. );
  102. #endif _AH_