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.

216 lines
5.4 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 1991 - 1992
  6. //
  7. // File: cryptdll.h
  8. //
  9. // Contents: How to use the crypt support dll
  10. //
  11. //
  12. // History: 04 Jun 92 RichardW Created
  13. //
  14. //------------------------------------------------------------------------
  15. #ifndef __CRYPTDLL_H__
  16. #define __CRYPTDLL_H__
  17. typedef PVOID PCRYPT_STATE_BUFFER;
  18. typedef NTSTATUS (NTAPI * PCRYPT_INITIALIZE_FN)(
  19. PUCHAR,
  20. ULONG,
  21. ULONG,
  22. PCRYPT_STATE_BUFFER *
  23. );
  24. typedef NTSTATUS (NTAPI * PCRYPT_ENCRYPT_FN)(
  25. PCRYPT_STATE_BUFFER StateBuffer,
  26. PUCHAR InputBuffer,
  27. ULONG InputBufferSize,
  28. PUCHAR OutputBuffer,
  29. PULONG OutputBufferSize
  30. );
  31. typedef NTSTATUS (NTAPI * PCRYPT_DECRYPT_FN)(
  32. PCRYPT_STATE_BUFFER StateBuffer,
  33. PUCHAR InputBuffer,
  34. ULONG InputBufferSize,
  35. PUCHAR OutputBuffer,
  36. PULONG OutputBufferSize
  37. );
  38. typedef NTSTATUS (NTAPI * PCRYPT_DISCARD_FN)(
  39. PCRYPT_STATE_BUFFER *
  40. );
  41. typedef NTSTATUS (NTAPI * PCRYPT_HASH_STRING_FN)(
  42. PUNICODE_STRING String,
  43. PUCHAR Buffer
  44. );
  45. typedef NTSTATUS (NTAPI * PCRYPT_RANDOM_KEY_FN)(
  46. OPTIONAL PUCHAR Seed,
  47. OPTIONAL ULONG SeedLength,
  48. PUCHAR Key
  49. );
  50. typedef NTSTATUS (NTAPI * PCRYPT_CONTROL_FN)(
  51. IN ULONG Function,
  52. IN PCRYPT_STATE_BUFFER StateBuffer,
  53. IN PUCHAR InputBuffer,
  54. IN ULONG InputBufferSize
  55. );
  56. //
  57. // functions for CryptControl
  58. #define CRYPT_CONTROL_SET_INIT_VECT 0x1
  59. typedef struct _CRYPTO_SYSTEM {
  60. ULONG EncryptionType;
  61. ULONG BlockSize;
  62. ULONG ExportableEncryptionType;
  63. ULONG KeySize;
  64. ULONG HeaderSize;
  65. ULONG PreferredCheckSum;
  66. ULONG Attributes;
  67. PWSTR Name;
  68. PCRYPT_INITIALIZE_FN Initialize;
  69. PCRYPT_ENCRYPT_FN Encrypt;
  70. PCRYPT_DECRYPT_FN Decrypt;
  71. PCRYPT_DISCARD_FN Discard;
  72. PCRYPT_HASH_STRING_FN HashString;
  73. PCRYPT_RANDOM_KEY_FN RandomKey;
  74. PCRYPT_CONTROL_FN Control;
  75. } CRYPTO_SYSTEM, *PCRYPTO_SYSTEM;
  76. #define CSYSTEM_USE_PRINCIPAL_NAME 0x01
  77. #define CSYSTEM_EXPORT_STRENGTH 0x02
  78. #define CSYSTEM_INTEGRITY_PROTECTED 0x04
  79. NTSTATUS NTAPI
  80. CDRegisterCSystem(PCRYPTO_SYSTEM);
  81. NTSTATUS NTAPI
  82. CDBuildVect(
  83. PULONG EncryptionTypesAvailable,
  84. PULONG EncryptionTypes
  85. );
  86. NTSTATUS NTAPI
  87. CDBuildIntegrityVect(
  88. PULONG pcCSystems,
  89. PULONG pdwEtypes
  90. );
  91. NTSTATUS NTAPI
  92. CDLocateCSystem(
  93. ULONG EncryptionType,
  94. PCRYPTO_SYSTEM * CryptoSystem
  95. );
  96. NTSTATUS NTAPI
  97. CDFindCommonCSystem(
  98. ULONG EncryptionTypeCount,
  99. PULONG EncryptionTypes,
  100. PULONG CommonEncryptionType
  101. );
  102. NTSTATUS NTAPI
  103. CDFindCommonCSystemWithKey(
  104. IN ULONG EncryptionEntries,
  105. IN PULONG EncryptionTypes,
  106. IN ULONG KeyTypeCount,
  107. IN PULONG KeyTypes,
  108. OUT PULONG CommonEtype
  109. );
  110. ////////////////////////////////////////////////////////////////////
  111. typedef PVOID PCHECKSUM_BUFFER;
  112. typedef NTSTATUS (NTAPI * PCHECKSUM_INITIALIZE_FN)(ULONG, PCHECKSUM_BUFFER *);
  113. typedef NTSTATUS (NTAPI * PCHECKSUM_INITIALIZEEX_FN)(PUCHAR,ULONG, ULONG, PCHECKSUM_BUFFER *);
  114. // add the ex2 function to allow the checksum to be passed in for verification
  115. // this is passed in the 4th parameter
  116. // this is necessary for checksums which use confounders, where the confounder must
  117. // be pulled from the checksum in order to calculate a new checksum when verifying
  118. typedef NTSTATUS (NTAPI * PCHECKSUM_INITIALIZEEX2_FN)(PUCHAR, ULONG, PUCHAR, ULONG, PCHECKSUM_BUFFER *);
  119. typedef NTSTATUS (NTAPI * PCHECKSUM_SUM_FN)(PCHECKSUM_BUFFER, ULONG, PUCHAR);
  120. typedef NTSTATUS (NTAPI * PCHECKSUM_FINALIZE_FN)(PCHECKSUM_BUFFER, PUCHAR);
  121. typedef NTSTATUS (NTAPI * PCHECKSUM_FINISH_FN)(PCHECKSUM_BUFFER *);
  122. typedef struct _CHECKSUM_FUNCTION {
  123. ULONG CheckSumType;
  124. ULONG CheckSumSize;
  125. ULONG Attributes;
  126. PCHECKSUM_INITIALIZE_FN Initialize;
  127. PCHECKSUM_SUM_FN Sum;
  128. PCHECKSUM_FINALIZE_FN Finalize;
  129. PCHECKSUM_FINISH_FN Finish;
  130. PCHECKSUM_INITIALIZEEX_FN InitializeEx;
  131. PCHECKSUM_INITIALIZEEX2_FN InitializeEx2; // allows passing in the checksum on intialization for verification
  132. } CHECKSUM_FUNCTION, *PCHECKSUM_FUNCTION;
  133. #define CKSUM_COLLISION 0x00000001
  134. #define CKSUM_KEYED 0x00000002
  135. #define CHECKSUM_SHA1 131
  136. NTSTATUS NTAPI
  137. CDRegisterCheckSum( PCHECKSUM_FUNCTION);
  138. NTSTATUS NTAPI
  139. CDLocateCheckSum( ULONG, PCHECKSUM_FUNCTION *);
  140. //////////////////////////////////////////////////////////////
  141. typedef BOOLEAN (NTAPI * PRANDOM_NUMBER_GENERATOR_FN)(PUCHAR, ULONG);
  142. typedef struct _RANDOM_NUMBER_GENERATOR {
  143. ULONG GeneratorId;
  144. ULONG Attributes;
  145. ULONG Seed;
  146. PRANDOM_NUMBER_GENERATOR_FN GenerateBitstream;
  147. } RANDOM_NUMBER_GENERATOR, *PRANDOM_NUMBER_GENERATOR;
  148. #define RNG_PSEUDO_RANDOM 0x00000001 // Pseudo-random function
  149. #define RNG_NOISE_CIRCUIT 0x00000002 // Noise circuit (ZNR diode, eg)
  150. #define RNG_NATURAL_PHENOM 0x00000004 // Natural sampler (geiger counter)
  151. BOOLEAN NTAPI
  152. CDGenerateRandomBits(PUCHAR pBuffer,
  153. ULONG cbBuffer);
  154. BOOLEAN NTAPI
  155. CDRegisterRng(PRANDOM_NUMBER_GENERATOR pRng);
  156. BOOLEAN NTAPI
  157. CDLocateRng(ULONG Id,
  158. PRANDOM_NUMBER_GENERATOR * ppRng);
  159. #define CD_BUILTIN_RNG 1
  160. ///////////////////////////////////////////////////////////
  161. //
  162. // Error codes
  163. //
  164. ///////////////////////////////////////////////////////////
  165. #define SEC_E_ETYPE_NOT_SUPP 0x80080341
  166. #define SEC_E_CHECKSUM_NOT_SUPP 0x80080342
  167. #endif