diff options
Diffstat (limited to 'src/lib/libcrypto/util')
| -rw-r--r-- | src/lib/libcrypto/util/libeay.num | 1 | ||||
| -rw-r--r-- | src/lib/libcrypto/util/mkerr.pl | 629 | ||||
| -rw-r--r-- | src/lib/libcrypto/util/mkstack.pl | 124 | ||||
| -rw-r--r-- | src/lib/libcrypto/util/pl/Mingw32f.pl | 73 |
4 files changed, 826 insertions, 1 deletions
diff --git a/src/lib/libcrypto/util/libeay.num b/src/lib/libcrypto/util/libeay.num index 7e5728495f..512185e257 100644 --- a/src/lib/libcrypto/util/libeay.num +++ b/src/lib/libcrypto/util/libeay.num | |||
| @@ -2792,4 +2792,3 @@ ASN1_UNIVERSALSTRING_it 3234 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA | |||
| 2792 | ASN1_UNIVERSALSTRING_it 3234 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: | 2792 | ASN1_UNIVERSALSTRING_it 3234 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: |
| 2793 | d2i_ASN1_UNIVERSALSTRING 3235 EXIST::FUNCTION: | 2793 | d2i_ASN1_UNIVERSALSTRING 3235 EXIST::FUNCTION: |
| 2794 | EVP_des_ede3_ecb 3236 EXIST::FUNCTION:DES | 2794 | EVP_des_ede3_ecb 3236 EXIST::FUNCTION:DES |
| 2795 | X509_REQ_print_ex 3237 EXIST::FUNCTION:BIO | ||
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl new file mode 100644 index 0000000000..4105047b21 --- /dev/null +++ b/src/lib/libcrypto/util/mkerr.pl | |||
| @@ -0,0 +1,629 @@ | |||
| 1 | #!/usr/local/bin/perl -w | ||
| 2 | |||
| 3 | my $config = "crypto/err/openssl.ec"; | ||
| 4 | my $debug = 0; | ||
| 5 | my $rebuild = 0; | ||
| 6 | my $static = 1; | ||
| 7 | my $recurse = 0; | ||
| 8 | my $reindex = 0; | ||
| 9 | my $dowrite = 0; | ||
| 10 | my $staticloader = ""; | ||
| 11 | |||
| 12 | while (@ARGV) { | ||
| 13 | my $arg = $ARGV[0]; | ||
| 14 | if($arg eq "-conf") { | ||
| 15 | shift @ARGV; | ||
| 16 | $config = shift @ARGV; | ||
| 17 | } elsif($arg eq "-debug") { | ||
| 18 | $debug = 1; | ||
| 19 | shift @ARGV; | ||
| 20 | } elsif($arg eq "-rebuild") { | ||
| 21 | $rebuild = 1; | ||
| 22 | shift @ARGV; | ||
| 23 | } elsif($arg eq "-recurse") { | ||
| 24 | $recurse = 1; | ||
| 25 | shift @ARGV; | ||
| 26 | } elsif($arg eq "-reindex") { | ||
| 27 | $reindex = 1; | ||
| 28 | shift @ARGV; | ||
| 29 | } elsif($arg eq "-nostatic") { | ||
| 30 | $static = 0; | ||
| 31 | shift @ARGV; | ||
| 32 | } elsif($arg eq "-staticloader") { | ||
| 33 | $staticloader = "static "; | ||
| 34 | shift @ARGV; | ||
| 35 | } elsif($arg eq "-write") { | ||
| 36 | $dowrite = 1; | ||
| 37 | shift @ARGV; | ||
| 38 | } else { | ||
| 39 | last; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | if($recurse) { | ||
| 44 | @source = (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>); | ||
| 45 | } else { | ||
| 46 | @source = @ARGV; | ||
| 47 | } | ||
| 48 | |||
| 49 | # Read in the config file | ||
| 50 | |||
| 51 | open(IN, "<$config") || die "Can't open config file $config"; | ||
| 52 | |||
| 53 | # Parse config file | ||
| 54 | |||
| 55 | while(<IN>) | ||
| 56 | { | ||
| 57 | if(/^L\s+(\S+)\s+(\S+)\s+(\S+)/) { | ||
| 58 | $hinc{$1} = $2; | ||
| 59 | $libinc{$2} = $1; | ||
| 60 | $cskip{$3} = $1; | ||
| 61 | if($3 ne "NONE") { | ||
| 62 | $csrc{$1} = $3; | ||
| 63 | $fmax{$1} = 99; | ||
| 64 | $rmax{$1} = 99; | ||
| 65 | $fnew{$1} = 0; | ||
| 66 | $rnew{$1} = 0; | ||
| 67 | } | ||
| 68 | } elsif (/^F\s+(\S+)/) { | ||
| 69 | # Add extra function with $1 | ||
| 70 | } elsif (/^R\s+(\S+)\s+(\S+)/) { | ||
| 71 | $rextra{$1} = $2; | ||
| 72 | $rcodes{$1} = $2; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | close IN; | ||
| 77 | |||
| 78 | # Scan each header file in turn and make a list of error codes | ||
| 79 | # and function names | ||
| 80 | |||
| 81 | while (($hdr, $lib) = each %libinc) | ||
| 82 | { | ||
| 83 | next if($hdr eq "NONE"); | ||
| 84 | print STDERR "Scanning header file $hdr\n" if $debug; | ||
| 85 | my $line = "", $def= "", $linenr = 0, $gotfile = 0; | ||
| 86 | if (open(IN, "<$hdr")) { | ||
| 87 | $gotfile = 1; | ||
| 88 | while(<IN>) { | ||
| 89 | $linenr++; | ||
| 90 | print STDERR "line: $linenr\r" if $debug; | ||
| 91 | |||
| 92 | last if(/BEGIN\s+ERROR\s+CODES/); | ||
| 93 | if ($line ne '') { | ||
| 94 | $_ = $line . $_; | ||
| 95 | $line = ''; | ||
| 96 | } | ||
| 97 | |||
| 98 | if (/\\$/) { | ||
| 99 | $line = $_; | ||
| 100 | next; | ||
| 101 | } | ||
| 102 | |||
| 103 | $cpp = 1 if /^#.*ifdef.*cplusplus/; # skip "C" declaration | ||
| 104 | if ($cpp) { | ||
| 105 | $cpp = 0 if /^#.*endif/; | ||
| 106 | next; | ||
| 107 | } | ||
| 108 | |||
| 109 | next if (/^\#/); # skip preprocessor directives | ||
| 110 | |||
| 111 | s/\/\*.*?\*\///gs; # ignore comments | ||
| 112 | s/{[^{}]*}//gs; # ignore {} blocks | ||
| 113 | |||
| 114 | if (/\{|\/\*/) { # Add a } so editor works... | ||
| 115 | $line = $_; | ||
| 116 | } else { | ||
| 117 | $def .= $_; | ||
| 118 | } | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | print STDERR " \r" if $debug; | ||
| 123 | $defnr = 0; | ||
| 124 | foreach (split /;/, $def) { | ||
| 125 | $defnr++; | ||
| 126 | print STDERR "def: $defnr\r" if $debug; | ||
| 127 | |||
| 128 | s/^[\n\s]*//g; | ||
| 129 | s/[\n\s]*$//g; | ||
| 130 | next if(/typedef\W/); | ||
| 131 | if (/\(\*(\w*)\([^\)]+/) { | ||
| 132 | my $name = $1; | ||
| 133 | $name =~ tr/[a-z]/[A-Z]/; | ||
| 134 | $ftrans{$name} = $1; | ||
| 135 | } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s){ | ||
| 136 | # K&R C | ||
| 137 | next ; | ||
| 138 | } elsif (/\w+\W+\w+\W*\(.*\)$/s) { | ||
| 139 | while (not /\(\)$/s) { | ||
| 140 | s/[^\(\)]*\)$/\)/s; | ||
| 141 | s/\([^\(\)]*\)\)$/\)/s; | ||
| 142 | } | ||
| 143 | s/\(void\)//; | ||
| 144 | /(\w+)\W*\(\)/s; | ||
| 145 | my $name = $1; | ||
| 146 | $name =~ tr/[a-z]/[A-Z]/; | ||
| 147 | $ftrans{$name} = $1; | ||
| 148 | } elsif (/\(/ and not (/=/ or /DECLARE_STACK/)) { | ||
| 149 | print STDERR "Header $hdr: cannot parse: $_;\n"; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | print STDERR " \r" if $debug; | ||
| 154 | |||
| 155 | next if $reindex; | ||
| 156 | |||
| 157 | # Scan function and reason codes and store them: keep a note of the | ||
| 158 | # maximum code used. | ||
| 159 | |||
| 160 | if ($gotfile) { | ||
| 161 | while(<IN>) { | ||
| 162 | if(/^\#define\s+(\S+)\s+(\S+)/) { | ||
| 163 | $name = $1; | ||
| 164 | $code = $2; | ||
| 165 | next if $name =~ /^${lib}err/; | ||
| 166 | unless($name =~ /^${lib}_([RF])_(\w+)$/) { | ||
| 167 | print STDERR "Invalid error code $name\n"; | ||
| 168 | next; | ||
| 169 | } | ||
| 170 | if($1 eq "R") { | ||
| 171 | $rcodes{$name} = $code; | ||
| 172 | if(!(exists $rextra{$name}) && | ||
| 173 | ($code > $rmax{$lib}) ) { | ||
| 174 | $rmax{$lib} = $code; | ||
| 175 | } | ||
| 176 | } else { | ||
| 177 | if($code > $fmax{$lib}) { | ||
| 178 | $fmax{$lib} = $code; | ||
| 179 | } | ||
| 180 | $fcodes{$name} = $code; | ||
| 181 | } | ||
| 182 | } | ||
| 183 | } | ||
| 184 | } | ||
| 185 | close IN; | ||
| 186 | } | ||
| 187 | |||
| 188 | # Scan each C source file and look for function and reason codes | ||
| 189 | # This is done by looking for strings that "look like" function or | ||
| 190 | # reason codes: basically anything consisting of all upper case and | ||
| 191 | # numerics which has _F_ or _R_ in it and which has the name of an | ||
| 192 | # error library at the start. This seems to work fine except for the | ||
| 193 | # oddly named structure BIO_F_CTX which needs to be ignored. | ||
| 194 | # If a code doesn't exist in list compiled from headers then mark it | ||
| 195 | # with the value "X" as a place holder to give it a value later. | ||
| 196 | # Store all function and reason codes found in %ufcodes and %urcodes | ||
| 197 | # so all those unreferenced can be printed out. | ||
| 198 | |||
| 199 | |||
| 200 | print STDERR "Files loaded: " if $debug; | ||
| 201 | foreach $file (@source) { | ||
| 202 | # Don't parse the error source file. | ||
| 203 | next if exists $cskip{$file}; | ||
| 204 | print STDERR $file if $debug; | ||
| 205 | open(IN, "<$file") || die "Can't open source file $file\n"; | ||
| 206 | while(<IN>) { | ||
| 207 | if(/(([A-Z0-9]+)_F_([A-Z0-9_]+))/) { | ||
| 208 | next unless exists $csrc{$2}; | ||
| 209 | next if($1 eq "BIO_F_BUFFER_CTX"); | ||
| 210 | $ufcodes{$1} = 1; | ||
| 211 | if(!exists $fcodes{$1}) { | ||
| 212 | $fcodes{$1} = "X"; | ||
| 213 | $fnew{$2}++; | ||
| 214 | } | ||
| 215 | $notrans{$1} = 1 unless exists $ftrans{$3}; | ||
| 216 | } | ||
| 217 | if(/(([A-Z0-9]+)_R_[A-Z0-9_]+)/) { | ||
| 218 | next unless exists $csrc{$2}; | ||
| 219 | $urcodes{$1} = 1; | ||
| 220 | if(!exists $rcodes{$1}) { | ||
| 221 | $rcodes{$1} = "X"; | ||
| 222 | $rnew{$2}++; | ||
| 223 | } | ||
| 224 | } | ||
| 225 | } | ||
| 226 | close IN; | ||
| 227 | } | ||
| 228 | print STDERR "\n" if $debug; | ||
| 229 | |||
| 230 | # Now process each library in turn. | ||
| 231 | |||
| 232 | foreach $lib (keys %csrc) | ||
| 233 | { | ||
| 234 | my $hfile = $hinc{$lib}; | ||
| 235 | my $cfile = $csrc{$lib}; | ||
| 236 | if(!$fnew{$lib} && !$rnew{$lib}) { | ||
| 237 | print STDERR "$lib:\t\tNo new error codes\n"; | ||
| 238 | next unless $rebuild; | ||
| 239 | } else { | ||
| 240 | print STDERR "$lib:\t\t$fnew{$lib} New Functions,"; | ||
| 241 | print STDERR " $rnew{$lib} New Reasons.\n"; | ||
| 242 | next unless $dowrite; | ||
| 243 | } | ||
| 244 | |||
| 245 | # If we get here then we have some new error codes so we | ||
| 246 | # need to rebuild the header file and C file. | ||
| 247 | |||
| 248 | # Make a sorted list of error and reason codes for later use. | ||
| 249 | |||
| 250 | my @function = sort grep(/^${lib}_/,keys %fcodes); | ||
| 251 | my @reasons = sort grep(/^${lib}_/,keys %rcodes); | ||
| 252 | |||
| 253 | # Rewrite the header file | ||
| 254 | |||
| 255 | if (open(IN, "<$hfile")) { | ||
| 256 | # Copy across the old file | ||
| 257 | while(<IN>) { | ||
| 258 | push @out, $_; | ||
| 259 | last if (/BEGIN ERROR CODES/); | ||
| 260 | } | ||
| 261 | close IN; | ||
| 262 | } else { | ||
| 263 | push @out, | ||
| 264 | "/* ====================================================================\n", | ||
| 265 | " * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved.\n", | ||
| 266 | " *\n", | ||
| 267 | " * Redistribution and use in source and binary forms, with or without\n", | ||
| 268 | " * modification, are permitted provided that the following conditions\n", | ||
| 269 | " * are met:\n", | ||
| 270 | " *\n", | ||
| 271 | " * 1. Redistributions of source code must retain the above copyright\n", | ||
| 272 | " * notice, this list of conditions and the following disclaimer. \n", | ||
| 273 | " *\n", | ||
| 274 | " * 2. Redistributions in binary form must reproduce the above copyright\n", | ||
| 275 | " * notice, this list of conditions and the following disclaimer in\n", | ||
| 276 | " * the documentation and/or other materials provided with the\n", | ||
| 277 | " * distribution.\n", | ||
| 278 | " *\n", | ||
| 279 | " * 3. All advertising materials mentioning features or use of this\n", | ||
| 280 | " * software must display the following acknowledgment:\n", | ||
| 281 | " * \"This product includes software developed by the OpenSSL Project\n", | ||
| 282 | " * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n", | ||
| 283 | " *\n", | ||
| 284 | " * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n", | ||
| 285 | " * endorse or promote products derived from this software without\n", | ||
| 286 | " * prior written permission. For written permission, please contact\n", | ||
| 287 | " * openssl-core\@openssl.org.\n", | ||
| 288 | " *\n", | ||
| 289 | " * 5. Products derived from this software may not be called \"OpenSSL\"\n", | ||
| 290 | " * nor may \"OpenSSL\" appear in their names without prior written\n", | ||
| 291 | " * permission of the OpenSSL Project.\n", | ||
| 292 | " *\n", | ||
| 293 | " * 6. Redistributions of any form whatsoever must retain the following\n", | ||
| 294 | " * acknowledgment:\n", | ||
| 295 | " * \"This product includes software developed by the OpenSSL Project\n", | ||
| 296 | " * for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n", | ||
| 297 | " *\n", | ||
| 298 | " * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n", | ||
| 299 | " * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n", | ||
| 300 | " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n", | ||
| 301 | " * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n", | ||
| 302 | " * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n", | ||
| 303 | " * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n", | ||
| 304 | " * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n", | ||
| 305 | " * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n", | ||
| 306 | " * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n", | ||
| 307 | " * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n", | ||
| 308 | " * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n", | ||
| 309 | " * OF THE POSSIBILITY OF SUCH DAMAGE.\n", | ||
| 310 | " * ====================================================================\n", | ||
| 311 | " *\n", | ||
| 312 | " * This product includes cryptographic software written by Eric Young\n", | ||
| 313 | " * (eay\@cryptsoft.com). This product includes software written by Tim\n", | ||
| 314 | " * Hudson (tjh\@cryptsoft.com).\n", | ||
| 315 | " *\n", | ||
| 316 | " */\n", | ||
| 317 | "\n", | ||
| 318 | "#ifndef HEADER_${lib}_ERR_H\n", | ||
| 319 | "#define HEADER_${lib}_ERR_H\n", | ||
| 320 | "\n", | ||
| 321 | "/* BEGIN ERROR CODES */\n"; | ||
| 322 | } | ||
| 323 | open (OUT, ">$hfile") || die "Can't Open File $hfile for writing\n"; | ||
| 324 | |||
| 325 | print OUT @out; | ||
| 326 | undef @out; | ||
| 327 | print OUT <<"EOF"; | ||
| 328 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 329 | * made after this point may be overwritten when the script is next run. | ||
| 330 | */ | ||
| 331 | EOF | ||
| 332 | if($static) { | ||
| 333 | print OUT <<"EOF"; | ||
| 334 | ${staticloader}void ERR_load_${lib}_strings(void); | ||
| 335 | |||
| 336 | EOF | ||
| 337 | } else { | ||
| 338 | print OUT <<"EOF"; | ||
| 339 | ${staticloader}void ERR_load_${lib}_strings(void); | ||
| 340 | ${staticloader}void ERR_unload_${lib}_strings(void); | ||
| 341 | ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line); | ||
| 342 | #define ${lib}err(f,r) ERR_${lib}_error((f),(r),__FILE__,__LINE__) | ||
| 343 | |||
| 344 | EOF | ||
| 345 | } | ||
| 346 | print OUT <<"EOF"; | ||
| 347 | /* Error codes for the $lib functions. */ | ||
| 348 | |||
| 349 | /* Function codes. */ | ||
| 350 | EOF | ||
| 351 | |||
| 352 | foreach $i (@function) { | ||
| 353 | $z=6-int(length($i)/8); | ||
| 354 | if($fcodes{$i} eq "X") { | ||
| 355 | $fcodes{$i} = ++$fmax{$lib}; | ||
| 356 | print STDERR "New Function code $i\n" if $debug; | ||
| 357 | } | ||
| 358 | printf OUT "#define $i%s $fcodes{$i}\n","\t" x $z; | ||
| 359 | } | ||
| 360 | |||
| 361 | print OUT "\n/* Reason codes. */\n"; | ||
| 362 | |||
| 363 | foreach $i (@reasons) { | ||
| 364 | $z=6-int(length($i)/8); | ||
| 365 | if($rcodes{$i} eq "X") { | ||
| 366 | $rcodes{$i} = ++$rmax{$lib}; | ||
| 367 | print STDERR "New Reason code $i\n" if $debug; | ||
| 368 | } | ||
| 369 | printf OUT "#define $i%s $rcodes{$i}\n","\t" x $z; | ||
| 370 | } | ||
| 371 | print OUT <<"EOF"; | ||
| 372 | |||
| 373 | #ifdef __cplusplus | ||
| 374 | } | ||
| 375 | #endif | ||
| 376 | #endif | ||
| 377 | EOF | ||
| 378 | close OUT; | ||
| 379 | |||
| 380 | # Rewrite the C source file containing the error details. | ||
| 381 | |||
| 382 | # First, read any existing reason string definitions: | ||
| 383 | my %err_reason_strings; | ||
| 384 | if (open(IN,"<$cfile")) { | ||
| 385 | while (<IN>) { | ||
| 386 | if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) { | ||
| 387 | $err_reason_strings{$1} = $2; | ||
| 388 | } | ||
| 389 | } | ||
| 390 | close(IN); | ||
| 391 | } | ||
| 392 | |||
| 393 | my $hincf; | ||
| 394 | if($static) { | ||
| 395 | $hfile =~ /([^\/]+)$/; | ||
| 396 | $hincf = "<openssl/$1>"; | ||
| 397 | } else { | ||
| 398 | $hincf = "\"$hfile\""; | ||
| 399 | } | ||
| 400 | |||
| 401 | |||
| 402 | open (OUT,">$cfile") || die "Can't open $cfile for writing"; | ||
| 403 | |||
| 404 | print OUT <<"EOF"; | ||
| 405 | /* $cfile */ | ||
| 406 | /* ==================================================================== | ||
| 407 | * Copyright (c) 1999-2002 The OpenSSL Project. All rights reserved. | ||
| 408 | * | ||
| 409 | * Redistribution and use in source and binary forms, with or without | ||
| 410 | * modification, are permitted provided that the following conditions | ||
| 411 | * are met: | ||
| 412 | * | ||
| 413 | * 1. Redistributions of source code must retain the above copyright | ||
| 414 | * notice, this list of conditions and the following disclaimer. | ||
| 415 | * | ||
| 416 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 417 | * notice, this list of conditions and the following disclaimer in | ||
| 418 | * the documentation and/or other materials provided with the | ||
| 419 | * distribution. | ||
| 420 | * | ||
| 421 | * 3. All advertising materials mentioning features or use of this | ||
| 422 | * software must display the following acknowledgment: | ||
| 423 | * "This product includes software developed by the OpenSSL Project | ||
| 424 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 425 | * | ||
| 426 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 427 | * endorse or promote products derived from this software without | ||
| 428 | * prior written permission. For written permission, please contact | ||
| 429 | * openssl-core\@OpenSSL.org. | ||
| 430 | * | ||
| 431 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 432 | * nor may "OpenSSL" appear in their names without prior written | ||
| 433 | * permission of the OpenSSL Project. | ||
| 434 | * | ||
| 435 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 436 | * acknowledgment: | ||
| 437 | * "This product includes software developed by the OpenSSL Project | ||
| 438 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 439 | * | ||
| 440 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 441 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 442 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 443 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 444 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 445 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 446 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 447 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 448 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 449 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 450 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 451 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 452 | * ==================================================================== | ||
| 453 | * | ||
| 454 | * This product includes cryptographic software written by Eric Young | ||
| 455 | * (eay\@cryptsoft.com). This product includes software written by Tim | ||
| 456 | * Hudson (tjh\@cryptsoft.com). | ||
| 457 | * | ||
| 458 | */ | ||
| 459 | |||
| 460 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 461 | * made to it will be overwritten when the script next updates this file, | ||
| 462 | * only reason strings will be preserved. | ||
| 463 | */ | ||
| 464 | |||
| 465 | #include <stdio.h> | ||
| 466 | #include <openssl/err.h> | ||
| 467 | #include $hincf | ||
| 468 | |||
| 469 | /* BEGIN ERROR CODES */ | ||
| 470 | #ifndef OPENSSL_NO_ERR | ||
| 471 | static ERR_STRING_DATA ${lib}_str_functs[]= | ||
| 472 | { | ||
| 473 | EOF | ||
| 474 | # Add each function code: if a function name is found then use it. | ||
| 475 | foreach $i (@function) { | ||
| 476 | my $fn; | ||
| 477 | $i =~ /^${lib}_F_(\S+)$/; | ||
| 478 | $fn = $1; | ||
| 479 | if(exists $ftrans{$fn}) { | ||
| 480 | $fn = $ftrans{$fn}; | ||
| 481 | } | ||
| 482 | print OUT "{ERR_PACK(0,$i,0),\t\"$fn\"},\n"; | ||
| 483 | } | ||
| 484 | print OUT <<"EOF"; | ||
| 485 | {0,NULL} | ||
| 486 | }; | ||
| 487 | |||
| 488 | static ERR_STRING_DATA ${lib}_str_reasons[]= | ||
| 489 | { | ||
| 490 | EOF | ||
| 491 | # Add each reason code. | ||
| 492 | foreach $i (@reasons) { | ||
| 493 | my $rn; | ||
| 494 | my $nspc = 0; | ||
| 495 | if (exists $err_reason_strings{$i}) { | ||
| 496 | $rn = $err_reason_strings{$i}; | ||
| 497 | } else { | ||
| 498 | $i =~ /^${lib}_R_(\S+)$/; | ||
| 499 | $rn = $1; | ||
| 500 | $rn =~ tr/_[A-Z]/ [a-z]/; | ||
| 501 | } | ||
| 502 | $nspc = 40 - length($i) unless length($i) > 40; | ||
| 503 | $nspc = " " x $nspc; | ||
| 504 | print OUT "{${i}${nspc},\"$rn\"},\n"; | ||
| 505 | } | ||
| 506 | if($static) { | ||
| 507 | print OUT <<"EOF"; | ||
| 508 | {0,NULL} | ||
| 509 | }; | ||
| 510 | |||
| 511 | #endif | ||
| 512 | |||
| 513 | ${staticloader}void ERR_load_${lib}_strings(void) | ||
| 514 | { | ||
| 515 | static int init=1; | ||
| 516 | |||
| 517 | if (init) | ||
| 518 | { | ||
| 519 | init=0; | ||
| 520 | #ifndef OPENSSL_NO_ERR | ||
| 521 | ERR_load_strings(ERR_LIB_${lib},${lib}_str_functs); | ||
| 522 | ERR_load_strings(ERR_LIB_${lib},${lib}_str_reasons); | ||
| 523 | #endif | ||
| 524 | |||
| 525 | } | ||
| 526 | } | ||
| 527 | EOF | ||
| 528 | } else { | ||
| 529 | print OUT <<"EOF"; | ||
| 530 | {0,NULL} | ||
| 531 | }; | ||
| 532 | |||
| 533 | #endif | ||
| 534 | |||
| 535 | #ifdef ${lib}_LIB_NAME | ||
| 536 | static ERR_STRING_DATA ${lib}_lib_name[]= | ||
| 537 | { | ||
| 538 | {0 ,${lib}_LIB_NAME}, | ||
| 539 | {0,NULL} | ||
| 540 | }; | ||
| 541 | #endif | ||
| 542 | |||
| 543 | |||
| 544 | static int ${lib}_lib_error_code=0; | ||
| 545 | static int ${lib}_error_init=1; | ||
| 546 | |||
| 547 | ${staticloader}void ERR_load_${lib}_strings(void) | ||
| 548 | { | ||
| 549 | if (${lib}_lib_error_code == 0) | ||
| 550 | ${lib}_lib_error_code=ERR_get_next_error_library(); | ||
| 551 | |||
| 552 | if (${lib}_error_init) | ||
| 553 | { | ||
| 554 | ${lib}_error_init=0; | ||
| 555 | #ifndef OPENSSL_NO_ERR | ||
| 556 | ERR_load_strings(${lib}_lib_error_code,${lib}_str_functs); | ||
| 557 | ERR_load_strings(${lib}_lib_error_code,${lib}_str_reasons); | ||
| 558 | #endif | ||
| 559 | |||
| 560 | #ifdef ${lib}_LIB_NAME | ||
| 561 | ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0); | ||
| 562 | ERR_load_strings(0,${lib}_lib_name); | ||
| 563 | #endif | ||
| 564 | } | ||
| 565 | } | ||
| 566 | |||
| 567 | ${staticloader}void ERR_unload_${lib}_strings(void) | ||
| 568 | { | ||
| 569 | if (${lib}_error_init == 0) | ||
| 570 | { | ||
| 571 | #ifndef OPENSSL_NO_ERR | ||
| 572 | ERR_unload_strings(${lib}_lib_error_code,${lib}_str_functs); | ||
| 573 | ERR_unload_strings(${lib}_lib_error_code,${lib}_str_reasons); | ||
| 574 | #endif | ||
| 575 | |||
| 576 | #ifdef ${lib}_LIB_NAME | ||
| 577 | ERR_unload_strings(0,${lib}_lib_name); | ||
| 578 | #endif | ||
| 579 | ${lib}_error_init=1; | ||
| 580 | } | ||
| 581 | } | ||
| 582 | |||
| 583 | ${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line) | ||
| 584 | { | ||
| 585 | if (${lib}_lib_error_code == 0) | ||
| 586 | ${lib}_lib_error_code=ERR_get_next_error_library(); | ||
| 587 | ERR_PUT_error(${lib}_lib_error_code,function,reason,file,line); | ||
| 588 | } | ||
| 589 | EOF | ||
| 590 | |||
| 591 | } | ||
| 592 | |||
| 593 | close OUT; | ||
| 594 | undef %err_reason_strings; | ||
| 595 | } | ||
| 596 | |||
| 597 | if($debug && defined(%notrans)) { | ||
| 598 | print STDERR "The following function codes were not translated:\n"; | ||
| 599 | foreach(sort keys %notrans) | ||
| 600 | { | ||
| 601 | print STDERR "$_\n"; | ||
| 602 | } | ||
| 603 | } | ||
| 604 | |||
| 605 | # Make a list of unreferenced function and reason codes | ||
| 606 | |||
| 607 | foreach (keys %fcodes) { | ||
| 608 | push (@funref, $_) unless exists $ufcodes{$_}; | ||
| 609 | } | ||
| 610 | |||
| 611 | foreach (keys %rcodes) { | ||
| 612 | push (@runref, $_) unless exists $urcodes{$_}; | ||
| 613 | } | ||
| 614 | |||
| 615 | if($debug && defined(@funref) ) { | ||
| 616 | print STDERR "The following function codes were not referenced:\n"; | ||
| 617 | foreach(sort @funref) | ||
| 618 | { | ||
| 619 | print STDERR "$_\n"; | ||
| 620 | } | ||
| 621 | } | ||
| 622 | |||
| 623 | if($debug && defined(@runref) ) { | ||
| 624 | print STDERR "The following reason codes were not referenced:\n"; | ||
| 625 | foreach(sort @runref) | ||
| 626 | { | ||
| 627 | print STDERR "$_\n"; | ||
| 628 | } | ||
| 629 | } | ||
diff --git a/src/lib/libcrypto/util/mkstack.pl b/src/lib/libcrypto/util/mkstack.pl new file mode 100644 index 0000000000..085c50f790 --- /dev/null +++ b/src/lib/libcrypto/util/mkstack.pl | |||
| @@ -0,0 +1,124 @@ | |||
| 1 | #!/usr/local/bin/perl -w | ||
| 2 | |||
| 3 | # This is a utility that searches out "DECLARE_STACK_OF()" | ||
| 4 | # declarations in .h and .c files, and updates/creates/replaces | ||
| 5 | # the corresponding macro declarations in crypto/stack/safestack.h. | ||
| 6 | # As it's not generally possible to have macros that generate macros, | ||
| 7 | # we need to control this from the "outside", here in this script. | ||
| 8 | # | ||
| 9 | # Geoff Thorpe, June, 2000 (with massive Perl-hacking | ||
| 10 | # help from Steve Robb) | ||
| 11 | |||
| 12 | my $safestack = "crypto/stack/safestack"; | ||
| 13 | |||
| 14 | my $do_write; | ||
| 15 | while (@ARGV) { | ||
| 16 | my $arg = $ARGV[0]; | ||
| 17 | if($arg eq "-write") { | ||
| 18 | $do_write = 1; | ||
| 19 | } | ||
| 20 | shift @ARGV; | ||
| 21 | } | ||
| 22 | |||
| 23 | |||
| 24 | @source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>); | ||
| 25 | foreach $file (@source) { | ||
| 26 | next if -l $file; | ||
| 27 | |||
| 28 | # Open the .c/.h file for reading | ||
| 29 | open(IN, "< $file") || die "Can't open $file for reading: $!"; | ||
| 30 | |||
| 31 | while(<IN>) { | ||
| 32 | if (/^DECLARE_STACK_OF\(([^)]+)\)/) { | ||
| 33 | push @stacklst, $1; | ||
| 34 | } if (/^DECLARE_ASN1_SET_OF\(([^)]+)\)/) { | ||
| 35 | push @asn1setlst, $1; | ||
| 36 | } if (/^DECLARE_PKCS12_STACK_OF\(([^)]+)\)/) { | ||
| 37 | push @p12stklst, $1; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | close(IN); | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | my $old_stackfile = ""; | ||
| 46 | my $new_stackfile = ""; | ||
| 47 | my $inside_block = 0; | ||
| 48 | my $type_thing; | ||
| 49 | |||
| 50 | open(IN, "< $safestack.h") || die "Can't open input file: $!"; | ||
| 51 | while(<IN>) { | ||
| 52 | $old_stackfile .= $_; | ||
| 53 | |||
| 54 | if (m|^/\* This block of defines is updated by util/mkstack.pl, please do not touch! \*/|) { | ||
| 55 | $inside_block = 1; | ||
| 56 | } | ||
| 57 | if (m|^/\* End of util/mkstack.pl block, you may now edit :-\) \*/|) { | ||
| 58 | $inside_block = 0; | ||
| 59 | } elsif ($inside_block == 0) { | ||
| 60 | $new_stackfile .= $_; | ||
| 61 | } | ||
| 62 | next if($inside_block != 1); | ||
| 63 | $new_stackfile .= "/* This block of defines is updated by util/mkstack.pl, please do not touch! */"; | ||
| 64 | |||
| 65 | foreach $type_thing (sort @stacklst) { | ||
| 66 | $new_stackfile .= <<EOF; | ||
| 67 | |||
| 68 | #define sk_${type_thing}_new(st) SKM_sk_new($type_thing, (st)) | ||
| 69 | #define sk_${type_thing}_new_null() SKM_sk_new_null($type_thing) | ||
| 70 | #define sk_${type_thing}_free(st) SKM_sk_free($type_thing, (st)) | ||
| 71 | #define sk_${type_thing}_num(st) SKM_sk_num($type_thing, (st)) | ||
| 72 | #define sk_${type_thing}_value(st, i) SKM_sk_value($type_thing, (st), (i)) | ||
| 73 | #define sk_${type_thing}_set(st, i, val) SKM_sk_set($type_thing, (st), (i), (val)) | ||
| 74 | #define sk_${type_thing}_zero(st) SKM_sk_zero($type_thing, (st)) | ||
| 75 | #define sk_${type_thing}_push(st, val) SKM_sk_push($type_thing, (st), (val)) | ||
| 76 | #define sk_${type_thing}_unshift(st, val) SKM_sk_unshift($type_thing, (st), (val)) | ||
| 77 | #define sk_${type_thing}_find(st, val) SKM_sk_find($type_thing, (st), (val)) | ||
| 78 | #define sk_${type_thing}_delete(st, i) SKM_sk_delete($type_thing, (st), (i)) | ||
| 79 | #define sk_${type_thing}_delete_ptr(st, ptr) SKM_sk_delete_ptr($type_thing, (st), (ptr)) | ||
| 80 | #define sk_${type_thing}_insert(st, val, i) SKM_sk_insert($type_thing, (st), (val), (i)) | ||
| 81 | #define sk_${type_thing}_set_cmp_func(st, cmp) SKM_sk_set_cmp_func($type_thing, (st), (cmp)) | ||
| 82 | #define sk_${type_thing}_dup(st) SKM_sk_dup($type_thing, st) | ||
| 83 | #define sk_${type_thing}_pop_free(st, free_func) SKM_sk_pop_free($type_thing, (st), (free_func)) | ||
| 84 | #define sk_${type_thing}_shift(st) SKM_sk_shift($type_thing, (st)) | ||
| 85 | #define sk_${type_thing}_pop(st) SKM_sk_pop($type_thing, (st)) | ||
| 86 | #define sk_${type_thing}_sort(st) SKM_sk_sort($type_thing, (st)) | ||
| 87 | EOF | ||
| 88 | } | ||
| 89 | foreach $type_thing (sort @asn1setlst) { | ||
| 90 | $new_stackfile .= <<EOF; | ||
| 91 | |||
| 92 | #define d2i_ASN1_SET_OF_${type_thing}(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\ | ||
| 93 | SKM_ASN1_SET_OF_d2i($type_thing, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class)) | ||
| 94 | #define i2d_ASN1_SET_OF_${type_thing}(st, pp, i2d_func, ex_tag, ex_class, is_set) \\ | ||
| 95 | SKM_ASN1_SET_OF_i2d($type_thing, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set)) | ||
| 96 | #define ASN1_seq_pack_${type_thing}(st, i2d_func, buf, len) \\ | ||
| 97 | SKM_ASN1_seq_pack($type_thing, (st), (i2d_func), (buf), (len)) | ||
| 98 | #define ASN1_seq_unpack_${type_thing}(buf, len, d2i_func, free_func) \\ | ||
| 99 | SKM_ASN1_seq_unpack($type_thing, (buf), (len), (d2i_func), (free_func)) | ||
| 100 | EOF | ||
| 101 | } | ||
| 102 | foreach $type_thing (sort @p12stklst) { | ||
| 103 | $new_stackfile .= <<EOF; | ||
| 104 | |||
| 105 | #define PKCS12_decrypt_d2i_${type_thing}(algor, d2i_func, free_func, pass, passlen, oct, seq) \\ | ||
| 106 | SKM_PKCS12_decrypt_d2i($type_thing, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq)) | ||
| 107 | EOF | ||
| 108 | } | ||
| 109 | $new_stackfile .= "/* End of util/mkstack.pl block, you may now edit :-) */\n"; | ||
| 110 | $inside_block = 2; | ||
| 111 | } | ||
| 112 | |||
| 113 | |||
| 114 | if ($new_stackfile eq $old_stackfile) { | ||
| 115 | print "No changes to $safestack.h.\n"; | ||
| 116 | exit 0; # avoid unnecessary rebuild | ||
| 117 | } | ||
| 118 | |||
| 119 | if ($do_write) { | ||
| 120 | print "Writing new $safestack.h.\n"; | ||
| 121 | open OUT, ">$safestack.h" || die "Can't open output file"; | ||
| 122 | print OUT $new_stackfile; | ||
| 123 | close OUT; | ||
| 124 | } | ||
diff --git a/src/lib/libcrypto/util/pl/Mingw32f.pl b/src/lib/libcrypto/util/pl/Mingw32f.pl new file mode 100644 index 0000000000..44f5673d7a --- /dev/null +++ b/src/lib/libcrypto/util/pl/Mingw32f.pl | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | #!/usr/local/bin/perl | ||
| 2 | # | ||
| 3 | # Mingw32f.pl -- copy files; Mingw32.pl is needed to do the compiling. | ||
| 4 | # | ||
| 5 | |||
| 6 | $o='\\'; | ||
| 7 | $cp='copy'; | ||
| 8 | $rm='del'; | ||
| 9 | |||
| 10 | # C compiler stuff | ||
| 11 | |||
| 12 | $cc='gcc'; | ||
| 13 | if ($debug) | ||
| 14 | { $cflags="-g2 -ggdb -DDSO_WIN32"; } | ||
| 15 | else | ||
| 16 | { $cflags="-O3 -fomit-frame-pointer -DDSO_WIN32"; } | ||
| 17 | |||
| 18 | $obj='.o'; | ||
| 19 | $ofile='-o '; | ||
| 20 | |||
| 21 | # EXE linking stuff | ||
| 22 | $link='${CC}'; | ||
| 23 | $lflags='${CFLAGS}'; | ||
| 24 | $efile='-o '; | ||
| 25 | $exep=''; | ||
| 26 | $ex_libs="-lwsock32 -lgdi32"; | ||
| 27 | |||
| 28 | # static library stuff | ||
| 29 | $mklib='ar r'; | ||
| 30 | $mlflags=''; | ||
| 31 | $ranlib='ranlib'; | ||
| 32 | $plib='lib'; | ||
| 33 | $libp=".a"; | ||
| 34 | $shlibp=".a"; | ||
| 35 | $lfile=''; | ||
| 36 | |||
| 37 | $asm='as'; | ||
| 38 | $afile='-o '; | ||
| 39 | $bn_asm_obj=""; | ||
| 40 | $bn_asm_src=""; | ||
| 41 | $des_enc_obj=""; | ||
| 42 | $des_enc_src=""; | ||
| 43 | $bf_enc_obj=""; | ||
| 44 | $bf_enc_src=""; | ||
| 45 | |||
| 46 | sub do_lib_rule | ||
| 47 | { | ||
| 48 | local($obj,$target,$name,$shlib)=@_; | ||
| 49 | local($ret,$_,$Name); | ||
| 50 | |||
| 51 | $target =~ s/\//$o/g if $o ne '/'; | ||
| 52 | $target="$target"; | ||
| 53 | ($Name=$name) =~ tr/a-z/A-Z/; | ||
| 54 | |||
| 55 | $ret.="$target: \$(${Name}OBJ)\n"; | ||
| 56 | $ret.="\t\$(RM) $target\n"; | ||
| 57 | $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n"; | ||
| 58 | $ret.="\t\$(RANLIB) $target\n\n"; | ||
| 59 | } | ||
| 60 | |||
| 61 | sub do_link_rule | ||
| 62 | { | ||
| 63 | local($target,$files,$dep_libs,$libs)=@_; | ||
| 64 | local($ret,$_); | ||
| 65 | |||
| 66 | $file =~ s/\//$o/g if $o ne '/'; | ||
| 67 | $n=&bname($target); | ||
| 68 | $ret.="$target: $files $dep_libs\n"; | ||
| 69 | $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n"; | ||
| 70 | return($ret); | ||
| 71 | } | ||
| 72 | 1; | ||
| 73 | |||
