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.

178 lines
4.2 KiB

  1. //+-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) Microsoft Corporation 1991 - 1992
  6. //
  7. // File: crypt.c
  8. //
  9. // Contents: Root DLL file
  10. //
  11. //
  12. // History: 04 Jun 92 RichardW Created
  13. //
  14. //------------------------------------------------------------------------
  15. #include <nt.h>
  16. #include <ntrtl.h>
  17. #include <nturtl.h>
  18. #include <windows.h>
  19. #include <security.h>
  20. #include <cryptdll.h>
  21. #include <kerbcon.h>
  22. //#define DONT_SUPPORT_OLD_ETYPES 1
  23. // List Default CryptoSystems here. If you add anything, be sure to add it
  24. // in the LoadCSystems() function
  25. extern CRYPTO_SYSTEM csRC4_HMAC;
  26. extern CRYPTO_SYSTEM csRC4_HMAC_EXP;
  27. extern CRYPTO_SYSTEM csRC4_LM;
  28. extern CRYPTO_SYSTEM csRC4_PLAIN;
  29. extern CRYPTO_SYSTEM csRC4_PLAIN_EXP;
  30. #ifndef DONT_SUPPORT_OLD_ETYPES
  31. extern CRYPTO_SYSTEM csRC4_MD4;
  32. extern CRYPTO_SYSTEM csRC4_HMAC_OLD;
  33. extern CRYPTO_SYSTEM csRC4_HMAC_OLD_EXP;
  34. extern CRYPTO_SYSTEM csRC4_PLAIN_OLD;
  35. extern CRYPTO_SYSTEM csRC4_PLAIN_OLD_EXP;
  36. #endif
  37. extern CRYPTO_SYSTEM csDES_MD5;
  38. extern CRYPTO_SYSTEM csDES_CRC32;
  39. extern CRYPTO_SYSTEM csDES_PLAIN;
  40. extern CRYPTO_SYSTEM csNULL;
  41. extern CHECKSUM_FUNCTION csfMD4;
  42. extern CHECKSUM_FUNCTION csfMD5;
  43. extern CHECKSUM_FUNCTION csfCRC32;
  44. extern CHECKSUM_FUNCTION csfKERB_CRC32;
  45. extern CHECKSUM_FUNCTION csfSHA;
  46. extern CHECKSUM_FUNCTION csfLM;
  47. extern CHECKSUM_FUNCTION csfRC4_MD5;
  48. extern CHECKSUM_FUNCTION csfDES_MAC_MD5;
  49. extern CHECKSUM_FUNCTION csfMD5_HMAC;
  50. extern CHECKSUM_FUNCTION csfHMAC_MD5;
  51. extern CHECKSUM_FUNCTION csfMD25;
  52. extern CHECKSUM_FUNCTION csfDesMac;
  53. extern CHECKSUM_FUNCTION csfDesMacK;
  54. extern CHECKSUM_FUNCTION csfDesMac1510;
  55. extern CHECKSUM_FUNCTION csfDES_MAC_MD5_1510;
  56. extern RANDOM_NUMBER_GENERATOR DefaultRng;
  57. SECURITY_STATUS LoadCSystems(void);
  58. SECURITY_STATUS LoadCheckSums(void);
  59. BOOLEAN LoadRngs(void);
  60. #ifdef WIN32_CHICAGO
  61. BOOL Sys003Initialize (PVOID hInstance, ULONG dwReason, PVOID lpReserved);
  62. #endif // WIN32_CHICAGO
  63. int
  64. LibAttach(
  65. HANDLE hInstance,
  66. PVOID lpReserved)
  67. {
  68. SECURITY_STATUS scRet;
  69. scRet = LoadCSystems();
  70. scRet = LoadCheckSums();
  71. (void) LoadRngs();
  72. if (scRet)
  73. return(0);
  74. else
  75. return(1);
  76. }
  77. #ifndef KERNEL_MODE
  78. #define _DECL_DLLMAIN
  79. #include <process.h>
  80. BOOL WINAPI DllMain (
  81. HANDLE hInstance,
  82. ULONG dwReason,
  83. PVOID lpReserved)
  84. {
  85. #ifdef WIN32_CHICAGO
  86. if (!Sys003Initialize ((PVOID) hInstance, dwReason, NULL ))
  87. {
  88. // Something really bad happened
  89. return FALSE;
  90. }
  91. #endif // WIN32_CHICAGO
  92. if ( dwReason == DLL_PROCESS_ATTACH )
  93. {
  94. DisableThreadLibraryCalls ( hInstance );
  95. return LibAttach ( hInstance, lpReserved );
  96. }
  97. else
  98. return TRUE;
  99. }
  100. #endif // KERNEL_MODE
  101. SECURITY_STATUS
  102. LoadCSystems(void)
  103. {
  104. //
  105. // The order here is the order of preference
  106. //
  107. CDRegisterCSystem( &csRC4_HMAC);
  108. #ifndef DONT_SUPPORT_OLD_ETYPES
  109. CDRegisterCSystem( &csRC4_HMAC_OLD);
  110. CDRegisterCSystem( &csRC4_MD4);
  111. #endif
  112. CDRegisterCSystem( &csDES_MD5);
  113. CDRegisterCSystem( &csDES_CRC32);
  114. CDRegisterCSystem( &csRC4_PLAIN);
  115. CDRegisterCSystem( &csRC4_PLAIN_EXP);
  116. CDRegisterCSystem( &csRC4_HMAC_EXP);
  117. #ifndef DONT_SUPPORT_OLD_ETYPES
  118. CDRegisterCSystem( &csRC4_HMAC_OLD_EXP);
  119. CDRegisterCSystem( &csRC4_PLAIN_OLD);
  120. CDRegisterCSystem( &csRC4_PLAIN_OLD_EXP);
  121. #endif
  122. CDRegisterCSystem( &csDES_PLAIN);
  123. return(0);
  124. }
  125. SECURITY_STATUS
  126. LoadCheckSums(void)
  127. {
  128. CDRegisterCheckSum( &csfMD5_HMAC );
  129. CDRegisterCheckSum( &csfHMAC_MD5 );
  130. CDRegisterCheckSum( &csfMD4);
  131. CDRegisterCheckSum( &csfMD5);
  132. CDRegisterCheckSum( &csfKERB_CRC32);
  133. CDRegisterCheckSum( &csfDES_MAC_MD5 );
  134. CDRegisterCheckSum( &csfMD25 );
  135. CDRegisterCheckSum( &csfDesMac );
  136. CDRegisterCheckSum( &csfRC4_MD5 );
  137. CDRegisterCheckSum( &csfCRC32);
  138. #ifndef KERNEL_MODE
  139. CDRegisterCheckSum( &csfLM );
  140. #endif
  141. CDRegisterCheckSum( &csfSHA );
  142. CDRegisterCheckSum( &csfDES_MAC_MD5_1510 );
  143. CDRegisterCheckSum( &csfDesMac1510 );
  144. CDRegisterCheckSum( &csfDesMacK );
  145. return(0);
  146. }
  147. BOOLEAN
  148. LoadRngs(void)
  149. {
  150. CDRegisterRng(&DefaultRng);
  151. return(TRUE);
  152. }