Add Rijndael as things to look through.
[openssl.git] / util / mkdef.pl
index 706073dd74e0906952bd143f9598e88d110cc6f7..403f82367617be91d450bc4ac60787e9a5253ea6 100755 (executable)
 #   symbol name replacements for platforms where the names are too long for the
 #   compiler or linker, or if the systems is case insensitive and there is a
 #   clash.  This script assumes those redefinitions are place in the file
-#   crypto/idhacks.h.
+#   crypto/symhacks.h.
+#   The semantics for the platforms list is a bit complicated.  The rule of
+#   thumb is that the list is exclusive, but it seems to mean different things.
+#   So, if the list is all negatives (like "!VMS,!WIN16"), the symbol exists
+#   on all platforms except those listed.  If the list is all positives (like
+#   "VMS,WIN16"), the symbol exists only on those platforms and nowhere else.
+#   The combination of positives and negatives will act as if the positives
+#   weren't there.
 # - "kind" is "FUNCTION" or "VARIABLE".  The meaning of that is obvious.
 # - "algorithms" is a comma-separated list of algorithm names.  This helps
 #   exclude symbols that are part of an algorithm that some user wants to
@@ -69,7 +76,8 @@ my @known_platforms = ( "__FreeBSD__", "VMS", "WIN16", "WIN32",
                        "WINNT", "PERL5", "NeXT" );
 my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
                         "CAST", "MD2", "MD4", "MD5", "SHA", "RIPEMD",
-                        "MDC2", "RSA", "DSA", "DH", "HMAC", "FP_API" );
+                        "MDC2", "RSA", "DSA", "DH", "HMAC", "FP_API",
+                        "RIJNDAEL" );
 
 my $options="";
 open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
@@ -84,7 +92,7 @@ close(IN);
 my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
 my $no_cast;
 my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
-my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0;
+my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_rijndael;
 my $no_fp_api;
 
 foreach (@ARGV, split(/ /, $options))
@@ -96,6 +104,8 @@ foreach (@ARGV, split(/ /, $options))
                $NT = 1;
        }
        $VMS=1 if $_ eq "VMS";
+       #$rsaref=1 if $_ eq "rsaref";
+
        $do_ssl=1 if $_ eq "ssleay";
        $do_ssl=1 if $_ eq "ssl";
        $do_crypto=1 if $_ eq "libeay";
@@ -104,14 +114,13 @@ foreach (@ARGV, split(/ /, $options))
        $do_rewrite=1 if $_ eq "rewrite";
        $do_ctest=1 if $_ eq "ctest";
        $do_ctestall=1 if $_ eq "ctestall";
-       $rsaref=1 if $_ eq "rsaref";
        #$safe_stack_def=1 if $_ eq "-DDEBUG_SAFESTACK";
 
        if    (/^no-rc2$/)      { $no_rc2=1; }
        elsif (/^no-rc4$/)      { $no_rc4=1; }
        elsif (/^no-rc5$/)      { $no_rc5=1; }
        elsif (/^no-idea$/)     { $no_idea=1; }
-       elsif (/^no-des$/)      { $no_des=1; }
+       elsif (/^no-des$/)      { $no_des=1; $no_mdc2=1; }
        elsif (/^no-bf$/)       { $no_bf=1; }
        elsif (/^no-cast$/)     { $no_cast=1; }
        elsif (/^no-md2$/)      { $no_md2=1; }
@@ -124,6 +133,7 @@ foreach (@ARGV, split(/ /, $options))
        elsif (/^no-dsa$/)      { $no_dsa=1; }
        elsif (/^no-dh$/)       { $no_dh=1; }
        elsif (/^no-hmac$/)     { $no_hmac=1; }
+       elsif (/^no-rijndael$/) { $no_rijndael=1; }
        }
 
 
@@ -139,7 +149,7 @@ if ($W16) {
 
 if (!$do_ssl && !$do_crypto)
        {
-       print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ] [rsaref]\n";
+       print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT ]\n";
        exit(1);
        }
 
@@ -164,6 +174,7 @@ $crypto.=" crypto/md5/md5.h" unless $no_md5;
 $crypto.=" crypto/mdc2/mdc2.h" unless $no_mdc2;
 $crypto.=" crypto/sha/sha.h" unless $no_sha;
 $crypto.=" crypto/ripemd/ripemd.h" unless $no_ripemd;
+$crypto.=" crypto/rijndael/rijndael.h" unless $no_rijndael;
 
 $crypto.=" crypto/bn/bn.h";
 $crypto.=" crypto/rsa/rsa.h" unless $no_rsa;
@@ -171,6 +182,7 @@ $crypto.=" crypto/dsa/dsa.h" unless $no_dsa;
 $crypto.=" crypto/dh/dh.h" unless $no_dh;
 $crypto.=" crypto/hmac/hmac.h" unless $no_hmac;
 
+$crypto.=" crypto/engine/engine.h";
 $crypto.=" crypto/stack/stack.h";
 $crypto.=" crypto/buffer/buffer.h";
 $crypto.=" crypto/bio/bio.h";
@@ -193,6 +205,7 @@ $crypto.=" crypto/x509/x509_vfy.h";
 $crypto.=" crypto/x509v3/x509v3.h";
 $crypto.=" crypto/rand/rand.h";
 $crypto.=" crypto/comp/comp.h";
+$crypto.=" crypto/ocsp/ocsp.h";
 $crypto.=" crypto/tmdiff.h";
 
 my $symhacks="crypto/symhacks.h";
@@ -614,6 +627,9 @@ sub maybe_add_info {
        }
        if ($new_info) {
                print STDERR "$new_info old symbols got an info update\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";
        }
@@ -692,15 +708,69 @@ EOF
                                        if(!$do_update);
                } else {
                        (my $n, my $i) = split /\\/, $nums{$s};
-                       my @p = split(/,/, ($i =~ /^.*?:(.*?):/,$1));
+                       my %pf = ();
+                       my @p = split(/,/, ($i =~ /^[^:]*:([^:]*):/,$1));
+                       my @a = split(/,/, ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1));
+                       # @p_purged must contain hardware platforms only
+                       my @p_purged = ();
+                       foreach $ptmp (@p) {
+                               next if $ptmp =~ /^!?RSAREF$/;
+                               push @p_purged, $ptmp;
+                       }
+                       my $negatives = !!grep(/^!/,@p);
                        # It is very important to check NT before W32
-                       if (($NT && (!@p || (grep(/^WINNT$/,@p)
-                                            || !grep(/^!WINNT$/,@p))))
-                           || ($W32 && (!@p || (grep(/^WIN32$/,@p)
-                                                || !grep(/^!WIN32$/,@p))))
-                           || ($W16 && (!@p || (grep(/^WIN16$/,@p)
-                                                || !grep(/^!WIN16$/,@p))))) {
+                       if ((($NT && (!@p_purged
+                                     || (!$negatives && grep(/^WINNT$/,@p))
+                                     || ($negatives && !grep(/^!WINNT$/,@p))))
+                            || ($W32 && (!@p_purged
+                                         || (!$negatives && grep(/^WIN32$/,@p))
+                                         || ($negatives && !grep(/^!WIN32$/,@p))))
+                            || ($W16 && (!@p_purged
+                                         || (!$negatives && grep(/^WIN16$/,@p))
+                                         || ($negatives && !grep(/^!WIN16$/,@p)))))
+                           && (!@p
+                               || (!$negatives
+                                   && ($rsaref || !grep(/^RSAREF$/,@p)))
+                               || ($negatives
+                                   && (!$rsaref || !grep(/^!RSAREF$/,@p))))
+                           && (!@a || (!$no_rc2 || !grep(/^RC2$/,@a)))
+                           && (!@a || (!$no_rc4 || !grep(/^RC4$/,@a)))
+                           && (!@a || (!$no_rc5 || !grep(/^RC5$/,@a)))
+                           && (!@a || (!$no_idea || !grep(/^IDEA$/,@a)))
+                           && (!@a || (!$no_des || !grep(/^DES$/,@a)))
+                           && (!@a || (!$no_bf || !grep(/^BF$/,@a)))
+                           && (!@a || (!$no_cast || !grep(/^CAST$/,@a)))
+                           && (!@a || (!$no_md2 || !grep(/^MD2$/,@a)))
+                           && (!@a || (!$no_md4 || !grep(/^MD4$/,@a)))
+                           && (!@a || (!$no_md5 || !grep(/^MD5$/,@a)))
+                           && (!@a || (!$no_sha || !grep(/^SHA$/,@a)))
+                           && (!@a || (!$no_ripemd || !grep(/^RIPEMD$/,@a)))
+                           && (!@a || (!$no_mdc2 || !grep(/^MDC2$/,@a)))
+                           && (!@a || (!$no_rsa || !grep(/^RSA$/,@a)))
+                           && (!@a || (!$no_dsa || !grep(/^DSA$/,@a)))
+                           && (!@a || (!$no_dh || !grep(/^DH$/,@a)))
+                           && (!@a || (!$no_hmac || !grep(/^HMAC$/,@a)))
+                           && (!@a || (!$no_rijndael || !grep(/^RIJNDAEL$/,@a)))
+                           && (!@a || (!$no_fp_api || !grep(/^FP_API$/,@a)))
+                           ) {
                                printf OUT "    %s%-40s@%d\n",($W32)?"":"_",$s,$n;
+#                      } else {
+#                              print STDERR "DEBUG: \"$sym\" (@p):",
+#                              " rsaref:", !!(!@p
+#                                             || (!$negatives
+#                                                 && ($rsaref || !grep(/^RSAREF$/,@p)))
+#                                             || ($negatives
+#                                                 && (!$rsaref || !grep(/^!RSAREF$/,@p))))?1:0,
+#                              " 16:", !!($W16 && (!@p_purged
+#                                                  || (!$negatives && grep(/^WIN16$/,@p))
+#                                                  || ($negatives && !grep(/^!WIN16$/,@p)))),
+#                              " 32:", !!($W32 && (!@p_purged
+#                                                  || (!$negatives && grep(/^WIN32$/,@p))
+#                                                  || ($negatives && !grep(/^!WIN32$/,@p)))),
+#                              " NT:", !!($NT && (!@p_purged
+#                                                 || (!$negatives && grep(/^WINNT$/,@p))
+#                                                 || ($negatives && !grep(/^!WINNT$/,@p)))),
+#                              "\n";
                        }
                }
        }
@@ -823,7 +893,7 @@ sub update_numbers
                        $new_syms++;
                        printf OUT "%s%-40s%d\t%s\n","",$s, ++$start_num,$i;
                        if (exists $r{$s}) {
-                               ($s, $i) = split /\\/,$r{$sym};
+                               ($s, $i) = split /\\/,$r{$s};
                                printf OUT "%s%-40s%d\t%s\n","",$s, $start_num,$i;
                        }
                }