summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rand/randtest.c
diff options
context:
space:
mode:
authormarkus <>2002-09-05 12:51:52 +0000
committermarkus <>2002-09-05 12:51:52 +0000
commit5514995a9d5ed91db089875adb509c7781357c0e (patch)
tree2484410a46ba6c05ef94c253da36fbceef990b64 /src/lib/libcrypto/rand/randtest.c
parentfd9566423b542798f5c8b06e68101a9ea5bb9885 (diff)
downloadopenbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.gz
openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.bz2
openbsd-5514995a9d5ed91db089875adb509c7781357c0e.zip
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/rand/randtest.c')
-rw-r--r--src/lib/libcrypto/rand/randtest.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/lib/libcrypto/rand/randtest.c b/src/lib/libcrypto/rand/randtest.c
index e0ba61e123..b64de616db 100644
--- a/src/lib/libcrypto/rand/randtest.c
+++ b/src/lib/libcrypto/rand/randtest.c
@@ -58,7 +58,7 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include "rand.h" 61#include <openssl/rand.h>
62 62
63/* some FIPS 140-1 random number test */ 63/* some FIPS 140-1 random number test */
64/* some simple tests */ 64/* some simple tests */
@@ -73,7 +73,13 @@ int main()
73 /*double d; */ 73 /*double d; */
74 long d; 74 long d;
75 75
76 RAND_bytes(buf,2500); 76 i = RAND_pseudo_bytes(buf,2500);
77 if (i < 0)
78 {
79 printf ("init failed, the rand method is not properly installed\n");
80 err++;
81 goto err;
82 }
77 83
78 n1=0; 84 n1=0;
79 for (i=0; i<16; i++) n2[i]=0; 85 for (i=0; i<16; i++) n2[i]=0;
@@ -117,7 +123,7 @@ int main()
117 /* test 1 */ 123 /* test 1 */
118 if (!((9654 < n1) && (n1 < 10346))) 124 if (!((9654 < n1) && (n1 < 10346)))
119 { 125 {
120 printf("test 1 failed, X=%ld\n",n1); 126 printf("test 1 failed, X=%lu\n",n1);
121 err++; 127 err++;
122 } 128 }
123 printf("test 1 done\n"); 129 printf("test 1 done\n");
@@ -150,37 +156,37 @@ int main()
150 { 156 {
151 if (!((2267 < runs[i][0]) && (runs[i][0] < 2733))) 157 if (!((2267 < runs[i][0]) && (runs[i][0] < 2733)))
152 { 158 {
153 printf("test 3 failed, bit=%d run=%d num=%ld\n", 159 printf("test 3 failed, bit=%d run=%d num=%lu\n",
154 i,1,runs[i][0]); 160 i,1,runs[i][0]);
155 err++; 161 err++;
156 } 162 }
157 if (!((1079 < runs[i][1]) && (runs[i][1] < 1421))) 163 if (!((1079 < runs[i][1]) && (runs[i][1] < 1421)))
158 { 164 {
159 printf("test 3 failed, bit=%d run=%d num=%ld\n", 165 printf("test 3 failed, bit=%d run=%d num=%lu\n",
160 i,2,runs[i][1]); 166 i,2,runs[i][1]);
161 err++; 167 err++;
162 } 168 }
163 if (!(( 502 < runs[i][2]) && (runs[i][2] < 748))) 169 if (!(( 502 < runs[i][2]) && (runs[i][2] < 748)))
164 { 170 {
165 printf("test 3 failed, bit=%d run=%d num=%ld\n", 171 printf("test 3 failed, bit=%d run=%d num=%lu\n",
166 i,3,runs[i][2]); 172 i,3,runs[i][2]);
167 err++; 173 err++;
168 } 174 }
169 if (!(( 223 < runs[i][3]) && (runs[i][3] < 402))) 175 if (!(( 223 < runs[i][3]) && (runs[i][3] < 402)))
170 { 176 {
171 printf("test 3 failed, bit=%d run=%d num=%ld\n", 177 printf("test 3 failed, bit=%d run=%d num=%lu\n",
172 i,4,runs[i][3]); 178 i,4,runs[i][3]);
173 err++; 179 err++;
174 } 180 }
175 if (!(( 90 < runs[i][4]) && (runs[i][4] < 223))) 181 if (!(( 90 < runs[i][4]) && (runs[i][4] < 223)))
176 { 182 {
177 printf("test 3 failed, bit=%d run=%d num=%ld\n", 183 printf("test 3 failed, bit=%d run=%d num=%lu\n",
178 i,5,runs[i][4]); 184 i,5,runs[i][4]);
179 err++; 185 err++;
180 } 186 }
181 if (!(( 90 < runs[i][5]) && (runs[i][5] < 223))) 187 if (!(( 90 < runs[i][5]) && (runs[i][5] < 223)))
182 { 188 {
183 printf("test 3 failed, bit=%d run=%d num=%ld\n", 189 printf("test 3 failed, bit=%d run=%d num=%lu\n",
184 i,6,runs[i][5]); 190 i,6,runs[i][5]);
185 err++; 191 err++;
186 } 192 }
@@ -190,17 +196,18 @@ int main()
190 /* test 4 */ 196 /* test 4 */
191 if (runs[0][33] != 0) 197 if (runs[0][33] != 0)
192 { 198 {
193 printf("test 4 failed, bit=%d run=%d num=%ld\n", 199 printf("test 4 failed, bit=%d run=%d num=%lu\n",
194 0,34,runs[0][33]); 200 0,34,runs[0][33]);
195 err++; 201 err++;
196 } 202 }
197 if (runs[1][33] != 0) 203 if (runs[1][33] != 0)
198 { 204 {
199 printf("test 4 failed, bit=%d run=%d num=%ld\n", 205 printf("test 4 failed, bit=%d run=%d num=%lu\n",
200 1,34,runs[1][33]); 206 1,34,runs[1][33]);
201 err++; 207 err++;
202 } 208 }
203 printf("test 4 done\n"); 209 printf("test 4 done\n");
210 err:
204 err=((err)?1:0); 211 err=((err)?1:0);
205 exit(err); 212 exit(err);
206 return(err); 213 return(err);