]> jfr.im git - solanum.git/blobdiff - librb/src/arc4random.c
Remove Windows support
[solanum.git] / librb / src / arc4random.c
index f6f53c76f031171d11fb379015c73c94cd07bd60..4082d3ce0eaf2cb95df28a4c3956b0fdd70b07a6 100644 (file)
@@ -91,10 +91,8 @@ arc4_stir(struct arc4_stream *as)
 {
        struct timeval tv;
        pid_t pid;
-       int n;
-#ifdef _WIN32
-       HMODULE lib;
-#endif
+       uint8_t rnd[128];
+       int fd, n;
        /* XXX this doesn't support egd sources or similiar */
 
        pid = getpid();
@@ -114,44 +112,14 @@ arc4_stir(struct arc4_stream *as)
        memset(&buf, 0, sizeof(buf))}
 #endif
 
-#if !defined(_WIN32)
+       fd = open("/dev/urandom", O_RDONLY);
+       if(fd != -1)
        {
-               uint8_t rnd[128];
-               int fd;
-               fd = open("/dev/urandom", O_RDONLY);
-               if(fd != -1)
-               {
-                       read(fd, rnd, sizeof(rnd));
-                       close(fd);
-                       arc4_addrandom(as, (void *)rnd, sizeof(rnd));
-                       memset(&rnd, 0, sizeof(rnd));
-               }
-
+               read(fd, rnd, sizeof(rnd));
+               close(fd);
+               arc4_addrandom(as, (void *)rnd, sizeof(rnd));
+               memset(&rnd, 0, sizeof(rnd));
        }
-#else
-       {
-               LARGE_INTEGER performanceCount;
-               if(QueryPerformanceCounter(&performanceCount))
-               {
-                       arc4_addrandom(as, (void *)&performanceCount, sizeof(performanceCount));
-               }
-               lib = LoadLibrary("ADVAPI32.DLL");
-               if(lib)
-               {
-                       uint8_t rnd[128];
-                       BOOLEAN(APIENTRY * pfn) (void *, ULONG) =
-                               (BOOLEAN(APIENTRY *) (void *, ULONG))GetProcAddress(lib,
-                                                                                   "SystemFunction036");
-                       if(pfn)
-                       {
-                               if(pfn(rnd, sizeof(rnd)) == TRUE)
-                                       arc4_addrandom(as, (void *)rnd, sizeof(rnd));
-                               memset(&rnd, 0, sizeof(rnd));
-                       }
-               }
-       }
-#endif
-
 
        /*
         * Throw away the first N words of output, as suggested in the