X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=util%2Fmkdef.pl;h=a6f64e3fc3a29d779f41138973b940dde468d269;hp=fa5848ace6a39cadbbe82183ee8c0c5dca2f488a;hb=c73ad690174171b63a53dabdb2f2d9ebfd30053a;hpb=6c61726b2af78a1985178d31e551351231b54b10 diff --git a/util/mkdef.pl b/util/mkdef.pl index fa5848ace6..a6f64e3fc3 100755 --- a/util/mkdef.pl +++ b/util/mkdef.pl @@ -69,22 +69,25 @@ my $do_ctestall = 0; my $do_checkexist = 0; my $VMSVAX=0; -my $VMSAlpha=0; +my $VMSNonVAX=0; my $VMS=0; my $W32=0; -my $W16=0; my $NT=0; my $OS2=0; # Set this to make typesafe STACK definitions appear in DEF my $safe_stack_def = 0; -my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT", - "EXPORT_VAR_AS_FUNCTION" ); -my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" ); +my @known_platforms = ( "__FreeBSD__", "PERL5", + "EXPORT_VAR_AS_FUNCTION", "ZLIB", + "OPENSSL_FIPS", "OPENSSL_FIPSCAPABLE" ); +my @known_ossl_platforms = ( "VMS", "WIN32", "WINNT", "OS2" ); my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF", "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1", "SHA256", "SHA512", "RIPEMD", - "MDC2", "RSA", "DSA", "DH", "EC", "ECDH", "ECDSA", "HMAC", "AES", + "MDC2", "WHIRLPOOL", "RSA", "DSA", "DH", "EC", "ECDH", "ECDSA", "EC2M", + "HMAC", "AES", "CAMELLIA", "SEED", "GOST", + # EC_NISTP_64_GCC_128 + "EC_NISTP_64_GCC_128", # Envelope "algorithms" "EVP", "X509", "ASN1_TYPEDEFS", # Helper "algorithms" @@ -94,8 +97,30 @@ my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF", "FP_API", "STDIO", "SOCK", "KRB5", "DGRAM", # Engines "STATIC_ENGINE", "ENGINE", "HW", "GMP", + # TLS + "TLSEXT", "PSK", "SRP", "HEARTBEATS", + # CMS + "CMS", + # CryptoAPI Engine + "CAPIENG", + # SSL v3 method + "SSL3_METHOD", + # JPAKE + "JPAKE", + # NEXTPROTONEG + "NEXTPROTONEG", # Deprecated functions - "DEPRECATED" ); + "DEPRECATED", + # Hide SSL internals + "SSL_INTERN", + # SCTP + "SCTP", + # SRTP + "SRTP", + # SSL TRACE + "SSL_TRACE", + # Unit testing + "UNIT_TEST"); my $options=""; open(IN," 0 } @known_platforms), (map { "OPENSSL_SYS_".$_ => 0 } @known_ossl_platforms), (map { "OPENSSL_NO_".$_ => 0 } @known_algorithms), + (map { "OPENSSL_USE_".$_ => 0 } @known_algorithms), NOPROTO => 0, PERL5 => 0, _WINDLL => 0, @@ -433,6 +499,11 @@ sub do_defs print STDERR "DEBUG: parsing ----------\n" if $debug; while() { + if($parens > 0) { + #Inside a DECLARE_DEPRECATED + $parens += count_parens($_); + next; + } if (/\/\* Error codes for the \w+ functions\. \*\//) { undef @tag; @@ -450,17 +521,22 @@ sub do_defs next; } - $cpp = 1 if /^\#.*ifdef.*cplusplus/; + if(/\/\*/) { + if (not /\*\//) { # multiline comment... + $line = $_; # ... just accumulate + next; + } else { + s/\/\*.*?\*\///gs;# wipe it + } + } + if ($cpp) { - $cpp = 0 if /^\#.*endif/; + $cpp++ if /^#\s*if/; + $cpp-- if /^#\s*endif/; next; } + $cpp = 1 if /^#.*ifdef.*cplusplus/; - s/\/\*.*?\*\///gs; # ignore comments - if (/\/\*/) { # if we have part - $line = $_; # of a comment, - next; # continue reading - } s/{[^{}]*}//gs; # ignore {} blocks print STDERR "DEBUG: \$def=\"$def\"\n" if $debug && $def ne ""; print STDERR "DEBUG: \$_=\"$_\"\n" if $debug; @@ -531,6 +607,8 @@ sub do_defs pop(@tag); if ($t =~ /^OPENSSL_NO_([A-Z0-9_]+)$/) { $t=$1; + } elsif($t =~ /^OPENSSL_USE_([A-Z0-9_]+)$/) { + $t=$1; } else { $t=""; } @@ -580,10 +658,15 @@ sub do_defs map { $tag{"OPENSSL_SYS_".$_} == 1 ? $_ : $tag{"OPENSSL_SYS_".$_} == -1 ? "!".$_ : "" } @known_ossl_platforms); + @current_algorithms = (); @current_algorithms = grep(!/^$/, map { $tag{"OPENSSL_NO_".$_} == -1 ? $_ : "" } @known_algorithms); + push @current_algorithms + , grep(!/^$/, + map { $tag{"OPENSSL_USE_".$_} == 1 ? $_ : "" } + @known_algorithms); $def .= "#INFO:" .join(',',@current_platforms).":" @@ -738,14 +821,20 @@ sub do_defs $def .= "int i2d_$1_NDEF(void);"; } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) { next; + } elsif (/^\s*DECLARE_ASN1_PRINT_FUNCTION\s*\(\s*(\w*)\s*\)/) { + $def .= "int $1_print_ctx(void);"; + next; + } elsif (/^\s*DECLARE_ASN1_PRINT_FUNCTION_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) { + $def .= "int $2_print_ctx(void);"; + next; } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) { next; } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ || - /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ) { - # Things not in Win16 + /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ || + /^DECLARE_PEM_rw_const\s*\(\s*(\w*)\s*,/ ) { $def .= "#INFO:" - .join(',',"!WIN16",@current_platforms).":" + .join(',',@current_platforms).":" .join(',',@current_algorithms).";"; $def .= "int PEM_read_$1(void);"; $def .= "int PEM_write_$1(void);"; @@ -758,11 +847,11 @@ sub do_defs $def .= "int PEM_write_bio_$1(void);"; next; } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ || + /^DECLARE_PEM_write_const\s*\(\s*(\w*)\s*,/ || /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) { - # Things not in Win16 $def .= "#INFO:" - .join(',',"!WIN16",@current_platforms).":" + .join(',',@current_platforms).":" .join(',',@current_algorithms).";"; $def .= "int PEM_write_$1(void);"; $def .= @@ -774,10 +863,9 @@ sub do_defs next; } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ || /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) { - # Things not in Win16 $def .= "#INFO:" - .join(',',"!WIN16",@current_platforms).":" + .join(',',@current_platforms).":" .join(',',@current_algorithms).";"; $def .= "int PEM_read_$1(void);"; $def .= @@ -806,6 +894,10 @@ sub do_defs &$make_variant("_shadow_$2","_shadow_$2", "EXPORT_VAR_AS_FUNCTION", "FUNCTION"); + } elsif (/^\s*DECLARE_DEPRECATED\s*\(\s*(\w*(\s|\*|\w)*)/) { + $def .= "$1(void);"; + $parens = count_parens($_); + next; } elsif ($tag{'CONST_STRICT'} != 1) { if (/\{|\/\*|\([^\)]*$/) { $line = $_; @@ -829,6 +921,18 @@ sub do_defs next if(/typedef\W/); next if(/\#define/); + # Reduce argument lists to empty () + # fold round brackets recursively: (t(*v)(t),t) -> (t{}{},t) -> {} + while(/\(.*\)/s) { + s/\([^\(\)]+\)/\{\}/gs; + s/\(\s*\*\s*(\w+)\s*\{\}\s*\)/$1/gs; #(*f{}) -> f + } + # pretend as we didn't use curly braces: {} -> () + s/\{\}/\(\)/gs; + + s/STACK_OF\(\)/void/gs; + s/LHASH_OF\(\)/void/gs; + print STDERR "DEBUG: \$_ = \"$_\"\n" if $debug; if (/^\#INFO:([^:]*):(.*)$/) { $plats = $1; @@ -839,25 +943,11 @@ sub do_defs $s = $1; $k = "VARIABLE"; print STDERR "DEBUG: found external variable $s\n" if $debug; - } elsif (/\(\*(\w*(\{[0-9]+\})?)\([^\)]+/) { - $s = $1; - print STDERR "DEBUG: found ANSI C function $s\n" if $debug; - } elsif (/\w+\W+(\w+)\W*\(\s*\)(\s*__attribute__\(.*\)\s*)?$/s) { - # K&R C - print STDERR "DEBUG: found K&R C function $s\n" if $debug; + } elsif (/TYPEDEF_\w+_OF/s) { next; - } elsif (/\w+\W+\w+(\{[0-9]+\})?\W*\(.*\)(\s*__attribute__\(.*\)\s*)?$/s) { - while (not /\(\)(\s*__attribute__\(.*\)\s*)?$/s) { - s/[^\(\)]*\)(\s*__attribute__\(.*\)\s*)?$/\)/s; - s/\([^\(\)]*\)\)(\s*__attribute__\(.*\)\s*)?$/\)/s; - } - s/\(void\)//; - /(\w+(\{[0-9]+\})?)\W*\(\)/s; - $s = $1; + } elsif (/(\w+)\s*\(\).*/s) { # first token prior [first] () is + $s = $1; # a function name! print STDERR "DEBUG: found function $s\n" if $debug; - - } elsif (/TYPEDEF_\w+_OF/) { - next; } elsif (/\(/ and not (/=/)) { print STDERR "File $file: cannot parse: $_;\n"; next; @@ -912,12 +1002,25 @@ sub do_defs # Prune the returned symbols delete $syms{"bn_dump1"}; - $platform{"BIO_s_log"} .= ",!WIN32,!WIN16,!macintosh"; + $platform{"BIO_s_log"} .= ",!WIN32,!macintosh"; $platform{"PEM_read_NS_CERT_SEQ"} = "VMS"; $platform{"PEM_write_NS_CERT_SEQ"} = "VMS"; $platform{"PEM_read_P8_PRIV_KEY_INFO"} = "VMS"; $platform{"PEM_write_P8_PRIV_KEY_INFO"} = "VMS"; + $platform{"EVP_sha384"} = "!VMSVAX"; + $platform{"EVP_sha512"} = "!VMSVAX"; + $platform{"SHA384_Init"} = "!VMSVAX"; + $platform{"SHA384_Transform"} = "!VMSVAX"; + $platform{"SHA384_Update"} = "!VMSVAX"; + $platform{"SHA384_Final"} = "!VMSVAX"; + $platform{"SHA384"} = "!VMSVAX"; + $platform{"SHA512_Init"} = "!VMSVAX"; + $platform{"SHA512_Transform"} = "!VMSVAX"; + $platform{"SHA512_Update"} = "!VMSVAX"; + $platform{"SHA512_Final"} = "!VMSVAX"; + $platform{"SHA512"} = "!VMSVAX"; + # Info we know about @@ -1042,18 +1145,26 @@ sub is_valid if ($platforms) { # platforms + if ($keyword eq "VMSVAX" && $VMSVAX) { return 1; } + if ($keyword eq "VMSNonVAX" && $VMSNonVAX) { return 1; } if ($keyword eq "VMS" && $VMS) { return 1; } if ($keyword eq "WIN32" && $W32) { return 1; } - if ($keyword eq "WIN16" && $W16) { return 1; } if ($keyword eq "WINNT" && $NT) { return 1; } if ($keyword eq "OS2" && $OS2) { return 1; } # Special platforms: # EXPORT_VAR_AS_FUNCTION means that global variables # will be represented as functions. This currently # only happens on VMS-VAX. - if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) { + if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32)) { + return 1; + } + if ($keyword eq "OPENSSL_FIPSCAPABLE") { + return 0; + } + if ($keyword eq "OPENSSL_FIPS" && $fips) { return 1; } + if ($keyword eq "ZLIB" && $zlib) { return 1; } return 0; } else { # algorithms @@ -1070,6 +1181,7 @@ sub is_valid if ($keyword eq "SHA" && $no_sha) { return 0; } if ($keyword eq "RIPEMD" && $no_ripemd) { return 0; } if ($keyword eq "MDC2" && $no_mdc2) { return 0; } + if ($keyword eq "WHIRLPOOL" && $no_whirlpool) { return 0; } if ($keyword eq "RSA" && $no_rsa) { return 0; } if ($keyword eq "DSA" && $no_dsa) { return 0; } if ($keyword eq "DH" && $no_dh) { return 0; } @@ -1078,6 +1190,8 @@ sub is_valid if ($keyword eq "ECDH" && $no_ecdh) { return 0; } if ($keyword eq "HMAC" && $no_hmac) { return 0; } if ($keyword eq "AES" && $no_aes) { return 0; } + if ($keyword eq "CAMELLIA" && $no_camellia) { return 0; } + if ($keyword eq "SEED" && $no_seed) { return 0; } if ($keyword eq "EVP" && $no_evp) { return 0; } if ($keyword eq "LHASH" && $no_lhash) { return 0; } if ($keyword eq "STACK" && $no_stack) { return 0; } @@ -1092,6 +1206,21 @@ sub is_valid if ($keyword eq "FP_API" && $no_fp_api) { return 0; } if ($keyword eq "STATIC_ENGINE" && $no_static_engine) { return 0; } if ($keyword eq "GMP" && $no_gmp) { return 0; } + if ($keyword eq "TLSEXT" && $no_tlsext) { return 0; } + if ($keyword eq "PSK" && $no_psk) { return 0; } + if ($keyword eq "CMS" && $no_cms) { return 0; } + if ($keyword eq "EC_NISTP_64_GCC_128" && $no_nistp_gcc) + { return 0; } + if ($keyword eq "EC2M" && $no_ec2m) { return 0; } + if ($keyword eq "NEXTPROTONEG" && $no_nextprotoneg) { return 0; } + if ($keyword eq "SSL3_METHOD" && $no_ssl3_method) { return 0; } + if ($keyword eq "SSL_TRACE" && $no_ssl_trace) { return 0; } + if ($keyword eq "CAPIENG" && $no_capieng) { return 0; } + if ($keyword eq "JPAKE" && $no_jpake) { return 0; } + if ($keyword eq "SRP" && $no_srp) { return 0; } + if ($keyword eq "SCTP" && $no_sctp) { return 0; } + if ($keyword eq "SRTP" && $no_srtp) { return 0; } + if ($keyword eq "UNIT_TEST" && $no_unit_test) { return 0; } if ($keyword eq "DEPRECATED" && $no_deprecated) { return 0; } # Nothing recognise as true @@ -1171,8 +1300,6 @@ sub print_def_file if ($W32) { $libname.="32"; } - elsif ($W16) - { $libname.="16"; } elsif ($OS2) { # DLL names should not clash on the whole system. # However, they should not have any particular relationship @@ -1195,23 +1322,8 @@ EOO LIBRARY $libname $liboptions -DESCRIPTION '$description' - EOF - if ($W16) { - print <<"EOF"; -CODE PRELOAD MOVEABLE -DATA PRELOAD MOVEABLE SINGLE - -EXETYPE WINDOWS - -HEAPSIZE 4096 -STACKSIZE 8192 - -EOF - } - print "EXPORTS\n"; (@e)=grep(/^SSLeay(\{[0-9]+\})?\\.*?:.*?:FUNCTION/,@symbols); @@ -1385,6 +1497,7 @@ sub update_numbers next if defined($rsyms{$sym}); die "ERROR: Symbol $sym had no info attached to it." if $i eq ""; + next if $i =~ /OPENSSL_FIPSCAPABLE/; if (!exists $nums{$s}) { $new_syms++; my $s2 = $s; @@ -1426,3 +1539,13 @@ sub check_existing } } +sub count_parens +{ + my $line = shift(@_); + + my $open = $line =~ tr/\(//; + my $close = $line =~ tr/\)//; + + return $open - $close; +} +