Latest update.

This commit is contained in:
2019-10-17 23:54:38 +09:00
parent 41a23ae6f6
commit ee84d0dd84
1357 changed files with 41111 additions and 9603 deletions
+27
View File
@@ -9,6 +9,33 @@
Changes between 1.1.1 and 3.0.0 [xx XXX xxxx] Changes between 1.1.1 and 3.0.0 [xx XXX xxxx]
*) Added functionality to create an EVP_PKEY context based on data
for methods from providers. This takes an algorithm name and a
property query string and simply stores them, with the intent
that any operation that uses this context will use those strings
to fetch the needed methods implicitly, thereby making the port
of application written for pre-3.0 OpenSSL easier.
[Richard Levitte]
*) The undocumented function NCONF_WIN32() has been deprecated; for
conversion details see the HISTORY section of doc/man5/config.pod
[Rich Salz]
*) Introduced the new functions EVP_DigestSignInit_ex() and
EVP_DigestVerifyInit_ex(). The macros EVP_DigestSignUpdate() and
EVP_DigestVerifyUpdate() have been converted to functions. See the man
pages for further details.
[Matt Caswell]
*) Over two thousand fixes were made to the documentation, including:
adding missing command flags, better style conformance, documentation
of internals, etc.
[Rich Salz, Richard Levitte]
*) s390x assembly pack: add hardware-support for P-256, P-384, P-521,
X25519, X448, Ed25519 and Ed448.
[Patrick Steuer]
*) Print all values for a PKCS#12 attribute with 'openssl pkcs12', not just *) Print all values for a PKCS#12 attribute with 'openssl pkcs12', not just
the first value. the first value.
[Jon Spillett] [Jon Spillett]
+1 -1
View File
@@ -450,7 +450,7 @@ my %targets = (
# 32-bit message digests. (For the moment of this writing) HP C # 32-bit message digests. (For the moment of this writing) HP C
# doesn't seem to "digest" too many local variables (they make "him" # doesn't seem to "digest" too many local variables (they make "him"
# chew forever:-). For more details look-up MD32_XARRAY comment in # chew forever:-). For more details look-up MD32_XARRAY comment in
# crypto/sha/sha_lcl.h. # crypto/sha/sha_local.h.
# - originally there were 32-bit hpux-parisc2-* targets. They were # - originally there were 32-bit hpux-parisc2-* targets. They were
# scrapped, because a) they were not interchangeable with other 32-bit # scrapped, because a) they were not interchangeable with other 32-bit
# targets; b) performance-critical 32-bit assembly modules implement # targets; b) performance-critical 32-bit assembly modules implement
+286 -53
View File
@@ -2,37 +2,99 @@
use File::Basename; use File::Basename;
my $debug_resolvedepends = $ENV{BUILDFILE_DEBUG_DEPENDS};
my $debug_rules = $ENV{BUILDFILE_DEBUG_RULES};
# A cache of objects for which a recipe has already been generated # A cache of objects for which a recipe has already been generated
my %cache; my %cache;
# resolvedepends and reducedepends work in tandem to make sure # collectdepends, expanddepends and reducedepends work together to make
# there are no duplicate dependencies and that they are in the # sure there are no duplicate or weak dependencies and that they are in
# right order. This is especially used to sort the list of # the right order. This is used to sort the list of libraries that a
# libraries that a build depends on. # build depends on.
sub extensionlesslib { sub extensionlesslib {
my @result = map { $_ =~ /(\.a)?$/; $` } @_; my @result = map { $_ =~ /(\.a)?$/; $` } @_;
return @result if wantarray; return @result if wantarray;
return $result[0]; return $result[0];
} }
sub resolvedepends {
# collectdepends dives into the tree of dependencies and returns
# a list of all the non-weak ones.
sub collectdepends {
return () unless @_;
my $thing = shift; my $thing = shift;
my $extensionlessthing = extensionlesslib($thing); my $extensionlessthing = extensionlesslib($thing);
my @listsofar = @_; # to check if we're looping my @listsofar = @_; # to check if we're looping
my @list = @{$unified_info{depends}->{$thing} // my @list = @{$unified_info{depends}->{$thing} //
$unified_info{depends}->{$extensionlessthing}}; $unified_info{depends}->{$extensionlessthing}};
my @newlist = (); my @newlist = ();
if (scalar @list) {
foreach my $item (@list) { print STDERR "DEBUG[collectdepends] $thing > ", join(' ', @listsofar), "\n"
my $extensionlessitem = extensionlesslib($item); if $debug_resolvedepends;
# It's time to break off when the dependency list starts looping foreach my $item (@list) {
next if grep { extensionlesslib($_) eq $extensionlessitem } @listsofar; my $extensionlessitem = extensionlesslib($item);
push @newlist, $item, resolvedepends($item, @listsofar, $item); # It's time to break off when the dependency list starts looping
} next if grep { extensionlesslib($_) eq $extensionlessitem } @listsofar;
# Don't add anything here if the dependency is weak
next if defined $unified_info{attributes}->{depends}->{$thing}->{$item}->{'weak'};
my @resolved = collectdepends($item, @listsofar, $item);
push @newlist, $item, @resolved;
} }
print STDERR "DEBUG[collectdepends] $thing < ", join(' ', @newlist), "\n"
if $debug_resolvedepends;
@newlist; @newlist;
} }
# expanddepends goes through a list of stuff, checks if they have any
# dependencies, and adds them at the end of the current position if
# they aren't already present later on.
sub expanddepends {
my @after = ( @_ );
print STDERR "DEBUG[expanddepends]> ", join(' ', @after), "\n"
if $debug_resolvedepends;
my @before = ();
while (@after) {
my $item = shift @after;
print STDERR "DEBUG[expanddepends]\\ ", join(' ', @before), "\n"
if $debug_resolvedepends;
print STDERR "DEBUG[expanddepends] - ", $item, "\n"
if $debug_resolvedepends;
my @middle = (
$item,
map {
my $x = $_;
my $extlessx = extensionlesslib($x);
if (grep { $extlessx eq extensionlesslib($_) } @before
and
!grep { $extlessx eq extensionlesslib($_) } @after) {
print STDERR "DEBUG[expanddepends] + ", $x, "\n"
if $debug_resolvedepends;
( $x )
} else {
print STDERR "DEBUG[expanddepends] ! ", $x, "\n"
if $debug_resolvedepends;
()
}
} @{$unified_info{depends}->{$item} // []}
);
print STDERR "DEBUG[expanddepends] = ", join(' ', @middle), "\n"
if $debug_resolvedepends;
print STDERR "DEBUG[expanddepends]/ ", join(' ', @after), "\n"
if $debug_resolvedepends;
push @before, @middle;
}
print STDERR "DEBUG[expanddepends]< ", join(' ', @before), "\n"
if $debug_resolvedepends;
@before;
}
# reducedepends looks through a list, and checks if each item is
# repeated later on. If it is, the earlier copy is dropped.
sub reducedepends { sub reducedepends {
my @list = @_; my @list = @_;
print STDERR "DEBUG[reducedepends]> ", join(' ', @list), "\n"
if $debug_resolvedepends;
my @newlist = (); my @newlist = ();
my %replace = (); my %replace = ();
while (@list) { while (@list) {
@@ -49,7 +111,25 @@
push @newlist, $item; push @newlist, $item;
} }
} }
map { $replace{$_} // $_; } @newlist; @newlist = map { $replace{$_} // $_; } @newlist;
print STDERR "DEBUG[reducedepends]< ", join(' ', @newlist), "\n"
if $debug_resolvedepends;
@newlist;
}
# Do it all
# This takes multiple inputs and combine them into a single list of
# interdependent things. The returned value will include all the input.
# Callers are responsible for taking away the things they are building.
sub resolvedepends {
print STDERR "DEBUG[resolvedepends] START (", join(', ', @_), ")\n"
if $debug_resolvedepends;
my @all =
reducedepends(expanddepends(map { ( $_, collectdepends($_) ) } @_));
print STDERR "DEBUG[resolvedepends] END (", join(', ', @_), ") : ",
join(',', map { "\n $_" } @all), "\n"
if $debug_resolvedepends;
@all;
} }
# dogenerate is responsible for producing all the recipes that build # dogenerate is responsible for producing all the recipes that build
@@ -91,14 +171,30 @@
my $bin = shift; my $bin = shift;
my %opts = @_; my %opts = @_;
if (@{$unified_info{sources}->{$obj}}) { if (@{$unified_info{sources}->{$obj}}) {
$OUT .= src2obj(obj => $obj, my @srcs = @{$unified_info{sources}->{$obj}};
product => $bin, my @deps = @{$unified_info{depends}->{$obj}};
srcs => $unified_info{sources}->{$obj}, my @incs = ( @{$unified_info{includes}->{$obj}},
deps => $unified_info{depends}->{$obj}, @{$unified_info{includes}->{$bin}} );
incs => [ @{$unified_info{includes}->{$obj}}, my @defs = ( @{$unified_info{defines}->{$obj}},
@{$unified_info{includes}->{$bin}} ], @{$unified_info{defines}->{$bin}} );
defs => [ @{$unified_info{defines}->{$obj}}, print STDERR "DEBUG[doobj] \@srcs for $obj ($bin) : ",
@{$unified_info{defines}->{$bin}} ], join(",", map { "\n $_" } @srcs), "\n"
if $debug_rules;
print STDERR "DEBUG[doobj] \@deps for $obj ($bin) : ",
join(",", map { "\n $_" } @deps), "\n"
if $debug_rules;
print STDERR "DEBUG[doobj] \@incs for $obj ($bin) : ",
join(",", map { "\n $_" } @incs), "\n"
if $debug_rules;
print STDERR "DEBUG[doobj] \@defs for $obj ($bin) : ",
join(",", map { "\n $_" } @defs), "\n"
if $debug_rules;
print STDERR "DEBUG[doobj] \%opts for $obj ($bin) : ", ,
join(",", map { "\n $_ = $opts{$_}" } sort keys %opts), "\n"
if $debug_rules;
$OUT .= src2obj(obj => $obj, product => $bin,
srcs => [ @srcs ], deps => [ @deps ],
incs => [ @incs ], defs => [ @defs ],
%opts); %opts);
foreach ((@{$unified_info{sources}->{$obj}}, foreach ((@{$unified_info{sources}->{$obj}},
@{$unified_info{depends}->{$obj}})) { @{$unified_info{depends}->{$obj}})) {
@@ -108,37 +204,152 @@
$cache{$obj} = 1; $cache{$obj} = 1;
} }
# Helper functions to grab all applicable intermediary files.
# This is particularly useful when a library is given as source
# rather than a dependency. In that case, we consider it to be a
# container with object file references, or possibly references
# to further libraries to pilfer in the same way.
sub getsrclibs {
my $section = shift;
# For all input, see if it sources static libraries. If it does,
# return them together with the result of a recursive call.
map { ( $_, getsrclibs($section, $_) ) }
grep { $_ =~ m|\.a$| }
map { @{$unified_info{$section}->{$_} // []} }
@_;
}
sub getlibobjs {
my $section = shift;
# For all input, see if it's an intermediary file (library or object).
# If it is, collect the result of a recursive call, or if that returns
# an empty list, the element itself. Return the result.
map {
my @x = getlibobjs($section, @{$unified_info{$section}->{$_}});
@x ? @x : ( $_ );
}
grep { defined $unified_info{$section}->{$_} }
@_;
}
# dolib is responsible for building libraries. It will call # dolib is responsible for building libraries. It will call
# obj2shlib is shared libraries are produced, and obj2lib in all # obj2shlib if shared libraries are produced, and obj2lib in all
# cases. It also makes sure all object files for the library are # cases. It also makes sure all object files for the library are
# built. # built.
sub dolib { sub dolib {
my $lib = shift; my $lib = shift;
return "" if $cache{$lib}; return "" if $cache{$lib};
my %attrs = %{$unified_info{attributes}->{libraries}->{$lib}};
my @deps = ( resolvedepends(getsrclibs('sources', $lib)) );
# We support two types of objs, those who are specific to this library
# (they end up in @objs) and those that we get indirectly, via other
# libraries (they end up in @foreign_objs). We get the latter any time
# someone has done something like this in build.info:
# SOURCE[libfoo.a]=libbar.a
# The indirect object files must be kept in a separate array so they
# don't get rebuilt unnecessarily (and with incorrect auxiliary
# information).
#
# Object files can't be collected commonly for shared and static
# libraries, because we contain their respective object files in
# {shared_sources} and {sources}, and because the implications are
# slightly different for each library form.
#
# We grab all these "foreign" object files recursively with getlibobjs().
unless ($disabled{shared} || $lib =~ /\.a$/) { unless ($disabled{shared} || $lib =~ /\.a$/) {
my $obj2shlib = defined &obj2shlib ? \&obj2shlib : \&libobj2shlib; my $obj2shlib = defined &obj2shlib ? \&obj2shlib : \&libobj2shlib;
# If this library sources other static libraries and those
# libraries are marked {noinst}, there's no need to include
# all of their object files. Instead, we treat those static
# libraries as dependents alongside any other library this
# one depends on, and let symbol resolution do its job.
my @sourced_libs = ();
my @objs = ();
my @foreign_objs = ();
my @deps = ();
foreach (@{$unified_info{shared_sources}->{$lib}}) {
if ($_ !~ m|\.a$|) {
push @objs, $_;
} elsif ($unified_info{attributes}->{libraries}->{$_}->{noinst}) {
push @deps, $_;
} else {
push @deps, getsrclibs('sources', $_);
push @foreign_objs, getlibobjs('sources', $_);
}
}
@deps = ( grep { $_ ne $lib } resolvedepends($lib, @deps) );
print STDERR "DEBUG[dolib:shlib] \%attrs for $lib : ", ,
join(",", map { "\n $_ = $attrs{$_}" } sort keys %attrs), "\n"
if %attrs && $debug_rules;
print STDERR "DEBUG[dolib:shlib] \@deps for $lib : ",
join(",", map { "\n $_" } @deps), "\n"
if @deps && $debug_rules;
print STDERR "DEBUG[dolib:shlib] \@objs for $lib : ",
join(",", map { "\n $_" } @objs), "\n"
if @objs && $debug_rules;
print STDERR "DEBUG[dolib:shlib] \@foreign_objs for $lib : ",
join(",", map { "\n $_" } @foreign_objs), "\n"
if @foreign_objs && $debug_rules;
$OUT .= $obj2shlib->(lib => $lib, $OUT .= $obj2shlib->(lib => $lib,
attrs => $unified_info{attributes}->{$lib}, attrs => { %attrs },
objs => $unified_info{shared_sources}->{$lib}, objs => [ @objs, @foreign_objs ],
deps => [ reducedepends(resolvedepends($lib)) ]); deps => [ @deps ]);
foreach ((@{$unified_info{shared_sources}->{$lib}}, foreach (@objs) {
@{$unified_info{sources}->{$lib}})) {
# If this is somehow a compiled object, take care of it that way # If this is somehow a compiled object, take care of it that way
# Otherwise, it might simply be generated # Otherwise, it might simply be generated
if (defined $unified_info{sources}->{$_}) { if (defined $unified_info{sources}->{$_}) {
doobj($_, $lib, intent => "shlib", if($_ =~ /\.a$/) {
attrs => $unified_info{attributes}->{$lib}); dolib($_);
} else {
doobj($_, $lib, intent => "shlib", attrs => { %attrs });
}
} else { } else {
dogenerate($_, undef, undef, intent => "lib"); dogenerate($_, undef, undef, intent => "lib");
} }
} }
} }
$OUT .= obj2lib(lib => $lib, {
attrs => $unified_info{attributes}->{$lib}, # When putting static libraries together, we cannot rely on any
objs => [ @{$unified_info{sources}->{$lib}} ]); # symbol resolution, so for all static libraries used as source for
foreach (@{$unified_info{sources}->{$lib}}) { # this one, as well as other libraries they depend on, we simply
doobj($_, $lib, intent => "lib", # grab all their object files unconditionally,
attrs => $unified_info{attributes}->{$lib}); # Symbol resolution will happen when any program, module or shared
# library is linked with this one.
my @objs = ();
my @sourcedeps = ();
my @foreign_objs = ();
foreach (@{$unified_info{sources}->{$lib}}) {
if ($_ !~ m|\.a$|) {
push @objs, $_;
} else {
push @sourcedeps, $_;
}
}
@sourcedeps = ( grep { $_ ne $lib } resolvedepends(@sourcedeps) );
print STDERR "DEBUG[dolib:lib] : \@sourcedeps for $_ : ",
join(",", map { "\n $_" } @sourcedeps), "\n"
if @sourcedeps && $debug_rules;
@foreign_objs = getlibobjs('sources', @sourcedeps);
print STDERR "DEBUG[dolib:lib] \%attrs for $lib : ", ,
join(",", map { "\n $_ = $attrs{$_}" } sort keys %attrs), "\n"
if %attrs && $debug_rules;
print STDERR "DEBUG[dolib:lib] \@objs for $lib : ",
join(",", map { "\n $_" } @objs), "\n"
if @objs && $debug_rules;
print STDERR "DEBUG[dolib:lib] \@foreign_objs for $lib : ",
join(",", map { "\n $_" } @foreign_objs), "\n"
if @foreign_objs && $debug_rules;
$OUT .= obj2lib(lib => $lib, attrs => { %attrs },
objs => [ @objs, @foreign_objs ]);
foreach (@objs) {
doobj($_, $lib, intent => "lib", attrs => { %attrs });
}
} }
$cache{$lib} = 1; $cache{$lib} = 1;
} }
@@ -147,23 +358,35 @@
# obj2dso, and also makes sure all object files for the library # obj2dso, and also makes sure all object files for the library
# are built. # are built.
sub domodule { sub domodule {
my $lib = shift; my $module = shift;
return "" if $cache{$lib}; return "" if $cache{$module};
$OUT .= obj2dso(lib => $lib, my %attrs = %{$unified_info{attributes}->{modules}->{$module}};
attrs => $unified_info{attributes}->{$lib}, my @objs = @{$unified_info{sources}->{$module}};
objs => $unified_info{sources}->{$lib}, my @deps = ( grep { $_ ne $module }
deps => [ resolvedepends($lib) ]); resolvedepends($module) );
foreach (@{$unified_info{sources}->{$lib}}) { print STDERR "DEBUG[domodule] \%attrs for $module :",
join(",", map { "\n $_ = $attrs{$_}" } sort keys %attrs), "\n"
if $debug_rules;
print STDERR "DEBUG[domodule] \@objs for $module : ",
join(",", map { "\n $_" } @objs), "\n"
if $debug_rules;
print STDERR "DEBUG[domodule] \@deps for $module : ",
join(",", map { "\n $_" } @deps), "\n"
if $debug_rules;
$OUT .= obj2dso(module => $module,
attrs => { %attrs },
objs => [ @objs ],
deps => [ @deps ]);
foreach (@{$unified_info{sources}->{$module}}) {
# If this is somehow a compiled object, take care of it that way # If this is somehow a compiled object, take care of it that way
# Otherwise, it might simply be generated # Otherwise, it might simply be generated
if (defined $unified_info{sources}->{$_}) { if (defined $unified_info{sources}->{$_}) {
doobj($_, $lib, intent => "dso", doobj($_, $module, intent => "dso", attrs => { %attrs });
attrs => $unified_info{attributes}->{$lib});
} else { } else {
dogenerate($_, undef, $lib, intent => "dso"); dogenerate($_, undef, $module, intent => "dso");
} }
} }
$cache{$lib} = 1; $cache{$module} = 1;
} }
# dobin is responsible for building programs. It will call obj2bin, # dobin is responsible for building programs. It will call obj2bin,
@@ -171,14 +394,24 @@
sub dobin { sub dobin {
my $bin = shift; my $bin = shift;
return "" if $cache{$bin}; return "" if $cache{$bin};
my $deps = [ reducedepends(resolvedepends($bin)) ]; my %attrs = %{$unified_info{attributes}->{programs}->{$bin}};
my @objs = @{$unified_info{sources}->{$bin}};
my @deps = ( grep { $_ ne $bin } resolvedepends($bin) );
print STDERR "DEBUG[dobin] \%attrs for $bin : ",
join(",", map { "\n $_ = $attrs{$_}" } sort keys %attrs), "\n"
if %attrs && $debug_rules;
print STDERR "DEBUG[dobin] \@objs for $bin : ",
join(",", map { "\n $_" } @objs), "\n"
if @objs && $debug_rules;
print STDERR "DEBUG[dobin] \@deps for $bin : ",
join(",", map { "\n $_" } @deps), "\n"
if @deps && $debug_rules;
$OUT .= obj2bin(bin => $bin, $OUT .= obj2bin(bin => $bin,
attrs => $unified_info{attributes}->{$bin}, attrs => { %attrs },
objs => [ @{$unified_info{sources}->{$bin}} ], objs => [ @objs ],
deps => $deps); deps => [ @deps ]);
foreach (@{$unified_info{sources}->{$bin}}) { foreach (@objs) {
doobj($_, $bin, intent => "bin", doobj($_, $bin, intent => "bin", attrs => { %attrs });
attrs => $unified_info{attributes}->{$bin});
} }
$cache{$bin} = 1; $cache{$bin} = 1;
} }
+18 -14
View File
@@ -48,26 +48,26 @@
@{$unified_info{libraries}}; @{$unified_info{libraries}};
our @install_libs = our @install_libs =
map { platform->staticname($_) } map { platform->staticname($_) }
grep { !$unified_info{attributes}->{$_}->{noinst} } grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
@{$unified_info{libraries}}; @{$unified_info{libraries}};
our @install_shlibs = our @install_shlibs =
map { platform->sharedname($_) // () } map { platform->sharedname($_) // () }
grep { !$unified_info{attributes}->{$_}->{noinst} } grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
@{$unified_info{libraries}}; @{$unified_info{libraries}};
our @install_engines = our @install_engines =
grep { !$unified_info{attributes}->{$_}->{noinst} grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
&& $unified_info{attributes}->{$_}->{engine} } && $unified_info{attributes}->{modules}->{$_}->{engine} }
@{$unified_info{modules}}; @{$unified_info{modules}};
our @install_programs = our @install_programs =
grep { !$unified_info{attributes}->{$_}->{noinst} } grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
@{$unified_info{programs}}; @{$unified_info{programs}};
our @install_bin_scripts = our @install_bin_scripts =
grep { !$unified_info{attributes}->{$_}->{noinst} grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
&& !$unified_info{attributes}->{$_}->{misc} } && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
@{$unified_info{scripts}}; @{$unified_info{scripts}};
our @install_misc_scripts = our @install_misc_scripts =
grep { !$unified_info{attributes}->{$_}->{noinst} grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
&& $unified_info{attributes}->{$_}->{misc} } && $unified_info{attributes}->{scripts}->{$_}->{misc} }
@{$unified_info{scripts}}; @{$unified_info{scripts}};
# This is a horrible hack, but is needed because recursive inclusion of files # This is a horrible hack, but is needed because recursive inclusion of files
@@ -704,7 +704,7 @@ reconfigure reconf :
# On Unix platforms, we depend on {shlibname}.so # On Unix platforms, we depend on {shlibname}.so
return map { return map {
{ lib => platform->sharedlib($_) // platform->staticlib($_), { lib => platform->sharedlib($_) // platform->staticlib($_),
attrs => $unified_info{attributes}->{$_} } attrs => $unified_info{attributes}->{libraries}->{$_} }
} @_; } @_;
} }
@@ -775,10 +775,14 @@ EOF
my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
"util", "dofile.pl")), "util", "dofile.pl")),
rel2abs($config{builddir})); rel2abs($config{builddir}));
my @modules = ( 'configdata.pm',
grep { $_ =~ m|\.pm$| } @{$args{deps}} );
my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
@modules = map { '"-M'.basename($_, '.pm').'"' } @modules;
my $modules = join(' ', '', sort keys %moduleincs, @modules);
return <<"EOF"; return <<"EOF";
$target : $args{generator}->[0] $deps $target : $args{generator}->[0] $deps
\$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\ \$(PERL)$modules $dofile "-o$target{build_file}" $generator > \$\@
"-o$target{build_file}" $generator > \$\@
EOF EOF
} else { } else {
return <<"EOF"; return <<"EOF";
@@ -1014,8 +1018,8 @@ EOF
} }
sub obj2dso { sub obj2dso {
my %args = @_; my %args = @_;
my $dsoname = platform->dsoname($args{lib}); my $dsoname = platform->dsoname($args{module});
my $dso = platform->dso($args{lib}); my $dso = platform->dso($args{module});
my @objs = map { platform->convertext($_) } my @objs = map { platform->convertext($_) }
grep { platform->isobj($_) } grep { platform->isobj($_) }
@{$args{objs}}; @{$args{objs}};
+6 -4
View File
@@ -52,11 +52,13 @@ sub isdef { return $_[1] =~ m|\.ld$|; }
sub isobj { return $_[1] =~ m|\.o$|; } sub isobj { return $_[1] =~ m|\.o$|; }
sub isres { return $_[1] =~ m|\.res$|; } sub isres { return $_[1] =~ m|\.res$|; }
sub isasm { return $_[1] =~ m|\.[Ss]$|; } sub isasm { return $_[1] =~ m|\.[Ss]$|; }
sub isstaticlib { return $_[1] =~ m|\.a$|; }
sub convertext { sub convertext {
if ($_[0]->isdef($_[1])) { return $_[0]->def($_[1]); } if ($_[0]->isdef($_[1])) { return $_[0]->def($_[1]); }
if ($_[0]->isobj($_[1])) { return $_[0]->obj($_[1]); } if ($_[0]->isobj($_[1])) { return $_[0]->obj($_[1]); }
if ($_[0]->isres($_[1])) { return $_[0]->res($_[1]); } if ($_[0]->isres($_[1])) { return $_[0]->res($_[1]); }
if ($_[0]->isasm($_[1])) { return $_[0]->asm($_[1]); } if ($_[0]->isasm($_[1])) { return $_[0]->asm($_[1]); }
if ($_[0]->isstaticlib($_[1])) { return $_[0]->staticlib($_[1]); }
return $_[1]; return $_[1];
} }
+3
View File
@@ -17,6 +17,9 @@ sub objext { '.obj' }
sub libext { '.a' } sub libext { '.a' }
sub dsoext { '.dll' } sub dsoext { '.dll' }
sub defext { '.def' } sub defext { '.def' }
# Other extra that aren't defined in platform::BASE
sub resext { '.res.obj' }
sub shlibext { '.dll' } sub shlibext { '.dll' }
sub shlibextimport { $target{shared_import_extension} || '.dll.a' } sub shlibextimport { $target{shared_import_extension} || '.dll.a' }
sub shlibextsimple { undef } sub shlibextsimple { undef }
+219 -99
View File
@@ -20,6 +20,40 @@
return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target"; return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
} }
our $COLUMNS = $ENV{COLUMNS};
if ($COLUMNS =~ /^\d+$/) {
$COLUMNS = int($COLUMNS) - 2; # 2 to leave space for ending ' \'
} else {
$COLUMNS = 76;
}
sub fill_lines {
my $item_sep = shift; # string
my $line_length = shift; # number of chars
my @result = ();
my $resultpos = 0;
foreach (@_) {
my $fill_line = $result[$resultpos] // '';
my $newline =
($fill_line eq '' ? '' : $fill_line . $item_sep) . $_;
if (length($newline) > $line_length) {
# If this is a single item and the intended result line
# is empty, we put it there anyway
if ($fill_line eq '') {
$result[$resultpos++] = $newline;
} else {
$result[++$resultpos] = $_;
}
} else {
$result[$resultpos] = $newline;
}
}
return @result;
}
''; '';
-} -}
PLATFORM={- $config{target} -} PLATFORM={- $config{target} -}
@@ -34,65 +68,99 @@ MINOR={- $config{minor} -}
SHLIB_VERSION_NUMBER={- $config{shlib_version} -} SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
SHLIB_TARGET={- $target{shared_target} -} SHLIB_TARGET={- $target{shared_target} -}
LIBS={- join(" ", map { platform->staticlib($_) // () } @{$unified_info{libraries}}) -} LIBS={- join(" \\\n" . ' ' x 5,
SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -} fill_lines(" ", $COLUMNS - 5,
SHLIB_INFO={- join(" ", map { my $x = platform->sharedlib($_); map { platform->staticlib($_) // () }
my $y = platform->sharedlib_simple($_); @{$unified_info{libraries}})) -}
$x ? "\"$x;$y\"" : () } SHLIBS={- join(" \\\n" . ' ' x 7,
@{$unified_info{libraries}}) -} fill_lines(" ", $COLUMNS - 7,
MODULES={- join(" ", map { platform->dso($_) } @{$unified_info{modules}}) -} map { platform->sharedlib($_) // () }
PROGRAMS={- join(" ", map { platform->bin($_) } @{$unified_info{programs}}) -} @{$unified_info{libraries}})) -}
SCRIPTS={- join(" ", @{$unified_info{scripts}}) -} SHLIB_INFO={- join(" \\\n" . ' ' x 11,
fill_lines(" ", $COLUMNS - 11,
map { my $x = platform->sharedlib($_);
my $y = platform->sharedlib_simple($_);
$x ? "\"$x;$y\"" : () }
@{$unified_info{libraries}})) -}
MODULES={- join(" \\\n" . ' ' x 8,
fill_lines(" ", $COLUMNS - 8,
map { platform->dso($_) }
@{$unified_info{modules}})) -}
PROGRAMS={- join(" \\\n" . ' ' x 9,
fill_lines(" ", $COLUMNS - 9,
map { platform->bin($_) }
@{$unified_info{programs}})) -}
SCRIPTS={- join(" \\\n" . ' ' x 8,
fill_lines(" ", $COLUMNS - 8, @{$unified_info{scripts}})) -}
{- output_off() if $disabled{makedepend}; "" -} {- output_off() if $disabled{makedepend}; "" -}
DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () } DEPS={- join(" \\\n" . ' ' x 5,
grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } fill_lines(" ", $COLUMNS - 5,
keys %{$unified_info{sources}}); -} map { platform->isobj($_) ? platform->dep($_) : () }
grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
keys %{$unified_info{sources}})); -}
{- output_on() if $disabled{makedepend}; "" -} {- output_on() if $disabled{makedepend}; "" -}
GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -} GENERATED_MANDATORY={- join(" \\\n" . ' ' x 20,
fill_lines(" ", $COLUMNS - 20,
@{$unified_info{depends}->{""}})) -}
GENERATED={- # common0.tmpl provides @generated GENERATED={- # common0.tmpl provides @generated
join(" ", map { platform->convertext($_) } @generated ) -} join(" \\\n" . ' ' x 5,
fill_lines(" ", $COLUMNS - 5,
map { platform->convertext($_) } @generated )) -}
INSTALL_LIBS={- INSTALL_LIBS={-
join(" ", map { platform->staticlib($_) // () } join(" \\\n" . ' ' x 13,
grep { !$unified_info{attributes}->{$_}->{noinst} } fill_lines(" ", $COLUMNS - 13,
@{$unified_info{libraries}}) map { platform->staticlib($_) // () }
grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
@{$unified_info{libraries}}))
-} -}
INSTALL_SHLIBS={- INSTALL_SHLIBS={-
join(" ", map { platform->sharedlib($_) // () } join(" \\\n" . ' ' x 15,
grep { !$unified_info{attributes}->{$_}->{noinst} } fill_lines(" ", $COLUMNS - 15,
@{$unified_info{libraries}}) map { platform->sharedlib($_) // () }
grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
@{$unified_info{libraries}}))
-} -}
INSTALL_SHLIB_INFO={- INSTALL_SHLIB_INFO={-
join(" ", map { my $x = platform->sharedlib($_); join(" \\\n" . ' ' x 19,
my $y = platform->sharedlib_simple($_); fill_lines(" ", $COLUMNS - 19,
$x ? "\"$x;$y\"" : () } map { my $x = platform->sharedlib($_);
grep { !$unified_info{attributes}->{$_}->{noinst} } my $y = platform->sharedlib_simple($_);
@{$unified_info{libraries}}) $x ? "\"$x;$y\"" : () }
grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
@{$unified_info{libraries}}))
-} -}
INSTALL_ENGINES={- INSTALL_ENGINES={-
join(" ", map { platform->dso($_) } join(" \\\n" . ' ' x 16,
grep { !$unified_info{attributes}->{$_}->{noinst} fill_lines(" ", $COLUMNS - 16,
&& $unified_info{attributes}->{$_}->{engine} } map { platform->dso($_) }
@{$unified_info{modules}}) grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
&& $unified_info{attributes}->{modules}->{$_}->{engine} }
@{$unified_info{modules}}))
-} -}
INSTALL_PROGRAMS={- INSTALL_PROGRAMS={-
join(" ", map { platform->bin($_) } join(" \\\n" . ' ' x 16,
grep { !$unified_info{attributes}->{$_}->{noinst} } fill_lines(" ", $COLUMNS - 16, map { platform->bin($_) }
@{$unified_info{programs}}) grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
@{$unified_info{programs}}))
-} -}
BIN_SCRIPTS={- BIN_SCRIPTS={-
join(" ", map { my $x = $unified_info{attributes}->{$_}->{linkname}; join(" \\\n" . ' ' x 12,
$x ? "$_:$x" : $_ } fill_lines(" ", $COLUMNS - 12,
grep { !$unified_info{attributes}->{$_}->{noinst} map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname};
&& !$unified_info{attributes}->{$_}->{misc} } $x ? "$_:$x" : $_ }
@{$unified_info{scripts}}) grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
&& !$unified_info{attributes}->{scripts}->{$_}->{misc} }
@{$unified_info{scripts}}))
-} -}
MISC_SCRIPTS={- MISC_SCRIPTS={-
join(" ", map { my $x = $unified_info{attributes}->{$_}->{linkname}; join(" \\\n" . ' ' x 13,
$x ? "$_:$x" : $_ } fill_lines(" ", $COLUMNS - 13,
grep { !$unified_info{attributes}->{$_}->{noinst} map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname};
&& $unified_info{attributes}->{$_}->{misc} } $x ? "$_:$x" : $_ }
@{$unified_info{scripts}}) grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
&& $unified_info{attributes}->{scripts}->{$_}->{misc} }
@{$unified_info{scripts}}))
-} -}
APPS_OPENSSL={- use File::Spec::Functions; APPS_OPENSSL={- use File::Spec::Functions;
@@ -729,7 +797,7 @@ generate: generate_apps generate_crypto_bn generate_crypto_objects \
.PHONY: doc-nits .PHONY: doc-nits
doc-nits: build_generated doc-nits: build_generated
(cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p -s ) (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -e )
# Test coverage is a good idea for the future # Test coverage is a good idea for the future
#coverage: $(PROGRAMS) $(TESTPROGRAMS) #coverage: $(PROGRAMS) $(TESTPROGRAMS)
@@ -823,8 +891,10 @@ errors:
} }
""; "";
-} -}
CRYPTOHEADERS={- join(" \\\n\t", sort @cryptoheaders) -} CRYPTOHEADERS={- join(" \\\n" . ' ' x 14,
SSLHEADERS={- join(" \\\n\t", sort @sslheaders) -} fill_lines(" ", $COLUMNS - 14, sort @cryptoheaders)) -}
SSLHEADERS={- join(" \\\n" . ' ' x 11,
fill_lines(" ", $COLUMNS - 11, sort @sslheaders)) -}
ordinals: ordinals:
( cd $(SRCDIR); \ ( cd $(SRCDIR); \
$(PERL) util/mknum.pl --version $(VERSION) --no-warnings \ $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
@@ -918,7 +988,12 @@ openssl.pc:
echo 'Version: '$(VERSION); \ echo 'Version: '$(VERSION); \
echo 'Requires: libssl libcrypto' ) > openssl.pc echo 'Requires: libssl libcrypto' ) > openssl.pc
configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -} configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config \
{- join(" \\\n" . ' ' x 15,
fill_lines(" ", $COLUMNS - 15,
@{$config{build_file_templates}},
@{$config{build_infos}},
@{$config{conf_files}})) -}
@echo "Detected changed: $?" @echo "Detected changed: $?"
$(PERL) configdata.pm -r $(PERL) configdata.pm -r
@echo "**************************************************" @echo "**************************************************"
@@ -966,10 +1041,14 @@ EOF
my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
"util", "dofile.pl")), "util", "dofile.pl")),
rel2abs($config{builddir})); rel2abs($config{builddir}));
my @modules = ( 'configdata.pm',
grep { $_ =~ m|\.pm$| } @{$args{deps}} );
my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
@modules = map { "-M".basename($_, '.pm') } @modules;
my $modules = join(' ', '', sort keys %moduleincs, @modules);
return <<"EOF"; return <<"EOF";
$args{src}: $args{generator}->[0] $deps $args{src}: $args{generator}->[0] $deps \$(BLDDIR)/configdata.pm
\$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ \$(PERL)$modules "$dofile" "-o$target{build_file}" $generator > \$@
"-o$target{build_file}" $generator > \$@
EOF EOF
} else { } else {
return <<"EOF"; return <<"EOF";
@@ -1015,7 +1094,7 @@ EOF
# last in the line. We may therefore need to put back a line ending. # last in the line. We may therefore need to put back a line ending.
sub src2obj { sub src2obj {
my %args = @_; my %args = @_;
my $obj = platform->obj($args{obj}); my $obj = platform->convertext($args{obj});
my $dep = platform->dep($args{obj}); my $dep = platform->dep($args{obj});
my @srcs = @{$args{srcs}}; my @srcs = @{$args{srcs}};
my $srcs = join(" ", @srcs); my $srcs = join(" ", @srcs);
@@ -1095,15 +1174,22 @@ EOF
sub obj2shlib { sub obj2shlib {
my %args = @_; my %args = @_;
my @linkdirs = (); my @linkdirs = ();
foreach (@{args{deps}}) { my @linklibs = ();
my $d = dirname($_); foreach (@{$args{deps}}) {
push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; if (platform->isstaticlib($_)) {
push @linklibs, platform->convertext($_);
} else {
my $d = "-L" . dirname($_);
my $l = basename($_);
$l =~ s/^lib//;
$l = "-l" . $l;
push @linklibs, $l;
push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
}
} }
my $linkflags = join("", map { "-L$_ " } @linkdirs); my $linkflags = join("", map { $_." " } @linkdirs);
my $linklibs = join("", map { my $f = basename($_); my $linklibs = join("", map { $_." " } @linklibs);
(my $l = $f) =~ s/^lib//; my @objs = map { platform->convertext($_) }
" -l$l" } @{$args{deps}});
my @objs = map { platform->obj($_) }
grep { !platform->isdef($_) } grep { !platform->isdef($_) }
@{$args{objs}}; @{$args{objs}};
my @defs = map { platform->def($_) } my @defs = map { platform->def($_) }
@@ -1111,8 +1197,7 @@ EOF
@{$args{objs}}; @{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}}); my @deps = compute_lib_depends(@{$args{deps}});
die "More than one exported symbol map" if scalar @defs > 1; die "More than one exported symbol map" if scalar @defs > 1;
my $objs = join(" ", @objs);
my $deps = join(" ", @objs, @defs, @deps);
my $simple = platform->sharedlib_simple($args{lib}); my $simple = platform->sharedlib_simple($args{lib});
my $full = platform->sharedlib($args{lib}); my $full = platform->sharedlib($args{lib});
my $shared_soname = ""; my $shared_soname = "";
@@ -1122,6 +1207,12 @@ EOF
$shared_imp .= ' '.$target{shared_impflag}.basename($simple) $shared_imp .= ' '.$target{shared_impflag}.basename($simple)
if defined $target{shared_impflag}; if defined $target{shared_impflag};
my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
my $deps = join(" \\\n" . ' ' x (length($full) + 2),
fill_lines(' ', $COLUMNS - length($full) - 2,
@objs, @defs, @deps));
my $recipe = <<"EOF"; my $recipe = <<"EOF";
$simple: $full $simple: $full
EOF EOF
@@ -1139,8 +1230,9 @@ EOF
$recipe .= <<"EOF"; $recipe .= <<"EOF";
$full: $deps $full: $deps
\$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\ \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
-o $full$shared_def $objs \\ -o $full$shared_def \\
$linklibs \$(LIB_EX_LIBS) $objs \\
$linklibs \$(LIB_EX_LIBS)
EOF EOF
if (windowsdll()) { if (windowsdll()) {
$recipe .= <<"EOF"; $recipe .= <<"EOF";
@@ -1156,38 +1248,52 @@ EOF
} }
sub obj2dso { sub obj2dso {
my %args = @_; my %args = @_;
my $dso = platform->dso($args{lib}); my $dso = platform->dso($args{module});
my @linkdirs = (); my @linkdirs = ();
foreach (@{args{deps}}) { my @linklibs = ();
my $d = dirname($_); foreach (@{$args{deps}}) {
push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; next unless defined $_;
if (platform->isstaticlib($_)) {
push @linklibs, platform->convertext($_);
} else {
my $d = "-L" . dirname($_);
my $l = basename($_);
$l =~ s/^lib//;
$l = "-l" . $l;
push @linklibs, $l;
push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
}
} }
my $linkflags = join("", map { "-L$_ " } @linkdirs); my $linkflags = join("", map { $_." " } @linkdirs);
my $linklibs = join("", map { my $f = basename($_); my $linklibs = join("", map { $_." " } @linklibs);
(my $l = $f) =~ s/^lib//; my @objs = map { platform->convertext($_) }
" -l$l" } @{$args{deps}});
my @objs = map { platform->obj($_) }
grep { !platform->isdef($_) } grep { !platform->isdef($_) }
@{$args{objs}}; @{$args{objs}};
my @defs = map { platform->def($_) } my @defs = map { platform->def($_) }
grep { platform->isdef($_) } grep { platform->isdef($_) }
@{$args{objs}}; @{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}}); my @deps = compute_lib_depends(@{$args{deps}});
my $objs = join(" ", @objs);
my $deps = join(" ", @objs, @defs, @deps);
my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
my $deps = join(" \\\n" . ' ' x (length($dso) + 2),
fill_lines(' ', $COLUMNS - length($dso) - 2,
@objs, @defs, @deps));
return <<"EOF"; return <<"EOF";
$dso: $deps $dso: $deps
\$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\ \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
-o $dso$shared_def $objs \\ -o $dso$shared_def \\
$linklibs \$(DSO_EX_LIBS) $objs \\
$linklibs\$(DSO_EX_LIBS)
EOF EOF
} }
sub obj2lib { sub obj2lib {
my %args = @_; my %args = @_;
my $lib = platform->staticlib($args{lib}); my $lib = platform->staticlib($args{lib});
my @objs = map { platform->obj($_) } @{$args{objs}}; my @objs = map { platform->obj($_) } @{$args{objs}};
my $objs = join(" ", @objs); my $objs = join(" \\\n" . ' ' x (length($lib) + 2),
fill_lines(' ', $COLUMNS - length($lib) - 2, @objs));
return <<"EOF"; return <<"EOF";
$lib: $objs $lib: $objs
\$(AR) \$(ARFLAGS) \$\@ \$\? \$(AR) \$(ARFLAGS) \$\@ \$\?
@@ -1197,35 +1303,46 @@ EOF
sub obj2bin { sub obj2bin {
my %args = @_; my %args = @_;
my $bin = platform->bin($args{bin}); my $bin = platform->bin($args{bin});
my $objs = join(" ", map { platform->obj($_) } @{$args{objs}}); my @objs = map { platform->obj($_) } @{$args{objs}};
my $deps = join(" ", compute_lib_depends(@{$args{deps}})); my @deps = compute_lib_depends(@{$args{deps}});
my $objs = join(" \\\n" . ' ' x (length($bin) + 2),
fill_lines(' ', $COLUMNS - length($bin) - 2, @objs));
my @linkdirs = (); my @linkdirs = ();
foreach (@{args{deps}}) { my @linklibs = ();
next if $_ =~ /\.a$/; foreach (@{$args{deps}}) {
my $d = dirname($_); next unless defined $_;
push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; if (platform->isstaticlib($_)) {
push @linklibs, platform->convertext($_);
} else {
my $d = "-L" . dirname($_);
my $l = basename($_);
$l =~ s/^lib//;
$l = "-l" . $l;
push @linklibs, $l;
push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
}
} }
my $linkflags = join("", map { "-L$_ " } @linkdirs); my $linkflags = join("", map { $_." " } @linkdirs);
my $linklibs = join("", map { if ($_ =~ m/\.a$/) { my $linklibs = join("", map { $_." " } @linklibs);
" ".platform->staticlib($_);
} else {
my $f = basename($_);
(my $l = $f) =~ s/^lib//;
" -l$l"
}
} @{$args{deps}});
my $cmd = '$(CC)'; my $cmd = '$(CC)';
my $cmdflags = '$(BIN_CFLAGS)'; my $cmdflags = '$(BIN_CFLAGS)';
if (grep /_cc\.o$/, @{$args{objs}}) { if (grep /_cc\.o$/, @{$args{objs}}) {
$cmd = '$(CXX)'; $cmd = '$(CXX)';
$cmdflags = '$(BIN_CXXFLAGS)'; $cmdflags = '$(BIN_CXXFLAGS)';
} }
my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
my $deps = join(" \\\n" . ' ' x (length($bin) + 2),
fill_lines(' ', $COLUMNS - length($bin) - 2,
@objs, @deps));
return <<"EOF"; return <<"EOF";
$bin: $objs $deps $bin: $deps
rm -f $bin rm -f $bin
\$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\ \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
-o $bin $objs \\ -o $bin \\
$linklibs \$(BIN_EX_LIBS) $objs \\
$linklibs\$(BIN_EX_LIBS)
EOF EOF
} }
sub in2script { sub in2script {
@@ -1246,7 +1363,7 @@ EOF
my %args = @_; my %args = @_;
my $dir = $args{dir}; my $dir = $args{dir};
my @deps = map { platform->convertext($_) } @{$args{deps}}; my @deps = map { platform->convertext($_) } @{$args{deps}};
my @actions = (); my @comments = ();
my %extinfo = ( dso => platform->dsoext(), my %extinfo = ( dso => platform->dsoext(),
lib => platform->libext(), lib => platform->libext(),
bin => platform->binext() ); bin => platform->binext() );
@@ -1266,16 +1383,19 @@ EOF
if (dirname($prod) eq $dir) { if (dirname($prod) eq $dir) {
push @deps, $prod.$extinfo{$type}; push @deps, $prod.$extinfo{$type};
} else { } else {
push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}}); push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
} }
} }
} }
} }
my $deps = join(" ", @deps); my $target = "$dir $dir/";
my $actions = join("\n", "", @actions); my $deps = join(" \\\n\t",
fill_lines(' ', $COLUMNS - 8, @deps));
my $comments = join("\n", "", @comments);
return <<"EOF"; return <<"EOF";
$dir $dir/: $deps$actions $target: \\
$deps$comments
EOF EOF
} }
"" # Important! This becomes part of the template result. "" # Important! This becomes part of the template result.
+21 -17
View File
@@ -62,53 +62,53 @@ GENERATED={- # common0.tmpl provides @generated
INSTALL_LIBS={- INSTALL_LIBS={-
join(" ", map { quotify1(platform->sharedlib_import($_) join(" ", map { quotify1(platform->sharedlib_import($_)
// platform->staticlib($_)) } // platform->staticlib($_)) }
grep { !$unified_info{attributes}->{$_}->{noinst} } grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
@{$unified_info{libraries}}) @{$unified_info{libraries}})
-} -}
INSTALL_SHLIBS={- INSTALL_SHLIBS={-
join(" ", map { my $x = platform->sharedlib($_); join(" ", map { my $x = platform->sharedlib($_);
$x ? quotify_l($x) : () } $x ? quotify_l($x) : () }
grep { !$unified_info{attributes}->{$_}->{noinst} } grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
@{$unified_info{libraries}}) @{$unified_info{libraries}})
-} -}
INSTALL_SHLIBPDBS={- INSTALL_SHLIBPDBS={-
join(" ", map { my $x = platform->sharedlibpdb($_); join(" ", map { my $x = platform->sharedlibpdb($_);
$x ? quotify_l($x) : () } $x ? quotify_l($x) : () }
grep { !$unified_info{attributes}->{$_}->{noinst} } grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
@{$unified_info{libraries}}) @{$unified_info{libraries}})
-} -}
INSTALL_ENGINES={- INSTALL_ENGINES={-
join(" ", map { quotify1(platform->dso($_)) } join(" ", map { quotify1(platform->dso($_)) }
grep { !$unified_info{attributes}->{$_}->{noinst} grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
&& $unified_info{attributes}->{$_}->{engine} } && $unified_info{attributes}->{modules}->{$_}->{engine} }
@{$unified_info{modules}}) @{$unified_info{modules}})
-} -}
INSTALL_ENGINEPDBS={- INSTALL_ENGINEPDBS={-
join(" ", map { quotify1(platform->dsopdb($_)) } join(" ", map { quotify1(platform->dsopdb($_)) }
grep { !$unified_info{attributes}->{$_}->{noinst} grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
&& $unified_info{attributes}->{$_}->{engine} } && $unified_info{attributes}->{modules}->{$_}->{engine} }
@{$unified_info{modules}}) @{$unified_info{modules}})
-} -}
INSTALL_PROGRAMS={- INSTALL_PROGRAMS={-
join(" ", map { quotify1(platform->bin($_)) } join(" ", map { quotify1(platform->bin($_)) }
grep { !$unified_info{attributes}->{$_}->{noinst} } grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
@{$unified_info{programs}}) @{$unified_info{programs}})
-} -}
INSTALL_PROGRAMPDBS={- INSTALL_PROGRAMPDBS={-
join(" ", map { quotify1(platform->binpdb($_)) } join(" ", map { quotify1(platform->binpdb($_)) }
grep { !$unified_info{attributes}->{$_}->{noinst} } grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
@{$unified_info{programs}}) @{$unified_info{programs}})
-} -}
BIN_SCRIPTS={- BIN_SCRIPTS={-
join(" ", map { quotify1($_) } join(" ", map { quotify1($_) }
grep { !$unified_info{attributes}->{$_}->{noinst} grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
&& !$unified_info{attributes}->{$_}->{misc} } && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
@{$unified_info{scripts}}) @{$unified_info{scripts}})
-} -}
MISC_SCRIPTS={- MISC_SCRIPTS={-
join(" ", map { quotify1($_) } join(" ", map { quotify1($_) }
grep { !$unified_info{attributes}->{$_}->{noinst} grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
&& $unified_info{attributes}->{$_}->{misc} } && $unified_info{attributes}->{scripts}->{$_}->{misc} }
@{$unified_info{scripts}}) @{$unified_info{scripts}})
-} -}
@@ -558,10 +558,14 @@ EOF
my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
"util", "dofile.pl")), "util", "dofile.pl")),
rel2abs($config{builddir})); rel2abs($config{builddir}));
my @modules = ( 'configdata.pm',
grep { $_ =~ m|\.pm$| } @{$args{deps}} );
my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
@modules = map { "-M".basename($_, '.pm') } @modules;
my $modules = join(' ', '', sort keys %moduleincs, @modules);
return <<"EOF"; return <<"EOF";
$target: "$args{generator}->[0]" $deps $target: "$args{generator}->[0]" $deps
"\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ "\$(PERL)"$modules "$dofile" "-o$target{build_file}" $generator > \$@
"-o$target{build_file}" $generator > \$@
EOF EOF
} else { } else {
return <<"EOF"; return <<"EOF";
@@ -714,8 +718,8 @@ EOF
} }
sub obj2dso { sub obj2dso {
my %args = @_; my %args = @_;
my $dso = platform->dso($args{lib}); my $dso = platform->dso($args{module});
my $dso_n = platform->dsoname($args{lib}); my $dso_n = platform->dsoname($args{module});
my @objs = map { platform->convertext($_) } my @objs = map { platform->convertext($_) }
grep { platform->isobj($_) || platform->isres($_) } grep { platform->isobj($_) || platform->isres($_) }
@{$args{objs}}; @{$args{objs}};
+141 -103
View File
@@ -73,7 +73,15 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [-Dxxx] [-lx
# no-sse2 disables IA-32 SSE2 code in assembly modules, the above # no-sse2 disables IA-32 SSE2 code in assembly modules, the above
# mentioned '386' option implies this one # mentioned '386' option implies this one
# no-<cipher> build without specified algorithm (rsa, idea, rc5, ...) # no-<cipher> build without specified algorithm (rsa, idea, rc5, ...)
# -<xxx> +<xxx> compiler options are passed through # -<xxx> +<xxx> All options which are unknown to the 'Configure' script are
# /<xxx> passed through to the compiler. Unix-style options beginning
# with a '-' or '+' are recognized, as well as Windows-style
# options beginning with a '/'. If the option contains arguments
# separated by spaces, then the URL-style notation %20 can be
# used for the space character in order to avoid having to quote
# the option. For example, -opt%20arg gets expanded to -opt arg.
# In fact, any ASCII character can be encoded as %xx using its
# hexadecimal encoding.
# -static while -static is also a pass-through compiler option (and # -static while -static is also a pass-through compiler option (and
# as such is limited to environments where it's actually # as such is limited to environments where it's actually
# meaningful), it triggers a number configuration options, # meaningful), it triggers a number configuration options,
@@ -518,7 +526,7 @@ my @disable_cascades = (
# or modules. # or modules.
"pic" => [ "shared", "module" ], "pic" => [ "shared", "module" ],
"module" => [ "fips", "legacy" ], "module" => [ "fips" ],
"engine" => [ grep /eng$/, @disablables ], "engine" => [ grep /eng$/, @disablables ],
"hw" => [ "padlockeng" ], "hw" => [ "padlockeng" ],
@@ -821,7 +829,7 @@ while (@argvcopy)
{ {
die "FIPS mode not supported\n"; die "FIPS mode not supported\n";
} }
elsif (/^[-+]/) elsif (m|^[-+/]|)
{ {
if (/^--prefix=(.*)$/) if (/^--prefix=(.*)$/)
{ {
@@ -898,11 +906,11 @@ while (@argvcopy)
{ {
push @{$useradd{LDFLAGS}}, $_; push @{$useradd{LDFLAGS}}, $_;
} }
elsif (/^-D(.*)$/) elsif (m|^[-/]D(.*)$|)
{ {
push @{$useradd{CPPDEFINES}}, $1; push @{$useradd{CPPDEFINES}}, $1;
} }
elsif (/^-I(.*)$/) elsif (m|^[-/]I(.*)$|)
{ {
push @{$useradd{CPPINCLUDES}}, $1; push @{$useradd{CPPINCLUDES}}, $1;
} }
@@ -912,11 +920,23 @@ while (@argvcopy)
} }
else # common if (/^[-+]/), just pass down... else # common if (/^[-+]/), just pass down...
{ {
# Treat %xx as an ASCII code (e.g. replace %20 by a space character).
# This provides a simple way to pass options with arguments separated
# by spaces without quoting (e.g. -opt%20arg translates to -opt arg).
$_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei; $_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei;
push @{$useradd{CFLAGS}}, $_; push @{$useradd{CFLAGS}}, $_;
push @{$useradd{CXXFLAGS}}, $_; push @{$useradd{CXXFLAGS}}, $_;
} }
} }
elsif (m|^/|)
{
# Treat %xx as an ASCII code (e.g. replace %20 by a space character).
# This provides a simple way to pass options with arguments separated
# by spaces without quoting (e.g. /opt%20arg translates to /opt arg).
$_ =~ s/%([0-9a-f]{1,2})/chr(hex($1))/gei;
push @{$useradd{CFLAGS}}, $_;
push @{$useradd{CXXFLAGS}}, $_;
}
else else
{ {
die "target already defined - $target (offending arg: $_)\n" if ($target ne ""); die "target already defined - $target (offending arg: $_)\n" if ($target ne "");
@@ -1724,7 +1744,6 @@ if ($builder eq "unified") {
my @modules = (); my @modules = ();
my @scripts = (); my @scripts = ();
my %attributes = ();
my %sources = (); my %sources = ();
my %shared_sources = (); my %shared_sources = ();
my %includes = (); my %includes = ();
@@ -1737,19 +1756,56 @@ if ($builder eq "unified") {
# contains a dollar sign, it had better be escaped, or it will be # contains a dollar sign, it had better be escaped, or it will be
# taken for a variable name prefix. # taken for a variable name prefix.
my %variables = (); my %variables = ();
my $variable_re = qr/\$([[:alpha:]][[:alnum:]_]*)/; my $variable_re = qr/\$(?P<VARIABLE>[[:alpha:]][[:alnum:]_]*)/;
my $expand_variables = sub { my $expand_variables = sub {
my $value = ''; my $value = '';
my $value_rest = shift; my $value_rest = shift;
if ($ENV{CONFIGURE_DEBUG_VARIABLE_EXPAND}) {
print STDERR
"DEBUG[\$expand_variables] Parsed '$value_rest' into:\n"
}
while ($value_rest =~ /(?<!\\)${variable_re}/) { while ($value_rest =~ /(?<!\\)${variable_re}/) {
$value .= $`; $value .= $`;
$value .= $variables{$1}; $value .= $variables{$+{VARIABLE}};
$value_rest = $'; $value_rest = $';
} }
if ($ENV{CONFIGURE_DEBUG_VARIABLE_EXPAND}) {
print STDERR
"DEBUG[\$expand_variables] ... '$value$value_rest'\n";
}
return $value . $value_rest; return $value . $value_rest;
}; };
# Support for attributes in build.info files
my %attributes = ();
my $handle_attributes = sub {
my $attr_str = shift;
my $ref = shift;
my @goals = @_;
return unless defined $attr_str;
my @a = tokenize($attr_str, qr|\s*,\s*|);
foreach my $a (@a) {
my $ac = 1;
my $ak = $a;
my $av = 1;
if ($a =~ m|^(!)?(.*?)\s* = \s*(.*?)$|) {
$ac = ! $1;
$ak = $1;
$av = $2;
}
foreach my $g (@goals) {
if ($ac) {
$$ref->{$g}->{$ak} = $av;
} else {
delete $$ref->{$g}->{$ak};
}
}
}
};
# We want to detect configdata.pm in the source tree, so we # We want to detect configdata.pm in the source tree, so we
# don't use it if the build tree is different. # don't use it if the build tree is different.
my $src_configdata = cleanfile($srcdir, "configdata.pm", $blddir); my $src_configdata = cleanfile($srcdir, "configdata.pm", $blddir);
@@ -1779,148 +1835,129 @@ if ($builder eq "unified") {
# 1 last was positive (don't skip lines until next ELSE, ELSIF or ENDIF) # 1 last was positive (don't skip lines until next ELSE, ELSIF or ENDIF)
# 2 positive ELSE (following ELSIF should fail) # 2 positive ELSE (following ELSIF should fail)
my @skip = (); my @skip = ();
# A few useful generic regexps
my $index_re = qr/\[\s*(?P<INDEX>(?:\\.|.)*?)\s*\]/;
my $cond_re = qr/\[\s*(?P<COND>(?:\\.|.)*?)\s*\]/;
my $attribs_re = qr/(?:\{\s*(?P<ATTRIBS>(?:\\.|.)*?)\s*\})?/;
my $value_re = qr/\s*(?P<VALUE>.*?)\s*/;
collect_information( collect_information(
collect_from_array([ @text ], collect_from_array([ @text ],
qr/\\$/ => sub { my $l1 = shift; my $l2 = shift; qr/\\$/ => sub { my $l1 = shift; my $l2 = shift;
$l1 =~ s/\\$//; $l1.$l2 }), $l1 =~ s/\\$//; $l1.$l2 }),
# Info we're looking for # Info we're looking for
qr/^\s*IF\[((?:\\.|[^\\\]])*)\]\s*$/ qr/^\s* IF ${cond_re} \s*$/x
=> sub { => sub {
if (! @skip || $skip[$#skip] > 0) { if (! @skip || $skip[$#skip] > 0) {
push @skip, !! $expand_variables->($1); push @skip, !! $expand_variables->($+{COND});
} else { } else {
push @skip, -1; push @skip, -1;
} }
}, },
qr/^\s*ELSIF\[((?:\\.|[^\\\]])*)\]\s*$/ qr/^\s* ELSIF ${cond_re} \s*$/x
=> sub { die "ELSIF out of scope" if ! @skip; => sub { die "ELSIF out of scope" if ! @skip;
die "ELSIF following ELSE" if abs($skip[$#skip]) == 2; die "ELSIF following ELSE" if abs($skip[$#skip]) == 2;
$skip[$#skip] = -1 if $skip[$#skip] != 0; $skip[$#skip] = -1 if $skip[$#skip] != 0;
$skip[$#skip] = !! $expand_variables->($1) $skip[$#skip] = !! $expand_variables->($+{COND})
if $skip[$#skip] == 0; }, if $skip[$#skip] == 0; },
qr/^\s*ELSE\s*$/ qr/^\s* ELSE \s*$/x
=> sub { die "ELSE out of scope" if ! @skip; => sub { die "ELSE out of scope" if ! @skip;
$skip[$#skip] = -2 if $skip[$#skip] != 0; $skip[$#skip] = -2 if $skip[$#skip] != 0;
$skip[$#skip] = 2 if $skip[$#skip] == 0; }, $skip[$#skip] = 2 if $skip[$#skip] == 0; },
qr/^\s*ENDIF\s*$/ qr/^\s* ENDIF \s*$/x
=> sub { die "ENDIF out of scope" if ! @skip; => sub { die "ENDIF out of scope" if ! @skip;
pop @skip; }, pop @skip; },
qr/^\s*${variable_re}\s*=\s*(.*?)\s*$/ qr/^\s* ${variable_re} \s* = ${value_re} $/x
=> sub { => sub {
if (!@skip || $skip[$#skip] > 0) { if (!@skip || $skip[$#skip] > 0) {
my $n = $1; $variables{$+{VARIABLE}} = $expand_variables->($+{VALUE});
my $v = $2;
$variables{$n} = $expand_variables->($v);
} }
}, },
qr/^\s*SUBDIRS\s*=\s*(.*)\s*$/ qr/^\s* SUBDIRS \s* = ${value_re} $/x
=> sub { => sub {
if (!@skip || $skip[$#skip] > 0) { if (!@skip || $skip[$#skip] > 0) {
foreach (tokenize($expand_variables->($1))) { foreach (tokenize($expand_variables->($+{VALUE}))) {
push @build_dirs, [ @curd, splitdir($_, 1) ]; push @build_dirs, [ @curd, splitdir($_, 1) ];
} }
} }
}, },
qr/^\s*PROGRAMS(?:{([\w=]+(?:\s*,\s*[\w=]+)*)})?\s*=\s*(.*)\s*$/ qr/^\s* PROGRAMS ${attribs_re} \s* = ${value_re} $/x
=> sub { => sub {
if (!@skip || $skip[$#skip] > 0) { if (!@skip || $skip[$#skip] > 0) {
my @a = tokenize($1, qr|\s*,\s*|); my @p = tokenize($expand_variables->($+{VALUE}));
my @p = tokenize($expand_variables->($2));
push @programs, @p; push @programs, @p;
foreach my $a (@a) { $handle_attributes->($+{ATTRIBS},
my $ak = $a; \$attributes{programs},
my $av = 1; @p);
if ($a =~ m|^(.*?)\s*=\s*(.*?)$|) {
$ak = $1;
$av = $2;
}
foreach my $p (@p) {
$attributes{$p}->{$ak} = $av;
}
}
} }
}, },
qr/^\s*LIBS(?:{([\w=]+(?:\s*,\s*[\w=]+)*)})?\s*=\s*(.*)\s*$/ qr/^\s* LIBS ${attribs_re} \s* = ${value_re} $/x
=> sub { => sub {
if (!@skip || $skip[$#skip] > 0) { if (!@skip || $skip[$#skip] > 0) {
my @a = tokenize($1, qr|\s*,\s*|); my @l = tokenize($expand_variables->($+{VALUE}));
my @l = tokenize($expand_variables->($2));
push @libraries, @l; push @libraries, @l;
foreach my $a (@a) { $handle_attributes->($+{ATTRIBS},
my $ak = $a; \$attributes{libraries},
my $av = 1; @l);
if ($a =~ m|^(.*?)\s*=\s*(.*?)$|) {
$ak = $1;
$av = $2;
}
foreach my $l (@l) {
$attributes{$l}->{$ak} = $av;
}
}
} }
}, },
qr/^\s*MODULES(?:{([\w=]+(?:\s*,\s*[\w=]+)*)})?\s*=\s*(.*)\s*$/ qr/^\s* MODULES ${attribs_re} \s* = ${value_re} $/x
=> sub { => sub {
if (!@skip || $skip[$#skip] > 0) { if (!@skip || $skip[$#skip] > 0) {
my @a = tokenize($1, qr|\s*,\s*|); my @m = tokenize($expand_variables->($+{VALUE}));
my @m = tokenize($expand_variables->($2));
push @modules, @m; push @modules, @m;
foreach my $a (@a) { $handle_attributes->($+{ATTRIBS},
my $ak = $a; \$attributes{modules},
my $av = 1; @m);
if ($a =~ m|^(.*?)\s*=\s*(.*?)$|) {
$ak = $1;
$av = $2;
}
foreach my $m (@m) {
$attributes{$m}->{$ak} = $av;
}
}
} }
}, },
qr/^\s*SCRIPTS(?:{([\w=]+(?:\s*,\s*[\w=]+)*)})?\s*=\s*(.*)\s*$/ qr/^\s* SCRIPTS ${attribs_re} \s* = ${value_re} $/x
=> sub { => sub {
if (!@skip || $skip[$#skip] > 0) { if (!@skip || $skip[$#skip] > 0) {
my @a = tokenize($1, qr|\s*,\s*|); my @s = tokenize($expand_variables->($+{VALUE}));
my @s = tokenize($expand_variables->($2));
push @scripts, @s; push @scripts, @s;
foreach my $a (@a) { $handle_attributes->($+{ATTRIBS},
my $ak = $a; \$attributes{scripts},
my $av = 1; @s);
if ($a =~ m|^(.*?)\s*=\s*(.*?)$|) {
$ak = $1;
$av = $2;
}
foreach my $s (@s) {
$attributes{$s}->{$ak} = $av;
}
}
} }
}, },
qr/^\s*ORDINALS\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/, qr/^\s* ORDINALS ${index_re} = ${value_re} $/x
=> sub { push @{$ordinals{$1}}, tokenize($expand_variables->($2)) => sub { push @{$ordinals{$expand_variables->($+{INDEX})}},
tokenize($expand_variables->($+{VALUE}))
if !@skip || $skip[$#skip] > 0 }, if !@skip || $skip[$#skip] > 0 },
qr/^\s*SOURCE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/ qr/^\s* SOURCE ${index_re} = ${value_re} $/x
=> sub { push @{$sources{$1}}, tokenize($expand_variables->($2)) => sub { push @{$sources{$expand_variables->($+{INDEX})}},
tokenize($expand_variables->($+{VALUE}))
if !@skip || $skip[$#skip] > 0 }, if !@skip || $skip[$#skip] > 0 },
qr/^\s*SHARED_SOURCE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/ qr/^\s* SHARED_SOURCE ${index_re} = ${value_re} $/x
=> sub { push @{$shared_sources{$1}}, => sub { push @{$shared_sources{$expand_variables->($+{INDEX})}},
tokenize($expand_variables->($2)) tokenize($expand_variables->($+{VALUE}))
if !@skip || $skip[$#skip] > 0 }, if !@skip || $skip[$#skip] > 0 },
qr/^\s*INCLUDE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/ qr/^\s* INCLUDE ${index_re} = ${value_re} $/x
=> sub { push @{$includes{$1}}, tokenize($expand_variables->($2)) => sub { push @{$includes{$expand_variables->($+{INDEX})}},
tokenize($expand_variables->($+{VALUE}))
if !@skip || $skip[$#skip] > 0 }, if !@skip || $skip[$#skip] > 0 },
qr/^\s*DEFINE\[((?:\\.|[^\\\]])*)\]\s*=\s*(.*)\s*$/ qr/^\s* DEFINE ${index_re} = ${value_re} $/x
=> sub { push @{$defines{$1}}, tokenize($expand_variables->($2)) => sub { push @{$defines{$expand_variables->($+{INDEX})}},
tokenize($expand_variables->($+{VALUE}))
if !@skip || $skip[$#skip] > 0 }, if !@skip || $skip[$#skip] > 0 },
qr/^\s*DEPEND\[((?:\\.|[^\\\]])*)\]\s*=\s*(.*)\s*$/ qr/^\s* DEPEND ${index_re} ${attribs_re} = ${value_re} $/x
=> sub { push @{$depends{$1}}, tokenize($expand_variables->($2)) => sub {
if (!@skip || $skip[$#skip] > 0) {
my $i = $expand_variables->($+{INDEX});
my @d = tokenize($expand_variables->($+{VALUE}));
push @{$depends{$i}}, @d;
$handle_attributes->($+{ATTRIBS},
\$attributes{depends}->{$i},
@d);
}
},
qr/^\s* GENERATE ${index_re} = ${value_re} $/x
=> sub { push @{$generate{$expand_variables->($+{INDEX})}},
$+{VALUE}
if !@skip || $skip[$#skip] > 0 }, if !@skip || $skip[$#skip] > 0 },
qr/^\s*GENERATE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/ qr/^\s* (?:\#.*)? $/x => sub { },
=> sub { push @{$generate{$1}}, $2
if !@skip || $skip[$#skip] > 0 },
qr/^\s*(?:#.*)?$/ => sub { },
"OTHERWISE" => sub { die "Something wrong with this line:\n$_\nat $sourced/$f" }, "OTHERWISE" => sub { die "Something wrong with this line:\n$_\nat $sourced/$f" },
"BEFORE" => sub { "BEFORE" => sub {
if ($buildinfo_debug) { if ($buildinfo_debug) {
@@ -1936,7 +1973,7 @@ if ($builder eq "unified") {
); );
die "runaway IF?" if (@skip); die "runaway IF?" if (@skip);
if (grep { defined $attributes{$_}->{engine} } keys %attributes if (grep { defined $attributes{modules}->{$_}->{engine} } keys %attributes
and !$config{dynamic_engines}) { and !$config{dynamic_engines}) {
die <<"EOF" die <<"EOF"
ENGINES can only be used if configured with 'dynamic-engine'. ENGINES can only be used if configured with 'dynamic-engine'.
@@ -1944,15 +1981,6 @@ This is usually a fault in a build.info file.
EOF EOF
} }
foreach (keys %attributes) {
my $dest = $_;
my $ddest = cleanfile($buildd, $_, $blddir);
foreach (keys %{$attributes{$dest} // {}}) {
$unified_info{attributes}->{$ddest}->{$_} =
$attributes{$dest}->{$_};
}
}
{ {
my %infos = ( programs => [ @programs ], my %infos = ( programs => [ @programs ],
libraries => [ @libraries ], libraries => [ @libraries ],
@@ -1962,6 +1990,11 @@ EOF
foreach (@{$infos{$k}}) { foreach (@{$infos{$k}}) {
my $item = cleanfile($buildd, $_, $blddir); my $item = cleanfile($buildd, $_, $blddir);
$unified_info{$k}->{$item} = 1; $unified_info{$k}->{$item} = 1;
# Fix up associated attributes
$unified_info{attributes}->{$k}->{$item} =
$attributes{$k}->{$_}
if defined $attributes{$k}->{$_};
} }
} }
} }
@@ -2090,6 +2123,11 @@ EOF
my $e = $1 // ""; my $e = $1 // "";
$d = $`.$e; $d = $`.$e;
$unified_info{depends}->{$ddest}->{$d} = 1; $unified_info{depends}->{$ddest}->{$d} = 1;
# Fix up associated attributes
$unified_info{attributes}->{depends}->{$ddest}->{$d} =
$attributes{depends}->{$dest}->{$_}
if defined $attributes{depends}->{$dest}->{$_};
} }
} }
+12 -3
View File
@@ -641,10 +641,19 @@
Take note of the VAR=value documentation below and how Take note of the VAR=value documentation below and how
these flags interact with those variables. these flags interact with those variables.
-xxx, +xxx -xxx, +xxx, /xxx
Additional options that are not otherwise recognised are Additional options that are not otherwise recognised are
passed through as they are to the compiler as well. Again, passed through as they are to the compiler as well.
consult your compiler documentation. Unix-style options beginning with a '-' or '+' and
Windows-style options beginning with a '/' are recognized.
Again, consult your compiler documentation.
If the option contains arguments separated by spaces,
then the URL-style notation %20 can be used for the space
character in order to avoid having to quote the option.
For example, -opt%20arg gets expanded to -opt arg.
In fact, any ASCII character can be encoded as %xx using its
hexadecimal encoding.
Take note of the VAR=value documentation below and how Take note of the VAR=value documentation below and how
these flags interact with those variables. these flags interact with those variables.
+40 -22
View File
@@ -104,20 +104,29 @@ const OPTIONS cms_options[] = {
{"resign", OPT_RESIGN, '-', "Resign a signed message"}, {"resign", OPT_RESIGN, '-', "Resign a signed message"},
{"cades", OPT_CADES, '-', "Include signer certificate digest"}, {"cades", OPT_CADES, '-', "Include signer certificate digest"},
{"verify", OPT_VERIFY, '-', "Verify signed message"}, {"verify", OPT_VERIFY, '-', "Verify signed message"},
{"verify_retcode", OPT_VERIFY_RETCODE, '-'}, {"verify_retcode", OPT_VERIFY_RETCODE, '-',
{"verify_receipt", OPT_VERIFY_RECEIPT, '<'}, "Exit non-zero on verification failure"},
{"verify_receipt", OPT_VERIFY_RECEIPT, '<',
"Verify receipts; exit if receipt signatures do not verify"},
{"cmsout", OPT_CMSOUT, '-', "Output CMS structure"}, {"cmsout", OPT_CMSOUT, '-', "Output CMS structure"},
{"data_out", OPT_DATA_OUT, '-'}, {"data_out", OPT_DATA_OUT, '-', "Copy CMS \"Data\" object to output"},
{"data_create", OPT_DATA_CREATE, '-'}, {"data_create", OPT_DATA_CREATE, '-', "Create a CMS \"Data\" object"},
{"digest_verify", OPT_DIGEST_VERIFY, '-'}, {"digest_verify", OPT_DIGEST_VERIFY, '-',
{"digest_create", OPT_DIGEST_CREATE, '-'}, "Verify a CMS \"DigestedData\" object and output it"},
{"compress", OPT_COMPRESS, '-'}, {"digest_create", OPT_DIGEST_CREATE, '-',
{"uncompress", OPT_UNCOMPRESS, '-'}, "Create a CMS \"DigestedData\" object"},
{"EncryptedData_decrypt", OPT_ED_DECRYPT, '-'}, {"compress", OPT_COMPRESS, '-', "Create a CMS \"CompressedData\" object"},
{"EncryptedData_encrypt", OPT_ED_ENCRYPT, '-'}, {"uncompress", OPT_UNCOMPRESS, '-', "Uncompress a CMS \"CompressedData\" object"},
{"debug_decrypt", OPT_DEBUG_DECRYPT, '-'}, {"EncryptedData_decrypt", OPT_ED_DECRYPT, '-',
"Decrypt CMS \"EncryptedData\" object using symmetric key"},
{"EncryptedData_encrypt", OPT_ED_ENCRYPT, '-',
"Create CMS \"EncryptedData\" object using symmetric key"},
{"debug_decrypt", OPT_DEBUG_DECRYPT, '-',
"Disable MMA protection and return an error if no recipient found"
" (see documentation)"},
{"text", OPT_TEXT, '-', "Include or delete text MIME headers"}, {"text", OPT_TEXT, '-', "Include or delete text MIME headers"},
{"asciicrlf", OPT_ASCIICRLF, '-'}, {"asciicrlf", OPT_ASCIICRLF, '-',
"Perform CRLF canonicalisation when signing"},
{"nointern", OPT_NOINTERN, '-', {"nointern", OPT_NOINTERN, '-',
"Don't search certificates in message for signer"}, "Don't search certificates in message for signer"},
{"noverify", OPT_NOVERIFY, '-', "Don't verify signers certificate"}, {"noverify", OPT_NOVERIFY, '-', "Don't verify signers certificate"},
@@ -129,16 +138,20 @@ const OPTIONS cms_options[] = {
{"binary", OPT_BINARY, '-', "Don't translate message to text"}, {"binary", OPT_BINARY, '-', "Don't translate message to text"},
{"keyid", OPT_KEYID, '-', "Use subject key identifier"}, {"keyid", OPT_KEYID, '-', "Use subject key identifier"},
{"nosigs", OPT_NOSIGS, '-', "Don't verify message signature"}, {"nosigs", OPT_NOSIGS, '-', "Don't verify message signature"},
{"no_content_verify", OPT_NO_CONTENT_VERIFY, '-'}, {"no_content_verify", OPT_NO_CONTENT_VERIFY, '-',
{"no_attr_verify", OPT_NO_ATTR_VERIFY, '-'}, "Do not verify signed content signatures"},
{"no_attr_verify", OPT_NO_ATTR_VERIFY, '-',
"Do not verify signed attribute signatures"},
{"stream", OPT_INDEF, '-', "Enable CMS streaming"}, {"stream", OPT_INDEF, '-', "Enable CMS streaming"},
{"indef", OPT_INDEF, '-', "Same as -stream"}, {"indef", OPT_INDEF, '-', "Same as -stream"},
{"noindef", OPT_NOINDEF, '-', "Disable CMS streaming"}, {"noindef", OPT_NOINDEF, '-', "Disable CMS streaming"},
{"crlfeol", OPT_CRLFEOL, '-', "Use CRLF as EOL termination instead of CR only" }, {"crlfeol", OPT_CRLFEOL, '-', "Use CRLF as EOL termination instead of CR only" },
{"noout", OPT_NOOUT, '-', "For the -cmsout operation do not output the parsed CMS structure"}, {"noout", OPT_NOOUT, '-', "For the -cmsout operation do not output the parsed CMS structure"},
{"receipt_request_print", OPT_RR_PRINT, '-', "Print CMS Receipt Request" }, {"receipt_request_print", OPT_RR_PRINT, '-', "Print CMS Receipt Request" },
{"receipt_request_all", OPT_RR_ALL, '-'}, {"receipt_request_all", OPT_RR_ALL, '-',
{"receipt_request_first", OPT_RR_FIRST, '-'}, "When signing, create a receipt request for all recipients"},
{"receipt_request_first", OPT_RR_FIRST, '-',
"When signing, create a receipt request for first recipient"},
{"rctform", OPT_RCTFORM, 'F', "Receipt file format"}, {"rctform", OPT_RCTFORM, 'F', "Receipt file format"},
{"certfile", OPT_CERTFILE, '<', "Other certificates file"}, {"certfile", OPT_CERTFILE, '<', "Other certificates file"},
{"CAfile", OPT_CAFILE, '<', "Trusted certificates file"}, {"CAfile", OPT_CAFILE, '<', "Trusted certificates file"},
@@ -151,10 +164,13 @@ const OPTIONS cms_options[] = {
"Supply or override content for detached signature"}, "Supply or override content for detached signature"},
{"print", OPT_PRINT, '-', {"print", OPT_PRINT, '-',
"For the -cmsout operation print out all fields of the CMS structure"}, "For the -cmsout operation print out all fields of the CMS structure"},
{"secretkey", OPT_SECRETKEY, 's'}, {"secretkey", OPT_SECRETKEY, 's',
{"secretkeyid", OPT_SECRETKEYID, 's'}, "Use specified hex-encoded key to decrypt/encrypt recipients or content"},
{"pwri_password", OPT_PWRI_PASSWORD, 's'}, {"secretkeyid", OPT_SECRETKEYID, 's',
{"econtent_type", OPT_ECONTENT_TYPE, 's'}, "Identity of the -secretkey for CMS \"KEKRecipientInfo\" object"},
{"pwri_password", OPT_PWRI_PASSWORD, 's',
"Specific password for recipient"},
{"econtent_type", OPT_ECONTENT_TYPE, 's', "OID for external content"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"}, {"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
{"to", OPT_TO, 's', "To address"}, {"to", OPT_TO, 's', "To address"},
{"from", OPT_FROM, 's', "From address"}, {"from", OPT_FROM, 's', "From address"},
@@ -167,8 +183,10 @@ const OPTIONS cms_options[] = {
"Input private key (if not signer or recipient)"}, "Input private key (if not signer or recipient)"},
{"keyform", OPT_KEYFORM, 'f', "Input private key format (PEM or ENGINE)"}, {"keyform", OPT_KEYFORM, 'f', "Input private key format (PEM or ENGINE)"},
{"keyopt", OPT_KEYOPT, 's', "Set public key parameters as n:v pairs"}, {"keyopt", OPT_KEYOPT, 's', "Set public key parameters as n:v pairs"},
{"receipt_request_from", OPT_RR_FROM, 's'}, {"receipt_request_from", OPT_RR_FROM, 's',
{"receipt_request_to", OPT_RR_TO, 's'}, "Create signed receipt request with specified email address"},
{"receipt_request_to", OPT_RR_TO, 's',
"Create signed receipt targeted to specified address"},
{"", OPT_CIPHER, '-', "Any supported cipher"}, {"", OPT_CIPHER, '-', "Any supported cipher"},
OPT_R_OPTIONS, OPT_R_OPTIONS,
OPT_V_OPTIONS, OPT_V_OPTIONS,
+2 -2
View File
@@ -204,7 +204,7 @@ int crl_main(int argc, char **argv)
} }
pkey = X509_get_pubkey(X509_OBJECT_get0_X509(xobj)); pkey = X509_get_pubkey(X509_OBJECT_get0_X509(xobj));
X509_OBJECT_free(xobj); X509_OBJECT_free(xobj);
if (!pkey) { if (pkey == NULL) {
BIO_printf(bio_err, "Error getting CRL issuer public key\n"); BIO_printf(bio_err, "Error getting CRL issuer public key\n");
goto end; goto end;
} }
@@ -228,7 +228,7 @@ int crl_main(int argc, char **argv)
if (!newcrl) if (!newcrl)
goto end; goto end;
pkey = load_key(keyfile, keyformat, 0, NULL, NULL, "CRL signing key"); pkey = load_key(keyfile, keyformat, 0, NULL, NULL, "CRL signing key");
if (!pkey) { if (pkey == NULL) {
X509_CRL_free(newcrl); X509_CRL_free(newcrl);
goto end; goto end;
} }
+1 -1
View File
@@ -341,7 +341,7 @@ opthelp:
if (opts != NULL) { if (opts != NULL) {
int ok = 1; int ok = 1;
OSSL_PARAM *params = OSSL_PARAM *params =
app_params_new_from_opts(opts, EVP_MAC_CTX_settable_params(mac)); app_params_new_from_opts(opts, EVP_MAC_settable_ctx_params(mac));
if (params == NULL) if (params == NULL)
goto end; goto end;
+2 -2
View File
@@ -217,7 +217,7 @@ static int init_keygen_file(EVP_PKEY_CTX **pctx, const char *file, ENGINE *e)
} }
pbio = BIO_new_file(file, "r"); pbio = BIO_new_file(file, "r");
if (!pbio) { if (pbio == NULL) {
BIO_printf(bio_err, "Can't open parameter file %s\n", file); BIO_printf(bio_err, "Can't open parameter file %s\n", file);
return 0; return 0;
} }
@@ -225,7 +225,7 @@ static int init_keygen_file(EVP_PKEY_CTX **pctx, const char *file, ENGINE *e)
pkey = PEM_read_bio_Parameters(pbio, NULL); pkey = PEM_read_bio_Parameters(pbio, NULL);
BIO_free(pbio); BIO_free(pbio);
if (!pkey) { if (pkey == NULL) {
BIO_printf(bio_err, "Error reading parameter file %s\n", file); BIO_printf(bio_err, "Error reading parameter file %s\n", file);
return 0; return 0;
} }
+3 -3
View File
@@ -7,8 +7,8 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef HEADER_APPS_H #ifndef OSSL_APPS_H
# define HEADER_APPS_H # define OSSL_APPS_H
# include "e_os.h" /* struct timeval for DTLS */ # include "e_os.h" /* struct timeval for DTLS */
# include "internal/nelem.h" # include "internal/nelem.h"
@@ -21,7 +21,7 @@
# endif # endif
# include <openssl/e_os2.h> # include <openssl/e_os2.h>
# include <openssl/ossl_typ.h> # include <openssl/types.h>
# include <openssl/bio.h> # include <openssl/bio.h>
# include <openssl/x509.h> # include <openssl/x509.h>
# include <openssl/conf.h> # include <openssl/conf.h>
+2 -2
View File
@@ -7,8 +7,8 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef HEADER_APPS_UI_H #ifndef OSSL_APPS_UI_H
# define HEADER_APPS_UI_H # define OSSL_APPS_UI_H
# define PW_MIN_LENGTH 4 # define PW_MIN_LENGTH 4
+3 -3
View File
@@ -14,8 +14,8 @@
* shared fields have been moved into this file. * shared fields have been moved into this file.
*/ */
#ifndef HEADER_FMT_H #ifndef OSSL_APPS_FMT_H
#define HEADER_FMT_H #define OSSL_APPS_FMT_H
/* On some platforms, it's important to distinguish between text and binary /* On some platforms, it's important to distinguish between text and binary
* files. On some, there might even be specific file formats for different * files. On some, there might even be specific file formats for different
@@ -41,4 +41,4 @@
int FMT_istext(int format); int FMT_istext(int format);
#endif /* HEADER_FMT_H_ */ #endif /* OSSL_APPS_FMT_H_ */
+2 -2
View File
@@ -7,8 +7,8 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef APPS_FUNCTION_H #ifndef OSSL_APPS_FUNCTION_H
# define APPS_FUNCTION_H # define OSSL_APPS_FUNCTION_H
# include <openssl/lhash.h> # include <openssl/lhash.h>
# include "opt.h" # include "opt.h"
+17
View File
@@ -0,0 +1,17 @@
/*
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <openssl/safestack.h>
/* Standard comparing function for names */
int name_cmp(const char * const *a, const char * const *b);
/* collect_names is meant to be used with EVP_{type}_doall_names */
void collect_names(const char *name, void *vdata);
/* Sorts and prints a stack of names to |out| */
void print_names(BIO *out, STACK_OF(OPENSSL_CSTRING) *names);
+4 -4
View File
@@ -6,12 +6,12 @@
* in the file LICENSE in the source distribution or at * in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef HEADER_OPT_H #ifndef OSSL_APPS_OPT_H
#define HEADER_OPT_H #define OSSL_APPS_OPT_H
#include <sys/types.h> #include <sys/types.h>
#include <openssl/e_os2.h> #include <openssl/e_os2.h>
#include <openssl/ossl_typ.h> #include <openssl/types.h>
#include <stdarg.h> #include <stdarg.h>
/* /*
@@ -347,4 +347,4 @@ int opt_format_error(const char *s, unsigned long flags);
int opt_isdir(const char *name); int opt_isdir(const char *name);
int opt_printf_stderr(const char *fmt, ...); int opt_printf_stderr(const char *fmt, ...);
#endif /* HEADER_OPT_H */ #endif /* OSSL_APPS_OPT_H */
+2 -2
View File
@@ -7,8 +7,8 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef HEADER_PLATFORM_H #ifndef OSSL_APPS_PLATFORM_H
# define HEADER_PLATFORM_H # define OSSL_APPS_PLATFORM_H
# include <openssl/e_os2.h> # include <openssl/e_os2.h>
+2 -2
View File
@@ -8,8 +8,8 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef TERM_SOCK_H #ifndef OSSL_APPS_VMS_TERM_SOCK_H
# define TERM_SOCK_H # define OSSL_APPS_VMS_TERM_SOCK_H
/* /*
** Terminal Socket Function Codes ** Terminal Socket Function Codes
+1 -1
View File
@@ -96,7 +96,7 @@ opthelp:
if (opts != NULL) { if (opts != NULL) {
int ok = 1; int ok = 1;
OSSL_PARAM *params = OSSL_PARAM *params =
app_params_new_from_opts(opts, EVP_KDF_CTX_settable_params(kdf)); app_params_new_from_opts(opts, EVP_KDF_settable_ctx_params(kdf));
if (params == NULL) if (params == NULL)
goto err; goto err;
+28 -8
View File
@@ -85,7 +85,7 @@ int chopup_args(ARGS *arg, char *buf)
/* Skip whitespace. */ /* Skip whitespace. */
while (*p && isspace(_UC(*p))) while (*p && isspace(_UC(*p)))
p++; p++;
if (!*p) if (*p == '\0')
break; break;
/* The start of something good :-) */ /* The start of something good :-) */
@@ -258,7 +258,7 @@ static char *app_get_pass(const char *arg, int keepbio)
#endif #endif
} else if (strcmp(arg, "stdin") == 0) { } else if (strcmp(arg, "stdin") == 0) {
pwdbio = dup_bio_in(FORMAT_TEXT); pwdbio = dup_bio_in(FORMAT_TEXT);
if (!pwdbio) { if (pwdbio == NULL) {
BIO_printf(bio_err, "Can't open BIO for stdin\n"); BIO_printf(bio_err, "Can't open BIO for stdin\n");
return NULL; return NULL;
} }
@@ -407,7 +407,7 @@ static int load_pkcs12(BIO *in, const char *desc,
if (PKCS12_verify_mac(p12, "", 0) || PKCS12_verify_mac(p12, NULL, 0)) { if (PKCS12_verify_mac(p12, "", 0) || PKCS12_verify_mac(p12, NULL, 0)) {
pass = ""; pass = "";
} else { } else {
if (!pem_cb) if (pem_cb == NULL)
pem_cb = (pem_password_cb *)password_callback; pem_cb = (pem_password_cb *)password_callback;
len = pem_cb(tpass, PEM_BUFSIZE, 0, cb_data); len = pem_cb(tpass, PEM_BUFSIZE, 0, cb_data);
if (len < 0) { if (len < 0) {
@@ -1809,26 +1809,46 @@ unsigned char *next_protos_parse(size_t *outlen, const char *in)
size_t len; size_t len;
unsigned char *out; unsigned char *out;
size_t i, start = 0; size_t i, start = 0;
size_t skipped = 0;
len = strlen(in); len = strlen(in);
if (len >= 65535) if (len == 0 || len >= 65535)
return NULL; return NULL;
out = app_malloc(strlen(in) + 1, "NPN buffer"); out = app_malloc(len + 1, "NPN buffer");
for (i = 0; i <= len; ++i) { for (i = 0; i <= len; ++i) {
if (i == len || in[i] == ',') { if (i == len || in[i] == ',') {
/*
* Zero-length ALPN elements are invalid on the wire, we could be
* strict and reject the entire string, but just ignoring extra
* commas seems harmless and more friendly.
*
* Every comma we skip in this way puts the input buffer another
* byte ahead of the output buffer, so all stores into the output
* buffer need to be decremented by the number commas skipped.
*/
if (i == start) {
++start;
++skipped;
continue;
}
if (i - start > 255) { if (i - start > 255) {
OPENSSL_free(out); OPENSSL_free(out);
return NULL; return NULL;
} }
out[start] = (unsigned char)(i - start); out[start-skipped] = (unsigned char)(i - start);
start = i + 1; start = i + 1;
} else { } else {
out[i + 1] = in[i]; out[i + 1 - skipped] = in[i];
} }
} }
*outlen = len + 1; if (len <= skipped) {
OPENSSL_free(out);
return NULL;
}
*outlen = len + 1 - skipped;
return out; return out;
} }
+1 -1
View File
@@ -9,7 +9,7 @@ ENDIF
# Source for libapps # Source for libapps
$LIBAPPSSRC=apps.c apps_ui.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \ $LIBAPPSSRC=apps.c apps_ui.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \
bf_prefix.c columns.c app_params.c bf_prefix.c columns.c app_params.c names.c
IF[{- !$disabled{apps} -}] IF[{- !$disabled{apps} -}]
LIBS{noinst}=../libapps.a LIBS{noinst}=../libapps.a
+48
View File
@@ -0,0 +1,48 @@
/*
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <string.h>
#include <openssl/bio.h>
#include <openssl/safestack.h>
#include "names.h"
#ifdef _WIN32
# define strcasecmp _stricmp
#endif
int name_cmp(const char * const *a, const char * const *b)
{
return strcasecmp(*a, *b);
}
void collect_names(const char *name, void *vdata)
{
STACK_OF(OPENSSL_CSTRING) *names = vdata;
sk_OPENSSL_CSTRING_push(names, name);
}
void print_names(BIO *out, STACK_OF(OPENSSL_CSTRING) *names)
{
int i = sk_OPENSSL_CSTRING_num(names);
int j;
sk_OPENSSL_CSTRING_sort(names);
if (i > 1)
BIO_printf(out, "{ ");
for (j = 0; j < i; j++) {
const char *name = sk_OPENSSL_CSTRING_value(names, j);
if (j > 0)
BIO_printf(out, ", ");
BIO_printf(out, "%s", name);
}
if (i > 1)
BIO_printf(out, " }");
}
+59 -24
View File
@@ -17,6 +17,7 @@
#include "app_params.h" #include "app_params.h"
#include "progs.h" #include "progs.h"
#include "opt.h" #include "opt.h"
#include "names.h"
static int verbose = 0; static int verbose = 0;
@@ -38,7 +39,7 @@ DEFINE_STACK_OF(EVP_CIPHER)
static int cipher_cmp(const EVP_CIPHER * const *a, static int cipher_cmp(const EVP_CIPHER * const *a,
const EVP_CIPHER * const *b) const EVP_CIPHER * const *b)
{ {
int ret = strcasecmp(EVP_CIPHER_name(*a), EVP_CIPHER_name(*b)); int ret = EVP_CIPHER_number(*a) - EVP_CIPHER_number(*b);
if (ret == 0) if (ret == 0)
ret = strcmp(OSSL_PROVIDER_name(EVP_CIPHER_provider(*a)), ret = strcmp(OSSL_PROVIDER_name(EVP_CIPHER_provider(*a)),
@@ -64,21 +65,29 @@ static void list_ciphers(void)
EVP_CIPHER_do_all_sorted(legacy_cipher_fn, bio_out); EVP_CIPHER_do_all_sorted(legacy_cipher_fn, bio_out);
BIO_printf(bio_out, "Provided:\n"); BIO_printf(bio_out, "Provided:\n");
EVP_CIPHER_do_all_ex(NULL, collect_ciphers, ciphers); EVP_CIPHER_do_all_provided(NULL, collect_ciphers, ciphers);
sk_EVP_CIPHER_sort(ciphers); sk_EVP_CIPHER_sort(ciphers);
for (i = 0; i < sk_EVP_CIPHER_num(ciphers); i++) { for (i = 0; i < sk_EVP_CIPHER_num(ciphers); i++) {
const EVP_CIPHER *c = sk_EVP_CIPHER_value(ciphers, i); const EVP_CIPHER *c = sk_EVP_CIPHER_value(ciphers, i);
STACK_OF(OPENSSL_CSTRING) *names =
sk_OPENSSL_CSTRING_new(name_cmp);
BIO_printf(bio_out, " %s", EVP_CIPHER_name(c)); EVP_CIPHER_names_do_all(c, collect_names, names);
BIO_printf(bio_out, " ");
print_names(bio_out, names);
BIO_printf(bio_out, " @ %s\n", BIO_printf(bio_out, " @ %s\n",
OSSL_PROVIDER_name(EVP_CIPHER_provider(c))); OSSL_PROVIDER_name(EVP_CIPHER_provider(c)));
sk_OPENSSL_CSTRING_free(names);
if (verbose) { if (verbose) {
print_param_types("retrievable algorithm parameters", print_param_types("retrievable algorithm parameters",
EVP_CIPHER_gettable_params(c), 4); EVP_CIPHER_gettable_params(c), 4);
print_param_types("retrievable operation parameters", print_param_types("retrievable operation parameters",
EVP_CIPHER_CTX_gettable_params(c), 4); EVP_CIPHER_gettable_ctx_params(c), 4);
print_param_types("settable operation parameters", print_param_types("settable operation parameters",
EVP_CIPHER_CTX_settable_params(c), 4); EVP_CIPHER_settable_ctx_params(c), 4);
} }
} }
sk_EVP_CIPHER_pop_free(ciphers, EVP_CIPHER_free); sk_EVP_CIPHER_pop_free(ciphers, EVP_CIPHER_free);
@@ -101,7 +110,7 @@ static void list_md_fn(const EVP_MD *m,
DEFINE_STACK_OF(EVP_MD) DEFINE_STACK_OF(EVP_MD)
static int md_cmp(const EVP_MD * const *a, const EVP_MD * const *b) static int md_cmp(const EVP_MD * const *a, const EVP_MD * const *b)
{ {
int ret = strcasecmp(EVP_MD_name(*a), EVP_MD_name(*b)); int ret = EVP_MD_number(*a) - EVP_MD_number(*b);
if (ret == 0) if (ret == 0)
ret = strcmp(OSSL_PROVIDER_name(EVP_MD_provider(*a)), ret = strcmp(OSSL_PROVIDER_name(EVP_MD_provider(*a)),
@@ -127,21 +136,29 @@ static void list_digests(void)
EVP_MD_do_all_sorted(list_md_fn, bio_out); EVP_MD_do_all_sorted(list_md_fn, bio_out);
BIO_printf(bio_out, "Provided:\n"); BIO_printf(bio_out, "Provided:\n");
EVP_MD_do_all_ex(NULL, collect_digests, digests); EVP_MD_do_all_provided(NULL, collect_digests, digests);
sk_EVP_MD_sort(digests); sk_EVP_MD_sort(digests);
for (i = 0; i < sk_EVP_MD_num(digests); i++) { for (i = 0; i < sk_EVP_MD_num(digests); i++) {
const EVP_MD *m = sk_EVP_MD_value(digests, i); const EVP_MD *m = sk_EVP_MD_value(digests, i);
STACK_OF(OPENSSL_CSTRING) *names =
sk_OPENSSL_CSTRING_new(name_cmp);
BIO_printf(bio_out, " %s", EVP_MD_name(m)); EVP_MD_names_do_all(m, collect_names, names);
BIO_printf(bio_out, " ");
print_names(bio_out, names);
BIO_printf(bio_out, " @ %s\n", BIO_printf(bio_out, " @ %s\n",
OSSL_PROVIDER_name(EVP_MD_provider(m))); OSSL_PROVIDER_name(EVP_MD_provider(m)));
sk_OPENSSL_CSTRING_free(names);
if (verbose) { if (verbose) {
print_param_types("retrievable algorithm parameters", print_param_types("retrievable algorithm parameters",
EVP_MD_gettable_params(m), 4); EVP_MD_gettable_params(m), 4);
print_param_types("retrievable operation parameters", print_param_types("retrievable operation parameters",
EVP_MD_CTX_gettable_params(m), 4); EVP_MD_gettable_ctx_params(m), 4);
print_param_types("settable operation parameters", print_param_types("settable operation parameters",
EVP_MD_CTX_settable_params(m), 4); EVP_MD_settable_ctx_params(m), 4);
} }
} }
sk_EVP_MD_pop_free(digests, EVP_MD_free); sk_EVP_MD_pop_free(digests, EVP_MD_free);
@@ -150,7 +167,7 @@ static void list_digests(void)
DEFINE_STACK_OF(EVP_MAC) DEFINE_STACK_OF(EVP_MAC)
static int mac_cmp(const EVP_MAC * const *a, const EVP_MAC * const *b) static int mac_cmp(const EVP_MAC * const *a, const EVP_MAC * const *b)
{ {
int ret = strcasecmp(EVP_MAC_name(*a), EVP_MAC_name(*b)); int ret = EVP_MAC_number(*a) - EVP_MAC_number(*b);
if (ret == 0) if (ret == 0)
ret = strcmp(OSSL_PROVIDER_name(EVP_MAC_provider(*a)), ret = strcmp(OSSL_PROVIDER_name(EVP_MAC_provider(*a)),
@@ -173,22 +190,29 @@ static void list_macs(void)
int i; int i;
BIO_printf(bio_out, "Provided MACs:\n"); BIO_printf(bio_out, "Provided MACs:\n");
EVP_MAC_do_all_ex(NULL, collect_macs, macs); EVP_MAC_do_all_provided(NULL, collect_macs, macs);
sk_EVP_MAC_sort(macs); sk_EVP_MAC_sort(macs);
for (i = 0; i < sk_EVP_MAC_num(macs); i++) { for (i = 0; i < sk_EVP_MAC_num(macs); i++) {
const EVP_MAC *m = sk_EVP_MAC_value(macs, i); const EVP_MAC *m = sk_EVP_MAC_value(macs, i);
STACK_OF(OPENSSL_CSTRING) *names =
sk_OPENSSL_CSTRING_new(name_cmp);
BIO_printf(bio_out, " %s", EVP_MAC_name(m)); EVP_MAC_names_do_all(m, collect_names, names);
BIO_printf(bio_out, " ");
print_names(bio_out, names);
BIO_printf(bio_out, " @ %s\n", BIO_printf(bio_out, " @ %s\n",
OSSL_PROVIDER_name(EVP_MAC_provider(m))); OSSL_PROVIDER_name(EVP_MAC_provider(m)));
sk_OPENSSL_CSTRING_free(names);
if (verbose) { if (verbose) {
print_param_types("retrievable algorithm parameters", print_param_types("retrievable algorithm parameters",
EVP_MAC_gettable_params(m), 4); EVP_MAC_gettable_params(m), 4);
print_param_types("retrievable operation parameters", print_param_types("retrievable operation parameters",
EVP_MAC_CTX_gettable_params(m), 4); EVP_MAC_gettable_ctx_params(m), 4);
print_param_types("settable operation parameters", print_param_types("settable operation parameters",
EVP_MAC_CTX_settable_params(m), 4); EVP_MAC_settable_ctx_params(m), 4);
} }
} }
sk_EVP_MAC_pop_free(macs, EVP_MAC_free); sk_EVP_MAC_pop_free(macs, EVP_MAC_free);
@@ -200,7 +224,7 @@ static void list_macs(void)
DEFINE_STACK_OF(EVP_KDF) DEFINE_STACK_OF(EVP_KDF)
static int kdf_cmp(const EVP_KDF * const *a, const EVP_KDF * const *b) static int kdf_cmp(const EVP_KDF * const *a, const EVP_KDF * const *b)
{ {
int ret = strcasecmp(EVP_KDF_name(*a), EVP_KDF_name(*b)); int ret = EVP_KDF_number(*a) - EVP_KDF_number(*b);
if (ret == 0) if (ret == 0)
ret = strcmp(OSSL_PROVIDER_name(EVP_KDF_provider(*a)), ret = strcmp(OSSL_PROVIDER_name(EVP_KDF_provider(*a)),
@@ -223,22 +247,29 @@ static void list_kdfs(void)
int i; int i;
BIO_printf(bio_out, "Provided KDFs and PDFs:\n"); BIO_printf(bio_out, "Provided KDFs and PDFs:\n");
EVP_KDF_do_all_ex(NULL, collect_kdfs, kdfs); EVP_KDF_do_all_provided(NULL, collect_kdfs, kdfs);
sk_EVP_KDF_sort(kdfs); sk_EVP_KDF_sort(kdfs);
for (i = 0; i < sk_EVP_KDF_num(kdfs); i++) { for (i = 0; i < sk_EVP_KDF_num(kdfs); i++) {
const EVP_KDF *m = sk_EVP_KDF_value(kdfs, i); const EVP_KDF *k = sk_EVP_KDF_value(kdfs, i);
STACK_OF(OPENSSL_CSTRING) *names =
sk_OPENSSL_CSTRING_new(name_cmp);
BIO_printf(bio_out, " %s", EVP_KDF_name(m)); EVP_KDF_names_do_all(k, collect_names, names);
BIO_printf(bio_out, " ");
print_names(bio_out, names);
BIO_printf(bio_out, " @ %s\n", BIO_printf(bio_out, " @ %s\n",
OSSL_PROVIDER_name(EVP_KDF_provider(m))); OSSL_PROVIDER_name(EVP_KDF_provider(k)));
sk_OPENSSL_CSTRING_free(names);
if (verbose) { if (verbose) {
print_param_types("retrievable algorithm parameters", print_param_types("retrievable algorithm parameters",
EVP_KDF_gettable_params(m), 4); EVP_KDF_gettable_params(k), 4);
print_param_types("retrievable operation parameters", print_param_types("retrievable operation parameters",
EVP_KDF_CTX_gettable_params(m), 4); EVP_KDF_gettable_ctx_params(k), 4);
print_param_types("settable operation parameters", print_param_types("settable operation parameters",
EVP_KDF_CTX_settable_params(m), 4); EVP_KDF_settable_ctx_params(k), 4);
} }
} }
sk_EVP_KDF_pop_free(kdfs, EVP_KDF_free); sk_EVP_KDF_pop_free(kdfs, EVP_KDF_free);
@@ -331,12 +362,16 @@ static void list_options_for_command(const char *command)
return; return;
for ( ; o->name != NULL; o++) { for ( ; o->name != NULL; o++) {
char c = o->valtype;
if (o->name == OPT_HELP_STR if (o->name == OPT_HELP_STR
|| o->name == OPT_MORE_STR || o->name == OPT_MORE_STR
|| o->name[0] == '\0') || o->name[0] == '\0')
continue; continue;
BIO_printf(bio_out, "%s %c\n", o->name, o->valtype); BIO_printf(bio_out, "%s %c\n", o->name, c == '\0' ? '-' : c);
} }
/* Always output the -- marker since it is sometimes documented. */
BIO_printf(bio_out, "- -\n");
} }
static void list_type(FUNC_TYPE ft, int one) static void list_type(FUNC_TYPE ft, int one)
+1 -1
View File
@@ -105,7 +105,7 @@ opthelp:
if (opts != NULL) { if (opts != NULL) {
int ok = 1; int ok = 1;
OSSL_PARAM *params = OSSL_PARAM *params =
app_params_new_from_opts(opts, EVP_MAC_CTX_settable_params(mac)); app_params_new_from_opts(opts, EVP_MAC_settable_ctx_params(mac));
if (params == NULL) if (params == NULL)
goto err; goto err;
+1 -1
View File
@@ -465,7 +465,7 @@ int pkcs12_main(int argc, char **argv)
p12 = PKCS12_create(cpass, name, key, ucert, certs, p12 = PKCS12_create(cpass, name, key, ucert, certs,
key_pbe, cert_pbe, iter, -1, keytype); key_pbe, cert_pbe, iter, -1, keytype);
if (!p12) { if (p12 == NULL) {
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
goto export_end; goto export_end;
} }
+4 -3
View File
@@ -35,7 +35,7 @@ const OPTIONS prime_options[] = {
int prime_main(int argc, char **argv) int prime_main(int argc, char **argv)
{ {
BIGNUM *bn = NULL; BIGNUM *bn = NULL;
int hex = 0, checks = 20, generate = 0, bits = 0, safe = 0, ret = 1; int hex = 0, generate = 0, bits = 0, safe = 0, ret = 1;
char *prog; char *prog;
OPTION_CHOICE o; OPTION_CHOICE o;
@@ -64,7 +64,8 @@ opthelp:
safe = 1; safe = 1;
break; break;
case OPT_CHECKS: case OPT_CHECKS:
checks = atoi(opt_arg()); /* ignore parameter and argument */
opt_arg();
break; break;
} }
} }
@@ -121,7 +122,7 @@ opthelp:
BN_print(bio_out, bn); BN_print(bio_out, bn);
BIO_printf(bio_out, " (%s) %s prime\n", BIO_printf(bio_out, " (%s) %s prime\n",
argv[0], argv[0],
BN_is_prime_ex(bn, checks, NULL, NULL) BN_check_prime(bn, NULL, NULL)
? "is" : "is not"); ? "is" : "is not");
} }
} }
+107 -30
View File
@@ -12,6 +12,7 @@
#include "apps.h" #include "apps.h"
#include "app_params.h" #include "app_params.h"
#include "progs.h" #include "progs.h"
#include "names.h"
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/safestack.h> #include <openssl/safestack.h>
@@ -40,7 +41,7 @@ typedef struct info_st INFO;
typedef struct meta_st META; typedef struct meta_st META;
struct info_st { struct info_st {
const char *name; void (*collect_names_fn)(void *method, STACK_OF(OPENSSL_CSTRING) *names);
void *method; void *method;
const OSSL_PARAM *gettable_params; const OSSL_PARAM *gettable_params;
const OSSL_PARAM *gettable_ctx_params; const OSSL_PARAM *gettable_ctx_params;
@@ -58,11 +59,58 @@ struct meta_st {
void (*fn)(META *meta, INFO *info); void (*fn)(META *meta, INFO *info);
}; };
static void collect_cipher_names(void *method,
STACK_OF(OPENSSL_CSTRING) *names)
{
EVP_CIPHER_names_do_all(method, collect_names, names);
}
static void collect_digest_names(void *method,
STACK_OF(OPENSSL_CSTRING) *names)
{
EVP_MD_names_do_all(method, collect_names, names);
}
static void collect_mac_names(void *method,
STACK_OF(OPENSSL_CSTRING) *names)
{
EVP_MAC_names_do_all(method, collect_names, names);
}
static void collect_keymgmt_names(void *method,
STACK_OF(OPENSSL_CSTRING) *names)
{
EVP_KEYMGMT_names_do_all(method, collect_names, names);
}
static void collect_keyexch_names(void *method,
STACK_OF(OPENSSL_CSTRING) *names)
{
EVP_KEYEXCH_names_do_all(method, collect_names, names);
}
static void collect_signature_names(void *method,
STACK_OF(OPENSSL_CSTRING) *names)
{
EVP_SIGNATURE_names_do_all(method, collect_names, names);
}
static void print_method_names(BIO *out, INFO *info)
{
STACK_OF(OPENSSL_CSTRING) *names = sk_OPENSSL_CSTRING_new(name_cmp);
info->collect_names_fn(info->method, names);
print_names(out, names);
sk_OPENSSL_CSTRING_free(names);
}
static void print_caps(META *meta, INFO *info) static void print_caps(META *meta, INFO *info)
{ {
switch (meta->verbose) { switch (meta->verbose) {
case 1: case 1:
BIO_printf(bio_out, meta->first ? "%s" : " %s", info->name); if (!meta->first)
BIO_printf(bio_out, "; ");
print_method_names(bio_out, info);
break; break;
case 2: case 2:
if (meta->first) { if (meta->first) {
@@ -70,12 +118,14 @@ static void print_caps(META *meta, INFO *info)
BIO_printf(bio_out, "\n"); BIO_printf(bio_out, "\n");
BIO_printf(bio_out, "%*s%ss:", meta->indent, "", meta->label); BIO_printf(bio_out, "%*s%ss:", meta->indent, "", meta->label);
} }
BIO_printf(bio_out, " %s", info->name); BIO_printf(bio_out, " ");
print_method_names(bio_out, info);
break; break;
case 3: case 3:
default: default:
BIO_printf(bio_out, "%*s%s %s\n", meta->indent, "", meta->label, BIO_printf(bio_out, "%*s%s ", meta->indent, "", meta->label);
info->name); print_method_names(bio_out, info);
BIO_printf(bio_out, "\n");
print_param_types("retrievable algorithm parameters", print_param_types("retrievable algorithm parameters",
info->gettable_params, meta->subindent); info->gettable_params, meta->subindent);
print_param_types("retrievable operation parameters", print_param_types("retrievable operation parameters",
@@ -87,7 +137,9 @@ static void print_caps(META *meta, INFO *info)
meta->first = 0; meta->first = 0;
} }
static void do_method(void *method, const char *name, static void do_method(void *method,
void (*collect_names_fn)(void *method,
STACK_OF(OPENSSL_CSTRING) *names),
const OSSL_PARAM *gettable_params, const OSSL_PARAM *gettable_params,
const OSSL_PARAM *gettable_ctx_params, const OSSL_PARAM *gettable_ctx_params,
const OSSL_PARAM *settable_ctx_params, const OSSL_PARAM *settable_ctx_params,
@@ -95,7 +147,7 @@ static void do_method(void *method, const char *name,
{ {
INFO info; INFO info;
info.name = name; info.collect_names_fn = collect_names_fn;
info.method = method; info.method = method;
info.gettable_params = gettable_params; info.gettable_params = gettable_params;
info.gettable_ctx_params = gettable_ctx_params; info.gettable_ctx_params = gettable_ctx_params;
@@ -106,53 +158,78 @@ static void do_method(void *method, const char *name,
static void do_cipher(EVP_CIPHER *cipher, void *meta) static void do_cipher(EVP_CIPHER *cipher, void *meta)
{ {
do_method(cipher, EVP_CIPHER_name(cipher), do_method(cipher, collect_cipher_names,
EVP_CIPHER_gettable_params(cipher), EVP_CIPHER_gettable_params(cipher),
EVP_CIPHER_CTX_gettable_params(cipher), EVP_CIPHER_gettable_ctx_params(cipher),
EVP_CIPHER_CTX_settable_params(cipher), EVP_CIPHER_settable_ctx_params(cipher),
meta); meta);
} }
static void do_digest(EVP_MD *digest, void *meta) static void do_digest(EVP_MD *digest, void *meta)
{ {
do_method(digest, EVP_MD_name(digest), do_method(digest, collect_digest_names,
EVP_MD_gettable_params(digest), EVP_MD_gettable_params(digest),
EVP_MD_CTX_gettable_params(digest), EVP_MD_gettable_ctx_params(digest),
EVP_MD_CTX_settable_params(digest), EVP_MD_settable_ctx_params(digest),
meta); meta);
} }
static void do_mac(EVP_MAC *mac, void *meta) static void do_mac(EVP_MAC *mac, void *meta)
{ {
do_method(mac, EVP_MAC_name(mac), do_method(mac, collect_mac_names,
EVP_MAC_gettable_params(mac), EVP_MAC_gettable_params(mac),
EVP_MAC_CTX_gettable_params(mac), EVP_MAC_gettable_ctx_params(mac),
EVP_MAC_CTX_settable_params(mac), EVP_MAC_settable_ctx_params(mac),
meta); meta);
} }
static void do_keymgmt(EVP_KEYMGMT *keymgmt, void *meta)
{
do_method(keymgmt, collect_keymgmt_names,
/* /*
* TODO(3.0) Enable when KEYMGMT and KEYEXCH have gettables and settables * TODO(3.0) Enable when KEYMGMT and KEYEXCH have gettables and settables
*/ */
#if 0 #if 0
static void do_keymgmt(EVP_KEYMGMT *keymgmt, void *meta)
{
do_method(keymgmt, EVP_KEYMGMT_name(keymgmt),
EVP_KEYMGMT_gettable_params(keymgmt), EVP_KEYMGMT_gettable_params(keymgmt),
EVP_KEYMGMT_gettable_ctx_params(keymgmt), EVP_KEYMGMT_gettable_ctx_params(keymgmt),
EVP_KEYMGMT_settable_ctx_params(keymgmt), EVP_KEYMGMT_settable_ctx_params(keymgmt),
#else
NULL, NULL, NULL,
#endif
meta); meta);
} }
static void do_keyexch(EVP_KEYEXCH *keyexch, void *meta) static void do_keyexch(EVP_KEYEXCH *keyexch, void *meta)
{ {
do_method(keyexch, EVP_KEYEXCH_name(keyexch), do_method(keyexch, collect_keyexch_names,
/*
* TODO(3.0) Enable when KEYMGMT and KEYEXCH have gettables and settables
*/
#if 0
EVP_KEYEXCH_gettable_params(keyexch), EVP_KEYEXCH_gettable_params(keyexch),
EVP_KEYEXCH_gettable_ctx_params(keyexch), EVP_KEYEXCH_gettable_ctx_params(keyexch),
EVP_KEYEXCH_settable_ctx_params(keyexch), EVP_KEYEXCH_settable_ctx_params(keyexch),
#else
NULL, NULL, NULL,
#endif
meta); meta);
} }
static void do_signature(EVP_SIGNATURE *signature, void *meta)
{
do_method(signature, collect_signature_names,
/*
* TODO(3.0) Enable when KEYMGMT and SIGNATURE have gettables and settables
*/
#if 0
EVP_SIGNATURE_gettable_params(signature),
EVP_SIGNATURE_gettable_ctx_params(signature),
EVP_SIGNATURE_settable_ctx_params(signature),
#else
NULL, NULL, NULL,
#endif #endif
meta);
}
int provider_main(int argc, char **argv) int provider_main(int argc, char **argv)
{ {
@@ -231,33 +308,33 @@ int provider_main(int argc, char **argv)
data.first = 1; data.first = 1;
data.label = "Cipher"; data.label = "Cipher";
} }
EVP_CIPHER_do_all_ex(NULL, do_cipher, &data); EVP_CIPHER_do_all_provided(NULL, do_cipher, &data);
if (verbose > 1) { if (verbose > 1) {
data.first = 1; data.first = 1;
data.label = "Digest"; data.label = "Digest";
} }
EVP_MD_do_all_ex(NULL, do_digest, &data); EVP_MD_do_all_provided(NULL, do_digest, &data);
if (verbose > 1) { if (verbose > 1) {
data.first = 1; data.first = 1;
data.label = "MAC"; data.label = "MAC";
} }
EVP_MAC_do_all_ex(NULL, do_mac, &data); EVP_MAC_do_all_provided(NULL, do_mac, &data);
/*
* TODO(3.0) Enable when KEYMGMT and KEYEXCH have do_all_ex functions
*/
#if 0
if (verbose > 1) { if (verbose > 1) {
data.first = 1; data.first = 1;
data.label = "Key manager"; data.label = "Key manager";
} }
EVP_KEYMGMT_do_all_ex(NULL, do_keymgmt, &data); EVP_KEYMGMT_do_all_provided(NULL, do_keymgmt, &data);
if (verbose > 1) { if (verbose > 1) {
data.first = 1; data.first = 1;
data.label = "Key exchange"; data.label = "Key exchange";
} }
EVP_KEYEXCH_do_all_ex(NULL, do_keyexch, &data); EVP_KEYEXCH_do_all_provided(NULL, do_keyexch, &data);
#endif if (verbose > 1) {
data.first = 1;
data.label = "Signature";
}
EVP_SIGNATURE_do_all_provided(NULL, do_signature, &data);
switch (verbose) { switch (verbose) {
default: default:
+33 -20
View File
@@ -325,9 +325,10 @@ int req_main(int argc, char **argv)
newreq = 1; newreq = 1;
break; break;
case OPT_PKEYOPT: case OPT_PKEYOPT:
if (!pkeyopts) if (pkeyopts == NULL)
pkeyopts = sk_OPENSSL_STRING_new_null(); pkeyopts = sk_OPENSSL_STRING_new_null();
if (!pkeyopts || !sk_OPENSSL_STRING_push(pkeyopts, opt_arg())) if (pkeyopts == NULL
|| !sk_OPENSSL_STRING_push(pkeyopts, opt_arg()))
goto opthelp; goto opthelp;
break; break;
case OPT_SIGOPT: case OPT_SIGOPT:
@@ -1751,15 +1752,19 @@ int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
#endif #endif
rv = do_sign_init(mctx, pkey, md, sigopts); rv = do_sign_init(mctx, pkey, md, sigopts);
if (rv > 0) if (rv > 0) {
rv = X509_sign_ctx(x, mctx); rv = X509_sign_ctx(x, mctx);
#ifndef OPENSSL_NO_SM2 #ifndef OPENSSL_NO_SM2
/* only in SM2 case we need to free the pctx explicitly */ /*
if (ec_pkey_is_sm2(pkey)) { * only in SM2 case we need to free the pctx explicitly
pctx = EVP_MD_CTX_pkey_ctx(mctx); * if do_sign_init() fails, pctx is already freed in it
EVP_PKEY_CTX_free(pctx); */
} if (ec_pkey_is_sm2(pkey)) {
pctx = EVP_MD_CTX_pkey_ctx(mctx);
EVP_PKEY_CTX_free(pctx);
}
#endif #endif
}
EVP_MD_CTX_free(mctx); EVP_MD_CTX_free(mctx);
return rv > 0 ? 1 : 0; return rv > 0 ? 1 : 0;
} }
@@ -1774,15 +1779,19 @@ int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
#endif #endif
rv = do_sign_init(mctx, pkey, md, sigopts); rv = do_sign_init(mctx, pkey, md, sigopts);
if (rv > 0) if (rv > 0) {
rv = X509_REQ_sign_ctx(x, mctx); rv = X509_REQ_sign_ctx(x, mctx);
#ifndef OPENSSL_NO_SM2 #ifndef OPENSSL_NO_SM2
/* only in SM2 case we need to free the pctx explicitly */ /*
if (ec_pkey_is_sm2(pkey)) { * only in SM2 case we need to free the pctx explicitly
pctx = EVP_MD_CTX_pkey_ctx(mctx); * if do_sign_init() fails, pctx is already freed in it
EVP_PKEY_CTX_free(pctx); */
} if (ec_pkey_is_sm2(pkey)) {
pctx = EVP_MD_CTX_pkey_ctx(mctx);
EVP_PKEY_CTX_free(pctx);
}
#endif #endif
}
EVP_MD_CTX_free(mctx); EVP_MD_CTX_free(mctx);
return rv > 0 ? 1 : 0; return rv > 0 ? 1 : 0;
} }
@@ -1797,15 +1806,19 @@ int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
#endif #endif
rv = do_sign_init(mctx, pkey, md, sigopts); rv = do_sign_init(mctx, pkey, md, sigopts);
if (rv > 0) if (rv > 0) {
rv = X509_CRL_sign_ctx(x, mctx); rv = X509_CRL_sign_ctx(x, mctx);
#ifndef OPENSSL_NO_SM2 #ifndef OPENSSL_NO_SM2
/* only in SM2 case we need to free the pctx explicitly */ /*
if (ec_pkey_is_sm2(pkey)) { * only in SM2 case we need to free the pctx explicitly
pctx = EVP_MD_CTX_pkey_ctx(mctx); * if do_sign_init() fails, no need to double free pctx
EVP_PKEY_CTX_free(pctx); */
} if (ec_pkey_is_sm2(pkey)) {
pctx = EVP_MD_CTX_pkey_ctx(mctx);
EVP_PKEY_CTX_free(pctx);
}
#endif #endif
}
EVP_MD_CTX_free(mctx); EVP_MD_CTX_free(mctx);
return rv > 0 ? 1 : 0; return rv > 0 ? 1 : 0;
} }
+2 -4
View File
@@ -272,8 +272,6 @@ typedef struct srp_arg_st {
int strength; /* minimal size for N */ int strength; /* minimal size for N */
} SRP_ARG; } SRP_ARG;
# define SRP_NUMBER_ITERATIONS_FOR_PRIME 64
static int srp_Verify_N_and_g(const BIGNUM *N, const BIGNUM *g) static int srp_Verify_N_and_g(const BIGNUM *N, const BIGNUM *g)
{ {
BN_CTX *bn_ctx = BN_CTX_new(); BN_CTX *bn_ctx = BN_CTX_new();
@@ -281,10 +279,10 @@ static int srp_Verify_N_and_g(const BIGNUM *N, const BIGNUM *g)
BIGNUM *r = BN_new(); BIGNUM *r = BN_new();
int ret = int ret =
g != NULL && N != NULL && bn_ctx != NULL && BN_is_odd(N) && g != NULL && N != NULL && bn_ctx != NULL && BN_is_odd(N) &&
BN_is_prime_ex(N, SRP_NUMBER_ITERATIONS_FOR_PRIME, bn_ctx, NULL) == 1 && BN_check_prime(N, bn_ctx, NULL) == 1 &&
p != NULL && BN_rshift1(p, N) && p != NULL && BN_rshift1(p, N) &&
/* p = (N-1)/2 */ /* p = (N-1)/2 */
BN_is_prime_ex(p, SRP_NUMBER_ITERATIONS_FOR_PRIME, bn_ctx, NULL) == 1 && BN_check_prime(p, bn_ctx, NULL) == 1 &&
r != NULL && r != NULL &&
/* verify g^((N-1)/2) == -1 (mod N) */ /* verify g^((N-1)/2) == -1 (mod N) */
BN_mod_exp(r, g, p, N, bn_ctx) && BN_mod_exp(r, g, p, N, bn_ctx) &&
+358 -10
View File
@@ -15,6 +15,7 @@
#define ECDSA_SECONDS 10 #define ECDSA_SECONDS 10
#define ECDH_SECONDS 10 #define ECDH_SECONDS 10
#define EdDSA_SECONDS 10 #define EdDSA_SECONDS 10
#define SM2_SECONDS 10
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -127,6 +128,7 @@ typedef struct openssl_speed_sec_st {
int ecdsa; int ecdsa;
int ecdh; int ecdh;
int eddsa; int eddsa;
int sm2;
} openssl_speed_sec_t; } openssl_speed_sec_t;
static volatile int run = 0; static volatile int run = 0;
@@ -191,6 +193,10 @@ static int ECDSA_sign_loop(void *args);
static int ECDSA_verify_loop(void *args); static int ECDSA_verify_loop(void *args);
static int EdDSA_sign_loop(void *args); static int EdDSA_sign_loop(void *args);
static int EdDSA_verify_loop(void *args); static int EdDSA_verify_loop(void *args);
# ifndef OPENSSL_NO_SM2
static int SM2_sign_loop(void *args);
static int SM2_verify_loop(void *args);
# endif
#endif #endif
static double Time_F(int s); static double Time_F(int s);
@@ -604,6 +610,18 @@ static OPT_PAIR eddsa_choices[] = {
# define EdDSA_NUM OSSL_NELEM(eddsa_choices) # define EdDSA_NUM OSSL_NELEM(eddsa_choices)
static double eddsa_results[EdDSA_NUM][2]; /* 2 ops: sign then verify */ static double eddsa_results[EdDSA_NUM][2]; /* 2 ops: sign then verify */
# ifndef OPENSSL_NO_SM2
# define R_EC_CURVESM2 0
static OPT_PAIR sm2_choices[] = {
{"curveSM2", R_EC_CURVESM2}
};
# define SM2_ID "TLSv1.3+GM+Cipher+Suite"
# define SM2_ID_LEN sizeof("TLSv1.3+GM+Cipher+Suite") - 1
# define SM2_NUM OSSL_NELEM(sm2_choices)
static double sm2_results[SM2_NUM][2]; /* 2 ops: sign then verify */
# endif /* OPENSSL_NO_SM2 */
#endif /* OPENSSL_NO_EC */ #endif /* OPENSSL_NO_EC */
#ifndef SIGALRM #ifndef SIGALRM
@@ -634,6 +652,11 @@ typedef struct loopargs_st {
EC_KEY *ecdsa[ECDSA_NUM]; EC_KEY *ecdsa[ECDSA_NUM];
EVP_PKEY_CTX *ecdh_ctx[EC_NUM]; EVP_PKEY_CTX *ecdh_ctx[EC_NUM];
EVP_MD_CTX *eddsa_ctx[EdDSA_NUM]; EVP_MD_CTX *eddsa_ctx[EdDSA_NUM];
# ifndef OPENSSL_NO_SM2
EVP_MD_CTX *sm2_ctx[SM2_NUM];
EVP_MD_CTX *sm2_vfy_ctx[SM2_NUM];
EVP_PKEY *sm2_pkey[SM2_NUM];
# endif
unsigned char *secret_a; unsigned char *secret_a;
unsigned char *secret_b; unsigned char *secret_b;
size_t outlen[EC_NUM]; size_t outlen[EC_NUM];
@@ -1296,6 +1319,74 @@ static int EdDSA_verify_loop(void *args)
} }
return count; return count;
} }
# ifndef OPENSSL_NO_SM2
static long sm2_c[SM2_NUM][2];
static int SM2_sign_loop(void *args)
{
loopargs_t *tempargs = *(loopargs_t **) args;
unsigned char *buf = tempargs->buf;
EVP_MD_CTX **sm2ctx = tempargs->sm2_ctx;
unsigned char *sm2sig = tempargs->buf2;
size_t sm2sigsize = tempargs->sigsize;
const size_t max_size = tempargs->sigsize;
int ret, count;
EVP_PKEY **sm2_pkey = tempargs->sm2_pkey;
for (count = 0; COND(sm2_c[testnum][0]); count++) {
if (!EVP_DigestSignInit(sm2ctx[testnum], NULL, EVP_sm3(),
NULL, sm2_pkey[testnum])) {
BIO_printf(bio_err, "SM2 init sign failure\n");
ERR_print_errors(bio_err);
count = -1;
break;
}
ret = EVP_DigestSign(sm2ctx[testnum], sm2sig, &sm2sigsize,
buf, 20);
if (ret == 0) {
BIO_printf(bio_err, "SM2 sign failure\n");
ERR_print_errors(bio_err);
count = -1;
break;
}
/* update the latest returned size and always use the fixed buffer size */
tempargs->sigsize = sm2sigsize;
sm2sigsize = max_size;
}
return count;
}
static int SM2_verify_loop(void *args)
{
loopargs_t *tempargs = *(loopargs_t **) args;
unsigned char *buf = tempargs->buf;
EVP_MD_CTX **sm2ctx = tempargs->sm2_vfy_ctx;
unsigned char *sm2sig = tempargs->buf2;
size_t sm2sigsize = tempargs->sigsize;
int ret, count;
EVP_PKEY **sm2_pkey = tempargs->sm2_pkey;
for (count = 0; COND(sm2_c[testnum][1]); count++) {
if (!EVP_DigestVerifyInit(sm2ctx[testnum], NULL, EVP_sm3(),
NULL, sm2_pkey[testnum])) {
BIO_printf(bio_err, "SM2 verify init failure\n");
ERR_print_errors(bio_err);
count = -1;
break;
}
ret = EVP_DigestVerify(sm2ctx[testnum], sm2sig, sm2sigsize,
buf, 20);
if (ret != 1) {
BIO_printf(bio_err, "SM2 verify failure\n");
ERR_print_errors(bio_err);
count = -1;
break;
}
}
return count;
}
# endif /* OPENSSL_NO_SM2 */
#endif /* OPENSSL_NO_EC */ #endif /* OPENSSL_NO_EC */
static int run_benchmark(int async_jobs, static int run_benchmark(int async_jobs,
@@ -1477,7 +1568,7 @@ int speed_main(int argc, char **argv)
#endif #endif
openssl_speed_sec_t seconds = { SECONDS, RSA_SECONDS, DSA_SECONDS, openssl_speed_sec_t seconds = { SECONDS, RSA_SECONDS, DSA_SECONDS,
ECDSA_SECONDS, ECDH_SECONDS, ECDSA_SECONDS, ECDH_SECONDS,
EdDSA_SECONDS }; EdDSA_SECONDS, SM2_SECONDS };
/* What follows are the buffers and key material. */ /* What follows are the buffers and key material. */
#ifndef OPENSSL_NO_RC5 #ifndef OPENSSL_NO_RC5
@@ -1609,11 +1700,23 @@ int speed_main(int argc, char **argv)
{"Ed25519", NID_ED25519, 253, 64}, {"Ed25519", NID_ED25519, 253, 64},
{"Ed448", NID_ED448, 456, 114} {"Ed448", NID_ED448, 456, 114}
}; };
# ifndef OPENSSL_NO_SM2
static const struct {
const char *name;
unsigned int nid;
unsigned int bits;
} test_sm2_curves[] = {
/* SM2 */
{"CurveSM2", NID_sm2, 256}
};
# endif
int ecdsa_doit[ECDSA_NUM] = { 0 }; int ecdsa_doit[ECDSA_NUM] = { 0 };
int ecdh_doit[EC_NUM] = { 0 }; int ecdh_doit[EC_NUM] = { 0 };
int eddsa_doit[EdDSA_NUM] = { 0 }; int eddsa_doit[EdDSA_NUM] = { 0 };
int sm2_doit[SM2_NUM] = { 0 };
OPENSSL_assert(OSSL_NELEM(test_curves) >= EC_NUM); OPENSSL_assert(OSSL_NELEM(test_curves) >= EC_NUM);
OPENSSL_assert(OSSL_NELEM(test_ed_curves) >= EdDSA_NUM); OPENSSL_assert(OSSL_NELEM(test_ed_curves) >= EdDSA_NUM);
OPENSSL_assert(OSSL_NELEM(test_sm2_curves) >= SM2_NUM);
#endif /* ndef OPENSSL_NO_EC */ #endif /* ndef OPENSSL_NO_EC */
prog = opt_init(argc, argv, speed_options); prog = opt_init(argc, argv, speed_options);
@@ -1726,7 +1829,8 @@ int speed_main(int argc, char **argv)
break; break;
case OPT_SECONDS: case OPT_SECONDS:
seconds.sym = seconds.rsa = seconds.dsa = seconds.ecdsa seconds.sym = seconds.rsa = seconds.dsa = seconds.ecdsa
= seconds.ecdh = seconds.eddsa = atoi(opt_arg()); = seconds.ecdh = seconds.eddsa
= seconds.sm2 = atoi(opt_arg());
break; break;
case OPT_BYTES: case OPT_BYTES:
lengths_single = atoi(opt_arg()); lengths_single = atoi(opt_arg());
@@ -1819,6 +1923,17 @@ int speed_main(int argc, char **argv)
eddsa_doit[i] = 2; eddsa_doit[i] = 2;
continue; continue;
} }
# ifndef OPENSSL_NO_SM2
if (strcmp(*argv, "sm2") == 0) {
for (loop = 0; loop < OSSL_NELEM(sm2_doit); loop++)
sm2_doit[loop] = 1;
continue;
}
if (found(*argv, sm2_choices, &i)) {
sm2_doit[i] = 2;
continue;
}
# endif
#endif #endif
BIO_printf(bio_err, "%s: Unknown algorithm %s\n", prog, *argv); BIO_printf(bio_err, "%s: Unknown algorithm %s\n", prog, *argv);
goto end; goto end;
@@ -1921,6 +2036,10 @@ int speed_main(int argc, char **argv)
ecdh_doit[loop] = 1; ecdh_doit[loop] = 1;
for (loop = 0; loop < OSSL_NELEM(eddsa_doit); loop++) for (loop = 0; loop < OSSL_NELEM(eddsa_doit); loop++)
eddsa_doit[loop] = 1; eddsa_doit[loop] = 1;
# ifndef OPENSSL_NO_SM2
for (loop = 0; loop < OSSL_NELEM(sm2_doit); loop++)
sm2_doit[loop] = 1;
# endif
#endif #endif
} }
for (i = 0; i < ALGOR_NUM; i++) for (i = 0; i < ALGOR_NUM; i++)
@@ -2226,6 +2345,10 @@ int speed_main(int argc, char **argv)
eddsa_c[R_EC_Ed25519][0] = count / 1800; eddsa_c[R_EC_Ed25519][0] = count / 1800;
eddsa_c[R_EC_Ed448][0] = count / 7200; eddsa_c[R_EC_Ed448][0] = count / 7200;
# ifndef OPENSSL_NO_SM2
sm2_c[R_EC_SM2P256][0] = count / 1800;
# endif
# endif # endif
# else # else
@@ -3149,7 +3272,7 @@ int speed_main(int argc, char **argv)
pctx = NULL; pctx = NULL;
} }
if (kctx == NULL || /* keygen ctx is not null */ if (kctx == NULL || /* keygen ctx is not null */
!EVP_PKEY_keygen_init(kctx) /* init keygen ctx */ ) { EVP_PKEY_keygen_init(kctx) <= 0/* init keygen ctx */ ) {
ecdh_checks = 0; ecdh_checks = 0;
BIO_printf(bio_err, "ECDH keygen failure.\n"); BIO_printf(bio_err, "ECDH keygen failure.\n");
ERR_print_errors(bio_err); ERR_print_errors(bio_err);
@@ -3157,12 +3280,12 @@ int speed_main(int argc, char **argv)
break; break;
} }
if (!EVP_PKEY_keygen(kctx, &key_A) || /* generate secret key A */ if (EVP_PKEY_keygen(kctx, &key_A) <= 0 || /* generate secret key A */
!EVP_PKEY_keygen(kctx, &key_B) || /* generate secret key B */ EVP_PKEY_keygen(kctx, &key_B) <= 0 || /* generate secret key B */
!(ctx = EVP_PKEY_CTX_new(key_A, NULL)) || /* derivation ctx from skeyA */ !(ctx = EVP_PKEY_CTX_new(key_A, NULL)) || /* derivation ctx from skeyA */
!EVP_PKEY_derive_init(ctx) || /* init derivation ctx */ EVP_PKEY_derive_init(ctx) <= 0 || /* init derivation ctx */
!EVP_PKEY_derive_set_peer(ctx, key_B) || /* set peer pubkey in ctx */ EVP_PKEY_derive_set_peer(ctx, key_B) <= 0 || /* set peer pubkey in ctx */
!EVP_PKEY_derive(ctx, NULL, &outlen) || /* determine max length */ EVP_PKEY_derive(ctx, NULL, &outlen) <= 0 || /* determine max length */
outlen == 0 || /* ensure outlen is a valid size */ outlen == 0 || /* ensure outlen is a valid size */
outlen > MAX_ECDH_SIZE /* avoid buffer overflow */ ) { outlen > MAX_ECDH_SIZE /* avoid buffer overflow */ ) {
ecdh_checks = 0; ecdh_checks = 0;
@@ -3249,8 +3372,8 @@ int speed_main(int argc, char **argv)
if ((ed_pctx = EVP_PKEY_CTX_new_id(test_ed_curves[testnum].nid, NULL)) if ((ed_pctx = EVP_PKEY_CTX_new_id(test_ed_curves[testnum].nid, NULL))
== NULL == NULL
|| !EVP_PKEY_keygen_init(ed_pctx) || EVP_PKEY_keygen_init(ed_pctx) <= 0
|| !EVP_PKEY_keygen(ed_pctx, &ed_pkey)) { || EVP_PKEY_keygen(ed_pctx, &ed_pkey) <= 0) {
st = 0; st = 0;
EVP_PKEY_CTX_free(ed_pctx); EVP_PKEY_CTX_free(ed_pctx);
break; break;
@@ -3337,6 +3460,175 @@ int speed_main(int argc, char **argv)
} }
} }
# ifndef OPENSSL_NO_SM2
for (testnum = 0; testnum < SM2_NUM; testnum++) {
int st = 1;
EVP_PKEY *sm2_pkey = NULL;
EVP_PKEY_CTX *pctx = NULL;
EVP_PKEY_CTX *sm2_pctx = NULL;
EVP_PKEY_CTX *sm2_vfy_pctx = NULL;
size_t sm2_sigsize = 0;
if (!sm2_doit[testnum])
continue; /* Ignore Curve */
/* Init signing and verification */
for (i = 0; i < loopargs_len; i++) {
loopargs[i].sm2_ctx[testnum] = EVP_MD_CTX_new();
if (loopargs[i].sm2_ctx[testnum] == NULL) {
st = 0;
break;
}
loopargs[i].sm2_vfy_ctx[testnum] = EVP_MD_CTX_new();
if (loopargs[i].sm2_vfy_ctx[testnum] == NULL) {
st = 0;
break;
}
/* SM2 keys are generated as normal EC keys with a special curve */
if ((pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL)) == NULL
|| EVP_PKEY_keygen_init(pctx) <= 0
|| EVP_PKEY_CTX_set_ec_paramgen_curve_nid(pctx,
test_sm2_curves[testnum].nid) <= 0
|| EVP_PKEY_keygen(pctx, &sm2_pkey) <= 0) {
st = 0;
EVP_PKEY_CTX_free(pctx);
break;
}
/* free previous one and alloc a new one */
EVP_PKEY_CTX_free(pctx);
loopargs[i].sigsize = sm2_sigsize
= ECDSA_size(EVP_PKEY_get0_EC_KEY(sm2_pkey));
if (!EVP_PKEY_set_alias_type(sm2_pkey, EVP_PKEY_SM2)) {
st = 0;
EVP_PKEY_free(sm2_pkey);
break;
}
sm2_pctx = EVP_PKEY_CTX_new(sm2_pkey, NULL);
if (sm2_pctx == NULL) {
st = 0;
EVP_PKEY_free(sm2_pkey);
break;
}
sm2_vfy_pctx = EVP_PKEY_CTX_new(sm2_pkey, NULL);
if (sm2_vfy_pctx == NULL) {
st = 0;
EVP_PKEY_CTX_free(sm2_pctx);
EVP_PKEY_free(sm2_pkey);
break;
}
/*
* No need to allow user to set an explicit ID here, just use
* the one defined in the 'draft-yang-tls-tl13-sm-suites' I-D.
*/
if (EVP_PKEY_CTX_set1_id(sm2_pctx, SM2_ID, SM2_ID_LEN) != 1) {
st = 0;
EVP_PKEY_CTX_free(sm2_pctx);
EVP_PKEY_CTX_free(sm2_vfy_pctx);
EVP_PKEY_free(sm2_pkey);
break;
}
if (EVP_PKEY_CTX_set1_id(sm2_vfy_pctx, SM2_ID, SM2_ID_LEN) != 1) {
st = 0;
EVP_PKEY_CTX_free(sm2_pctx);
EVP_PKEY_CTX_free(sm2_vfy_pctx);
EVP_PKEY_free(sm2_pkey);
break;
}
EVP_MD_CTX_set_pkey_ctx(loopargs[i].sm2_ctx[testnum], sm2_pctx);
EVP_MD_CTX_set_pkey_ctx(loopargs[i].sm2_vfy_ctx[testnum], sm2_vfy_pctx);
if (!EVP_DigestSignInit(loopargs[i].sm2_ctx[testnum], NULL,
EVP_sm3(), NULL, sm2_pkey)) {
st = 0;
EVP_PKEY_free(sm2_pkey);
break;
}
if (!EVP_DigestVerifyInit(loopargs[i].sm2_vfy_ctx[testnum], NULL,
EVP_sm3(), NULL, sm2_pkey)) {
st = 0;
EVP_PKEY_free(sm2_pkey);
break;
}
loopargs[i].sm2_pkey[testnum] = sm2_pkey;
}
if (st == 0) {
BIO_printf(bio_err, "SM2 failure.\n");
ERR_print_errors(bio_err);
rsa_count = 1;
} else {
for (i = 0; i < loopargs_len; i++) {
sm2_sigsize = loopargs[i].sigsize;
/* Perform SM2 signature test */
st = EVP_DigestSign(loopargs[i].sm2_ctx[testnum],
loopargs[i].buf2, &sm2_sigsize,
loopargs[i].buf, 20);
if (st == 0)
break;
}
if (st == 0) {
BIO_printf(bio_err,
"SM2 sign failure. No SM2 sign will be done.\n");
ERR_print_errors(bio_err);
rsa_count = 1;
} else {
pkey_print_message("sign", test_sm2_curves[testnum].name,
sm2_c[testnum][0],
test_sm2_curves[testnum].bits, seconds.sm2);
Time_F(START);
count = run_benchmark(async_jobs, SM2_sign_loop, loopargs);
d = Time_F(STOP);
BIO_printf(bio_err,
mr ? "+R8:%ld:%u:%s:%.2f\n" :
"%ld %u bits %s signs in %.2fs \n",
count, test_sm2_curves[testnum].bits,
test_sm2_curves[testnum].name, d);
sm2_results[testnum][0] = (double)count / d;
rsa_count = count;
}
/* Perform SM2 verification test */
for (i = 0; i < loopargs_len; i++) {
st = EVP_DigestVerify(loopargs[i].sm2_vfy_ctx[testnum],
loopargs[i].buf2, loopargs[i].sigsize,
loopargs[i].buf, 20);
if (st != 1)
break;
}
if (st != 1) {
BIO_printf(bio_err,
"SM2 verify failure. No SM2 verify will be done.\n");
ERR_print_errors(bio_err);
sm2_doit[testnum] = 0;
} else {
pkey_print_message("verify", test_sm2_curves[testnum].name,
sm2_c[testnum][1],
test_sm2_curves[testnum].bits, seconds.sm2);
Time_F(START);
count = run_benchmark(async_jobs, SM2_verify_loop, loopargs);
d = Time_F(STOP);
BIO_printf(bio_err,
mr ? "+R9:%ld:%u:%s:%.2f\n"
: "%ld %u bits %s verify in %.2fs\n",
count, test_sm2_curves[testnum].bits,
test_sm2_curves[testnum].name, d);
sm2_results[testnum][1] = (double)count / d;
}
if (rsa_count <= 1) {
/* if longer than 10s, don't do any more */
for (testnum++; testnum < SM2_NUM; testnum++)
sm2_doit[testnum] = 0;
}
}
}
# endif /* OPENSSL_NO_SM2 */
#endif /* OPENSSL_NO_EC */ #endif /* OPENSSL_NO_EC */
#ifndef NO_FORK #ifndef NO_FORK
show_res: show_res:
@@ -3489,6 +3781,28 @@ int speed_main(int argc, char **argv)
1.0 / eddsa_results[k][0], 1.0 / eddsa_results[k][1], 1.0 / eddsa_results[k][0], 1.0 / eddsa_results[k][1],
eddsa_results[k][0], eddsa_results[k][1]); eddsa_results[k][0], eddsa_results[k][1]);
} }
# ifndef OPENSSL_NO_SM2
testnum = 1;
for (k = 0; k < OSSL_NELEM(sm2_doit); k++) {
if (!sm2_doit[k])
continue;
if (testnum && !mr) {
printf("%30ssign verify sign/s verify/s\n", " ");
testnum = 0;
}
if (mr)
printf("+F6:%u:%u:%s:%f:%f\n",
k, test_sm2_curves[k].bits, test_sm2_curves[k].name,
sm2_results[k][0], sm2_results[k][1]);
else
printf("%4u bits SM2 (%s) %8.4fs %8.4fs %8.1f %8.1f\n",
test_sm2_curves[k].bits, test_sm2_curves[k].name,
1.0 / sm2_results[k][0], 1.0 / sm2_results[k][1],
sm2_results[k][0], sm2_results[k][1]);
}
# endif
#endif #endif
ret = 0; ret = 0;
@@ -3514,6 +3828,24 @@ int speed_main(int argc, char **argv)
EVP_PKEY_CTX_free(loopargs[i].ecdh_ctx[k]); EVP_PKEY_CTX_free(loopargs[i].ecdh_ctx[k]);
for (k = 0; k < EdDSA_NUM; k++) for (k = 0; k < EdDSA_NUM; k++)
EVP_MD_CTX_free(loopargs[i].eddsa_ctx[k]); EVP_MD_CTX_free(loopargs[i].eddsa_ctx[k]);
# ifndef OPENSSL_NO_SM2
for (k = 0; k < SM2_NUM; k++) {
EVP_PKEY_CTX *pctx = NULL;
/* free signing ctx */
if (loopargs[i].sm2_ctx[k] != NULL
&& (pctx = EVP_MD_CTX_pkey_ctx(loopargs[i].sm2_ctx[k])) != NULL)
EVP_PKEY_CTX_free(pctx);
EVP_MD_CTX_free(loopargs[i].sm2_ctx[k]);
/* free verification ctx */
if (loopargs[i].sm2_vfy_ctx[k] != NULL
&& (pctx = EVP_MD_CTX_pkey_ctx(loopargs[i].sm2_vfy_ctx[k])) != NULL)
EVP_PKEY_CTX_free(pctx);
EVP_MD_CTX_free(loopargs[i].sm2_vfy_ctx[k]);
/* free pkey */
EVP_PKEY_free(loopargs[i].sm2_pkey[k]);
}
# endif
OPENSSL_free(loopargs[i].secret_a); OPENSSL_free(loopargs[i].secret_a);
OPENSSL_free(loopargs[i].secret_b); OPENSSL_free(loopargs[i].secret_b);
#endif #endif
@@ -3739,6 +4071,22 @@ static int do_multi(int multi, int size_num)
d = atof(sstrsep(&p, sep)); d = atof(sstrsep(&p, sep));
eddsa_results[k][1] += d; eddsa_results[k][1] += d;
} }
# ifndef OPENSSL_NO_SM2
else if (strncmp(buf, "+F7:", 4) == 0) {
int k;
double d;
p = buf + 4;
k = atoi(sstrsep(&p, sep));
sstrsep(&p, sep);
d = atof(sstrsep(&p, sep));
sm2_results[k][0] += d;
d = atof(sstrsep(&p, sep));
sm2_results[k][1] += d;
}
# endif /* OPENSSL_NO_SM2 */
# endif # endif
else if (strncmp(buf, "+H:", 3) == 0) { else if (strncmp(buf, "+H:", 3) == 0) {
+3 -3
View File
@@ -7,11 +7,11 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef INCLUDED_TIMEOUTS_H #ifndef OSSL_APPS_TIMEOUTS_H
# define INCLUDED_TIMEOUTS_H # define OSSL_APPS_TIMEOUTS_H
/* numbers in us */ /* numbers in us */
# define DGRAM_RCV_TIMEOUT 250000 # define DGRAM_RCV_TIMEOUT 250000
# define DGRAM_SND_TIMEOUT 250000 # define DGRAM_SND_TIMEOUT 250000
#endif /* ! INCLUDED_TIMEOUTS_H */ #endif /* ! OSSL_APPS_TIMEOUTS_H */
+3 -2
View File
@@ -507,8 +507,9 @@ static int create_digest(BIO *input, const char *digest, const EVP_MD *md,
md_value_len = EVP_MD_size(md); md_value_len = EVP_MD_size(md);
} else { } else {
long digest_len; long digest_len;
*md_value = OPENSSL_hexstr2buf(digest, &digest_len); *md_value = OPENSSL_hexstr2buf(digest, &digest_len);
if (!*md_value || md_value_len != digest_len) { if (*md_value == NULL || md_value_len != digest_len) {
OPENSSL_free(*md_value); OPENSSL_free(*md_value);
*md_value = NULL; *md_value = NULL;
BIO_printf(bio_err, "bad digest, %d bytes " BIO_printf(bio_err, "bad digest, %d bytes "
@@ -920,7 +921,7 @@ static TS_VERIFY_CTX *create_verify_ctx(const char *data, const char *digest,
/* Loading untrusted certificates. */ /* Loading untrusted certificates. */
if (untrusted if (untrusted
&& TS_VERIFY_CTS_set_certs(ctx, TS_CONF_load_certs(untrusted)) == NULL) && TS_VERIFY_CTX_set_certs(ctx, TS_CONF_load_certs(untrusted)) == NULL)
goto err; goto err;
ret = 1; ret = 1;
+5 -9
View File
@@ -3,21 +3,17 @@
SUBDIRS=crypto ssl apps test util tools fuzz engines providers SUBDIRS=crypto ssl apps test util tools fuzz engines providers
LIBS=libcrypto libssl LIBS=libcrypto libssl
INCLUDE[libcrypto]=. crypto/include include INCLUDE[libcrypto]=. include
INCLUDE[libssl]=. include INCLUDE[libssl]=. include
DEPEND[libssl]=libcrypto DEPEND[libssl]=libcrypto
# Empty DEPEND "indices" means the dependencies are expected to be built # Empty DEPEND "indices" means the dependencies are expected to be built
# unconditionally before anything else. # unconditionally before anything else.
DEPEND[]=include/openssl/opensslconf.h crypto/include/internal/bn_conf.h \ DEPEND[]=include/openssl/opensslconf.h include/crypto/bn_conf.h \
crypto/include/internal/dso_conf.h doc/man7/openssl_user_macros.pod include/crypto/dso_conf.h doc/man7/openssl_user_macros.pod
DEPEND[include/openssl/opensslconf.h]=configdata.pm
GENERATE[include/openssl/opensslconf.h]=include/openssl/opensslconf.h.in GENERATE[include/openssl/opensslconf.h]=include/openssl/opensslconf.h.in
DEPEND[crypto/include/internal/bn_conf.h]=configdata.pm GENERATE[include/crypto/bn_conf.h]=include/crypto/bn_conf.h.in
GENERATE[crypto/include/internal/bn_conf.h]=crypto/include/internal/bn_conf.h.in GENERATE[include/crypto/dso_conf.h]=include/crypto/dso_conf.h.in
DEPEND[crypto/include/internal/dso_conf.h]=configdata.pm
GENERATE[crypto/include/internal/dso_conf.h]=crypto/include/internal/dso_conf.h.in
DEPEND[doc/man7/openssl_user_macros.pod]=configdata.pm
GENERATE[doc/man7/openssl_user_macros.pod]=doc/man7/openssl_user_macros.pod.in GENERATE[doc/man7/openssl_user_macros.pod]=doc/man7/openssl_user_macros.pod.in
IF[{- defined $target{shared_defflag} -}] IF[{- defined $target{shared_defflag} -}]
+1 -1
View File
@@ -41,7 +41,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/aes.h> #include <openssl/aes.h>
#include "aes_locl.h" #include "aes_local.h"
#ifndef AES_ASM #ifndef AES_ASM
/*- /*-
+1 -1
View File
@@ -10,7 +10,7 @@
#include <assert.h> #include <assert.h>
#include <openssl/aes.h> #include <openssl/aes.h>
#include "aes_locl.h" #include "aes_local.h"
void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
const AES_KEY *key, const int enc) const AES_KEY *key, const int enc)
+1 -1
View File
@@ -14,7 +14,7 @@ NON_EMPTY_TRANSLATION_UNIT
#else #else
#include <openssl/aes.h> #include <openssl/aes.h>
#include "aes_locl.h" #include "aes_local.h"
#define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long)) #define N_WORDS (AES_BLOCK_SIZE / sizeof(unsigned long))
typedef struct { typedef struct {
@@ -7,8 +7,8 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef HEADER_AES_LOCL_H #ifndef OSSL_CRYPTO_AES_LOCAL_H
# define HEADER_AES_LOCL_H # define OSSL_CRYPTO_AES_LOCAL_H
# include <openssl/e_os2.h> # include <openssl/e_os2.h>
# include <stdio.h> # include <stdio.h>
@@ -39,4 +39,4 @@ typedef unsigned char u8;
/* This controls loop-unrolling in aes_core.c */ /* This controls loop-unrolling in aes_core.c */
# undef FULL_UNROLL # undef FULL_UNROLL
#endif /* !HEADER_AES_LOCL_H */ #endif /* !OSSL_CRYPTO_AES_LOCAL_H */
+1 -1
View File
@@ -9,7 +9,7 @@
#include <openssl/opensslv.h> #include <openssl/opensslv.h>
#include <openssl/aes.h> #include <openssl/aes.h>
#include "aes_locl.h" #include "aes_local.h"
const char *AES_options(void) const char *AES_options(void)
{ {
+1 -1
View File
@@ -46,7 +46,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <openssl/aes.h> #include <openssl/aes.h>
#include "aes_locl.h" #include "aes_local.h"
/* /*
* These two parameters control which table, 256-byte or 2KB, is * These two parameters control which table, 256-byte or 2KB, is
+7 -1
View File
@@ -61,8 +61,14 @@ ENDIF
$COMMON=aes_misc.c aes_ecb.c $AESASM $COMMON=aes_misc.c aes_ecb.c $AESASM
SOURCE[../../libcrypto]=$COMMON aes_cfb.c aes_ofb.c aes_ige.c aes_wrap.c SOURCE[../../libcrypto]=$COMMON aes_cfb.c aes_ofb.c aes_ige.c aes_wrap.c
SOURCE[../../providers/libfips.a]=$COMMON
# Implementations are now spread across several libraries, so the defines
# need to be applied to all affected libraries and modules.
DEFINE[../../libcrypto]=$AESDEF DEFINE[../../libcrypto]=$AESDEF
SOURCE[../../providers/fips]=$COMMON DEFINE[../../providers/libfips.a]=$AESDEF
DEFINE[../../providers/libimplementations.a]=$AESDEF
# fipsprov.c needs access to AESNI.
DEFINE[../../providers/fips]=$AESDEF DEFINE[../../providers/fips]=$AESDEF
GENERATE[aes-ia64.s]=asm/aes-ia64.S GENERATE[aes-ia64.s]=asm/aes-ia64.S
+1 -1
View File
@@ -19,7 +19,7 @@
*/ */
#include <openssl/e_os2.h> #include <openssl/e_os2.h>
#include "internal/aria.h" #include "crypto/aria.h"
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
+2 -2
View File
@@ -7,8 +7,8 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef __ARM_ARCH_H__ #ifndef OSSL_CRYPTO_ARM_ARCH_H
# define __ARM_ARCH_H__ # define OSSL_CRYPTO_ARM_ARCH_H
# if !defined(__ARM_ARCH__) # if !defined(__ARM_ARCH__)
# if defined(__CC_ARM) # if defined(__CC_ARM)
+1 -1
View File
@@ -11,7 +11,7 @@
#include <stdio.h> #include <stdio.h>
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include "asn1_locl.h" #include "asn1_local.h"
int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len) int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
{ {
+1 -1
View File
@@ -13,7 +13,7 @@
#include "internal/numbers.h" #include "internal/numbers.h"
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#ifndef NO_OLD_ASN1 #ifndef NO_OLD_ASN1
# ifndef OPENSSL_NO_STDIO # ifndef OPENSSL_NO_STDIO
+1 -1
View File
@@ -15,7 +15,7 @@
#include <time.h> #include <time.h>
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include "asn1_locl.h" #include "asn1_local.h"
/* This is the primary function used to parse ASN1_GENERALIZEDTIME */ /* This is the primary function used to parse ASN1_GENERALIZEDTIME */
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d) int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
+1 -1
View File
@@ -13,7 +13,7 @@
#include <limits.h> #include <limits.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include <openssl/bn.h> #include <openssl/bn.h>
#include "asn1_locl.h" #include "asn1_local.h"
ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x) ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x)
{ {
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include "internal/ctype.h" #include "crypto/ctype.h"
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1.h> #include <openssl/asn1.h>
+3 -3
View File
@@ -9,14 +9,14 @@
#include <stdio.h> #include <stdio.h>
#include <limits.h> #include <limits.h>
#include "internal/ctype.h" #include "crypto/ctype.h"
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/bn.h> #include <openssl/bn.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include "asn1_locl.h" #include "asn1_local.h"
int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp) int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp)
{ {
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include "internal/ctype.h" #include "crypto/ctype.h"
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1.h> #include <openssl/asn1.h>
+2 -2
View File
@@ -18,8 +18,8 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include "internal/evp_int.h" #include "crypto/evp.h"
#ifndef NO_ASN1_OLD #ifndef NO_ASN1_OLD
+1 -1
View File
@@ -10,7 +10,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
+1 -1
View File
@@ -51,7 +51,7 @@ int ASN1_STRING_set_default_mask_asc(const char *p)
char *end; char *end;
if (strncmp(p, "MASK:", 5) == 0) { if (strncmp(p, "MASK:", 5) == 0) {
if (!p[5]) if (p[5] == '\0')
return 0; return 0;
mask = strtoul(p + 5, &end, 0); mask = strtoul(p + 5, &end, 0);
if (*end) if (*end)
+2 -2
View File
@@ -16,10 +16,10 @@
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
#include "internal/ctype.h" #include "crypto/ctype.h"
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include "asn1_locl.h" #include "asn1_local.h"
IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME) IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
+1 -1
View File
@@ -11,7 +11,7 @@
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include "asn1_locl.h" #include "asn1_local.h"
int ASN1_TYPE_get(const ASN1_TYPE *a) int ASN1_TYPE_get(const ASN1_TYPE *a)
{ {
+1 -1
View File
@@ -11,7 +11,7 @@
#include <time.h> #include <time.h>
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include "asn1_locl.h" #include "asn1_local.h"
/* This is the primary function used to parse ASN1_UTCTIME */ /* This is the primary function used to parse ASN1_UTCTIME */
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d) int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)
+3 -3
View File
@@ -18,8 +18,8 @@
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include "internal/evp_int.h" #include "crypto/evp.h"
#ifndef NO_ASN1_OLD #ifndef NO_ASN1_OLD
@@ -116,7 +116,7 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a,
goto err; goto err;
} }
if (mdnid == NID_undef) { if (mdnid == NID_undef) {
if (!pkey->ameth || !pkey->ameth->item_verify) { if (pkey->ameth == NULL || pkey->ameth->item_verify == NULL) {
ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ASN1err(ASN1_F_ASN1_ITEM_VERIFY,
ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM); ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM);
goto err; goto err;
+4 -3
View File
@@ -13,8 +13,8 @@
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/engine.h> #include <openssl/engine.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include "internal/evp_int.h" #include "crypto/evp.h"
#include "standard_methods.h" #include "standard_methods.h"
@@ -56,6 +56,7 @@ static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)
{ {
EVP_PKEY_ASN1_METHOD tmp; EVP_PKEY_ASN1_METHOD tmp;
const EVP_PKEY_ASN1_METHOD *t = &tmp, **ret; const EVP_PKEY_ASN1_METHOD *t = &tmp, **ret;
tmp.pkey_id = type; tmp.pkey_id = type;
if (app_methods) { if (app_methods) {
int idx; int idx;
@@ -64,7 +65,7 @@ static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)
return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx); return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
} }
ret = OBJ_bsearch_ameth(&t, standard_methods, OSSL_NELEM(standard_methods)); ret = OBJ_bsearch_ameth(&t, standard_methods, OSSL_NELEM(standard_methods));
if (!ret || !*ret) if (ret == NULL || *ret == NULL)
return NULL; return NULL;
return *ret; return *ret;
} }
+1 -1
View File
@@ -11,7 +11,7 @@
#include <limits.h> #include <limits.h>
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include "asn1_locl.h" #include "asn1_local.h"
static int asn1_get_length(const unsigned char **pp, int *inf, long *rl, static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
long max); long max);
+4 -4
View File
@@ -8,15 +8,15 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include "internal/ctype.h" #include "crypto/ctype.h"
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include "internal/evp_int.h" #include "crypto/evp.h"
#include "internal/bio.h" #include "internal/bio.h"
#include "asn1_locl.h" #include "asn1_local.h"
/* /*
* Generalised MIME like utilities for streaming ASN1. Although many have a * Generalised MIME like utilities for streaming ASN1. Although many have a
@@ -399,7 +399,7 @@ ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it)
if (strcmp(hdr->value, "multipart/signed") == 0) { if (strcmp(hdr->value, "multipart/signed") == 0) {
/* Split into two parts */ /* Split into two parts */
prm = mime_param_find(hdr, "boundary"); prm = mime_param_find(hdr, "boundary");
if (!prm || !prm->param_value) { if (prm == NULL || prm->param_value == NULL) {
sk_MIME_HEADER_pop_free(headers, mime_hdr_free); sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_MULTIPART_BOUNDARY); ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_MULTIPART_BOUNDARY);
return NULL; return NULL;
+3 -3
View File
@@ -8,13 +8,13 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include "internal/ctype.h" #include "crypto/ctype.h"
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/conf.h> #include <openssl/conf.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include "internal/objects.h" #include "crypto/objects.h"
/* Simple ASN1 OID module: add all objects in a given section */ /* Simple ASN1 OID module: add all objects in a given section */
+5 -5
View File
@@ -108,7 +108,7 @@ static int ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg)
unsigned char *p; unsigned char *p;
int derlen; int derlen;
if (!parg) if (parg == NULL)
return 0; return 0;
ndef_aux = *(NDEF_SUPPORT **)parg; ndef_aux = *(NDEF_SUPPORT **)parg;
@@ -123,7 +123,7 @@ static int ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg)
*pbuf = p; *pbuf = p;
derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it); derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it);
if (!*ndef_aux->boundary) if (*ndef_aux->boundary == NULL)
return 0; return 0;
*plen = *ndef_aux->boundary - *pbuf; *plen = *ndef_aux->boundary - *pbuf;
@@ -136,7 +136,7 @@ static int ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen,
{ {
NDEF_SUPPORT *ndef_aux; NDEF_SUPPORT *ndef_aux;
if (!parg) if (parg == NULL)
return 0; return 0;
ndef_aux = *(NDEF_SUPPORT **)parg; ndef_aux = *(NDEF_SUPPORT **)parg;
@@ -168,7 +168,7 @@ static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg)
const ASN1_AUX *aux; const ASN1_AUX *aux;
ASN1_STREAM_ARG sarg; ASN1_STREAM_ARG sarg;
if (!parg) if (parg == NULL)
return 0; return 0;
ndef_aux = *(NDEF_SUPPORT **)parg; ndef_aux = *(NDEF_SUPPORT **)parg;
@@ -195,7 +195,7 @@ static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg)
*pbuf = p; *pbuf = p;
derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it); derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it);
if (!*ndef_aux->boundary) if (*ndef_aux->boundary == NULL)
return 0; return 0;
*pbuf = *ndef_aux->boundary; *pbuf = *ndef_aux->boundary;
*plen = derlen - (*ndef_aux->boundary - ndef_aux->derbuf); *plen = derlen - (*ndef_aux->boundary - ndef_aux->derbuf);
+2 -2
View File
@@ -11,8 +11,8 @@
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include "internal/evp_int.h" #include "crypto/evp.h"
#include "internal/asn1_int.h" #include "crypto/asn1.h"
EVP_PKEY *d2i_KeyParams(int type, EVP_PKEY **a, const unsigned char **pp, EVP_PKEY *d2i_KeyParams(int type, EVP_PKEY **a, const unsigned char **pp,
long length) long length)
+4 -4
View File
@@ -15,8 +15,8 @@
#include <openssl/engine.h> #include <openssl/engine.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include "internal/evp_int.h" #include "crypto/evp.h"
EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
long length) long length)
@@ -48,7 +48,7 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
EVP_PKEY *tmp; EVP_PKEY *tmp;
PKCS8_PRIV_KEY_INFO *p8 = NULL; PKCS8_PRIV_KEY_INFO *p8 = NULL;
p8 = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, length); p8 = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, length);
if (!p8) if (p8 == NULL)
goto err; goto err;
tmp = EVP_PKCS82PKEY(p8); tmp = EVP_PKCS82PKEY(p8);
PKCS8_PRIV_KEY_INFO_free(p8); PKCS8_PRIV_KEY_INFO_free(p8);
@@ -104,7 +104,7 @@ EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
EVP_PKEY *ret; EVP_PKEY *ret;
sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free); sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free);
if (!p8) { if (p8 == NULL) {
ASN1err(ASN1_F_D2I_AUTOPRIVATEKEY, ASN1err(ASN1_F_D2I_AUTOPRIVATEKEY,
ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE); ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
return NULL; return NULL;
+1 -1
View File
@@ -17,7 +17,7 @@
#include <openssl/dsa.h> #include <openssl/dsa.h>
#include <openssl/ec.h> #include <openssl/ec.h>
#include "internal/evp_int.h" #include "crypto/evp.h"
EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
long length) long length)
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include "internal/ctype.h" #include "crypto/ctype.h"
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include "internal/ctype.h" #include "crypto/ctype.h"
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
+2 -2
View File
@@ -12,8 +12,8 @@
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include "internal/evp_int.h" #include "crypto/evp.h"
int i2d_KeyParams(const EVP_PKEY *a, unsigned char **pp) int i2d_KeyParams(const EVP_PKEY *a, unsigned char **pp)
{ {
+2 -2
View File
@@ -11,8 +11,8 @@
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include "internal/evp_int.h" #include "crypto/evp.h"
int i2d_PrivateKey(const EVP_PKEY *a, unsigned char **pp) int i2d_PrivateKey(const EVP_PKEY *a, unsigned char **pp)
{ {
+1 -1
View File
@@ -107,7 +107,7 @@ X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
pbe2->keyfunc = PKCS5_pbkdf2_set(iter, salt, saltlen, prf_nid, keylen); pbe2->keyfunc = PKCS5_pbkdf2_set(iter, salt, saltlen, prf_nid, keylen);
if (!pbe2->keyfunc) if (pbe2->keyfunc == NULL)
goto merr; goto merr;
/* Now set up top level AlgorithmIdentifier */ /* Now set up top level AlgorithmIdentifier */
+1 -1
View File
@@ -11,7 +11,7 @@
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include "internal/x509_int.h" #include "crypto/x509.h"
/* Minor tweak to operation: zero private key data */ /* Minor tweak to operation: zero private key data */
static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
+1 -1
View File
@@ -11,7 +11,7 @@
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include "internal/bn_int.h" #include "crypto/bn.h"
/* Number of octets per line */ /* Number of octets per line */
#define ASN1_BUF_PRINT_WIDTH 15 #define ASN1_BUF_PRINT_WIDTH 15
+1 -1
View File
@@ -30,7 +30,7 @@ int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki)
BIO_printf(out, " Public Key Algorithm: %s\n", BIO_printf(out, " Public Key Algorithm: %s\n",
(i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i));
pkey = X509_PUBKEY_get(spki->spkac->pubkey); pkey = X509_PUBKEY_get(spki->spkac->pubkey);
if (!pkey) if (pkey == NULL)
BIO_printf(out, " Unable to load public key\n"); BIO_printf(out, " Unable to load public key\n");
else { else {
EVP_PKEY_print_public(out, pkey, 4, NULL); EVP_PKEY_print_public(out, pkey, 4, NULL);
+14 -10
View File
@@ -15,7 +15,7 @@
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/err.h> #include <openssl/err.h>
#include "internal/numbers.h" #include "internal/numbers.h"
#include "asn1_locl.h" #include "asn1_local.h"
/* /*
@@ -108,7 +108,8 @@ ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval,
{ {
ASN1_TLC c; ASN1_TLC c;
ASN1_VALUE *ptmpval = NULL; ASN1_VALUE *ptmpval = NULL;
if (!pval)
if (pval == NULL)
pval = &ptmpval; pval = &ptmpval;
asn1_tlc_clear_nc(&c); asn1_tlc_clear_nc(&c);
if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0) if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0)
@@ -149,7 +150,8 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
int otag; int otag;
int ret = 0; int ret = 0;
ASN1_VALUE **pchptr; ASN1_VALUE **pchptr;
if (!pval)
if (pval == NULL)
return 0; return 0;
if (aux && aux->asn1_cb) if (aux && aux->asn1_cb)
asn1_cb = aux->asn1_cb; asn1_cb = aux->asn1_cb;
@@ -303,7 +305,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
goto err; goto err;
} }
if (!*pval && !ASN1_item_ex_new(pval, it)) { if (*pval == NULL && !ASN1_item_ex_new(pval, it)) {
ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR); ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);
goto err; goto err;
} }
@@ -554,7 +556,7 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
return 0; return 0;
} else if (ret == -1) } else if (ret == -1)
return -1; return -1;
if (!*val) if (*val == NULL)
*val = (ASN1_VALUE *)sk_ASN1_VALUE_new_null(); *val = (ASN1_VALUE *)sk_ASN1_VALUE_new_null();
else { else {
/* /*
@@ -568,7 +570,7 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
} }
} }
if (!*val) { if (*val == NULL) {
ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_MALLOC_FAILURE); ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_MALLOC_FAILURE);
goto err; goto err;
} }
@@ -649,7 +651,8 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
BUF_MEM buf = { 0, NULL, 0, 0 }; BUF_MEM buf = { 0, NULL, 0, 0 };
const unsigned char *cont = NULL; const unsigned char *cont = NULL;
long len; long len;
if (!pval) {
if (pval == NULL) {
ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_NULL); ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_NULL);
return 0; /* Should never happen */ return 0; /* Should never happen */
} }
@@ -786,7 +789,7 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
return pf->prim_c2i(pval, cont, len, utype, free_cont, it); return pf->prim_c2i(pval, cont, len, utype, free_cont, it);
/* If ANY type clear type and set pointer to internal value */ /* If ANY type clear type and set pointer to internal value */
if (it->utype == V_ASN1_ANY) { if (it->utype == V_ASN1_ANY) {
if (!*pval) { if (*pval == NULL) {
typ = ASN1_TYPE_new(); typ = ASN1_TYPE_new();
if (typ == NULL) if (typ == NULL)
goto err; goto err;
@@ -866,7 +869,7 @@ static int asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
goto err; goto err;
} }
/* All based on ASN1_STRING and handled the same */ /* All based on ASN1_STRING and handled the same */
if (!*pval) { if (*pval == NULL) {
stmp = ASN1_STRING_type_new(utype); stmp = ASN1_STRING_type_new(utype);
if (stmp == NULL) { if (stmp == NULL) {
ASN1err(ASN1_F_ASN1_EX_C2I, ERR_R_MALLOC_FAILURE); ASN1err(ASN1_F_ASN1_EX_C2I, ERR_R_MALLOC_FAILURE);
@@ -1058,10 +1061,11 @@ static int collect_data(BUF_MEM *buf, const unsigned char **p, long plen)
static int asn1_check_eoc(const unsigned char **in, long len) static int asn1_check_eoc(const unsigned char **in, long len)
{ {
const unsigned char *p; const unsigned char *p;
if (len < 2) if (len < 2)
return 0; return 0;
p = *in; p = *in;
if (!p[0] && !p[1]) { if (p[0] == '\0' && p[1] == '\0') {
*in += 2; *in += 2;
return 1; return 1;
} }
+6 -6
View File
@@ -13,8 +13,8 @@
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include "asn1_locl.h" #include "asn1_local.h"
static int asn1_i2d_ex_primitive(const ASN1_VALUE **pval, unsigned char **out, static int asn1_i2d_ex_primitive(const ASN1_VALUE **pval, unsigned char **out,
const ASN1_ITEM *it, int tag, int aclass); const ASN1_ITEM *it, int tag, int aclass);
@@ -55,7 +55,7 @@ int ASN1_item_i2d(const ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *i
static int asn1_item_flags_i2d(const ASN1_VALUE *val, unsigned char **out, static int asn1_item_flags_i2d(const ASN1_VALUE *val, unsigned char **out,
const ASN1_ITEM *it, int flags) const ASN1_ITEM *it, int flags)
{ {
if (out && !*out) { if (out != NULL && *out == NULL) {
unsigned char *p, *buf; unsigned char *p, *buf;
int len; int len;
@@ -89,7 +89,7 @@ int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
const ASN1_AUX *aux = it->funcs; const ASN1_AUX *aux = it->funcs;
ASN1_aux_const_cb *asn1_cb = NULL; ASN1_aux_const_cb *asn1_cb = NULL;
if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) if ((it->itype != ASN1_ITYPE_PRIMITIVE) && *pval == NULL)
return 0; return 0;
if (aux != NULL) { if (aux != NULL) {
@@ -258,7 +258,7 @@ static int asn1_template_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
int skcontlen, sklen; int skcontlen, sklen;
const ASN1_VALUE *skitem; const ASN1_VALUE *skitem;
if (!*pval) if (*pval == NULL)
return 0; return 0;
if (flags & ASN1_TFLG_SET_OF) { if (flags & ASN1_TFLG_SET_OF) {
@@ -510,7 +510,7 @@ static int asn1_ex_i2c(const ASN1_VALUE **pval, unsigned char *cout, int *putype
/* Should type be omitted? */ /* Should type be omitted? */
if ((it->itype != ASN1_ITYPE_PRIMITIVE) if ((it->itype != ASN1_ITYPE_PRIMITIVE)
|| (it->utype != V_ASN1_BOOLEAN)) { || (it->utype != V_ASN1_BOOLEAN)) {
if (!*pval) if (*pval == NULL)
return -1; return -1;
} }
+6 -6
View File
@@ -11,7 +11,7 @@
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include "asn1_locl.h" #include "asn1_local.h"
/* Free up an ASN1 structure */ /* Free up an ASN1 structure */
@@ -33,9 +33,9 @@ void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
ASN1_aux_cb *asn1_cb; ASN1_aux_cb *asn1_cb;
int i; int i;
if (!pval) if (pval == NULL)
return; return;
if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval) if ((it->itype != ASN1_ITYPE_PRIMITIVE) && *pval == NULL)
return; return;
if (aux && aux->asn1_cb) if (aux && aux->asn1_cb)
asn1_cb = aux->asn1_cb; asn1_cb = aux->asn1_cb;
@@ -168,15 +168,15 @@ void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
utype = typ->type; utype = typ->type;
pval = &typ->value.asn1_value; pval = &typ->value.asn1_value;
if (!*pval) if (*pval == NULL)
return; return;
} else if (it->itype == ASN1_ITYPE_MSTRING) { } else if (it->itype == ASN1_ITYPE_MSTRING) {
utype = -1; utype = -1;
if (!*pval) if (*pval == NULL)
return; return;
} else { } else {
utype = it->utype; utype = it->utype;
if ((utype != V_ASN1_BOOLEAN) && !*pval) if ((utype != V_ASN1_BOOLEAN) && *pval == NULL)
return; return;
} }
+1 -1
View File
@@ -13,7 +13,7 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <string.h> #include <string.h>
#include "asn1_locl.h" #include "asn1_local.h"
static int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, static int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
int embed); int embed);
+2 -2
View File
@@ -15,8 +15,8 @@
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include "internal/asn1_int.h" #include "crypto/asn1.h"
#include "asn1_locl.h" #include "asn1_local.h"
/* /*
* Print routines. * Print routines.
+1 -1
View File
@@ -15,7 +15,7 @@
#include <openssl/buffer.h> #include <openssl/buffer.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include "asn1_locl.h" #include "asn1_local.h"
/* /*
* General ASN1 structure recursive scanner: iterate through all fields * General ASN1 structure recursive scanner: iterate through all fields
+1 -1
View File
@@ -15,7 +15,7 @@
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/err.h> #include <openssl/err.h>
#include "asn1_locl.h" #include "asn1_local.h"
/* Utility functions for manipulating fields and offsets */ /* Utility functions for manipulating fields and offsets */
+1 -1
View File
@@ -11,7 +11,7 @@
#include <openssl/x509.h> #include <openssl/x509.h>
#include <openssl/asn1.h> #include <openssl/asn1.h>
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include "internal/evp_int.h" #include "crypto/evp.h"
ASN1_SEQUENCE(X509_ALGOR) = { ASN1_SEQUENCE(X509_ALGOR) = {
ASN1_SIMPLE(X509_ALGOR, algorithm, ASN1_OBJECT), ASN1_SIMPLE(X509_ALGOR, algorithm, ASN1_OBJECT),
+3 -3
View File
@@ -82,7 +82,7 @@ static int bn_secure_new(ASN1_VALUE **pval, const ASN1_ITEM *it)
static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it) static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
{ {
if (!*pval) if (*pval == NULL)
return; return;
if (it->size & BN_SENSITIVE) if (it->size & BN_SENSITIVE)
BN_clear_free((BIGNUM *)*pval); BN_clear_free((BIGNUM *)*pval);
@@ -96,7 +96,7 @@ static int bn_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
{ {
BIGNUM *bn; BIGNUM *bn;
int pad; int pad;
if (!*pval) if (*pval == NULL)
return -1; return -1;
bn = (BIGNUM *)*pval; bn = (BIGNUM *)*pval;
/* If MSB set in an octet we need a padding byte */ /* If MSB set in an octet we need a padding byte */
@@ -133,7 +133,7 @@ static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
int ret; int ret;
BIGNUM *bn; BIGNUM *bn;
if (!*pval && !bn_secure_new(pval, it)) if (*pval == NULL && !bn_secure_new(pval, it))
return 0; return 0;
ret = bn_c2i(pval, cont, len, utype, free_cont, it); ret = bn_c2i(pval, cont, len, utype, free_cont, it);
+1 -1
View File
@@ -12,7 +12,7 @@
#include "internal/numbers.h" #include "internal/numbers.h"
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <openssl/bn.h> #include <openssl/bn.h>
#include "asn1_locl.h" #include "asn1_local.h"
/* /*
* Custom primitive types for handling int32_t, int64_t, uint32_t, uint64_t. * Custom primitive types for handling int32_t, int64_t, uint32_t, uint64_t.
+1 -1
View File
@@ -11,7 +11,7 @@
#include "internal/cryptlib.h" #include "internal/cryptlib.h"
#include <openssl/asn1t.h> #include <openssl/asn1t.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include "internal/x509_int.h" #include "crypto/x509.h"
ASN1_SEQUENCE(X509_SIG) = { ASN1_SEQUENCE(X509_SIG) = {
ASN1_SIMPLE(X509_SIG, algor, X509_ALGOR), ASN1_SIMPLE(X509_SIG, algor, X509_ALGOR),
+1 -1
View File
@@ -23,7 +23,7 @@
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/bn.h> #include <openssl/bn.h>
#include "internal/asn1_dsa.h" #include "crypto/asn1_dsa.h"
#include "internal/packet.h" #include "internal/packet.h"
#define ID_SEQUENCE 0x30 #define ID_SEQUENCE 0x30
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
/* This must be the first #include file */ /* This must be the first #include file */
#include "../async_locl.h" #include "../async_local.h"
#ifdef ASYNC_NULL #ifdef ASYNC_NULL
int ASYNC_is_capable(void) int ASYNC_is_capable(void)
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
/* This must be the first #include file */ /* This must be the first #include file */
#include "../async_locl.h" #include "../async_local.h"
#ifdef ASYNC_POSIX #ifdef ASYNC_POSIX
+3 -3
View File
@@ -7,8 +7,8 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef OPENSSL_ASYNC_ARCH_ASYNC_POSIX_H #ifndef OSSL_CRYPTO_ASYNC_POSIX_H
#define OPENSSL_ASYNC_ARCH_ASYNC_POSIX_H #define OSSL_CRYPTO_ASYNC_POSIX_H
#include <openssl/e_os2.h> #include <openssl/e_os2.h>
#if defined(OPENSSL_SYS_UNIX) \ #if defined(OPENSSL_SYS_UNIX) \
@@ -55,4 +55,4 @@ void async_fibre_free(async_fibre *fibre);
# endif # endif
#endif #endif
#endif /* OPENSSL_ASYNC_ARCH_ASYNC_POSIX_H */ #endif /* OSSL_CRYPTO_ASYNC_POSIX_H */
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
/* This must be the first #include file */ /* This must be the first #include file */
#include "../async_locl.h" #include "../async_local.h"
#ifdef ASYNC_WIN #ifdef ASYNC_WIN
+3 -3
View File
@@ -16,10 +16,10 @@
#undef _FORTIFY_SOURCE #undef _FORTIFY_SOURCE
/* This must be the first #include file */ /* This must be the first #include file */
#include "async_locl.h" #include "async_local.h"
#include <openssl/err.h> #include <openssl/err.h>
#include "internal/cryptlib_int.h" #include "crypto/cryptlib.h"
#include <string.h> #include <string.h>
#define ASYNC_JOB_RUNNING 0 #define ASYNC_JOB_RUNNING 0
@@ -287,7 +287,7 @@ static void async_empty_pool(async_pool *pool)
{ {
ASYNC_JOB *job; ASYNC_JOB *job;
if (!pool || !pool->jobs) if (pool == NULL || pool->jobs == NULL)
return; return;
do { do {
@@ -20,7 +20,7 @@
# include <windows.h> # include <windows.h>
#endif #endif
#include "internal/async.h" #include "crypto/async.h"
#include <openssl/crypto.h> #include <openssl/crypto.h>
typedef struct async_ctx_st async_ctx; typedef struct async_ctx_st async_ctx;
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
/* This must be the first #include file */ /* This must be the first #include file */
#include "async_locl.h" #include "async_local.h"
#include <openssl/err.h> #include <openssl/err.h>
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
#include <openssl/blowfish.h> #include <openssl/blowfish.h>
#include "bf_locl.h" #include "bf_local.h"
/* /*
* The input and output encrypted as though 64bit cfb mode is being used. * The input and output encrypted as though 64bit cfb mode is being used.
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
#include <openssl/blowfish.h> #include <openssl/blowfish.h>
#include "bf_locl.h" #include "bf_local.h"
#include <openssl/opensslv.h> #include <openssl/opensslv.h>
/* /*
+1 -1
View File
@@ -8,7 +8,7 @@
*/ */
#include <openssl/blowfish.h> #include <openssl/blowfish.h>
#include "bf_locl.h" #include "bf_local.h"
/* /*
* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' (From * Blowfish as implemented from 'Blowfish: Springer-Verlag paper' (From
+2 -2
View File
@@ -7,8 +7,8 @@
* https://www.openssl.org/source/license.html * https://www.openssl.org/source/license.html
*/ */
#ifndef HEADER_BF_LOCL_H #ifndef OSSL_CRYPTO_BF_LOCAL_H
# define HEADER_BF_LOCL_H # define OSSL_CRYPTO_BF_LOCAL_H
# include <openssl/opensslconf.h> # include <openssl/opensslconf.h>
/* NOTE - c is not incremented as per n2l */ /* NOTE - c is not incremented as per n2l */

Some files were not shown because too many files have changed in this diff Show More