summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bf
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/bf
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/bf')
-rw-r--r--src/lib/libcrypto/bf/asm/bf-686.pl1
-rw-r--r--src/lib/libcrypto/bf/bf_opts.c65
-rw-r--r--src/lib/libcrypto/bf/bfs.cpp2
-rw-r--r--src/lib/libcrypto/bf/bfspeed.c63
-rw-r--r--src/lib/libcrypto/bf/bftest.c61
5 files changed, 83 insertions, 109 deletions
diff --git a/src/lib/libcrypto/bf/asm/bf-686.pl b/src/lib/libcrypto/bf/asm/bf-686.pl
index bed303d786..8e4c25f598 100644
--- a/src/lib/libcrypto/bf/asm/bf-686.pl
+++ b/src/lib/libcrypto/bf/asm/bf-686.pl
@@ -1,4 +1,3 @@
1#!/usr/bin/perl
2#!/usr/local/bin/perl 1#!/usr/local/bin/perl
3 2
4push(@INC,"perlasm","../../perlasm"); 3push(@INC,"perlasm","../../perlasm");
diff --git a/src/lib/libcrypto/bf/bf_opts.c b/src/lib/libcrypto/bf/bf_opts.c
index 5cfa60c537..171dada2ca 100644
--- a/src/lib/libcrypto/bf/bf_opts.c
+++ b/src/lib/libcrypto/bf/bf_opts.c
@@ -59,19 +59,17 @@
59/* define PART1, PART2, PART3 or PART4 to build only with a few of the options. 59/* define PART1, PART2, PART3 or PART4 to build only with a few of the options.
60 * This is for machines with 64k code segment size restrictions. */ 60 * This is for machines with 64k code segment size restrictions. */
61 61
62#ifndef MSDOS 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
66#include <stdio.h> 66#include <stdio.h>
67#ifndef MSDOS 67
68#include <unistd.h> 68#include <openssl/e_os2.h>
69#else 69#include OPENSSL_UNISTD_IO
70#include <io.h> 70OPENSSL_DECLARE_EXIT
71extern void exit(); 71
72#endif
73#include <signal.h> 72#include <signal.h>
74#ifndef VMS
75#ifndef _IRIX 73#ifndef _IRIX
76#include <time.h> 74#include <time.h>
77#endif 75#endif
@@ -79,25 +77,26 @@ extern void exit();
79#include <sys/types.h> 77#include <sys/types.h>
80#include <sys/times.h> 78#include <sys/times.h>
81#endif 79#endif
82#else /* VMS */ 80
83#include <types.h> 81/* Depending on the VMS version, the tms structure is perhaps defined.
84struct tms { 82 The __TMS macro will show if it was. If it wasn't defined, we should
85 time_t tms_utime; 83 undefine TIMES, since that tells the rest of the program how things
86 time_t tms_stime; 84 should be handled. -- Richard Levitte */
87 time_t tms_uchild; /* I dunno... */ 85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
88 time_t tms_uchildsys; /* so these names are a guess :-) */ 86#undef TIMES
89 }
90#endif 87#endif
88
91#ifndef TIMES 89#ifndef TIMES
92#include <sys/timeb.h> 90#include <sys/timeb.h>
93#endif 91#endif
94 92
95#ifdef sun 93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
96#include <limits.h> 95#include <limits.h>
97#include <sys/param.h> 96#include <sys/param.h>
98#endif 97#endif
99 98
100#include "blowfish.h" 99#include <openssl/blowfish.h>
101 100
102#define BF_DEFAULT_OPTIONS 101#define BF_DEFAULT_OPTIONS
103 102
@@ -126,11 +125,7 @@ struct tms {
126#ifndef HZ 125#ifndef HZ
127# ifndef CLK_TCK 126# ifndef CLK_TCK
128# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */ 127# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
129# ifndef VMS 128# define HZ 100.0
130# define HZ 100.0
131# else /* VMS */
132# define HZ 100.0
133# endif
134# else /* _BSD_CLK_TCK_ */ 129# else /* _BSD_CLK_TCK_ */
135# define HZ ((double)_BSD_CLK_TCK_) 130# define HZ ((double)_BSD_CLK_TCK_)
136# endif 131# endif
@@ -142,12 +137,7 @@ struct tms {
142#define BUFSIZE ((long)1024) 137#define BUFSIZE ((long)1024)
143long run=0; 138long run=0;
144 139
145#ifndef NOPROTO
146double Time_F(int s); 140double Time_F(int s);
147#else
148double Time_F();
149#endif
150
151#ifdef SIGALRM 141#ifdef SIGALRM
152#if defined(__STDC__) || defined(sgi) 142#if defined(__STDC__) || defined(sgi)
153#define SIGRETTYPE void 143#define SIGRETTYPE void
@@ -155,14 +145,8 @@ double Time_F();
155#define SIGRETTYPE int 145#define SIGRETTYPE int
156#endif 146#endif
157 147
158#ifndef NOPROTO
159SIGRETTYPE sig_done(int sig); 148SIGRETTYPE sig_done(int sig);
160#else 149SIGRETTYPE sig_done(int sig)
161SIGRETTYPE sig_done();
162#endif
163
164SIGRETTYPE sig_done(sig)
165int sig;
166 { 150 {
167 signal(SIGALRM,sig_done); 151 signal(SIGALRM,sig_done);
168 run=0; 152 run=0;
@@ -175,8 +159,7 @@ int sig;
175#define START 0 159#define START 0
176#define STOP 1 160#define STOP 1
177 161
178double Time_F(s) 162double Time_F(int s)
179int s;
180 { 163 {
181 double ret; 164 double ret;
182#ifdef TIMES 165#ifdef TIMES
@@ -237,9 +220,7 @@ int s;
237 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \ 220 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
238 tm[index]*8,1.0e6/tm[index]); 221 tm[index]*8,1.0e6/tm[index]);
239 222
240int main(argc,argv) 223int main(int argc, char **argv)
241int argc;
242char **argv;
243 { 224 {
244 long count; 225 long count;
245 static unsigned char buf[BUFSIZE]; 226 static unsigned char buf[BUFSIZE];
@@ -261,7 +242,7 @@ char **argv;
261 } 242 }
262 243
263#ifndef TIMES 244#ifndef TIMES
264 fprintf(stderr,"To get the most acurate results, try to run this\n"); 245 fprintf(stderr,"To get the most accurate results, try to run this\n");
265 fprintf(stderr,"program when this computer is idle.\n"); 246 fprintf(stderr,"program when this computer is idle.\n");
266#endif 247#endif
267 248
@@ -341,7 +322,7 @@ char **argv;
341 break; 322 break;
342 } 323 }
343 exit(0); 324 exit(0);
344#if defined(LINT) || defined(MSDOS) 325#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
345 return(0); 326 return(0);
346#endif 327#endif
347 } 328 }
diff --git a/src/lib/libcrypto/bf/bfs.cpp b/src/lib/libcrypto/bf/bfs.cpp
index 272ed2f978..d74c457760 100644
--- a/src/lib/libcrypto/bf/bfs.cpp
+++ b/src/lib/libcrypto/bf/bfs.cpp
@@ -32,7 +32,7 @@ void GetTSC(unsigned long& tsc)
32 32
33#include <stdio.h> 33#include <stdio.h>
34#include <stdlib.h> 34#include <stdlib.h>
35#include "blowfish.h" 35#include <openssl/blowfish.h>
36 36
37void main(int argc,char *argv[]) 37void main(int argc,char *argv[])
38 { 38 {
diff --git a/src/lib/libcrypto/bf/bfspeed.c b/src/lib/libcrypto/bf/bfspeed.c
index 640d820dd3..f346af64f3 100644
--- a/src/lib/libcrypto/bf/bfspeed.c
+++ b/src/lib/libcrypto/bf/bfspeed.c
@@ -59,19 +59,17 @@
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ 59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */ 60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61 61
62#ifndef MSDOS 62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES 63#define TIMES
64#endif 64#endif
65 65
66#include <stdio.h> 66#include <stdio.h>
67#ifndef MSDOS 67
68#include <unistd.h> 68#include <openssl/e_os2.h>
69#else 69#include OPENSSL_UNISTD_IO
70#include <io.h> 70OPENSSL_DECLARE_EXIT
71extern int exit(); 71
72#endif
73#include <signal.h> 72#include <signal.h>
74#ifndef VMS
75#ifndef _IRIX 73#ifndef _IRIX
76#include <time.h> 74#include <time.h>
77#endif 75#endif
@@ -79,34 +77,31 @@ extern int exit();
79#include <sys/types.h> 77#include <sys/types.h>
80#include <sys/times.h> 78#include <sys/times.h>
81#endif 79#endif
82#else /* VMS */ 80
83#include <types.h> 81/* Depending on the VMS version, the tms structure is perhaps defined.
84struct tms { 82 The __TMS macro will show if it was. If it wasn't defined, we should
85 time_t tms_utime; 83 undefine TIMES, since that tells the rest of the program how things
86 time_t tms_stime; 84 should be handled. -- Richard Levitte */
87 time_t tms_uchild; /* I dunno... */ 85#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
88 time_t tms_uchildsys; /* so these names are a guess :-) */ 86#undef TIMES
89 }
90#endif 87#endif
88
91#ifndef TIMES 89#ifndef TIMES
92#include <sys/timeb.h> 90#include <sys/timeb.h>
93#endif 91#endif
94 92
95#ifdef sun 93#if defined(sun) || defined(__ultrix)
94#define _POSIX_SOURCE
96#include <limits.h> 95#include <limits.h>
97#include <sys/param.h> 96#include <sys/param.h>
98#endif 97#endif
99 98
100#include "blowfish.h" 99#include <openssl/blowfish.h>
101 100
102/* The following if from times(3) man page. It may need to be changed */ 101/* The following if from times(3) man page. It may need to be changed */
103#ifndef HZ 102#ifndef HZ
104#ifndef CLK_TCK 103#ifndef CLK_TCK
105#ifndef VMS
106#define HZ 100.0
107#else /* VMS */
108#define HZ 100.0 104#define HZ 100.0
109#endif
110#else /* CLK_TCK */ 105#else /* CLK_TCK */
111#define HZ ((double)CLK_TCK) 106#define HZ ((double)CLK_TCK)
112#endif 107#endif
@@ -115,12 +110,7 @@ struct tms {
115#define BUFSIZE ((long)1024) 110#define BUFSIZE ((long)1024)
116long run=0; 111long run=0;
117 112
118#ifndef NOPROTO
119double Time_F(int s); 113double Time_F(int s);
120#else
121double Time_F();
122#endif
123
124#ifdef SIGALRM 114#ifdef SIGALRM
125#if defined(__STDC__) || defined(sgi) || defined(_AIX) 115#if defined(__STDC__) || defined(sgi) || defined(_AIX)
126#define SIGRETTYPE void 116#define SIGRETTYPE void
@@ -128,14 +118,8 @@ double Time_F();
128#define SIGRETTYPE int 118#define SIGRETTYPE int
129#endif 119#endif
130 120
131#ifndef NOPROTO
132SIGRETTYPE sig_done(int sig); 121SIGRETTYPE sig_done(int sig);
133#else 122SIGRETTYPE sig_done(int sig)
134SIGRETTYPE sig_done();
135#endif
136
137SIGRETTYPE sig_done(sig)
138int sig;
139 { 123 {
140 signal(SIGALRM,sig_done); 124 signal(SIGALRM,sig_done);
141 run=0; 125 run=0;
@@ -148,8 +132,7 @@ int sig;
148#define START 0 132#define START 0
149#define STOP 1 133#define STOP 1
150 134
151double Time_F(s) 135double Time_F(int s)
152int s;
153 { 136 {
154 double ret; 137 double ret;
155#ifdef TIMES 138#ifdef TIMES
@@ -185,9 +168,7 @@ int s;
185#endif 168#endif
186 } 169 }
187 170
188int main(argc,argv) 171int main(int argc, char **argv)
189int argc;
190char **argv;
191 { 172 {
192 long count; 173 long count;
193 static unsigned char buf[BUFSIZE]; 174 static unsigned char buf[BUFSIZE];
@@ -202,7 +183,7 @@ char **argv;
202#endif 183#endif
203 184
204#ifndef TIMES 185#ifndef TIMES
205 printf("To get the most acurate results, try to run this\n"); 186 printf("To get the most accurate results, try to run this\n");
206 printf("program when this computer is idle.\n"); 187 printf("program when this computer is idle.\n");
207#endif 188#endif
208 189
@@ -287,7 +268,7 @@ char **argv;
287 printf("Blowfish raw ecb bytes per sec = %12.3f (%9.3fuS)\n",b,8.0e6/b); 268 printf("Blowfish raw ecb bytes per sec = %12.3f (%9.3fuS)\n",b,8.0e6/b);
288 printf("Blowfish cbc bytes per sec = %12.3f (%9.3fuS)\n",c,8.0e6/c); 269 printf("Blowfish cbc bytes per sec = %12.3f (%9.3fuS)\n",c,8.0e6/c);
289 exit(0); 270 exit(0);
290#if defined(LINT) || defined(MSDOS) 271#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
291 return(0); 272 return(0);
292#endif 273#endif
293 } 274 }
diff --git a/src/lib/libcrypto/bf/bftest.c b/src/lib/libcrypto/bf/bftest.c
index 9266cf813a..09895f2542 100644
--- a/src/lib/libcrypto/bf/bftest.c
+++ b/src/lib/libcrypto/bf/bftest.c
@@ -62,20 +62,32 @@
62#include <stdio.h> 62#include <stdio.h>
63#include <string.h> 63#include <string.h>
64#include <stdlib.h> 64#include <stdlib.h>
65#include "blowfish.h"
66 65
67char *bf_key[2]={ 66#ifdef OPENSSL_NO_BF
67int main(int argc, char *argv[])
68{
69 printf("No BF support\n");
70 return(0);
71}
72#else
73#include <openssl/blowfish.h>
74
75#ifdef CHARSET_EBCDIC
76#include <openssl/ebcdic.h>
77#endif
78
79static char *bf_key[2]={
68 "abcdefghijklmnopqrstuvwxyz", 80 "abcdefghijklmnopqrstuvwxyz",
69 "Who is John Galt?" 81 "Who is John Galt?"
70 }; 82 };
71 83
72/* big endian */ 84/* big endian */
73BF_LONG bf_plain[2][2]={ 85static BF_LONG bf_plain[2][2]={
74 {0x424c4f57L,0x46495348L}, 86 {0x424c4f57L,0x46495348L},
75 {0xfedcba98L,0x76543210L} 87 {0xfedcba98L,0x76543210L}
76 }; 88 };
77 89
78BF_LONG bf_cipher[2][2]={ 90static BF_LONG bf_cipher[2][2]={
79 {0x324ed0feL,0xf413a203L}, 91 {0x324ed0feL,0xf413a203L},
80 {0xcc91732bL,0x8022f684L} 92 {0xcc91732bL,0x8022f684L}
81 }; 93 };
@@ -216,16 +228,16 @@ static unsigned char ofb64_ok[]={
216 0x63,0xC2,0xCF,0x80,0xDA}; 228 0x63,0xC2,0xCF,0x80,0xDA};
217 229
218#define KEY_TEST_NUM 25 230#define KEY_TEST_NUM 25
219unsigned char key_test[KEY_TEST_NUM]={ 231static unsigned char key_test[KEY_TEST_NUM]={
220 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87, 232 0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87,
221 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f, 233 0x78,0x69,0x5a,0x4b,0x3c,0x2d,0x1e,0x0f,
222 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77, 234 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,
223 0x88}; 235 0x88};
224 236
225unsigned char key_data[8]= 237static unsigned char key_data[8]=
226 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}; 238 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10};
227 239
228unsigned char key_out[KEY_TEST_NUM][8]={ 240static unsigned char key_out[KEY_TEST_NUM][8]={
229 {0xF9,0xAD,0x59,0x7C,0x49,0xDB,0x00,0x5E}, 241 {0xF9,0xAD,0x59,0x7C,0x49,0xDB,0x00,0x5E},
230 {0xE9,0x1D,0x21,0xC1,0xD9,0x61,0xA6,0xD6}, 242 {0xE9,0x1D,0x21,0xC1,0xD9,0x61,0xA6,0xD6},
231 {0xE9,0xC2,0xB7,0x0A,0x1B,0xC6,0x5C,0xF3}, 243 {0xE9,0xC2,0xB7,0x0A,0x1B,0xC6,0x5C,0xF3},
@@ -252,17 +264,9 @@ unsigned char key_out[KEY_TEST_NUM][8]={
252 {0x05,0x04,0x4B,0x62,0xFA,0x52,0xD0,0x80}, 264 {0x05,0x04,0x4B,0x62,0xFA,0x52,0xD0,0x80},
253 }; 265 };
254 266
255#ifndef NOPROTO
256static int test(void ); 267static int test(void );
257static int print_test_data(void ); 268static int print_test_data(void );
258#else 269int main(int argc, char *argv[])
259static int test();
260static int print_test_data();
261#endif
262
263int main(argc,argv)
264int argc;
265char *argv[];
266 { 270 {
267 int ret; 271 int ret;
268 272
@@ -275,7 +279,7 @@ char *argv[];
275 return(0); 279 return(0);
276 } 280 }
277 281
278static int print_test_data() 282static int print_test_data(void)
279 { 283 {
280 unsigned int i,j; 284 unsigned int i,j;
281 285
@@ -304,7 +308,7 @@ static int print_test_data()
304 printf("c="); 308 printf("c=");
305 for (j=0; j<8; j++) 309 for (j=0; j<8; j++)
306 printf("%02X",key_out[i][j]); 310 printf("%02X",key_out[i][j]);
307 printf(" k[%2d]=",i+1); 311 printf(" k[%2u]=",i+1);
308 for (j=0; j<i+1; j++) 312 for (j=0; j<i+1; j++)
309 printf("%02X",key_test[j]); 313 printf("%02X",key_test[j]);
310 printf("\n"); 314 printf("\n");
@@ -342,7 +346,7 @@ static int print_test_data()
342 return(0); 346 return(0);
343 } 347 }
344 348
345static int test() 349static int test(void)
346 { 350 {
347 unsigned char cbc_in[40],cbc_out[40],iv[8]; 351 unsigned char cbc_in[40],cbc_out[40],iv[8];
348 int i,n,err=0; 352 int i,n,err=0;
@@ -351,9 +355,16 @@ static int test()
351 unsigned char out[8]; 355 unsigned char out[8];
352 BF_LONG len; 356 BF_LONG len;
353 357
358#ifdef CHARSET_EBCDIC
359 ebcdic2ascii(cbc_data, cbc_data, strlen(cbc_data));
360#endif
361
354 printf("testing blowfish in raw ecb mode\n"); 362 printf("testing blowfish in raw ecb mode\n");
355 for (n=0; n<2; n++) 363 for (n=0; n<2; n++)
356 { 364 {
365#ifdef CHARSET_EBCDIC
366 ebcdic2ascii(bf_key[n], bf_key[n], strlen(bf_key[n]));
367#endif
357 BF_set_key(&key,strlen(bf_key[n]),(unsigned char *)bf_key[n]); 368 BF_set_key(&key,strlen(bf_key[n]),(unsigned char *)bf_key[n]);
358 369
359 data[0]=bf_plain[n][0]; 370 data[0]=bf_plain[n][0];
@@ -364,11 +375,11 @@ static int test()
364 printf("BF_encrypt error encrypting\n"); 375 printf("BF_encrypt error encrypting\n");
365 printf("got :"); 376 printf("got :");
366 for (i=0; i<2; i++) 377 for (i=0; i<2; i++)
367 printf("%08lX ",data[i]); 378 printf("%08lX ",(unsigned long)data[i]);
368 printf("\n"); 379 printf("\n");
369 printf("expected:"); 380 printf("expected:");
370 for (i=0; i<2; i++) 381 for (i=0; i<2; i++)
371 printf("%08lX ",bf_cipher[n][i]); 382 printf("%08lX ",(unsigned long)bf_cipher[n][i]);
372 err=1; 383 err=1;
373 printf("\n"); 384 printf("\n");
374 } 385 }
@@ -379,11 +390,11 @@ static int test()
379 printf("BF_encrypt error decrypting\n"); 390 printf("BF_encrypt error decrypting\n");
380 printf("got :"); 391 printf("got :");
381 for (i=0; i<2; i++) 392 for (i=0; i<2; i++)
382 printf("%08lX ",data[i]); 393 printf("%08lX ",(unsigned long)data[i]);
383 printf("\n"); 394 printf("\n");
384 printf("expected:"); 395 printf("expected:");
385 for (i=0; i<2; i++) 396 for (i=0; i<2; i++)
386 printf("%08lX ",bf_plain[n][i]); 397 printf("%08lX ",(unsigned long)bf_plain[n][i]);
387 printf("\n"); 398 printf("\n");
388 err=1; 399 err=1;
389 } 400 }
@@ -431,7 +442,8 @@ static int test()
431 { 442 {
432 BF_set_key(&key,n,key_test); 443 BF_set_key(&key,n,key_test);
433 BF_ecb_encrypt(key_data,out,&key,BF_ENCRYPT); 444 BF_ecb_encrypt(key_data,out,&key,BF_ENCRYPT);
434 if (memcmp(out,&(key_out[n-1][0]),8) != 0) 445 /* mips-sgi-irix6.5-gcc vv -mabi=64 bug workaround */
446 if (memcmp(out,&(key_out[i=n-1][0]),8) != 0)
435 { 447 {
436 printf("blowfish setkey error\n"); 448 printf("blowfish setkey error\n");
437 err=1; 449 err=1;
@@ -519,3 +531,4 @@ static int test()
519 531
520 return(err); 532 return(err);
521 } 533 }
534#endif