summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/util/mkdef.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/util/mkdef.pl')
-rw-r--r--src/lib/libcrypto/util/mkdef.pl139
1 files changed, 120 insertions, 19 deletions
diff --git a/src/lib/libcrypto/util/mkdef.pl b/src/lib/libcrypto/util/mkdef.pl
index 80384af325..4e2845a4e1 100644
--- a/src/lib/libcrypto/util/mkdef.pl
+++ b/src/lib/libcrypto/util/mkdef.pl
@@ -6,26 +6,34 @@
6# prototyped functions: it then prunes the output. 6# prototyped functions: it then prunes the output.
7# 7#
8 8
9$crypto_num="util/libeay.num"; 9my $crypto_num="util/libeay.num";
10$ssl_num= "util/ssleay.num"; 10my $ssl_num= "util/ssleay.num";
11 11
12my $do_update = 0; 12my $do_update = 0;
13my $do_crypto = 0; 13my $do_crypto = 0;
14my $do_ssl = 0; 14my $do_ssl = 0;
15$rsaref = 0; 15my $do_ctest = 0;
16my $rsaref = 0;
16 17
17$W32=1; 18my $W32=1;
18$NT=0; 19my $NT=0;
19# Set this to make typesafe STACK definitions appear in DEF 20# Set this to make typesafe STACK definitions appear in DEF
20$safe_stack_def = 1; 21my $safe_stack_def = 1;
21 22
22$options=""; 23my $options="";
23open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n"; 24open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
24while(<IN>) { 25while(<IN>) {
25 $options=$1 if (/^OPTIONS=(.*)$/); 26 $options=$1 if (/^OPTIONS=(.*)$/);
26} 27}
27close(IN); 28close(IN);
28 29
30# The following ciphers may be excluded (by Configure). This means functions
31# defined with ifndef(NO_XXX) are not included in the .def file, and everything
32# in directory xxx is ignored.
33my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
34my $no_cast; my $no_md2; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
35my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0;
36
29foreach (@ARGV, split(/ /, $options)) 37foreach (@ARGV, split(/ /, $options))
30 { 38 {
31 $W32=1 if $_ eq "32"; 39 $W32=1 if $_ eq "32";
@@ -39,6 +47,7 @@ foreach (@ARGV, split(/ /, $options))
39 $do_crypto=1 if $_ eq "libeay"; 47 $do_crypto=1 if $_ eq "libeay";
40 $do_crypto=1 if $_ eq "crypto"; 48 $do_crypto=1 if $_ eq "crypto";
41 $do_update=1 if $_ eq "update"; 49 $do_update=1 if $_ eq "update";
50 $do_ctest=1 if $_ eq "ctest";
42 $rsaref=1 if $_ eq "rsaref"; 51 $rsaref=1 if $_ eq "rsaref";
43 52
44 if (/^no-rc2$/) { $no_rc2=1; } 53 if (/^no-rc2$/) { $no_rc2=1; }
@@ -59,6 +68,7 @@ foreach (@ARGV, split(/ /, $options))
59 elsif (/^no-hmac$/) { $no_hmac=1; } 68 elsif (/^no-hmac$/) { $no_hmac=1; }
60 } 69 }
61 70
71
62if (!$do_ssl && !$do_crypto) 72if (!$do_ssl && !$do_crypto)
63 { 73 {
64 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ] [rsaref]\n"; 74 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ] [rsaref]\n";
@@ -70,9 +80,9 @@ $max_ssl = $max_num;
70%crypto_list=&load_numbers($crypto_num); 80%crypto_list=&load_numbers($crypto_num);
71$max_crypto = $max_num; 81$max_crypto = $max_num;
72 82
73$ssl="ssl/ssl.h"; 83my $ssl="ssl/ssl.h";
74 84
75$crypto ="crypto/crypto.h"; 85my $crypto ="crypto/crypto.h";
76$crypto.=" crypto/des/des.h" unless $no_des; 86$crypto.=" crypto/des/des.h" unless $no_des;
77$crypto.=" crypto/idea/idea.h" unless $no_idea; 87$crypto.=" crypto/idea/idea.h" unless $no_idea;
78$crypto.=" crypto/rc4/rc4.h" unless $no_rc4; 88$crypto.=" crypto/rc4/rc4.h" unless $no_rc4;
@@ -115,8 +125,8 @@ $crypto.=" crypto/rand/rand.h";
115$crypto.=" crypto/comp/comp.h"; 125$crypto.=" crypto/comp/comp.h";
116$crypto.=" crypto/tmdiff.h"; 126$crypto.=" crypto/tmdiff.h";
117 127
118@ssl_func = &do_defs("SSLEAY", $ssl); 128my @ssl_func = &do_defs("SSLEAY", $ssl);
119@crypto_func = &do_defs("LIBEAY", $crypto); 129my @crypto_func = &do_defs("LIBEAY", $crypto);
120 130
121 131
122if ($do_update) { 132if ($do_update) {
@@ -131,7 +141,26 @@ if($do_crypto == 1) {
131 open(OUT, ">>$crypto_num"); 141 open(OUT, ">>$crypto_num");
132 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto, @crypto_func); 142 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto, @crypto_func);
133 close OUT; 143 close OUT;
134} 144}
145
146} elsif ($do_ctest) {
147
148 print <<"EOF";
149
150/* Test file to check all DEF file symbols are present by trying
151 * to link to all of them. This is *not* intended to be run!
152 */
153
154int main()
155{
156EOF
157 &print_test_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_func)
158 if $do_ssl == 1;
159
160 &print_test_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_func)
161 if $do_crypto == 1;
162
163 print "}\n";
135 164
136} else { 165} else {
137 166
@@ -147,14 +176,15 @@ if($do_crypto == 1) {
147sub do_defs 176sub do_defs
148{ 177{
149 my($name,$files)=@_; 178 my($name,$files)=@_;
179 my $file;
150 my @ret; 180 my @ret;
151 my %funcs; 181 my %funcs;
182 my $cpp;
152 183
153 foreach $file (split(/\s+/,$files)) 184 foreach $file (split(/\s+/,$files))
154 { 185 {
155 open(IN,"<$file") || die "unable to open $file:$!\n"; 186 open(IN,"<$file") || die "unable to open $file:$!\n";
156 187 my $line = "", my $def= "";
157 my $line = "", $def= "";
158 my %tag = ( 188 my %tag = (
159 FreeBSD => 0, 189 FreeBSD => 0,
160 NOPROTO => 0, 190 NOPROTO => 0,
@@ -164,6 +194,22 @@ sub do_defs
164 NO_FP_API => 0, 194 NO_FP_API => 0,
165 CONST_STRICT => 0, 195 CONST_STRICT => 0,
166 TRUE => 1, 196 TRUE => 1,
197 NO_RC2 => 0,
198 NO_RC4 => 0,
199 NO_RC5 => 0,
200 NO_IDEA => 0,
201 NO_DES => 0,
202 NO_BF => 0,
203 NO_CAST => 0,
204 NO_MD2 => 0,
205 NO_MD5 => 0,
206 NO_SHA => 0,
207 NO_RIPEMD => 0,
208 NO_MDC2 => 0,
209 NO_RSA => 0,
210 NO_DSA => 0,
211 NO_DH => 0,
212 NO_HMAC => 0,
167 ); 213 );
168 while(<IN>) { 214 while(<IN>) {
169 last if (/BEGIN ERROR CODES/); 215 last if (/BEGIN ERROR CODES/);
@@ -214,6 +260,11 @@ sub do_defs
214 push(@tag,"TRUE"); 260 push(@tag,"TRUE");
215 $tag{"TRUE"}=1; 261 $tag{"TRUE"}=1;
216 next; 262 next;
263 } elsif (/^\#\s*if\s+0/) {
264 # Dummy tag
265 push(@tag,"TRUE");
266 $tag{"TRUE"}=-1;
267 next;
217 } elsif (/^\#/) { 268 } elsif (/^\#/) {
218 next; 269 next;
219 } 270 }
@@ -250,7 +301,20 @@ sub do_defs
250 } 301 }
251 $funcs{"PEM_read_bio_${1}"} = 1; 302 $funcs{"PEM_read_bio_${1}"} = 1;
252 $funcs{"PEM_write_bio_${1}"} = 1; 303 $funcs{"PEM_write_bio_${1}"} = 1;
253 } elsif ( 304 } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ ||
305 /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) {
306 if($W32) {
307 $funcs{"PEM_write_${1}"} = 1;
308 }
309 $funcs{"PEM_write_bio_${1}"} = 1;
310 } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ ||
311 /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) {
312 if($W32) {
313 $funcs{"PEM_read_${1}"} = 1;
314 }
315 $funcs{"PEM_read_bio_${1}"} = 1;
316 } elsif (
317 ($tag{'TRUE'} != -1) &&
254 ($tag{'FreeBSD'} != 1) && 318 ($tag{'FreeBSD'} != 1) &&
255 ($tag{'CONST_STRICT'} != 1) && 319 ($tag{'CONST_STRICT'} != 1) &&
256 (($W32 && ($tag{'WIN16'} != 1)) || 320 (($W32 && ($tag{'WIN16'} != 1)) ||
@@ -260,7 +324,23 @@ sub do_defs
260 ((!$W32 && $tag{'_WINDLL'} != -1) || 324 ((!$W32 && $tag{'_WINDLL'} != -1) ||
261 ($W32 && $tag{'_WINDLL'} != 1)) && 325 ($W32 && $tag{'_WINDLL'} != 1)) &&
262 ((($tag{'NO_FP_API'} != 1) && $W32) || 326 ((($tag{'NO_FP_API'} != 1) && $W32) ||
263 (($tag{'NO_FP_API'} != -1) && !$W32))) 327 (($tag{'NO_FP_API'} != -1) && !$W32)) &&
328 ($tag{'NO_RC2'} == 0 || !$no_rc2) &&
329 ($tag{'NO_RC4'} == 0 || !$no_rc4) &&
330 ($tag{'NO_RC5'} == 0 || !$no_rc5) &&
331 ($tag{'NO_IDEA'} == 0 || !$no_idea) &&
332 ($tag{'NO_DES'} == 0 || !$no_des) &&
333 ($tag{'NO_BF'} == 0 || !$no_bf) &&
334 ($tag{'NO_CAST'} == 0 || !$no_cast) &&
335 ($tag{'NO_MD2'} == 0 || !$no_md2) &&
336 ($tag{'NO_MD5'} == 0 || !$no_md5) &&
337 ($tag{'NO_SHA'} == 0 || !$no_sha) &&
338 ($tag{'NO_RIPEMD'} == 0 || !$no_ripemd) &&
339 ($tag{'NO_MDC2'} == 0 || !$no_mdc2) &&
340 ($tag{'NO_RSA'} == 0 || !$no_rsa) &&
341 ($tag{'NO_DSA'} == 0 || !$no_dsa) &&
342 ($tag{'NO_DH'} == 0 || !$no_dh) &&
343 ($tag{'NO_HMAC'} == 0 || !$no_hmac))
264 { 344 {
265 if (/{|\/\*/) { # } 345 if (/{|\/\*/) { # }
266 $line = $_; 346 $line = $_;
@@ -309,8 +389,8 @@ sub do_defs
309 # Prune the returned functions 389 # Prune the returned functions
310 390
311 delete $funcs{"SSL_add_dir_cert_subjects_to_stack"}; 391 delete $funcs{"SSL_add_dir_cert_subjects_to_stack"};
312 delete $funcs{"des_crypt"};
313 delete $funcs{"RSA_PKCS1_RSAref"} unless $rsaref; 392 delete $funcs{"RSA_PKCS1_RSAref"} unless $rsaref;
393 delete $funcs{"bn_dump1"};
314 394
315 if($W32) { 395 if($W32) {
316 delete $funcs{"BIO_s_file_internal"}; 396 delete $funcs{"BIO_s_file_internal"};
@@ -334,10 +414,31 @@ sub do_defs
334 return(@ret); 414 return(@ret);
335} 415}
336 416
417sub print_test_file
418{
419 (*OUT,my $name,*nums,my @functions)=@_;
420 my $n = 1; my @e; my @r;
421 my $func;
422
423 (@e)=grep(/^SSLeay/,@functions);
424 (@r)=grep(!/^SSLeay/,@functions);
425 @functions=((sort @e),(sort @r));
426
427 foreach $func (@functions) {
428 if (!defined($nums{$func})) {
429 printf STDERR "$func does not have a number assigned\n"
430 if(!$do_update);
431 } else {
432 $n=$nums{$func};
433 print OUT "\t$func();\n";
434 }
435 }
436}
437
337sub print_def_file 438sub print_def_file
338{ 439{
339 (*OUT,my $name,*nums,@functions)=@_; 440 (*OUT,my $name,*nums,my @functions)=@_;
340 my $n =1; 441 my $n = 1; my @e; my @r;
341 442
342 if ($W32) 443 if ($W32)
343 { $name.="32"; } 444 { $name.="32"; }