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.

167 lines
4.1 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. int
  61. LibAttach(
  62. HANDLE hInstance,
  63. PVOID lpReserved)
  64. {
  65. SECURITY_STATUS scRet;
  66. scRet = LoadCSystems();
  67. scRet = LoadCheckSums();
  68. (void) LoadRngs();
  69. if (scRet)
  70. return(0);
  71. else
  72. return(1);
  73. }
  74. #ifndef KERNEL_MODE
  75. #define _DECL_DLLMAIN
  76. #include <process.h>
  77. BOOL WINAPI DllMain (
  78. HANDLE hInstance,
  79. ULONG dwReason,
  80. PVOID lpReserved)
  81. {
  82. if ( dwReason == DLL_PROCESS_ATTACH )
  83. {
  84. DisableThreadLibraryCalls ( hInstance );
  85. return LibAttach ( hInstance, lpReserved );
  86. }
  87. else
  88. return TRUE;
  89. }
  90. #endif // KERNEL_MODE
  91. SECURITY_STATUS
  92. LoadCSystems(void)
  93. {
  94. //
  95. // The order here is the order of preference
  96. //
  97. CDRegisterCSystem( &csRC4_HMAC);
  98. #ifndef DONT_SUPPORT_OLD_ETYPES
  99. CDRegisterCSystem( &csRC4_HMAC_OLD);
  100. CDRegisterCSystem( &csRC4_MD4);
  101. #endif
  102. CDRegisterCSystem( &csDES_MD5);
  103. CDRegisterCSystem( &csDES_CRC32);
  104. CDRegisterCSystem( &csRC4_PLAIN);
  105. CDRegisterCSystem( &csRC4_PLAIN_EXP);
  106. CDRegisterCSystem( &csRC4_HMAC_EXP);
  107. #ifndef DONT_SUPPORT_OLD_ETYPES
  108. CDRegisterCSystem( &csRC4_HMAC_OLD_EXP);
  109. CDRegisterCSystem( &csRC4_PLAIN_OLD);
  110. CDRegisterCSystem( &csRC4_PLAIN_OLD_EXP);
  111. #endif
  112. CDRegisterCSystem( &csDES_PLAIN);
  113. return(0);
  114. }
  115. SECURITY_STATUS
  116. LoadCheckSums(void)
  117. {
  118. CDRegisterCheckSum( &csfMD5_HMAC );
  119. CDRegisterCheckSum( &csfHMAC_MD5 );
  120. CDRegisterCheckSum( &csfMD4);
  121. CDRegisterCheckSum( &csfMD5);
  122. CDRegisterCheckSum( &csfKERB_CRC32);
  123. CDRegisterCheckSum( &csfDES_MAC_MD5 );
  124. CDRegisterCheckSum( &csfMD25 );
  125. CDRegisterCheckSum( &csfDesMac );
  126. CDRegisterCheckSum( &csfRC4_MD5 );
  127. CDRegisterCheckSum( &csfCRC32);
  128. #ifndef KERNEL_MODE
  129. CDRegisterCheckSum( &csfLM );
  130. #endif
  131. CDRegisterCheckSum( &csfSHA );
  132. CDRegisterCheckSum( &csfDES_MAC_MD5_1510 );
  133. CDRegisterCheckSum( &csfDesMac1510 );
  134. CDRegisterCheckSum( &csfDesMacK );
  135. return(0);
  136. }
  137. BOOLEAN
  138. LoadRngs(void)
  139. {
  140. CDRegisterRng(&DefaultRng);
  141. return(TRUE);
  142. }