X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=util%2Fmkdef.pl;h=2de27c078aefb922eac3329bd4a67b2158adc12f;hp=c0ca92cf21b4161a52bb934dc9439999b627d7bf;hb=65b1ff4a14b44c293d5488c68502e50e8f05981e;hpb=2854c7989db45d528b7e9b1f9f7f40112c316933 diff --git a/util/mkdef.pl b/util/mkdef.pl index c0ca92cf21..2de27c078a 100755 --- a/util/mkdef.pl +++ b/util/mkdef.pl @@ -38,10 +38,14 @@ # exclude. # +use lib "."; +use configdata; +use File::Spec::Functions; + my $debug=0; -my $crypto_num= "util/libeay.num"; -my $ssl_num= "util/ssleay.num"; +my $crypto_num= catfile($config{sourcedir},"util","libeay.num"); +my $ssl_num= catfile($config{sourcedir},"util","ssleay.num"); my $libname; my $do_update = 0; @@ -84,6 +88,8 @@ my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF", "CRYPTO_MDEBUG", # Engines "STATIC_ENGINE", "ENGINE", "HW", "GMP", + # Entropy Gathering + "EGD", # X.509v3 Signed Certificate Timestamps "SCT", # RFC3779 @@ -101,7 +107,9 @@ my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF", # NEXTPROTONEG "NEXTPROTONEG", # Deprecated functions - "DEPRECATED", + "DEPRECATEDIN_0_9_8", + "DEPRECATEDIN_1_0_0", + "DEPRECATEDIN_1_1_0", # SCTP "SCTP", # SRTP @@ -121,17 +129,12 @@ my %disabled_algorithms; foreach (@known_algorithms) { $disabled_algorithms{$_} = 0; } - -my $options=""; -open(IN,") { - $options=$1 if (/^OPTIONS=(.*)$/); -} -close(IN); +# disabled by default +$disabled_algorithms{"STATIC_ENGINE"} = 1; my $zlib; -foreach (@ARGV, split(/ /, $options)) +foreach (@ARGV, split(/ /, $config{options})) { $debug=1 if $_ eq "debug"; $W32=1 if $_ eq "32"; @@ -174,8 +177,23 @@ foreach (@ARGV, split(/ /, $options)) $do_ctestall=1 if $_ eq "ctestall"; $do_checkexist=1 if $_ eq "exist"; #$safe_stack_def=1 if $_ eq "-DDEBUG_SAFESTACK"; - - if (/^(enable|disable|no)-(.*)$/) { + if (/^--api=(\d+)\.(\d+)\.(\d+)$/) { + my $apiv = sprintf "%x%02x%02x", $1, $2, $3; + foreach (keys %disabled_algorithms) { + if (/^DEPRECATEDIN_(\d+)_(\d+)_(\d+)$/) { + my $depv = sprintf "%x%02x%02x", $1, $2, $3; + $disabled_algorithms{$_} = 1 if $apiv ge $depv; + } + } + } + if (/^no-deprecated$/) { + foreach (keys %disabled_algorithms) { + if (/^DEPRECATEDIN_/) { + $disabled_algorithms{$_} = 1; + } + } + } + elsif (/^(enable|disable|no)-(.*)$/) { my $alg = uc $2; $alg =~ tr/-/_/; if (exists $disabled_algorithms{$alg}) { @@ -216,10 +234,9 @@ my $ssl="include/openssl/ssl.h"; $ssl.=" include/openssl/tls1.h"; $ssl.=" include/openssl/srtp.h"; +# We use headers found in include/openssl and include/internal only. +# The latter is needed so libssl.so/.dll/.exe can link properly. my $crypto ="include/openssl/crypto.h"; -$crypto.=" crypto/include/internal/cryptlib.h"; -$crypto.=" crypto/include/internal/chacha.h"; # unless $no_chacha; -$crypto.=" crypto/include/internal/poly1305.h"; # unless $no_poly1305; $crypto.=" include/internal/o_dir.h"; $crypto.=" include/internal/o_str.h"; $crypto.=" include/openssl/des.h" ; # unless $no_des; @@ -275,7 +292,6 @@ $crypto.=" include/openssl/comp.h" ; # unless $no_comp; $crypto.=" include/openssl/ocsp.h"; $crypto.=" include/openssl/ui.h"; #$crypto.=" include/openssl/store.h"; -$crypto.=" include/openssl/pqueue.h"; $crypto.=" include/openssl/cms.h"; $crypto.=" include/openssl/jpake.h"; $crypto.=" include/openssl/srp.h"; @@ -368,8 +384,9 @@ sub do_defs foreach $file (split(/\s+/,$symhacksfile." ".$files)) { - print STDERR "DEBUG: starting on $file:\n" if $debug; - open(IN,"<$file") || die "unable to open $file:$!\n"; + my $fn = catfile($config{sourcedir},$file); + print STDERR "DEBUG: starting on $fn:\n" if $debug; + open(IN,"<$fn") || die "unable to open $fn:$!\n"; my $line = "", my $def= ""; my %tag = ( (map { $_ => 0 } @known_platforms), @@ -439,14 +456,15 @@ sub do_defs print STDERR "DEBUG: parsing ----------\n" if $debug; while() { if($parens > 0) { - #Inside a DECLARE_DEPRECATED + #Inside a DEPRECATEDIN $stored_multiline .= $_; - chomp $stored_multiline; - print STDERR "DEBUG: Continuing multiline DEPRECATED: $stored_multiline\n" if $debug; + $stored_multiline =~ s|\R$||; # Better chomp + print STDERR "DEBUG: Continuing multiline DEPRECATEDIN: $stored_multiline\n" if $debug; $parens = count_parens($stored_multiline); if ($parens == 0) { - $stored_multiline =~ /^\s*DECLARE_DEPRECATED\s*\(\s*(\w*(\s|\*|\w)*)/; - $def .= "$1(void);"; + $def .= do_deprecated($stored_multiline, + \@current_platforms, + \@current_algorithms); } next; } @@ -461,9 +479,7 @@ sub do_defs } if (/\\$/) { - chomp; # remove eol - chop; # remove ending backslash - $line = $_; + $line = $`; # keep what was before the backslash next; } @@ -480,7 +496,7 @@ sub do_defs $cpp++ if /^#\s*if/; $cpp-- if /^#\s*endif/; next; - } + } $cpp = 1 if /^#.*ifdef.*cplusplus/; s/{[^{}]*}//gs; # ignore {} blocks @@ -840,14 +856,16 @@ sub do_defs &$make_variant("_shadow_$2","_shadow_$2", "EXPORT_VAR_AS_FUNCTION", "FUNCTION"); - } elsif (/^\s*DECLARE_DEPRECATED\s*\(\s*(\w*(\s|\*|\w)*)/) { + } elsif (/^\s*DEPRECATEDIN/) { $parens = count_parens($_); if ($parens == 0) { - $def .= "$1(void);"; + $def .= do_deprecated($_, + \@current_platforms, + \@current_algorithms); } else { $stored_multiline = $_; - chomp $stored_multiline; - print STDERR "DEBUG: Found multiline DEPRECATED starting with: $stored_multiline\n" if $debug; + $stored_multiline =~ s|\R$||; + print STDERR "DEBUG: Found multiline DEPRECATEDIN starting with: $stored_multiline\n" if $debug; next; } } elsif ($tag{'CONST_STRICT'} != 1) { @@ -912,21 +930,6 @@ sub do_defs $p = $plats; $a = $algs; - $a .= ",BF" if($s =~ /EVP_bf/); - $a .= ",CAST" if($s =~ /EVP_cast/); - $a .= ",DES" if($s =~ /EVP_des/); - $a .= ",DSA" if($s =~ /EVP_dss/); - $a .= ",IDEA" if($s =~ /EVP_idea/); - $a .= ",MD2" if($s =~ /EVP_md2/); - $a .= ",MD4" if($s =~ /EVP_md4/); - $a .= ",MD5" if($s =~ /EVP_md5/); - $a .= ",RC2" if($s =~ /EVP_rc2/); - $a .= ",RC4" if($s =~ /EVP_rc4/); - $a .= ",RC5" if($s =~ /EVP_rc5/); - $a .= ",RMD160" if($s =~ /EVP_ripemd/); - $a .= ",RSA" if($s =~ /EVP_(Open|Seal)(Final|Init)/); - $a .= ",RSA" if($s =~ /RSAPrivateKey/); - $a .= ",RSA" if($s =~ /SSLv23?_((client|server)_)?method/); $platform{$s} = &reduce_platforms((defined($platform{$s})?$platform{$s}.',':"").$p); @@ -1024,7 +1027,8 @@ sub reduce_platforms return $ret; } -sub info_string { +sub info_string +{ (my $symbol, my $exist, my $platforms, my $kind, my $algorithms) = @_; my %a = defined($algorithms) ? @@ -1042,13 +1046,13 @@ sub info_string { return $ret; } -sub maybe_add_info { +sub maybe_add_info +{ (my $name, *nums, my @symbols) = @_; my $sym; my $new_info = 0; my %syms=(); - print STDERR "Updating $name info\n"; foreach $sym (@symbols) { (my $s, my $i) = split /\\/, $sym; if (defined($nums{$s})) { @@ -1072,12 +1076,11 @@ sub maybe_add_info { } } if ($new_info) { - print STDERR "$new_info old symbols got an info update\n"; + print STDERR "$name: $new_info old symbols have updated info\n"; if (!$do_rewrite) { print STDERR "You should do a rewrite to fix this.\n"; } } else { - print STDERR "No old symbols needed info update\n"; } } @@ -1167,15 +1170,9 @@ sub print_test_file } } -sub get_version { - local *MF; - my $v = '?'; - open MF, 'Makefile' or return $v; - while () { - $v = $1, last if /^VERSION=(.*?)\s*$/; - } - close MF; - return $v; +sub get_version +{ + return $config{version}; } sub print_def_file @@ -1191,7 +1188,7 @@ sub print_def_file my $prevsymversion = "", $prevprevsymversion = ""; # For VMS my $prevnum = 0; - my $symbolcount = 0; + my $symvtextcount = 0; if ($W32) { $libname.="32"; } @@ -1225,13 +1222,11 @@ EOF } elsif ($VMS) { - my $libref = $name eq "ssl" ? "LIBCRYPTO.EXE /SHARE" : ""; print OUT <<"EOF"; -IDENTIFICATION="LIB$libname V$version" -LIB$libname.OLB /LIBRARY -$libref +CASE_SENSITIVE=YES SYMBOL_VECTOR=(- EOF + $symvtextcount = 16; # length of "SYMBOL_VECTOR=(-" } (@r)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:FUNCTION/,@symbols); @@ -1295,25 +1290,35 @@ EOF print OUT " $s2;\n"; } elsif ($VMS) { while(++$prevnum < $n) { - if ($symbolcount > 1023) { + my $symline=" ,SPARE -\n ,SPARE -\n"; + if ($symvtextcount + length($symline) - 2 > 1024) { print OUT ")\nSYMBOL_VECTOR=(-\n"; - $symbolcount = 0; + $symvtextcount = 16; # length of "SYMBOL_VECTOR=(-" } - print OUT $symbolcount - ? " ," : " "; - print OUT "dummy$prevnum=PRIVATE_PROCEDURE -\n"; - $symbolcount++; + if ($symvtextcount == 16) { + # Take away first comma + $symline =~ s/,//; + } + print OUT $symline; + $symvtextcount += length($symline) - 2; } (my $s_uc = $s) =~ tr/a-z/A-Z/; - if ($symbolcount > 1023) { + my $symtype= + $v ? "DATA" : "PROCEDURE"; + my $symline= + ($s_uc ne $s + ? " ,$s_uc/$s=$symtype -\n ,$s=$symtype -\n" + : " ,$s=$symtype -\n ,SPARE -\n"); + if ($symvtextcount + length($symline) - 2 > 1024) { print OUT ")\nSYMBOL_VECTOR=(-\n"; - $symbolcount = 0; + $symvtextcount = 16; # length of "SYMBOL_VECTOR=(-" + } + if ($symvtextcount == 16) { + # Take away first comma + $symline =~ s/,//; } - print OUT $symbolcount - ? " ," : " "; - print OUT "$s_uc/$s=" - , ($v ? "DATA" : "PROCEDURE"), " -\n"; - $symbolcount++; + print OUT $symline; + $symvtextcount += length($symline) - 2; } elsif($v && !$OS2) { printf OUT " %s%-39s @%-8d DATA\n", ($W32)?"":"_",$s2,$n; @@ -1357,7 +1362,7 @@ sub load_numbers open(IN,"<$name") || die "unable to open $name:$!\n"; while () { - chop; + s|\R$||; # Better chomp s/#.*$//; next if /^\s*$/; @a=split; @@ -1423,8 +1428,6 @@ sub rewrite_numbers (*OUT,$name,*nums,@symbols)=@_; my $thing; - print STDERR "Rewriting $name\n"; - my @r = grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:\w+\(\w+\)/,@symbols); my $r; my %r; my %rsyms; foreach $r (@r) { @@ -1473,8 +1476,6 @@ sub update_numbers ($basevers, $vers) = get_openssl_version(); - print STDERR "Updating $name numbers\n"; - my @r = grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:\w+\(\w+\)/,@symbols); my $r; my %r; my %rsyms; foreach $r (@r) { @@ -1504,9 +1505,9 @@ sub update_numbers } } if($new_syms) { - print STDERR "$new_syms New symbols added\n"; + print STDERR "$name: Added $new_syms new symbols\n"; } else { - print STDERR "No New symbols Added\n"; + print STDERR "$name: No new symbols added\n"; } } @@ -1547,12 +1548,13 @@ sub count_parens #version sub get_openssl_version() { - open (IN, "include/openssl/opensslv.h") || die "Can't open opensslv.h"; + my $fn = catfile($config{sourcedir},"include","openssl","opensslv.h"); + open (IN, "$fn") || die "Can't open opensslv.h"; while() { if (/OPENSSL_VERSION_TEXT\s+"OpenSSL (\d\.\d\.)(\d[a-z]*)(-| )/) { my $suffix = $2; - my $baseversion = $1 =~ s/\./_/gr; + (my $baseversion = $1) =~ s/\./_/g; close IN; return ($baseversion."0", $baseversion.$suffix); } @@ -1672,3 +1674,16 @@ sub check_version_lte() if (($cvbase ne $tvbase) && ($tvletter gt $cvletter)); } } + +sub do_deprecated() +{ + my ($decl, $plats, $algs) = @_; + $decl =~ /^\s*(DEPRECATEDIN_\d+_\d+_\d+)\s*\((.*)\)\s*$/ + or die "Bad DEPRECTEDIN: $decl\n"; + my $info1 .= "#INFO:"; + $info1 .= join(',', @{$plats}) . ":"; + my $info2 = $info1; + $info1 .= join(',',@{$algs}, $1) . ";"; + $info2 .= join(',',@{$algs}) . ";"; + return $info1 . $2 . ";" . $info2; +}