aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--win32/isaac.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/win32/isaac.c b/win32/isaac.c
index f419a3f2e..6b174b69e 100644
--- a/win32/isaac.c
+++ b/win32/isaac.c
@@ -118,7 +118,7 @@ static void randinit(isaac_t *t, int flag)
118 fn(&dt); \ 118 fn(&dt); \
119 u = (uint32_t *)&dt; \ 119 u = (uint32_t *)&dt; \
120 for (j=0; j<sizeof(dt)/sizeof(uint32_t); ++j) { \ 120 for (j=0; j<sizeof(dt)/sizeof(uint32_t); ++j) { \
121 t->randrsl[i++] = *u++; \ 121 t->randrsl[i++ % 256] = *u++; \
122 } 122 }
123 123
124/* 124/*
@@ -128,15 +128,14 @@ static void randinit(isaac_t *t, int flag)
128 */ 128 */
129static void get_entropy(isaac_t *t) 129static void get_entropy(isaac_t *t)
130{ 130{
131 int i, j, len; 131 int i, j;
132 FILETIME tm; 132 FILETIME tm;
133 MEMORYSTATUS ms; 133 MEMORYSTATUS ms;
134 SYSTEM_INFO si; 134 SYSTEM_INFO si;
135 LARGE_INTEGER pc; 135 LARGE_INTEGER pc;
136 uint32_t *u; 136 uint32_t *u;
137 char *env, *s; 137 char *env, *s;
138 md5_ctx_t ctx; 138 unsigned char *p;
139 unsigned char buf[16];
140 139
141 i = 0; 140 i = 0;
142 t->randrsl[i++] = (uint32_t)GetProcessId(GetCurrentProcess()); 141 t->randrsl[i++] = (uint32_t)GetProcessId(GetCurrentProcess());
@@ -150,27 +149,18 @@ static void get_entropy(isaac_t *t)
150 149
151 env = GetEnvironmentStringsA(); 150 env = GetEnvironmentStringsA();
152 151
153 /* get length of environment: it ends with two nuls */ 152 /* environment ends with two nuls */
154 for (s=env,len=0; *s && *(s+1); ++s,++len) 153 p = (unsigned char *)t->randrsl;
155 ; 154 i *= sizeof(uint32_t);
156 155 for (s=env; *s || *(s+1); ++s)
157 md5_begin(&ctx); 156 p[i++ % (256 * sizeof(uint32_t))] ^= *s;
158 md5_hash(&ctx, env, len);
159 md5_end(&ctx, buf);
160 157
161 FreeEnvironmentStringsA(env); 158 FreeEnvironmentStringsA(env);
162 159
163 u = (uint32_t *)buf;
164 for (j=0; j<sizeof(buf)/sizeof(uint32_t); ++j) {
165 t->randrsl[i++] = *u++;
166 }
167
168#if 0 160#if 0
169 { 161 {
170 unsigned char *p = (unsigned char *)t->randrsl; 162 for (j=0; j<256; ++j) {
171 163 fprintf(stderr, "%02x", p[j]);
172 for (j=0; j<i*sizeof(uint32_t); ++j) {
173 fprintf(stderr, "%02x", *p++);
174 if ((j&31) == 31) { 164 if ((j&31) == 31) {
175 fprintf(stderr, "\n"); 165 fprintf(stderr, "\n");
176 } 166 }