[KSECDD]
[reactos.git] / reactos / drivers / crypto / ksecdd / random.c
index 392ad0f..0dc1b59 100644 (file)
@@ -9,10 +9,6 @@
 /* INCLUDES *******************************************************************/
 
 #include "ksecdd.h"
-#include <ndk/exfuncs.h>
-#include <ndk/kefuncs.h>
-#include <pseh/pseh2.h>
-#include <md4.h>
 
 #define NDEBUG
 #include <debug.h>
@@ -31,11 +27,13 @@ KsecGenRandom(
     PVOID Buffer,
     SIZE_T Length)
 {
+    LARGE_INTEGER TickCount;
     ULONG i, RandomValue;
     PULONG P;
 
     /* Try to generate a more random seed */
-    KsecRandomSeed ^= _rotl(KeTickCount.LowPart, (KsecRandomSeed % 23));
+    KeQueryTickCount(&TickCount);
+    KsecRandomSeed ^= _rotl(TickCount.LowPart, (KsecRandomSeed % 23));
 
     P = Buffer;
     for (i = 0; i < Length / sizeof(ULONG); i++)
@@ -65,10 +63,10 @@ KsecReadMachineSpecificCounters(
         /* Read the TSC value */
         MachineSpecificCounters->Tsc = __rdtsc();
     }
-
+#if 0 // FIXME: investigate what the requirements are for these
     /* Read the CPU event counter MSRs */
-    MachineSpecificCounters->Ctr0 = __readmsr(0x12);
-    MachineSpecificCounters->Ctr1 = __readmsr(0x13);
+    //MachineSpecificCounters->Ctr0 = __readmsr(0x12);
+    //MachineSpecificCounters->Ctr1 = __readmsr(0x13);
 
     /* Check if this is an MMX capable CPU */
     if (ExIsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE))
@@ -77,6 +75,7 @@ KsecReadMachineSpecificCounters(
         MachineSpecificCounters->Pmc0 = __readpmc(0);
         MachineSpecificCounters->Pmc1 = __readpmc(1);
     }
+#endif
 #else
     #error Implement me!
 #endif
@@ -94,7 +93,7 @@ KsecGatherEntropyData(
     PTEB Teb;
     PPEB Peb;
     PWSTR String;
-    ULONG ReturnLength;
+    SIZE_T ReturnLength;
     NTSTATUS Status;
 
     /* Query some generic values */
@@ -125,7 +124,7 @@ KsecGatherEntropyData(
             /* Update the MD4 context from the environment data */
             MD4Update(&Md4Context,
                       (PUCHAR)Peb->ProcessParameters->Environment,
-                      (PUCHAR)String - (PUCHAR)Peb->ProcessParameters->Environment);
+                      (ULONG)((PUCHAR)String - (PUCHAR)Peb->ProcessParameters->Environment));
         }
         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {