Latest update.
This commit is contained in:
@@ -9,6 +9,143 @@
|
||||
|
||||
Changes between 1.1.1 and 3.0.0 [xx XXX xxxx]
|
||||
|
||||
*) Print all values for a PKCS#12 attribute with 'openssl pkcs12', not just
|
||||
the first value.
|
||||
[Jon Spillett]
|
||||
|
||||
*) Deprecated the public definition of ERR_STATE as well as the function
|
||||
ERR_get_state(). This is done in preparation of making ERR_STATE an
|
||||
opaque type.
|
||||
[Richard Levitte]
|
||||
|
||||
*) Added ERR functionality to give callers access to the stored function
|
||||
names that have replaced the older function code based functions.
|
||||
|
||||
New functions are ERR_get_error_func(), ERR_peek_error_func(),
|
||||
ERR_peek_last_error_func(), ERR_get_error_data(), ERR_peek_error_data(),
|
||||
ERR_peek_last_error_data(), ERR_get_error_all(), ERR_peek_error_all()
|
||||
and ERR_peek_last_error_all().
|
||||
|
||||
These functions have become deprecated: ERR_get_error_line_data(),
|
||||
ERR_peek_error_line_data(), ERR_peek_last_error_line_data() and
|
||||
ERR_func_error_string().
|
||||
[Richard Levitte]
|
||||
|
||||
*) Extended testing to be verbose for failing tests only. The make variables
|
||||
VERBOSE_FAILURE or VF can be used to enable this:
|
||||
|
||||
$ make VF=1 test # Unix
|
||||
$ mms /macro=(VF=1) test ! OpenVMS
|
||||
$ nmake VF=1 test # Windows
|
||||
|
||||
[Richard Levitte]
|
||||
|
||||
*) For built-in EC curves, ensure an EC_GROUP built from the curve name is
|
||||
used even when parsing explicit parameters, when loading a serialized key
|
||||
or calling `EC_GROUP_new_from_ecpkparameters()`/
|
||||
`EC_GROUP_new_from_ecparameters()`.
|
||||
This prevents bypass of security hardening and performance gains,
|
||||
especially for curves with specialized EC_METHODs.
|
||||
By default, if a key encoded with explicit parameters is loaded and later
|
||||
serialized, the output is still encoded with explicit parameters, even if
|
||||
internally a "named" EC_GROUP is used for computation.
|
||||
[Nicola Tuveri]
|
||||
|
||||
*) Compute ECC cofactors if not provided during EC_GROUP construction. Before
|
||||
this change, EC_GROUP_set_generator would accept order and/or cofactor as
|
||||
NULL. After this change, only the cofactor parameter can be NULL. It also
|
||||
does some minimal sanity checks on the passed order.
|
||||
(CVE-2019-1547)
|
||||
[Billy Bob Brumley]
|
||||
|
||||
*) Fixed a padding oracle in PKCS7_dataDecode and CMS_decrypt_set1_pkey.
|
||||
An attack is simple, if the first CMS_recipientInfo is valid but the
|
||||
second CMS_recipientInfo is chosen ciphertext. If the second
|
||||
recipientInfo decodes to PKCS #1 v1.5 form plaintext, the correct
|
||||
encryption key will be replaced by garbage, and the message cannot be
|
||||
decoded, but if the RSA decryption fails, the correct encryption key is
|
||||
used and the recipient will not notice the attack.
|
||||
As a work around for this potential attack the length of the decrypted
|
||||
key must be equal to the cipher default key length, in case the
|
||||
certifiate is not given and all recipientInfo are tried out.
|
||||
The old behaviour can be re-enabled in the CMS code by setting the
|
||||
CMS_DEBUG_DECRYPT flag.
|
||||
[Bernd Edlinger]
|
||||
|
||||
*) Early start up entropy quality from the DEVRANDOM seed source has been
|
||||
improved for older Linux systems. The RAND subsystem will wait for
|
||||
/dev/random to be producing output before seeding from /dev/urandom.
|
||||
The seeded state is stored for future library initialisations using
|
||||
a system global shared memory segment. The shared memory identifier
|
||||
can be configured by defining OPENSSL_RAND_SEED_DEVRANDOM_SHM_ID to
|
||||
the desired value. The default identifier is 114.
|
||||
[Paul Dale]
|
||||
|
||||
*) Revised BN_generate_prime_ex to not avoid factors 2..17863 in p-1
|
||||
when primes for RSA keys are computed.
|
||||
Since we previously always generated primes == 2 (mod 3) for RSA keys,
|
||||
the 2-prime and 3-prime RSA modules were easy to distinguish, since
|
||||
N = p*q = 1 (mod 3), but N = p*q*r = 2 (mod 3). Therefore fingerprinting
|
||||
2-prime vs. 3-prime RSA keys was possible by computing N mod 3.
|
||||
This avoids possible fingerprinting of newly generated RSA modules.
|
||||
[Bernd Edlinger]
|
||||
|
||||
*) Correct the extended master secret constant on EBCDIC systems. Without this
|
||||
fix TLS connections between an EBCDIC system and a non-EBCDIC system that
|
||||
negotiate EMS will fail. Unfortunately this also means that TLS connections
|
||||
between EBCDIC systems with this fix, and EBCDIC systems without this
|
||||
fix will fail if they negotiate EMS.
|
||||
[Matt Caswell]
|
||||
|
||||
*) Changed the library initialisation so that the config file is now loaded
|
||||
by default. This was already the case for libssl. It now occurs for both
|
||||
libcrypto and libssl. Use the OPENSSL_INIT_NO_LOAD_CONFIG option to
|
||||
OPENSSL_init_crypto() to suppress automatic loading of a config file.
|
||||
[Matt Caswell]
|
||||
|
||||
*) Introduced new error raising macros, ERR_raise() and ERR_raise_data(),
|
||||
where the former acts as a replacement for ERR_put_error(), and the
|
||||
latter replaces the combination ERR_put_error()+ERR_add_error_data().
|
||||
ERR_raise_data() adds more flexibility by taking a format string and
|
||||
an arbitrary number of arguments following it, to be processed with
|
||||
BIO_snprintf().
|
||||
[Richard Levitte]
|
||||
|
||||
*) Introduced a new function, OSSL_PROVIDER_available(), which can be used
|
||||
to check if a named provider is loaded and available. When called, it
|
||||
will also activate all fallback providers if such are still present.
|
||||
[Richard Levitte]
|
||||
|
||||
*) Enforce a minimum DH modulus size of 512 bits.
|
||||
[Bernd Edlinger]
|
||||
|
||||
*) Changed DH parameters to generate the order q subgroup instead of 2q.
|
||||
Previously generated DH parameters are still accepted by DH_check
|
||||
but DH_generate_key works around that by clearing bit 0 of the
|
||||
private key for those. This avoids leaking bit 0 of the private key.
|
||||
[Bernd Edlinger]
|
||||
|
||||
*) Significantly reduce secure memory usage by the randomness pools.
|
||||
[Paul Dale]
|
||||
|
||||
*) {CRYPTO,OPENSSL}_mem_debug_{push,pop} are now no-ops and have been
|
||||
deprecated.
|
||||
[Rich Salz]
|
||||
|
||||
*) A new type, EVP_KEYEXCH, has been introduced to represent key exchange
|
||||
algorithms. An implementation of a key exchange algorithm can be obtained
|
||||
by using the function EVP_KEYEXCH_fetch(). An EVP_KEYEXCH algorithm can be
|
||||
used in a call to EVP_PKEY_derive_init_ex() which works in a similar way to
|
||||
the older EVP_PKEY_derive_init() function. See the man pages for the new
|
||||
functions for further details.
|
||||
[Matt Caswell]
|
||||
|
||||
*) The EVP_PKEY_CTX_set_dh_pad() macro has now been converted to a function.
|
||||
[Matt Caswell]
|
||||
|
||||
*) Removed the function names from error messages and deprecated the
|
||||
xxx_F_xxx define's.
|
||||
|
||||
*) Removed NextStep support and the macro OPENSSL_UNISTD
|
||||
[Rich Salz]
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
## -*- mode: perl; -*-
|
||||
# Windows OneCore targets.
|
||||
#
|
||||
# OneCore is new API stability "contract" that transcends Desktop, IoT and
|
||||
@@ -10,6 +11,25 @@
|
||||
# TODO: extend error handling to use ETW based eventing
|
||||
# (Or rework whole error messaging)
|
||||
|
||||
my $UWP_info = {};
|
||||
sub UWP_info {
|
||||
unless (%$UWP_info) {
|
||||
my $SDKver = `powershell -Command \"& {\$(Get-Item \\\"hklm:\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\\").GetValue(\\\"CurrentVersion\\\")}\"`;
|
||||
$SDKver =~ s|\R$||;
|
||||
my @SDKver_split = split(/\./, $SDKver);
|
||||
# SDK version older than 10.0.17763 don't support our ASM builds
|
||||
if ($SDKver_split[0] < 10
|
||||
|| ($SDKver_split[0] == 10
|
||||
&& $SDKver_split[1] == 0
|
||||
&& $SDKver_split[2] < 17763)) {
|
||||
$UWP_info->{disable} = [ 'asm' ];
|
||||
} else {
|
||||
$UWP_info->{disable} = [ ];
|
||||
}
|
||||
}
|
||||
return $UWP_info;
|
||||
}
|
||||
|
||||
my %targets = (
|
||||
"VC-WIN32-ONECORE" => {
|
||||
inherit_from => [ "VC-WIN32" ],
|
||||
@@ -80,7 +100,8 @@ my %targets = (
|
||||
defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP",
|
||||
"_WIN32_WINNT=0x0A00"),
|
||||
dso_scheme => "",
|
||||
disable => [ 'ui-console', 'stdio', 'async', 'uplink' ],
|
||||
disable => sub { [ 'ui-console', 'stdio', 'async', 'uplink',
|
||||
@{ UWP_info()->{disable} } ] },
|
||||
ex_libs => "WindowsApp.lib",
|
||||
},
|
||||
"VC-WIN64A-UWP" => {
|
||||
@@ -89,7 +110,8 @@ my %targets = (
|
||||
defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP",
|
||||
"_WIN32_WINNT=0x0A00"),
|
||||
dso_scheme => "",
|
||||
disable => [ 'ui-console', 'stdio', 'async', 'uplink' ],
|
||||
disable => sub { [ 'ui-console', 'stdio', 'async', 'uplink',
|
||||
@{ UWP_info()->{disable} } ] },
|
||||
ex_libs => "WindowsApp.lib",
|
||||
},
|
||||
"VC-WIN32-ARM-UWP" => {
|
||||
@@ -98,7 +120,8 @@ my %targets = (
|
||||
defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP",
|
||||
"_WIN32_WINNT=0x0A00"),
|
||||
dso_scheme => "",
|
||||
disable => [ 'ui-console', 'stdio', 'async', 'uplink' ],
|
||||
disable => sub { [ 'ui-console', 'stdio', 'async', 'uplink',
|
||||
@{ UWP_info()->{disable} } ] },
|
||||
ex_libs => "WindowsApp.lib",
|
||||
},
|
||||
"VC-WIN64-ARM-UWP" => {
|
||||
@@ -107,7 +130,8 @@ my %targets = (
|
||||
defines => add("WINAPI_FAMILY=WINAPI_FAMILY_APP",
|
||||
"_WIN32_WINNT=0x0A00"),
|
||||
dso_scheme => "",
|
||||
disable => [ 'ui-console', 'stdio', 'async', 'uplink' ],
|
||||
disable => sub { [ 'ui-console', 'stdio', 'async', 'uplink',
|
||||
@{ UWP_info()->{disable} } ] },
|
||||
ex_libs => "WindowsApp.lib",
|
||||
},
|
||||
);
|
||||
@@ -114,6 +114,7 @@ BLDDIR={- $config{builddir} -}
|
||||
# Allow both V and VERBOSE to indicate verbosity. This only applies
|
||||
# to testing.
|
||||
VERBOSE=$(V)
|
||||
VERBOSE_FAILURE=$(VF)
|
||||
|
||||
VERSION={- "$config{full_version}" -}
|
||||
MAJOR={- $config{major} -}
|
||||
@@ -435,10 +436,12 @@ test : tests
|
||||
DEFINE BLDTOP {- builddir() -}
|
||||
DEFINE RESULT_D {- builddir(qw(test test-runs)) -}
|
||||
DEFINE OPENSSL_ENGINES {- builddir("engines") -}
|
||||
DEFINE OPENSSL_MODULES {- builddir("providers") -}
|
||||
DEFINE OPENSSL_DEBUG_MEMORY "on"
|
||||
IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
|
||||
$(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
|
||||
DEASSIGN OPENSSL_DEBUG_MEMORY
|
||||
DEASSIGN OPENSSL_MODULES
|
||||
DEASSIGN OPENSSL_ENGINES
|
||||
DEASSIGN BLDTOP
|
||||
DEASSIGN SRCTOP
|
||||
@@ -784,15 +787,6 @@ $target : $args{generator}->[0] $deps
|
||||
EOF
|
||||
}
|
||||
} else {
|
||||
my $target = platform->asm($args{src});
|
||||
if ($args{generator}->[0] =~ /\.pl$/) {
|
||||
$generator = '$(PERL)'.$generator_incs.' '.$generator;
|
||||
} elsif ($args{generator}->[0] =~ /\.S$/) {
|
||||
$generator = undef;
|
||||
} else {
|
||||
die "Generator type for $src unknown: $generator\n";
|
||||
}
|
||||
|
||||
my $cppflags = {
|
||||
shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
|
||||
lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
|
||||
@@ -809,6 +803,17 @@ EOF
|
||||
my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
|
||||
my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
|
||||
my $defs = join("", map { ",".$_ } @{$args{defs}});
|
||||
my $target = platform->asm($args{src});
|
||||
|
||||
if ($args{generator}->[0] =~ /\.pl$/) {
|
||||
$generator = '$(PERL)'.$generator_incs.' '.$generator
|
||||
.' '.$cppflags;
|
||||
} elsif ($args{generator}->[0] =~ /\.S$/) {
|
||||
$generator = undef;
|
||||
} else {
|
||||
die "Generator type for $src unknown: $generator\n";
|
||||
}
|
||||
|
||||
if (defined($generator)) {
|
||||
# If the target is named foo.S in build.info, we want to
|
||||
# end up generating foo.s in two steps.
|
||||
@@ -829,7 +834,11 @@ EOF
|
||||
# Otherwise....
|
||||
return <<"EOF";
|
||||
$target : $args{generator}->[0] $deps
|
||||
\@ $incs_on
|
||||
\@ extradefines = "$defs"
|
||||
$generator \$\@
|
||||
\@ DELETE/SYMBOL/LOCAL extradefines
|
||||
\@ $incs_off
|
||||
EOF
|
||||
}
|
||||
return <<"EOF";
|
||||
|
||||
@@ -352,6 +352,7 @@ test: tests
|
||||
PERL="$(PERL)" \
|
||||
EXE_EXT={- platform->binext() -} \
|
||||
OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \
|
||||
OPENSSL_MODULES=`cd ../$(BLDDIR)/providers 2>/dev/null && pwd` \
|
||||
OPENSSL_DEBUG_MEMORY=on \
|
||||
$(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
|
||||
@ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
|
||||
@@ -391,13 +392,13 @@ libclean:
|
||||
clean: libclean
|
||||
$(RM) $(PROGRAMS) $(TESTPROGS) $(MODULES) $(SCRIPTS)
|
||||
$(RM) $(GENERATED_MANDATORY) $(GENERATED)
|
||||
-$(RM) `find . -name .git -prune -o -name '*{- platform->depext() -}' -print`
|
||||
-$(RM) `find . -name .git -prune -o -name '*{- platform->objext() -}' -print`
|
||||
-$(RM) `find . -name '*{- platform->depext() -}' \! -name '.*' -print`
|
||||
-$(RM) `find . -name '*{- platform->objext() -}' \! -name '.*' -print`
|
||||
$(RM) core
|
||||
$(RM) tags TAGS doc-nits
|
||||
$(RM) -r test/test-runs
|
||||
$(RM) openssl.pc libcrypto.pc libssl.pc
|
||||
-$(RM) `find . -name .git -prune -o -type l -print`
|
||||
-$(RM) `find . -type l \! -name '.*' -print`
|
||||
$(RM) $(TARFILE)
|
||||
|
||||
distclean: clean
|
||||
@@ -728,9 +729,7 @@ generate: generate_apps generate_crypto_bn generate_crypto_objects \
|
||||
|
||||
.PHONY: doc-nits
|
||||
doc-nits: build_generated
|
||||
(cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p -s ) >doc-nits
|
||||
@if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \
|
||||
else echo 'doc-nits: no errors.'; rm doc-nits ; fi
|
||||
(cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p -s )
|
||||
|
||||
# Test coverage is a good idea for the future
|
||||
#coverage: $(PROGRAMS) $(TESTPROGRAMS)
|
||||
@@ -742,6 +741,12 @@ lint:
|
||||
generate_apps:
|
||||
( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
|
||||
< apps/openssl.cnf > apps/openssl-vms.cnf )
|
||||
@ : {- output_off() if $disabled{apps}; "" -}
|
||||
( b=`pwd`; cd $(SRCDIR); \
|
||||
$(PERL) -I$$b apps/progs.pl -H $(APPS_OPENSSL) > apps/progs.h )
|
||||
( b=`pwd`; cd $(SRCDIR); \
|
||||
$(PERL) -I$$b apps/progs.pl -C $(APPS_OPENSSL) > apps/progs.c )
|
||||
@ : {- output_on() if $disabled{apps}; "" -}
|
||||
|
||||
generate_crypto_bn:
|
||||
( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
|
||||
@@ -973,8 +978,16 @@ $args{src}: $args{generator}->[0] $deps
|
||||
EOF
|
||||
}
|
||||
} else {
|
||||
my $cppflags = {
|
||||
shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
|
||||
lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
|
||||
dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
|
||||
bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
|
||||
} -> {$args{intent}};
|
||||
|
||||
if ($args{generator}->[0] =~ /\.pl$/) {
|
||||
$generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
|
||||
$generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator
|
||||
.' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSSOR)';
|
||||
} elsif ($args{generator}->[0] =~ /\.m4$/) {
|
||||
$generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
|
||||
} elsif ($args{generator}->[0] =~ /\.S$/) {
|
||||
@@ -983,12 +996,6 @@ EOF
|
||||
die "Generator type for $args{src} unknown: $generator\n";
|
||||
}
|
||||
|
||||
my $cppflags = {
|
||||
shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
|
||||
lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
|
||||
dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
|
||||
bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
|
||||
} -> {$args{intent}};
|
||||
if (defined($generator)) {
|
||||
return <<"EOF";
|
||||
$args{src}: $args{generator}->[0] $deps
|
||||
|
||||
@@ -369,6 +369,7 @@ test: tests
|
||||
set RESULT_D=$(BLDDIR)\test\test-runs
|
||||
set PERL=$(PERL)
|
||||
set OPENSSL_ENGINES=$(MAKEDIR)\engines
|
||||
set OPENSSL_MODULES=$(MAKEDIR)\providers
|
||||
set OPENSSL_DEBUG_MEMORY=on
|
||||
"$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
|
||||
@{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
|
||||
@@ -569,22 +570,23 @@ $target: "$args{generator}->[0]" $deps
|
||||
EOF
|
||||
}
|
||||
} else {
|
||||
my $cppflags = {
|
||||
shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
|
||||
lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
|
||||
dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
|
||||
bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
|
||||
} -> {$args{intent}};
|
||||
my $target = platform->asm($args{src});
|
||||
|
||||
if ($args{generator}->[0] =~ /\.pl$/) {
|
||||
$generator = '"$(PERL)"'.$generator_incs.' '.$generator;
|
||||
$generator = '"$(PERL)"'.$generator_incs.' '.$generator
|
||||
.' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSSOR)';
|
||||
} elsif ($args{generator}->[0] =~ /\.S$/) {
|
||||
$generator = undef;
|
||||
} else {
|
||||
die "Generator type for $src unknown: $generator\n";
|
||||
}
|
||||
|
||||
my $cppflags = $incs;
|
||||
$cppflags .= {
|
||||
shlib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
|
||||
lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
|
||||
dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
|
||||
bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
|
||||
} -> {$args{intent}};
|
||||
if (defined($generator)) {
|
||||
# If the target is named foo.S in build.info, we want to
|
||||
# end up generating foo.s in two steps.
|
||||
@@ -593,7 +595,7 @@ EOF
|
||||
$target: "$args{generator}->[0]" $deps
|
||||
set ASM=\$(AS)
|
||||
$generator \$@.S
|
||||
\$(CPP) $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
|
||||
\$(CPP) $incs $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
|
||||
del /Q \$@.S
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ use lib "$FindBin::Bin/util/perl";
|
||||
use File::Basename;
|
||||
use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs splitdir/;
|
||||
use File::Path qw/mkpath/;
|
||||
use OpenSSL::fallback "$FindBin::Bin/external/perl/MODULES.txt";
|
||||
use OpenSSL::Glob;
|
||||
use OpenSSL::Template;
|
||||
|
||||
# see INSTALL for instructions.
|
||||
|
||||
@@ -144,13 +146,13 @@ my @gcc_devteam_warn = qw(
|
||||
# -Wunused-macros -- no, too tricky for BN and _XOPEN_SOURCE etc
|
||||
# -Wextended-offsetof -- no, needed in CMS ASN1 code
|
||||
my @clang_devteam_warn = qw(
|
||||
-Wno-unknown-warning-option
|
||||
-Wswitch-default
|
||||
-Wno-parentheses-equality
|
||||
-Wno-language-extension-token
|
||||
-Wno-extended-offsetof
|
||||
-Wconditional-uninitialized
|
||||
-Wincompatible-pointer-types-discards-qualifiers
|
||||
-Wno-unknown-warning-option
|
||||
-Wmissing-variable-declarations
|
||||
);
|
||||
|
||||
@@ -348,6 +350,7 @@ my @disablables = (
|
||||
"dgram",
|
||||
"dh",
|
||||
"dsa",
|
||||
"dso",
|
||||
"dtls",
|
||||
"dynamic-engine",
|
||||
"ec",
|
||||
@@ -440,7 +443,6 @@ my %deprecated_disablables = (
|
||||
"hw-padlock" => "padlockeng",
|
||||
"ripemd" => "rmd160",
|
||||
"ui" => "ui-console",
|
||||
"dso" => undef,
|
||||
"heartbeats" => undef,
|
||||
);
|
||||
|
||||
@@ -508,6 +510,7 @@ my @disable_cascades = (
|
||||
# (note that even with shared libraries, both the app and dynamic engines
|
||||
# must be linked with the same library)
|
||||
"shared" => [ "dynamic-engine", "uplink" ],
|
||||
"dso" => [ "dynamic-engine", "module" ],
|
||||
# Other modules don't necessarily have to link with libcrypto, so shared
|
||||
# libraries do not have to be a condition to produce those.
|
||||
|
||||
@@ -1237,7 +1240,7 @@ foreach my $what (sort keys %disabled) {
|
||||
|
||||
$skipdir{engines} = $what if $what eq 'engine';
|
||||
$skipdir{"crypto/$skipdir"} = $what
|
||||
unless $what eq 'async' || $what eq 'err';
|
||||
unless $what eq 'async' || $what eq 'err' || $what eq 'dso';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1617,7 +1620,7 @@ my %unified_info = ();
|
||||
|
||||
my $buildinfo_debug = defined($ENV{CONFIGURE_DEBUG_BUILDINFO});
|
||||
if ($builder eq "unified") {
|
||||
use with_fallback qw(Text::Template);
|
||||
use Text::Template 1.46;
|
||||
|
||||
sub cleandir {
|
||||
my $base = shift;
|
||||
@@ -1908,7 +1911,7 @@ if ($builder eq "unified") {
|
||||
qr/^\s*INCLUDE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
|
||||
=> sub { push @{$includes{$1}}, tokenize($expand_variables->($2))
|
||||
if !@skip || $skip[$#skip] > 0 },
|
||||
qr/^\s*DEFINE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
|
||||
qr/^\s*DEFINE\[((?:\\.|[^\\\]])*)\]\s*=\s*(.*)\s*$/
|
||||
=> sub { push @{$defines{$1}}, tokenize($expand_variables->($2))
|
||||
if !@skip || $skip[$#skip] > 0 },
|
||||
qr/^\s*DEPEND\[((?:\\.|[^\\\]])*)\]\s*=\s*(.*)\s*$/
|
||||
@@ -2109,24 +2112,33 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
foreach (keys %defines) {
|
||||
my $dest = $_;
|
||||
my $ddest = cleanfile($sourced, $_, $blddir);
|
||||
foreach my $dest (keys %defines) {
|
||||
my $ddest;
|
||||
|
||||
# If the destination doesn't exist in source, it can only be
|
||||
# a generated file in the build tree.
|
||||
if (! -f $ddest) {
|
||||
$ddest = cleanfile($buildd, $_, $blddir);
|
||||
if ($unified_info{rename}->{$ddest}) {
|
||||
$ddest = $unified_info{rename}->{$ddest};
|
||||
if ($dest ne "") {
|
||||
$ddest = cleanfile($sourced, $dest, $blddir);
|
||||
|
||||
# If the destination doesn't exist in source, it can only
|
||||
# be a generated file in the build tree.
|
||||
if (! -f $ddest) {
|
||||
$ddest = cleanfile($buildd, $dest, $blddir);
|
||||
if ($unified_info{rename}->{$ddest}) {
|
||||
$ddest = $unified_info{rename}->{$ddest};
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (@{$defines{$dest}}) {
|
||||
m|^([^=]*)(=.*)?$|;
|
||||
foreach my $v (@{$defines{$dest}}) {
|
||||
$v =~ m|^([^=]*)(=.*)?$|;
|
||||
die "0 length macro name not permitted\n" if $1 eq "";
|
||||
die "$1 defined more than once\n"
|
||||
if defined $unified_info{defines}->{$ddest}->{$1};
|
||||
$unified_info{defines}->{$ddest}->{$1} = $2;
|
||||
if ($dest ne "") {
|
||||
die "$1 defined more than once\n"
|
||||
if defined $unified_info{defines}->{$ddest}->{$1};
|
||||
$unified_info{defines}->{$ddest}->{$1} = $2;
|
||||
} else {
|
||||
die "$1 defined more than once\n"
|
||||
if grep { $v eq $_ } @{$config{defines}};
|
||||
push @{$config{defines}}, $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2377,452 +2389,50 @@ foreach (grep /_(asm|aux)_src$/, keys %target) {
|
||||
|
||||
# Write down our configuration where it fits #########################
|
||||
|
||||
print "Creating configdata.pm\n";
|
||||
open(OUT,">configdata.pm") || die "unable to create configdata.pm: $!\n";
|
||||
print OUT <<"EOF";
|
||||
#! $config{HASHBANGPERL}
|
||||
|
||||
package configdata;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Exporter;
|
||||
#use vars qw(\@ISA \@EXPORT);
|
||||
our \@ISA = qw(Exporter);
|
||||
our \@EXPORT = qw(\%config \%target \%disabled \%withargs \%unified_info \@disablables \@disablables_int);
|
||||
|
||||
EOF
|
||||
print OUT "our %config = (\n";
|
||||
foreach (sort keys %config) {
|
||||
if (ref($config{$_}) eq "ARRAY") {
|
||||
print OUT " ", $_, " => [ ", join(", ",
|
||||
map { quotify("perl", $_) }
|
||||
@{$config{$_}}), " ],\n";
|
||||
} elsif (ref($config{$_}) eq "HASH") {
|
||||
print OUT " ", $_, " => {";
|
||||
if (scalar keys %{$config{$_}} > 0) {
|
||||
print OUT "\n";
|
||||
foreach my $key (sort keys %{$config{$_}}) {
|
||||
print OUT " ",
|
||||
join(" => ",
|
||||
quotify("perl", $key),
|
||||
defined $config{$_}->{$key}
|
||||
? quotify("perl", $config{$_}->{$key})
|
||||
: "undef");
|
||||
print OUT ",\n";
|
||||
}
|
||||
print OUT " ";
|
||||
}
|
||||
print OUT "},\n";
|
||||
} else {
|
||||
print OUT " ", $_, " => ", quotify("perl", $config{$_}), ",\n"
|
||||
}
|
||||
}
|
||||
print OUT <<"EOF";
|
||||
my %template_vars = (
|
||||
config => \%config,
|
||||
target => \%target,
|
||||
disablables => \@disablables,
|
||||
disablables_int => \@disablables_int,
|
||||
disabled => \%disabled,
|
||||
withargs => \%withargs,
|
||||
unified_info => \%unified_info,
|
||||
tls => \@tls,
|
||||
dtls => \@dtls,
|
||||
makevars => [ sort keys %user ],
|
||||
disabled_info => \%disabled_info,
|
||||
user_crossable => \@user_crossable,
|
||||
);
|
||||
|
||||
EOF
|
||||
print OUT "our %target = (\n";
|
||||
foreach (sort keys %target) {
|
||||
if (ref($target{$_}) eq "ARRAY") {
|
||||
print OUT " ", $_, " => [ ", join(", ",
|
||||
map { quotify("perl", $_) }
|
||||
@{$target{$_}}), " ],\n";
|
||||
} else {
|
||||
print OUT " ", $_, " => ", quotify("perl", $target{$_}), ",\n"
|
||||
}
|
||||
}
|
||||
print OUT <<"EOF";
|
||||
);
|
||||
|
||||
EOF
|
||||
print OUT "our \%available_protocols = (\n";
|
||||
print OUT " tls => [ ", join(", ", map { quotify("perl", $_) } @tls), " ],\n";
|
||||
print OUT " dtls => [ ", join(", ", map { quotify("perl", $_) } @dtls), " ],\n";
|
||||
print OUT <<"EOF";
|
||||
);
|
||||
|
||||
EOF
|
||||
print OUT "our \@disablables = (\n";
|
||||
foreach (@disablables) {
|
||||
print OUT " ", quotify("perl", $_), ",\n";
|
||||
}
|
||||
print OUT <<"EOF";
|
||||
);
|
||||
|
||||
EOF
|
||||
print OUT "# The following come from Configure's @disablables_int\n";
|
||||
print OUT "our \@disablables_int = (\n";
|
||||
foreach (@disablables_int) {
|
||||
print OUT " ", quotify("perl", $_), ",\n";
|
||||
}
|
||||
print OUT <<"EOF";
|
||||
);
|
||||
|
||||
EOF
|
||||
print OUT "our \%disabled = (\n";
|
||||
foreach (sort keys %disabled) {
|
||||
print OUT " ", quotify("perl", $_), " => ", quotify("perl", $disabled{$_}), ",\n";
|
||||
}
|
||||
print OUT <<"EOF";
|
||||
);
|
||||
|
||||
EOF
|
||||
print OUT "our %withargs = (\n";
|
||||
foreach (sort keys %withargs) {
|
||||
if (ref($withargs{$_}) eq "ARRAY") {
|
||||
print OUT " ", $_, " => [ ", join(", ",
|
||||
map { quotify("perl", $_) }
|
||||
@{$withargs{$_}}), " ],\n";
|
||||
} else {
|
||||
print OUT " ", $_, " => ", quotify("perl", $withargs{$_}), ",\n"
|
||||
}
|
||||
}
|
||||
print OUT <<"EOF";
|
||||
);
|
||||
|
||||
EOF
|
||||
if ($builder eq "unified") {
|
||||
my $recurse;
|
||||
$recurse = sub {
|
||||
my $indent = shift;
|
||||
foreach (@_) {
|
||||
if (ref $_ eq "ARRAY") {
|
||||
print OUT " "x$indent, "[\n";
|
||||
foreach (@$_) {
|
||||
$recurse->($indent + 4, $_);
|
||||
}
|
||||
print OUT " "x$indent, "],\n";
|
||||
} elsif (ref $_ eq "HASH") {
|
||||
my %h = %$_;
|
||||
print OUT " "x$indent, "{\n";
|
||||
foreach (sort keys %h) {
|
||||
if (ref $h{$_} eq "") {
|
||||
print OUT " "x($indent + 4), quotify("perl", $_), " => ", quotify("perl", $h{$_}), ",\n";
|
||||
} else {
|
||||
print OUT " "x($indent + 4), quotify("perl", $_), " =>\n";
|
||||
$recurse->($indent + 8, $h{$_});
|
||||
}
|
||||
}
|
||||
print OUT " "x$indent, "},\n";
|
||||
} else {
|
||||
print OUT " "x$indent, quotify("perl", $_), ",\n";
|
||||
}
|
||||
}
|
||||
};
|
||||
print OUT "our %unified_info = (\n";
|
||||
foreach (sort keys %unified_info) {
|
||||
if (ref $unified_info{$_} eq "") {
|
||||
print OUT " "x4, quotify("perl", $_), " => ", quotify("perl", $unified_info{$_}), ",\n";
|
||||
} else {
|
||||
print OUT " "x4, quotify("perl", $_), " =>\n";
|
||||
$recurse->(8, $unified_info{$_});
|
||||
}
|
||||
}
|
||||
print OUT <<"EOF";
|
||||
);
|
||||
|
||||
EOF
|
||||
}
|
||||
print OUT
|
||||
"# The following data is only used when this files is use as a script\n";
|
||||
print OUT "my \@makevars = (\n";
|
||||
foreach (sort keys %user) {
|
||||
print OUT " '",$_,"',\n";
|
||||
}
|
||||
print OUT ");\n";
|
||||
print OUT "my \%disabled_info = (\n";
|
||||
foreach my $what (sort keys %disabled_info) {
|
||||
print OUT " '$what' => {\n";
|
||||
foreach my $info (sort keys %{$disabled_info{$what}}) {
|
||||
if (ref $disabled_info{$what}->{$info} eq 'ARRAY') {
|
||||
print OUT " $info => [ ",
|
||||
join(', ', map { "'$_'" } @{$disabled_info{$what}->{$info}}),
|
||||
" ],\n";
|
||||
} else {
|
||||
print OUT " $info => '", $disabled_info{$what}->{$info},
|
||||
"',\n";
|
||||
}
|
||||
}
|
||||
print OUT " },\n";
|
||||
}
|
||||
print OUT ");\n";
|
||||
print OUT 'my @user_crossable = qw( ', join (' ', @user_crossable), " );\n";
|
||||
print OUT << 'EOF';
|
||||
# If run directly, we can give some answers, and even reconfigure
|
||||
unless (caller) {
|
||||
use Getopt::Long;
|
||||
use File::Spec::Functions;
|
||||
use File::Basename;
|
||||
use Pod::Usage;
|
||||
|
||||
my $here = dirname($0);
|
||||
|
||||
my $dump = undef;
|
||||
my $cmdline = undef;
|
||||
my $options = undef;
|
||||
my $target = undef;
|
||||
my $envvars = undef;
|
||||
my $makevars = undef;
|
||||
my $buildparams = undef;
|
||||
my $reconf = undef;
|
||||
my $verbose = undef;
|
||||
my $help = undef;
|
||||
my $man = undef;
|
||||
GetOptions('dump|d' => \$dump,
|
||||
'command-line|c' => \$cmdline,
|
||||
'options|o' => \$options,
|
||||
'target|t' => \$target,
|
||||
'environment|e' => \$envvars,
|
||||
'make-variables|m' => \$makevars,
|
||||
'build-parameters|b' => \$buildparams,
|
||||
'reconfigure|reconf|r' => \$reconf,
|
||||
'verbose|v' => \$verbose,
|
||||
'help' => \$help,
|
||||
'man' => \$man)
|
||||
or die "Errors in command line arguments\n";
|
||||
|
||||
unless ($dump || $cmdline || $options || $target || $envvars || $makevars
|
||||
|| $buildparams || $reconf || $verbose || $help || $man) {
|
||||
print STDERR <<"_____";
|
||||
You must give at least one option.
|
||||
For more information, do '$0 --help'
|
||||
_____
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if ($help) {
|
||||
pod2usage(-exitval => 0,
|
||||
-verbose => 1);
|
||||
}
|
||||
if ($man) {
|
||||
pod2usage(-exitval => 0,
|
||||
-verbose => 2);
|
||||
}
|
||||
if ($dump || $cmdline) {
|
||||
print "\nCommand line (with current working directory = $here):\n\n";
|
||||
print ' ',join(' ',
|
||||
$config{PERL},
|
||||
catfile($config{sourcedir}, 'Configure'),
|
||||
@{$config{perlargv}}), "\n";
|
||||
print "\nPerl information:\n\n";
|
||||
print ' ',$config{perl_cmd},"\n";
|
||||
print ' ',$config{perl_version},' for ',$config{perl_archname},"\n";
|
||||
}
|
||||
if ($dump || $options) {
|
||||
my $longest = 0;
|
||||
my $longest2 = 0;
|
||||
foreach my $what (@disablables) {
|
||||
$longest = length($what) if $longest < length($what);
|
||||
$longest2 = length($disabled{$what})
|
||||
if $disabled{$what} && $longest2 < length($disabled{$what});
|
||||
}
|
||||
print "\nEnabled features:\n\n";
|
||||
foreach my $what (@disablables) {
|
||||
print " $what\n" unless $disabled{$what};
|
||||
}
|
||||
print "\nDisabled features:\n\n";
|
||||
foreach my $what (@disablables) {
|
||||
if ($disabled{$what}) {
|
||||
print " $what", ' ' x ($longest - length($what) + 1),
|
||||
"[$disabled{$what}]", ' ' x ($longest2 - length($disabled{$what}) + 1);
|
||||
print $disabled_info{$what}->{macro}
|
||||
if $disabled_info{$what}->{macro};
|
||||
print ' (skip ',
|
||||
join(', ', @{$disabled_info{$what}->{skipped}}),
|
||||
')'
|
||||
if $disabled_info{$what}->{skipped};
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($dump || $target) {
|
||||
print "\nConfig target attributes:\n\n";
|
||||
foreach (sort keys %target) {
|
||||
next if $_ =~ m|^_| || $_ eq 'template';
|
||||
my $quotify = sub {
|
||||
map { (my $x = $_) =~ s|([\\\$\@"])|\\$1|g; "\"$x\""} @_;
|
||||
};
|
||||
print ' ', $_, ' => ';
|
||||
if (ref($target{$_}) eq "ARRAY") {
|
||||
print '[ ', join(', ', $quotify->(@{$target{$_}})), " ],\n";
|
||||
} else {
|
||||
print $quotify->($target{$_}), ",\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($dump || $envvars) {
|
||||
print "\nRecorded environment:\n\n";
|
||||
foreach (sort keys %{$config{perlenv}}) {
|
||||
print ' ',$_,' = ',($config{perlenv}->{$_} || ''),"\n";
|
||||
}
|
||||
}
|
||||
if ($dump || $makevars) {
|
||||
print "\nMakevars:\n\n";
|
||||
foreach my $var (@makevars) {
|
||||
my $prefix = '';
|
||||
$prefix = $config{CROSS_COMPILE}
|
||||
if grep { $var eq $_ } @user_crossable;
|
||||
$prefix //= '';
|
||||
print ' ',$var,' ' x (16 - length $var),'= ',
|
||||
(ref $config{$var} eq 'ARRAY'
|
||||
? join(' ', @{$config{$var}})
|
||||
: $prefix.$config{$var}),
|
||||
"\n"
|
||||
if defined $config{$var};
|
||||
}
|
||||
|
||||
my @buildfile = ($config{builddir}, $config{build_file});
|
||||
unshift @buildfile, $here
|
||||
unless file_name_is_absolute($config{builddir});
|
||||
my $buildfile = canonpath(catdir(@buildfile));
|
||||
print <<"_____";
|
||||
|
||||
NOTE: These variables only represent the configuration view. The build file
|
||||
template may have processed these variables further, please have a look at the
|
||||
build file for more exact data:
|
||||
$buildfile
|
||||
_____
|
||||
}
|
||||
if ($dump || $buildparams) {
|
||||
my @buildfile = ($config{builddir}, $config{build_file});
|
||||
unshift @buildfile, $here
|
||||
unless file_name_is_absolute($config{builddir});
|
||||
print "\nbuild file:\n\n";
|
||||
print " ", canonpath(catfile(@buildfile)),"\n";
|
||||
|
||||
print "\nbuild file templates:\n\n";
|
||||
foreach (@{$config{build_file_templates}}) {
|
||||
my @tmpl = ($_);
|
||||
unshift @tmpl, $here
|
||||
unless file_name_is_absolute($config{sourcedir});
|
||||
print ' ',canonpath(catfile(@tmpl)),"\n";
|
||||
}
|
||||
}
|
||||
if ($reconf) {
|
||||
if ($verbose) {
|
||||
print 'Reconfiguring with: ', join(' ',@{$config{perlargv}}), "\n";
|
||||
foreach (sort keys %{$config{perlenv}}) {
|
||||
print ' ',$_,' = ',($config{perlenv}->{$_} || ""),"\n";
|
||||
}
|
||||
}
|
||||
|
||||
chdir $here;
|
||||
exec $^X,catfile($config{sourcedir}, 'Configure'),'reconf';
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
configdata.pm - configuration data for OpenSSL builds
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Interactive:
|
||||
|
||||
perl configdata.pm [options]
|
||||
|
||||
As data bank module:
|
||||
|
||||
use configdata;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module can be used in two modes, interactively and as a module containing
|
||||
all the data recorded by OpenSSL's Configure script.
|
||||
|
||||
When used interactively, simply run it as any perl script, with at least one
|
||||
option, and you will get the information you ask for. See L</OPTIONS> below.
|
||||
|
||||
When loaded as a module, you get a few databanks with useful information to
|
||||
perform build related tasks. The databanks are:
|
||||
|
||||
%config Configured things.
|
||||
%target The OpenSSL config target with all inheritances
|
||||
resolved.
|
||||
%disabled The features that are disabled.
|
||||
@disablables The list of features that can be disabled.
|
||||
%withargs All data given through --with-THING options.
|
||||
%unified_info All information that was computed from the build.info
|
||||
files.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 4
|
||||
|
||||
=item B<--help>
|
||||
|
||||
Print a brief help message and exit.
|
||||
|
||||
=item B<--man>
|
||||
|
||||
Print the manual page and exit.
|
||||
|
||||
=item B<--dump> | B<-d>
|
||||
|
||||
Print all relevant configuration data. This is equivalent to B<--command-line>
|
||||
B<--options> B<--target> B<--environment> B<--make-variables>
|
||||
B<--build-parameters>.
|
||||
|
||||
=item B<--command-line> | B<-c>
|
||||
|
||||
Print the current configuration command line.
|
||||
|
||||
=item B<--options> | B<-o>
|
||||
|
||||
Print the features, both enabled and disabled, and display defined macro and
|
||||
skipped directories where applicable.
|
||||
|
||||
=item B<--target> | B<-t>
|
||||
|
||||
Print the config attributes for this config target.
|
||||
|
||||
=item B<--environment> | B<-e>
|
||||
|
||||
Print the environment variables and their values at the time of configuration.
|
||||
|
||||
=item B<--make-variables> | B<-m>
|
||||
|
||||
Print the main make variables generated in the current configuration
|
||||
|
||||
=item B<--build-parameters> | B<-b>
|
||||
|
||||
Print the build parameters, i.e. build file and build file templates.
|
||||
|
||||
=item B<--reconfigure> | B<--reconf> | B<-r>
|
||||
|
||||
Redo the configuration.
|
||||
|
||||
=item B<--verbose> | B<-v>
|
||||
|
||||
Verbose output.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
EOF
|
||||
close(OUT);
|
||||
my $configdata_outname = 'configdata.pm';
|
||||
print "Creating $configdata_outname\n";
|
||||
open CONFIGDATA, ">$configdata_outname.new"
|
||||
or die "Trying to create $configdata_outname.new: $!";
|
||||
my $configdata_tmplname = cleanfile($srcdir, "configdata.pm.in", $blddir);
|
||||
my $configdata_tmpl =
|
||||
OpenSSL::Template->new(TYPE => 'FILE', SOURCE => $configdata_tmplname);
|
||||
$configdata_tmpl->fill_in(
|
||||
FILENAME => $configdata_tmplname,
|
||||
OUTPUT => \*CONFIGDATA,
|
||||
HASH => { %template_vars,
|
||||
autowarntext => [
|
||||
'WARNING: do not edit!',
|
||||
"Generated by Configure from $configdata_tmplname",
|
||||
] }
|
||||
) or die $Text::Template::ERROR;
|
||||
close CONFIGDATA;
|
||||
rename "$configdata_outname.new", $configdata_outname;
|
||||
if ($builder_platform eq 'unix') {
|
||||
my $mode = (0755 & ~umask);
|
||||
chmod $mode, 'configdata.pm'
|
||||
or warn sprintf("WARNING: Couldn't change mode for 'configdata.pm' to 0%03o: %s\n",$mode,$!);
|
||||
}
|
||||
|
||||
my %builders = (
|
||||
unified => sub {
|
||||
print 'Creating ',$target{build_file},"\n";
|
||||
run_dofile(catfile($blddir, $target{build_file}),
|
||||
@{$config{build_file_templates}});
|
||||
},
|
||||
);
|
||||
|
||||
$builders{$builder}->($builder_platform, @builder_opts);
|
||||
print "Running $configdata_outname\n";
|
||||
my $perlcmd = (quotify("maybeshell", $config{PERL}))[0];
|
||||
my $cmd = "$perlcmd $configdata_outname";
|
||||
#print STDERR "DEBUG[run_dofile]: \$cmd = $cmd\n";
|
||||
system($cmd);
|
||||
exit 1 if $? != 0;
|
||||
|
||||
$SIG{__DIE__} = $orig_death_handler;
|
||||
|
||||
@@ -3213,24 +2823,6 @@ sub usage
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sub run_dofile
|
||||
{
|
||||
my $out = shift;
|
||||
my @templates = @_;
|
||||
|
||||
unlink $out || warn "Can't remove $out, $!"
|
||||
if -f $out;
|
||||
foreach (@templates) {
|
||||
die "Can't open $_, $!" unless -f $_;
|
||||
}
|
||||
my $perlcmd = (quotify("maybeshell", $config{PERL}))[0];
|
||||
my $cmd = "$perlcmd \"-I.\" \"-Mconfigdata\" \"$dofile\" -o\"Configure\" \"".join("\" \"",@templates)."\" > \"$out.new\"";
|
||||
#print STDERR "DEBUG[run_dofile]: \$cmd = $cmd\n";
|
||||
system($cmd);
|
||||
exit 1 if $? != 0;
|
||||
rename("$out.new", $out) || die "Can't rename $out.new, $!";
|
||||
}
|
||||
|
||||
sub compiler_predefined {
|
||||
state %predefined;
|
||||
my $cc = shift;
|
||||
|
||||
@@ -99,6 +99,9 @@
|
||||
$ nmake test
|
||||
$ nmake install
|
||||
|
||||
Note that in order to perform the install step above you need to have
|
||||
appropriate permissions to write to the installation directory.
|
||||
|
||||
If any of these steps fails, see section Installation in Detail below.
|
||||
|
||||
This will build and install OpenSSL in the default location, which is:
|
||||
@@ -108,6 +111,12 @@
|
||||
OpenSSL version number with underscores instead of periods.
|
||||
Windows: C:\Program Files\OpenSSL or C:\Program Files (x86)\OpenSSL
|
||||
|
||||
The installation directory should be appropriately protected to ensure
|
||||
unprivileged users cannot make changes to OpenSSL binaries or files, or install
|
||||
engines. If you already have a pre-installed version of OpenSSL as part of
|
||||
your Operating System it is recommended that you do not overwrite the system
|
||||
version and instead install to somewhere else.
|
||||
|
||||
If you want to install it anywhere else, run config like this:
|
||||
|
||||
On Unix:
|
||||
@@ -136,7 +145,10 @@
|
||||
Don't build with support for deprecated APIs below the
|
||||
specified version number. For example "--api=1.1.0" will
|
||||
remove support for all APIS that were deprecated in OpenSSL
|
||||
version 1.1.0 or below.
|
||||
version 1.1.0 or below. This is a rather specialized option
|
||||
for developers. If you just intend to remove all deprecated
|
||||
APIs entirely (up to the current version), it is easier
|
||||
to add the 'no-deprecated' option instead (see below).
|
||||
|
||||
--cross-compile-prefix=PREFIX
|
||||
The PREFIX to include in front of commands for your
|
||||
@@ -230,7 +242,7 @@
|
||||
source exists.
|
||||
getrandom: Use the L<getrandom(2)> or equivalent system
|
||||
call.
|
||||
devrandom: Use the the first device from the DEVRANDOM list
|
||||
devrandom: Use the first device from the DEVRANDOM list
|
||||
which can be opened to read random bytes. The
|
||||
DEVRANDOM preprocessor constant expands to
|
||||
"/dev/urandom","/dev/random","/dev/srandom" on
|
||||
@@ -352,6 +364,9 @@
|
||||
Don't build support for datagram based BIOs. Selecting this
|
||||
option will also force the disabling of DTLS.
|
||||
|
||||
no-dso
|
||||
Don't build support for loading Dynamic Shared Objects.
|
||||
|
||||
enable-devcryptoeng
|
||||
Build the /dev/crypto engine. It is automatically selected
|
||||
on BSD implementations, in which case it can be disabled with
|
||||
@@ -899,11 +914,17 @@
|
||||
malfunction with Perl). You may want increased verbosity, that
|
||||
can be accomplished like this:
|
||||
|
||||
$ make VERBOSE=1 test # Unix
|
||||
Verbosity on failure only (make macro VERBOSE_FAILURE or VF):
|
||||
|
||||
$ mms /macro=(VERBOSE=1) test ! OpenVMS
|
||||
$ make VF=1 test # Unix
|
||||
$ mms /macro=(VF=1) test ! OpenVMS
|
||||
$ nmake VF=1 test # Windows
|
||||
|
||||
$ nmake VERBOSE=1 test # Windows
|
||||
Full verbosity (make macro VERBOSE or V):
|
||||
|
||||
$ make V=1 test # Unix
|
||||
$ mms /macro=(V=1) test ! OpenVMS
|
||||
$ nmake V=1 test # Windows
|
||||
|
||||
If you want to run just one or a few specific tests, you can use
|
||||
the make variable TESTS to specify them, like this:
|
||||
@@ -914,7 +935,7 @@
|
||||
|
||||
And of course, you can combine (Unix example shown):
|
||||
|
||||
$ make VERBOSE=1 TESTS='test_rsa test_dsa' test
|
||||
$ make VF=1 TESTS='test_rsa test_dsa' test
|
||||
|
||||
You can find the list of available tests like this:
|
||||
|
||||
@@ -941,8 +962,11 @@
|
||||
$ mms install ! OpenVMS
|
||||
$ nmake install # Windows
|
||||
|
||||
This will install all the software components in this directory
|
||||
tree under PREFIX (the directory given with --prefix or its
|
||||
Note that in order to perform the install step above you need to have
|
||||
appropriate permissions to write to the installation directory.
|
||||
|
||||
The above commands will install all the software components in this
|
||||
directory tree under PREFIX (the directory given with --prefix or its
|
||||
default):
|
||||
|
||||
Unix:
|
||||
@@ -998,6 +1022,12 @@
|
||||
for private key files.
|
||||
misc Various scripts.
|
||||
|
||||
The installation directory should be appropriately protected to ensure
|
||||
unprivileged users cannot make changes to OpenSSL binaries or files, or
|
||||
install engines. If you already have a pre-installed version of OpenSSL as
|
||||
part of your Operating System it is recommended that you do not overwrite
|
||||
the system version and instead install to somewhere else.
|
||||
|
||||
Package builders who want to configure the library for standard
|
||||
locations, but have the package installed somewhere else so that
|
||||
it can easily be packaged, can use
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
Major changes between OpenSSL 1.1.1 and OpenSSL 3.0.0 [under development]
|
||||
|
||||
o Added error raising macros, ERR_raise() and ERR_raise_data().
|
||||
o Deprecated ERR_put_error().
|
||||
o Added OSSL_PROVIDER_available(), to check provider availibility.
|
||||
o Added 'openssl mac' that uses the EVP_MAC API.
|
||||
o Added 'openssl kdf' that uses the EVP_KDF API.
|
||||
o Add OPENSSL_info() and 'openssl info' to get built-in data.
|
||||
|
||||
+11
-33
@@ -1,3 +1,5 @@
|
||||
SUBDIRS=lib
|
||||
|
||||
# Program init source, that don't have direct linkage with the rest of the
|
||||
# source, and can therefore not be part of a library.
|
||||
IF[{- !$disabled{uplink} -}]
|
||||
@@ -7,37 +9,18 @@ IF[{- $config{target} =~ /^vms-/ -}]
|
||||
$INITSRC=vms_decc_init.c
|
||||
ENDIF
|
||||
|
||||
# Auxilliary program source
|
||||
IF[{- $config{target} =~ /^(?:VC-|mingw)/ -}]
|
||||
# It's called 'init', but doesn't have much 'init' in it...
|
||||
$AUXLIBAPPSSRC=win32_init.c
|
||||
ENDIF
|
||||
IF[{- $config{target} =~ /^vms-/ -}]
|
||||
$AUXLIBAPPSSRC=vms_term_sock.c vms_decc_argv.c
|
||||
ENDIF
|
||||
|
||||
# Source for the 'openssl' program
|
||||
# We need the perl variable for the DEPEND generator further down.
|
||||
$OPENSSLSRC={-
|
||||
our @opensslsrc =
|
||||
qw(openssl.c
|
||||
asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c dgst.c dhparam.c
|
||||
dsa.c dsaparam.c ec.c ecparam.c enc.c engine.c errstr.c gendsa.c
|
||||
genpkey.c genrsa.c kdf.c mac.c nseq.c ocsp.c passwd.c pkcs12.c pkcs7.c
|
||||
pkcs8.c pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c rsa.c
|
||||
rsautl.c s_client.c s_server.c s_time.c sess_id.c smime.c speed.c
|
||||
spkac.c srp.c ts.c verify.c version.c x509.c rehash.c storeutl.c
|
||||
info.c);
|
||||
join(' ', @opensslsrc); -}
|
||||
# Source for libapps
|
||||
$LIBAPPSSRC=apps.c apps_ui.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \
|
||||
bf_prefix.c
|
||||
$OPENSSLSRC=\
|
||||
openssl.c progs.c \
|
||||
asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c dgst.c dhparam.c \
|
||||
dsa.c dsaparam.c ec.c ecparam.c enc.c engine.c errstr.c gendsa.c \
|
||||
genpkey.c genrsa.c kdf.c mac.c nseq.c ocsp.c passwd.c pkcs12.c pkcs7.c \
|
||||
pkcs8.c pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c rsa.c \
|
||||
rsautl.c s_client.c s_server.c s_time.c sess_id.c smime.c speed.c \
|
||||
spkac.c srp.c ts.c verify.c version.c x509.c rehash.c storeutl.c \
|
||||
list.c info.c provider.c fipsinstall.c
|
||||
|
||||
IF[{- !$disabled{apps} -}]
|
||||
LIBS{noinst}=libapps.a
|
||||
SOURCE[libapps.a]=$LIBAPPSSRC $AUXLIBAPPSSRC
|
||||
INCLUDE[libapps.a]=.. ../include include
|
||||
|
||||
PROGRAMS=openssl
|
||||
SOURCE[openssl]=$INITSRC $OPENSSLSRC
|
||||
INCLUDE[openssl]=.. ../include include
|
||||
@@ -48,11 +31,6 @@ IF[{- !$disabled{apps} -}]
|
||||
SOURCE[openssl]=openssl.rc
|
||||
ENDIF
|
||||
|
||||
{- join("\n ", map { (my $x = $_) =~ s|\.c$|.o|; "DEPEND[$x]=progs.h" }
|
||||
@opensslsrc) -}
|
||||
GENERATE[progs.h]=progs.pl $(APPS_OPENSSL)
|
||||
DEPEND[progs.h]=../configdata.pm
|
||||
|
||||
SCRIPTS{misc}=CA.pl
|
||||
SOURCE[CA.pl]=CA.pl.in
|
||||
# linkname tells build files that a symbolic link or copy of this script
|
||||
|
||||
+1
-1
@@ -461,7 +461,7 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
size_t len;
|
||||
int i, backslash = 0;
|
||||
|
||||
for (;;) {
|
||||
while (BIO_pending(bp) || !BIO_eof(bp)) {
|
||||
i = BIO_read(bp, (char *)buf, BUFSIZE);
|
||||
if (i < 0) {
|
||||
BIO_printf(bio_err, "Read Error in %s\n", file);
|
||||
|
||||
+5
-1
@@ -37,7 +37,7 @@ typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT,
|
||||
OPT_ENGINE, OPT_CHECK, OPT_TEXT, OPT_NOOUT,
|
||||
OPT_DSAPARAM, OPT_C, OPT_2, OPT_5,
|
||||
OPT_DSAPARAM, OPT_C, OPT_2, OPT_3, OPT_5,
|
||||
OPT_R_ENUM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
@@ -55,6 +55,7 @@ const OPTIONS dhparam_options[] = {
|
||||
OPT_R_OPTIONS,
|
||||
{"C", OPT_C, '-', "Print C code"},
|
||||
{"2", OPT_2, '-', "Generate parameters using 2 as the generator value"},
|
||||
{"3", OPT_3, '-', "Generate parameters using 3 as the generator value"},
|
||||
{"5", OPT_5, '-', "Generate parameters using 5 as the generator value"},
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
{"dsaparam", OPT_DSAPARAM, '-',
|
||||
@@ -125,6 +126,9 @@ int dhparam_main(int argc, char **argv)
|
||||
case OPT_2:
|
||||
g = 2;
|
||||
break;
|
||||
case OPT_3:
|
||||
g = 3;
|
||||
break;
|
||||
case OPT_5:
|
||||
g = 5;
|
||||
break;
|
||||
|
||||
+1
-1
@@ -273,7 +273,7 @@ int ecparam_main(int argc, char **argv)
|
||||
|
||||
if (check_named) {
|
||||
BIO_printf(bio_err, "validating named elliptic curve parameters: ");
|
||||
if (EC_GROUP_check_named_curve(group, 0) <= 0) {
|
||||
if (EC_GROUP_check_named_curve(group, 0, NULL) <= 0) {
|
||||
BIO_printf(bio_err, "failed\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
|
||||
+1
-1
@@ -586,7 +586,7 @@ int enc_main(int argc, char **argv)
|
||||
if (benc != NULL)
|
||||
wbio = BIO_push(benc, wbio);
|
||||
|
||||
for (;;) {
|
||||
while (BIO_pending(rbio) || !BIO_eof(rbio)) {
|
||||
inl = BIO_read(rbio, (char *)buff, bsize);
|
||||
if (inl <= 0)
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,420 @@
|
||||
/*
|
||||
* 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/evp.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/params.h>
|
||||
#include <openssl/fips_names.h>
|
||||
#include "apps.h"
|
||||
#include "progs.h"
|
||||
|
||||
#define BUFSIZE 4096
|
||||
#define DEFAULT_MAC_NAME "HMAC"
|
||||
#define DEFAULT_FIPS_SECTION "fips_check_section"
|
||||
|
||||
/* Configuration file values */
|
||||
#define VERSION_KEY "version"
|
||||
#define VERSION_VAL "1"
|
||||
#define INSTALL_STATUS_VAL "INSTALL_SELF_TEST_KATS_RUN"
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_IN, OPT_OUT, OPT_MODULE,
|
||||
OPT_PROV_NAME, OPT_SECTION_NAME, OPT_MAC_NAME, OPT_MACOPT, OPT_VERIFY
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS fipsinstall_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{OPT_MORE_STR, 0, 0, "e.g: openssl fipsinstall -provider_name fips"
|
||||
"-section_name fipsinstall -out fips.conf -module ./fips.so"
|
||||
"-mac_name HMAC -macopt digest:SHA256 -macopt hexkey:00"},
|
||||
{"verify", OPT_VERIFY, '-', "Verification mode, i.e verify a config file "
|
||||
"instead of generating one"},
|
||||
{"in", OPT_IN, '<', "Input config file, used when verifying"},
|
||||
{"out", OPT_OUT, '>', "Output config file, used when generating"},
|
||||
{"module", OPT_MODULE, '<', "File name of the provider module"},
|
||||
{"provider_name", OPT_PROV_NAME, 's', "FIPS provider name"},
|
||||
{"section_name", OPT_SECTION_NAME, 's',
|
||||
"FIPS Provider config section name (optional)"},
|
||||
{"mac_name", OPT_MAC_NAME, 's', "MAC name"},
|
||||
{"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form. "
|
||||
"See 'PARAMETER NAMES' in the EVP_MAC_ docs"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static int do_mac(EVP_MAC_CTX *ctx, unsigned char *tmp, BIO *in,
|
||||
unsigned char *out, size_t *out_len)
|
||||
{
|
||||
int ret = 0;
|
||||
int i;
|
||||
size_t outsz = *out_len;
|
||||
|
||||
if (!EVP_MAC_init(ctx))
|
||||
goto err;
|
||||
if (EVP_MAC_size(ctx) > outsz)
|
||||
goto end;
|
||||
while ((i = BIO_read(in, (char *)tmp, BUFSIZE)) != 0) {
|
||||
if (i < 0 || !EVP_MAC_update(ctx, tmp, i))
|
||||
goto err;
|
||||
}
|
||||
end:
|
||||
if (!EVP_MAC_final(ctx, out, out_len, outsz))
|
||||
goto err;
|
||||
ret = 1;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int load_fips_prov_and_run_self_test(const char *prov_name)
|
||||
{
|
||||
int ret = 0;
|
||||
OSSL_PROVIDER *prov = NULL;
|
||||
|
||||
prov = OSSL_PROVIDER_load(NULL, prov_name);
|
||||
if (prov == NULL) {
|
||||
BIO_printf(bio_err, "Failed to load FIPS module\n");
|
||||
goto end;
|
||||
}
|
||||
ret = 1;
|
||||
end:
|
||||
OSSL_PROVIDER_unload(prov);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int print_mac(BIO *bio, const char *label, const unsigned char *mac,
|
||||
size_t len)
|
||||
{
|
||||
int ret;
|
||||
char *hexstr = NULL;
|
||||
|
||||
hexstr = OPENSSL_buf2hexstr(mac, (long)len);
|
||||
if (hexstr == NULL)
|
||||
return 0;
|
||||
ret = BIO_printf(bio, "%s = %s\n", label, hexstr);
|
||||
OPENSSL_free(hexstr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int write_config_header(BIO *out, const char *prov_name,
|
||||
const char *section)
|
||||
{
|
||||
return BIO_printf(out, "openssl_conf = openssl_init\n\n")
|
||||
&& BIO_printf(out, "[openssl_init]\n")
|
||||
&& BIO_printf(out, "providers = provider_section\n\n")
|
||||
&& BIO_printf(out, "[provider_section]\n")
|
||||
&& BIO_printf(out, "%s = %s\n\n", prov_name, section);
|
||||
}
|
||||
|
||||
/*
|
||||
* Outputs a fips related config file that contains entries for the fips
|
||||
* module checksum and the installation indicator checksum.
|
||||
*
|
||||
* Returns 1 if the config file is written otherwise it returns 0 on error.
|
||||
*/
|
||||
static int write_config_fips_section(BIO *out, const char *section,
|
||||
unsigned char *module_mac,
|
||||
size_t module_mac_len,
|
||||
unsigned char *install_mac,
|
||||
size_t install_mac_len)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (!(BIO_printf(out, "[%s]\n", section) > 0
|
||||
&& BIO_printf(out, "activate = 1\n") > 0
|
||||
&& BIO_printf(out, "%s = %s\n", OSSL_PROV_FIPS_PARAM_INSTALL_VERSION,
|
||||
VERSION_VAL) > 0
|
||||
&& print_mac(out, OSSL_PROV_FIPS_PARAM_MODULE_MAC, module_mac,
|
||||
module_mac_len)))
|
||||
goto end;
|
||||
|
||||
if (install_mac != NULL) {
|
||||
if (!(print_mac(out, OSSL_PROV_FIPS_PARAM_INSTALL_MAC, install_mac,
|
||||
install_mac_len)
|
||||
&& BIO_printf(out, "%s = %s\n",
|
||||
OSSL_PROV_FIPS_PARAM_INSTALL_STATUS,
|
||||
INSTALL_STATUS_VAL) > 0))
|
||||
goto end;
|
||||
}
|
||||
ret = 1;
|
||||
end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static CONF *generate_config_and_load(const char *prov_name,
|
||||
const char *section,
|
||||
unsigned char *module_mac,
|
||||
size_t module_mac_len)
|
||||
{
|
||||
BIO *mem_bio = NULL;
|
||||
CONF *conf = NULL;
|
||||
|
||||
mem_bio = BIO_new(BIO_s_mem());
|
||||
if (mem_bio == NULL)
|
||||
return 0;
|
||||
if (!write_config_header(mem_bio, prov_name, section)
|
||||
|| !write_config_fips_section(mem_bio, section, module_mac,
|
||||
module_mac_len, NULL, 0))
|
||||
goto end;
|
||||
|
||||
conf = app_load_config_bio(mem_bio, NULL);
|
||||
if (conf == NULL)
|
||||
goto end;
|
||||
|
||||
if (!CONF_modules_load(conf, NULL, 0))
|
||||
goto end;
|
||||
BIO_free(mem_bio);
|
||||
return conf;
|
||||
end:
|
||||
NCONF_free(conf);
|
||||
BIO_free(mem_bio);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void free_config_and_unload(CONF *conf)
|
||||
{
|
||||
if (conf != NULL) {
|
||||
NCONF_free(conf);
|
||||
CONF_modules_unload(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns 1 if the config file entries match the passed in module_mac and
|
||||
* install_mac values, otherwise it returns 0.
|
||||
*/
|
||||
static int verify_config(const char *infile, const char *section,
|
||||
unsigned char *module_mac, size_t module_mac_len,
|
||||
unsigned char *install_mac, size_t install_mac_len)
|
||||
{
|
||||
int ret = 0;
|
||||
char *s = NULL;
|
||||
unsigned char *buf1 = NULL, *buf2 = NULL;
|
||||
long len;
|
||||
CONF *conf = NULL;
|
||||
|
||||
/* read in the existing values and check they match the saved values */
|
||||
conf = app_load_config(infile);
|
||||
if (conf == NULL)
|
||||
goto end;
|
||||
|
||||
s = NCONF_get_string(conf, section, OSSL_PROV_FIPS_PARAM_INSTALL_VERSION);
|
||||
if (s == NULL || strcmp(s, VERSION_VAL) != 0) {
|
||||
BIO_printf(bio_err, "version not found\n");
|
||||
goto end;
|
||||
}
|
||||
s = NCONF_get_string(conf, section, OSSL_PROV_FIPS_PARAM_INSTALL_STATUS);
|
||||
if (s == NULL || strcmp(s, INSTALL_STATUS_VAL) != 0) {
|
||||
BIO_printf(bio_err, "install status not found\n");
|
||||
goto end;
|
||||
}
|
||||
s = NCONF_get_string(conf, section, OSSL_PROV_FIPS_PARAM_MODULE_MAC);
|
||||
if (s == NULL) {
|
||||
BIO_printf(bio_err, "Module integrity MAC not found\n");
|
||||
goto end;
|
||||
}
|
||||
buf1 = OPENSSL_hexstr2buf(s, &len);
|
||||
if (buf1 == NULL
|
||||
|| (size_t)len != module_mac_len
|
||||
|| memcmp(module_mac, buf1, module_mac_len) != 0) {
|
||||
BIO_printf(bio_err, "Module integrity mismatch\n");
|
||||
goto end;
|
||||
}
|
||||
s = NCONF_get_string(conf, section, OSSL_PROV_FIPS_PARAM_INSTALL_MAC);
|
||||
if (s == NULL) {
|
||||
BIO_printf(bio_err, "Install indicator MAC not found\n");
|
||||
goto end;
|
||||
}
|
||||
buf2 = OPENSSL_hexstr2buf(s, &len);
|
||||
if (buf2 == NULL
|
||||
|| (size_t)len != install_mac_len
|
||||
|| memcmp(install_mac, buf2, install_mac_len) != 0) {
|
||||
BIO_printf(bio_err, "Install indicator status mismatch\n");
|
||||
goto end;
|
||||
}
|
||||
ret = 1;
|
||||
end:
|
||||
OPENSSL_free(buf1);
|
||||
OPENSSL_free(buf2);
|
||||
NCONF_free(conf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fipsinstall_main(int argc, char **argv)
|
||||
{
|
||||
int ret = 1, verify = 0;
|
||||
BIO *module_bio = NULL, *mem_bio = NULL, *fout = NULL;
|
||||
char *in_fname = NULL, *out_fname = NULL, *prog, *section_name = NULL;
|
||||
char *prov_name = NULL, *module_fname = NULL;
|
||||
static const char *mac_name = DEFAULT_MAC_NAME;
|
||||
EVP_MAC_CTX *ctx = NULL, *ctx2 = NULL;
|
||||
STACK_OF(OPENSSL_STRING) *opts = NULL;
|
||||
OPTION_CHOICE o;
|
||||
unsigned char *read_buffer = NULL;
|
||||
unsigned char module_mac[EVP_MAX_MD_SIZE];
|
||||
size_t module_mac_len = EVP_MAX_MD_SIZE;
|
||||
unsigned char install_mac[EVP_MAX_MD_SIZE];
|
||||
size_t install_mac_len = EVP_MAX_MD_SIZE;
|
||||
EVP_MAC *mac = NULL;
|
||||
CONF *conf = NULL;
|
||||
|
||||
section_name = DEFAULT_FIPS_SECTION;
|
||||
|
||||
prog = opt_init(argc, argv, fipsinstall_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(fipsinstall_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_IN:
|
||||
in_fname = opt_arg();
|
||||
break;
|
||||
case OPT_OUT:
|
||||
out_fname = opt_arg();
|
||||
break;
|
||||
case OPT_PROV_NAME:
|
||||
prov_name = opt_arg();
|
||||
break;
|
||||
case OPT_MODULE:
|
||||
module_fname = opt_arg();
|
||||
break;
|
||||
case OPT_SECTION_NAME:
|
||||
section_name = opt_arg();
|
||||
break;
|
||||
case OPT_MAC_NAME:
|
||||
mac_name = opt_arg();
|
||||
break;
|
||||
case OPT_MACOPT:
|
||||
if (opts == NULL)
|
||||
opts = sk_OPENSSL_STRING_new_null();
|
||||
if (opts == NULL || !sk_OPENSSL_STRING_push(opts, opt_arg()))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_VERIFY:
|
||||
verify = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
if (module_fname == NULL
|
||||
|| (verify && in_fname == NULL)
|
||||
|| (!verify && (out_fname == NULL || prov_name == NULL))
|
||||
|| opts == NULL
|
||||
|| argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
module_bio = bio_open_default(module_fname, 'r', FORMAT_BINARY);
|
||||
if (module_bio == NULL) {
|
||||
BIO_printf(bio_err, "Failed to open module file\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
read_buffer = app_malloc(BUFSIZE, "I/O buffer");
|
||||
if (read_buffer == NULL)
|
||||
goto end;
|
||||
|
||||
mac = EVP_MAC_fetch(NULL, mac_name, NULL);
|
||||
if (mac == NULL) {
|
||||
BIO_printf(bio_err, "Unable to get MAC of type %s\n", mac_name);
|
||||
goto end;
|
||||
}
|
||||
|
||||
ctx = EVP_MAC_CTX_new(mac);
|
||||
if (ctx == NULL) {
|
||||
BIO_printf(bio_err, "Unable to create MAC CTX for module check\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (opts != NULL) {
|
||||
int ok = 1;
|
||||
OSSL_PARAM *params =
|
||||
app_params_new_from_opts(opts, EVP_MAC_CTX_settable_params(mac));
|
||||
|
||||
if (params == NULL)
|
||||
goto end;
|
||||
|
||||
if (!EVP_MAC_CTX_set_params(ctx, params)) {
|
||||
BIO_printf(bio_err, "MAC parameter error\n");
|
||||
ERR_print_errors(bio_err);
|
||||
ok = 0;
|
||||
}
|
||||
app_params_free(params);
|
||||
if (!ok)
|
||||
goto end;
|
||||
}
|
||||
|
||||
ctx2 = EVP_MAC_CTX_dup(ctx);
|
||||
if (ctx2 == NULL) {
|
||||
BIO_printf(bio_err, "Unable to create MAC CTX for install indicator\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!do_mac(ctx, read_buffer, module_bio, module_mac, &module_mac_len))
|
||||
goto end;
|
||||
|
||||
mem_bio = BIO_new_mem_buf((const void *)INSTALL_STATUS_VAL,
|
||||
strlen(INSTALL_STATUS_VAL));
|
||||
if (mem_bio == NULL) {
|
||||
BIO_printf(bio_err, "Unable to create memory BIO\n");
|
||||
goto end;
|
||||
}
|
||||
if (!do_mac(ctx2, read_buffer, mem_bio, install_mac, &install_mac_len))
|
||||
goto end;
|
||||
|
||||
if (verify) {
|
||||
if (!verify_config(in_fname, section_name, module_mac, module_mac_len,
|
||||
install_mac, install_mac_len))
|
||||
goto end;
|
||||
BIO_printf(bio_out, "VERIFY PASSED\n");
|
||||
} else {
|
||||
|
||||
conf = generate_config_and_load(prov_name, section_name, module_mac,
|
||||
module_mac_len);
|
||||
if (conf == NULL)
|
||||
goto end;
|
||||
if (!load_fips_prov_and_run_self_test(prov_name))
|
||||
goto end;
|
||||
|
||||
fout = bio_open_default(out_fname, 'w', FORMAT_TEXT);
|
||||
if (fout == NULL) {
|
||||
BIO_printf(bio_err, "Failed to open file\n");
|
||||
goto end;
|
||||
}
|
||||
if (!write_config_fips_section(fout, section_name, module_mac,
|
||||
module_mac_len, install_mac,
|
||||
install_mac_len))
|
||||
goto end;
|
||||
BIO_printf(bio_out, "INSTALL PASSED\n");
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
end:
|
||||
if (ret == 1) {
|
||||
BIO_printf(bio_err, "%s FAILED\n", verify ? "VERIFY" : "INSTALL");
|
||||
ERR_print_errors(bio_err);
|
||||
}
|
||||
|
||||
BIO_free(fout);
|
||||
BIO_free(mem_bio);
|
||||
BIO_free(module_bio);
|
||||
sk_OPENSSL_STRING_free(opts);
|
||||
EVP_MAC_free(mac);
|
||||
EVP_MAC_CTX_free(ctx2);
|
||||
EVP_MAC_CTX_free(ctx);
|
||||
OPENSSL_free(read_buffer);
|
||||
free_config_and_unload(conf);
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* 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/core.h>
|
||||
|
||||
int print_param_types(const char *thing, const OSSL_PARAM *pdefs, int indent);
|
||||
|
||||
+4
-2
@@ -102,11 +102,9 @@ typedef struct args_st {
|
||||
int wrap_password_callback(char *buf, int bufsiz, int verify, void *cb_data);
|
||||
|
||||
int chopup_args(ARGS *arg, char *buf);
|
||||
# ifdef HEADER_X509_H
|
||||
int dump_cert_text(BIO *out, X509 *x);
|
||||
void print_name(BIO *out, const char *title, X509_NAME *nm,
|
||||
unsigned long lflags);
|
||||
# endif
|
||||
void print_bignum_var(BIO *, const BIGNUM *, const char*,
|
||||
int, unsigned char *);
|
||||
void print_array(BIO *, const char *, int, const unsigned char *);
|
||||
@@ -266,4 +264,8 @@ typedef struct verify_options_st {
|
||||
|
||||
extern VERIFY_CB_ARGS verify_args;
|
||||
|
||||
OSSL_PARAM *app_params_new_from_opts(STACK_OF(OPENSSL_STRING) *opts,
|
||||
const OSSL_PARAM *paramdefs);
|
||||
void app_params_free(OSSL_PARAM *params);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef APPS_FUNCTION_H
|
||||
# define APPS_FUNCTION_H
|
||||
|
||||
# include <openssl/lhash.h>
|
||||
# include "opt.h"
|
||||
|
||||
typedef enum FUNC_TYPE {
|
||||
FT_none, FT_general, FT_md, FT_cipher, FT_pkey,
|
||||
FT_md_alg, FT_cipher_alg
|
||||
} FUNC_TYPE;
|
||||
|
||||
typedef struct function_st {
|
||||
FUNC_TYPE type;
|
||||
const char *name;
|
||||
int (*func)(int argc, char *argv[]);
|
||||
const OPTIONS *help;
|
||||
} FUNCTION;
|
||||
|
||||
DEFINE_LHASH_OF(FUNCTION);
|
||||
|
||||
/* Structure to hold the number of columns to be displayed and the
|
||||
* field width used to display them.
|
||||
*/
|
||||
typedef struct {
|
||||
int columns;
|
||||
int width;
|
||||
} DISPLAY_COLUMNS;
|
||||
|
||||
void calculate_columns(FUNCTION *functions, DISPLAY_COLUMNS *dc);
|
||||
|
||||
#endif
|
||||
@@ -266,6 +266,7 @@
|
||||
*/
|
||||
extern const char OPT_HELP_STR[];
|
||||
extern const char OPT_MORE_STR[];
|
||||
extern const char OPT_SECTION_STR[];
|
||||
typedef struct options_st {
|
||||
const char *name;
|
||||
int retval;
|
||||
@@ -307,6 +308,9 @@ typedef struct string_int_pair_st {
|
||||
OPT_FMT_ENGINE | OPT_FMT_MSBLOB | OPT_FMT_NSS | \
|
||||
OPT_FMT_TEXT | OPT_FMT_HTTP | OPT_FMT_PVK)
|
||||
|
||||
/* Divide options into sections when displaying usage */
|
||||
#define OPT_SECTION(sec) {OPT_SECTION_STR, 1, '-', sec " options:\n"}
|
||||
|
||||
char *opt_progname(const char *argv0);
|
||||
char *opt_getprog(void);
|
||||
char *opt_init(int ac, char **av, const OPTIONS * o);
|
||||
@@ -338,6 +342,7 @@ int opt_num_rest(void);
|
||||
int opt_verify(int i, X509_VERIFY_PARAM *vpm);
|
||||
int opt_rand(int i);
|
||||
void opt_help(const OPTIONS * list);
|
||||
void opt_print(const OPTIONS * opt, int width);
|
||||
int opt_format_error(const char *s, unsigned long flags);
|
||||
int opt_isdir(const char *name);
|
||||
int opt_printf_stderr(const char *fmt, ...);
|
||||
|
||||
+3
-15
@@ -9,13 +9,7 @@
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
|
||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
|
||||
# include <conio.h>
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_SYS_MSDOS) && !defined(_WIN32)
|
||||
# define _kbhit kbhit
|
||||
#endif
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#define PORT "4433"
|
||||
#define PROTOCOL "tcp"
|
||||
@@ -24,17 +18,15 @@ typedef int (*do_server_cb)(int s, int stype, int prot, unsigned char *context);
|
||||
int do_server(int *accept_sock, const char *host, const char *port,
|
||||
int family, int type, int protocol, do_server_cb cb,
|
||||
unsigned char *context, int naccept, BIO *bio_s_out);
|
||||
#ifdef HEADER_X509_H
|
||||
|
||||
int verify_callback(int ok, X509_STORE_CTX *ctx);
|
||||
#endif
|
||||
#ifdef HEADER_SSL_H
|
||||
|
||||
int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
|
||||
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key,
|
||||
STACK_OF(X509) *chain, int build_chain);
|
||||
int ssl_print_sigalgs(BIO *out, SSL *s);
|
||||
int ssl_print_point_formats(BIO *out, SSL *s);
|
||||
int ssl_print_groups(BIO *out, SSL *s, int noshared);
|
||||
#endif
|
||||
int ssl_print_tmp_key(BIO *out, SSL *s);
|
||||
int init_client(int *sock, const char *host, const char *port,
|
||||
const char *bindhost, const char *bindport,
|
||||
@@ -44,13 +36,11 @@ int should_retry(int i);
|
||||
long bio_dump_callback(BIO *bio, int cmd, const char *argp,
|
||||
int argi, long argl, long ret);
|
||||
|
||||
#ifdef HEADER_SSL_H
|
||||
void apps_ssl_info_callback(const SSL *s, int where, int ret);
|
||||
void msg_cb(int write_p, int version, int content_type, const void *buf,
|
||||
size_t len, SSL *ssl, void *arg);
|
||||
void tlsext_cb(SSL *s, int client_server, int type, const unsigned char *data,
|
||||
int len, void *arg);
|
||||
#endif
|
||||
|
||||
int generate_cookie_callback(SSL *ssl, unsigned char *cookie,
|
||||
unsigned int *cookie_len);
|
||||
@@ -75,7 +65,6 @@ int args_excert(int option, SSL_EXCERT **pexc);
|
||||
int load_excert(SSL_EXCERT **pexc);
|
||||
void print_verify_detail(SSL *s, BIO *bio);
|
||||
void print_ssl_summary(SSL *s);
|
||||
#ifdef HEADER_SSL_H
|
||||
int config_ctx(SSL_CONF_CTX *cctx, STACK_OF(OPENSSL_STRING) *str, SSL_CTX *ctx);
|
||||
int ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls,
|
||||
int crl_download);
|
||||
@@ -86,4 +75,3 @@ int ssl_load_stores(SSL_CTX *ctx, const char *vfyCApath,
|
||||
void ssl_ctx_security_debug(SSL_CTX *ctx, int verbose);
|
||||
int set_keylog_file(SSL_CTX *ctx, const char *keylog_file);
|
||||
void print_ca_names(BIO *bio, SSL *s);
|
||||
#endif
|
||||
+11
-1
@@ -14,7 +14,7 @@
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_CONFIGDIR, OPT_ENGINESDIR, OPT_MODULESDIR, OPT_DSOEXT, OPT_DIRNAMESEP,
|
||||
OPT_LISTSEP
|
||||
OPT_LISTSEP, OPT_SEEDS, OPT_CPUSETTINGS
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS info_options[] = {
|
||||
@@ -30,6 +30,8 @@ const OPTIONS info_options[] = {
|
||||
{"dsoext", OPT_DSOEXT, '-', "Configured extension for modules"},
|
||||
{"dirnamesep", OPT_DIRNAMESEP, '-', "Directory-filename separator"},
|
||||
{"listsep", OPT_LISTSEP, '-', "List separator character"},
|
||||
{"seeds", OPT_SEEDS, '-', "Seed sources"},
|
||||
{"cpusettings", OPT_CPUSETTINGS, '-', "CPU settings info"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@@ -74,6 +76,14 @@ opthelp:
|
||||
type = OPENSSL_INFO_LIST_SEPARATOR;
|
||||
dirty++;
|
||||
break;
|
||||
case OPT_SEEDS:
|
||||
type = OPENSSL_INFO_SEED_SOURCE;
|
||||
dirty++;
|
||||
break;
|
||||
case OPT_CPUSETTINGS:
|
||||
type = OPENSSL_INFO_CPU_SETTINGS;
|
||||
dirty++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (opt_num_rest() != 0) {
|
||||
|
||||
+20
-29
@@ -15,6 +15,7 @@
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include <openssl/params.h>
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
@@ -34,27 +35,9 @@ const OPTIONS kdf_options[] = {
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static int kdf_ctrl_string(EVP_KDF_CTX *ctx, const char *value)
|
||||
{
|
||||
int rv;
|
||||
char *stmp, *vtmp = NULL;
|
||||
|
||||
stmp = OPENSSL_strdup(value);
|
||||
if (stmp == NULL)
|
||||
return -1;
|
||||
vtmp = strchr(stmp, ':');
|
||||
if (vtmp != NULL) {
|
||||
*vtmp = 0;
|
||||
vtmp++;
|
||||
}
|
||||
rv = EVP_KDF_ctrl_str(ctx, stmp, vtmp);
|
||||
OPENSSL_free(stmp);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int kdf_main(int argc, char **argv)
|
||||
{
|
||||
int ret = 1, i, id, out_bin = 0;
|
||||
int ret = 1, out_bin = 0;
|
||||
OPTION_CHOICE o;
|
||||
STACK_OF(OPENSSL_STRING) *opts = NULL;
|
||||
char *prog, *hexout = NULL;
|
||||
@@ -62,6 +45,7 @@ int kdf_main(int argc, char **argv)
|
||||
unsigned char *dkm_bytes = NULL;
|
||||
size_t dkm_len = 0;
|
||||
BIO *out = NULL;
|
||||
EVP_KDF *kdf = NULL;
|
||||
EVP_KDF_CTX *ctx = NULL;
|
||||
|
||||
prog = opt_init(argc, argv, kdf_options);
|
||||
@@ -100,25 +84,31 @@ opthelp:
|
||||
goto opthelp;
|
||||
}
|
||||
|
||||
id = OBJ_sn2nid(argv[0]);
|
||||
if (id == NID_undef) {
|
||||
if ((kdf = EVP_KDF_fetch(NULL, argv[0], NULL)) == NULL) {
|
||||
BIO_printf(bio_err, "Invalid KDF name %s\n", argv[0]);
|
||||
goto opthelp;
|
||||
}
|
||||
|
||||
ctx = EVP_KDF_CTX_new_id(id);
|
||||
ctx = EVP_KDF_CTX_new(kdf);
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
|
||||
if (opts != NULL) {
|
||||
for (i = 0; i < sk_OPENSSL_STRING_num(opts); i++) {
|
||||
char *opt = sk_OPENSSL_STRING_value(opts, i);
|
||||
if (kdf_ctrl_string(ctx, opt) <= 0) {
|
||||
BIO_printf(bio_err, "KDF parameter error '%s'\n", opt);
|
||||
ERR_print_errors(bio_err);
|
||||
goto err;
|
||||
}
|
||||
int ok = 1;
|
||||
OSSL_PARAM *params =
|
||||
app_params_new_from_opts(opts, EVP_KDF_CTX_settable_params(kdf));
|
||||
|
||||
if (params == NULL)
|
||||
goto err;
|
||||
|
||||
if (!EVP_KDF_CTX_set_params(ctx, params)) {
|
||||
BIO_printf(bio_err, "KDF parameter error\n");
|
||||
ERR_print_errors(bio_err);
|
||||
ok = 0;
|
||||
}
|
||||
app_params_free(params);
|
||||
if (!ok)
|
||||
goto err;
|
||||
}
|
||||
|
||||
out = bio_open_default(outfile, 'w', out_bin ? FORMAT_BINARY : FORMAT_TEXT);
|
||||
@@ -151,6 +141,7 @@ err:
|
||||
ERR_print_errors(bio_err);
|
||||
OPENSSL_clear_free(dkm_bytes, dkm_len);
|
||||
sk_OPENSSL_STRING_free(opts);
|
||||
EVP_KDF_free(kdf);
|
||||
EVP_KDF_CTX_free(ctx);
|
||||
BIO_free(out);
|
||||
OPENSSL_free(hexout);
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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 "apps.h"
|
||||
#include "app_params.h"
|
||||
|
||||
static int describe_param_type(char *buf, size_t bufsz, const OSSL_PARAM *param)
|
||||
{
|
||||
const char *type_mod = "";
|
||||
const char *type = NULL;
|
||||
int show_type_number = 0;
|
||||
int printed_len;
|
||||
|
||||
switch (param->data_type) {
|
||||
case OSSL_PARAM_UNSIGNED_INTEGER:
|
||||
type_mod = "unsigned ";
|
||||
/* FALLTHRU */
|
||||
case OSSL_PARAM_INTEGER:
|
||||
type = "integer";
|
||||
break;
|
||||
case OSSL_PARAM_UTF8_PTR:
|
||||
type_mod = "pointer to a ";
|
||||
/* FALLTHRU */
|
||||
case OSSL_PARAM_UTF8_STRING:
|
||||
type = "UTF8 encoded string";
|
||||
break;
|
||||
case OSSL_PARAM_OCTET_PTR:
|
||||
type_mod = "pointer to an ";
|
||||
/* FALLTHRU */
|
||||
case OSSL_PARAM_OCTET_STRING:
|
||||
type = "octet string";
|
||||
break;
|
||||
default:
|
||||
type = "unknown type";
|
||||
show_type_number = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
printed_len = BIO_snprintf(buf, bufsz, "%s: ", param->key);
|
||||
if (printed_len > 0) {
|
||||
buf += printed_len;
|
||||
bufsz -= printed_len;
|
||||
}
|
||||
printed_len = BIO_snprintf(buf, bufsz, "%s%s", type_mod, type);
|
||||
if (printed_len > 0) {
|
||||
buf += printed_len;
|
||||
bufsz -= printed_len;
|
||||
}
|
||||
if (show_type_number) {
|
||||
printed_len = BIO_snprintf(buf, bufsz, " [%d]", param->data_type);
|
||||
if (printed_len > 0) {
|
||||
buf += printed_len;
|
||||
bufsz -= printed_len;
|
||||
}
|
||||
}
|
||||
if (param->data_size == 0)
|
||||
printed_len = BIO_snprintf(buf, bufsz, " (arbitrary size)");
|
||||
else
|
||||
printed_len = BIO_snprintf(buf, bufsz, " (max %zu bytes large)",
|
||||
param->data_size);
|
||||
if (printed_len > 0) {
|
||||
buf += printed_len;
|
||||
bufsz -= printed_len;
|
||||
}
|
||||
*buf = '\0';
|
||||
return 1;
|
||||
}
|
||||
|
||||
int print_param_types(const char *thing, const OSSL_PARAM *pdefs, int indent)
|
||||
{
|
||||
if (pdefs == NULL) {
|
||||
BIO_printf(bio_out, "%*sNo declared %s\n", indent, "", thing);
|
||||
} else if (pdefs->key == NULL) {
|
||||
/*
|
||||
* An empty list? This shouldn't happen, but let's just make sure to
|
||||
* say something if there's a badly written provider...
|
||||
*/
|
||||
BIO_printf(bio_out, "%*sEmpty list of %s (!!!)\n", indent, "", thing);
|
||||
} else {
|
||||
BIO_printf(bio_out, "%*s%s:\n", indent, "", thing);
|
||||
for (; pdefs->key != NULL; pdefs++) {
|
||||
char buf[200]; /* This should be ample space */
|
||||
|
||||
describe_param_type(buf, sizeof(buf), pdefs);
|
||||
BIO_printf(bio_out, "%*s %s\n", indent, "", buf);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#endif
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include "s_apps.h"
|
||||
#include "apps.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -48,6 +47,14 @@ static int WIN32_rename(const char *from, const char *to);
|
||||
# define rename(from,to) WIN32_rename((from),(to))
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
|
||||
# include <conio.h>
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_SYS_MSDOS) && !defined(_WIN32)
|
||||
# define _kbhit kbhit
|
||||
#endif
|
||||
|
||||
#define PASS_SOURCE_SIZE_MAX 4
|
||||
|
||||
typedef struct {
|
||||
@@ -1388,8 +1395,8 @@ CA_DB *load_index(const char *dbfile, DB_ATTR *db_attr)
|
||||
#ifndef OPENSSL_NO_POSIX_IO
|
||||
BIO_get_fp(in, &dbfp);
|
||||
if (fstat(fileno(dbfp), &dbst) == -1) {
|
||||
SYSerr(SYS_F_FSTAT, errno);
|
||||
ERR_add_error_data(3, "fstat('", dbfile, "')");
|
||||
ERR_raise_data(ERR_LIB_SYS, errno,
|
||||
"calling fstat(%s)", dbfile);
|
||||
ERR_print_errors(bio_err);
|
||||
goto err;
|
||||
}
|
||||
@@ -2559,3 +2566,53 @@ int opt_printf_stderr(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
OSSL_PARAM *app_params_new_from_opts(STACK_OF(OPENSSL_STRING) *opts,
|
||||
const OSSL_PARAM *paramdefs)
|
||||
{
|
||||
OSSL_PARAM *params = NULL;
|
||||
size_t sz = (size_t)sk_OPENSSL_STRING_num(opts);
|
||||
size_t params_n;
|
||||
char *opt = "", *stmp, *vtmp = NULL;
|
||||
|
||||
if (opts == NULL)
|
||||
return NULL;
|
||||
|
||||
params = OPENSSL_zalloc(sizeof(OSSL_PARAM) * (sz + 1));
|
||||
if (params == NULL)
|
||||
return NULL;
|
||||
|
||||
for (params_n = 0; params_n < sz; params_n++) {
|
||||
opt = sk_OPENSSL_STRING_value(opts, (int)params_n);
|
||||
if ((stmp = OPENSSL_strdup(opt)) == NULL
|
||||
|| (vtmp = strchr(stmp, ':')) == NULL)
|
||||
goto err;
|
||||
/* Replace ':' with 0 to terminate the string pointed to by stmp */
|
||||
*vtmp = 0;
|
||||
/* Skip over the separator so that vmtp points to the value */
|
||||
vtmp++;
|
||||
if (!OSSL_PARAM_allocate_from_text(¶ms[params_n], paramdefs,
|
||||
stmp, vtmp, strlen(vtmp)))
|
||||
goto err;
|
||||
OPENSSL_free(stmp);
|
||||
}
|
||||
params[params_n] = OSSL_PARAM_construct_end();
|
||||
return params;
|
||||
err:
|
||||
OPENSSL_free(stmp);
|
||||
BIO_printf(bio_err, "Parameter error '%s'\n", opt);
|
||||
ERR_print_errors(bio_err);
|
||||
app_params_free(params);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void app_params_free(OSSL_PARAM *params)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (params != NULL) {
|
||||
for (i = 0; params[i].key != NULL; ++i)
|
||||
OPENSSL_free(params[i].data);
|
||||
OPENSSL_free(params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Auxilliary program source
|
||||
IF[{- $config{target} =~ /^(?:VC-|mingw)/ -}]
|
||||
# It's called 'init', but doesn't have much 'init' in it...
|
||||
$AUXLIBAPPSSRC=win32_init.c
|
||||
ENDIF
|
||||
IF[{- $config{target} =~ /^vms-/ -}]
|
||||
$AUXLIBAPPSSRC=vms_term_sock.c vms_decc_argv.c
|
||||
ENDIF
|
||||
|
||||
# Source for libapps
|
||||
$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
|
||||
|
||||
IF[{- !$disabled{apps} -}]
|
||||
LIBS{noinst}=../libapps.a
|
||||
SOURCE[../libapps.a]=$LIBAPPSSRC $AUXLIBAPPSSRC
|
||||
INCLUDE[../libapps.a]=../.. ../../include ../include
|
||||
ENDIF
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2017-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 "apps.h"
|
||||
#include "function.h"
|
||||
|
||||
void calculate_columns(FUNCTION *functions, DISPLAY_COLUMNS *dc)
|
||||
{
|
||||
FUNCTION *f;
|
||||
int len, maxlen = 0;
|
||||
|
||||
for (f = functions; f->name != NULL; ++f)
|
||||
if (f->type == FT_general || f->type == FT_md || f->type == FT_cipher)
|
||||
if ((len = strlen(f->name)) > maxlen)
|
||||
maxlen = len;
|
||||
|
||||
dc->width = maxlen + 2;
|
||||
dc->columns = (80 - 1) / dc->width;
|
||||
}
|
||||
|
||||
+42
-30
@@ -28,6 +28,7 @@
|
||||
#define MAX_OPT_HELP_WIDTH 30
|
||||
const char OPT_HELP_STR[] = "--";
|
||||
const char OPT_MORE_STR[] = "---";
|
||||
const char OPT_SECTION_STR[] = "----";
|
||||
|
||||
/* Our state */
|
||||
static char **argv;
|
||||
@@ -133,7 +134,8 @@ char *opt_init(int ac, char **av, const OPTIONS *o)
|
||||
int duplicated, i;
|
||||
#endif
|
||||
|
||||
if (o->name == OPT_HELP_STR || o->name == OPT_MORE_STR)
|
||||
if (o->name == OPT_HELP_STR || o->name == OPT_MORE_STR ||
|
||||
o->name == OPT_SECTION_STR)
|
||||
continue;
|
||||
#ifndef NDEBUG
|
||||
i = o->valtype;
|
||||
@@ -832,40 +834,16 @@ static const char *valtype2param(const OPTIONS *o)
|
||||
return "parm";
|
||||
}
|
||||
|
||||
void opt_help(const OPTIONS *list)
|
||||
void opt_print(const OPTIONS *o, int width)
|
||||
{
|
||||
const OPTIONS *o;
|
||||
int i;
|
||||
int standard_prolog;
|
||||
int width = 5;
|
||||
const char* help;
|
||||
char start[80 + 1];
|
||||
char *p;
|
||||
const char *help;
|
||||
|
||||
/* Starts with its own help message? */
|
||||
standard_prolog = list[0].name != OPT_HELP_STR;
|
||||
|
||||
/* Find the widest help. */
|
||||
for (o = list; o->name; o++) {
|
||||
if (o->name == OPT_MORE_STR)
|
||||
continue;
|
||||
i = 2 + (int)strlen(o->name);
|
||||
if (o->valtype != '-')
|
||||
i += 1 + strlen(valtype2param(o));
|
||||
if (i < MAX_OPT_HELP_WIDTH && i > width)
|
||||
width = i;
|
||||
OPENSSL_assert(i < (int)sizeof(start));
|
||||
}
|
||||
|
||||
if (standard_prolog)
|
||||
opt_printf_stderr("Usage: %s [options]\nValid options are:\n", prog);
|
||||
|
||||
/* Now let's print. */
|
||||
for (o = list; o->name; o++) {
|
||||
help = o->helpstr ? o->helpstr : "(No additional info)";
|
||||
if (o->name == OPT_HELP_STR) {
|
||||
if (o->name == OPT_HELP_STR || o->name == OPT_SECTION_STR) {
|
||||
opt_printf_stderr(help, prog);
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Pad out prefix */
|
||||
@@ -876,7 +854,7 @@ void opt_help(const OPTIONS *list)
|
||||
/* Continuation of previous line; pad and print. */
|
||||
start[width] = '\0';
|
||||
opt_printf_stderr("%s %s\n", start, help);
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Build up the "-flag [param]" part. */
|
||||
@@ -899,6 +877,40 @@ void opt_help(const OPTIONS *list)
|
||||
}
|
||||
start[width] = '\0';
|
||||
opt_printf_stderr("%s %s\n", start, help);
|
||||
}
|
||||
|
||||
void opt_help(const OPTIONS *list)
|
||||
{
|
||||
const OPTIONS *o;
|
||||
int i;
|
||||
int standard_prolog;
|
||||
int width = 5;
|
||||
char start[80 + 1];
|
||||
|
||||
/* Starts with its own help message? */
|
||||
standard_prolog = list[0].name != OPT_HELP_STR;
|
||||
|
||||
/* Find the widest help. */
|
||||
for (o = list; o->name; o++) {
|
||||
if (o->name == OPT_MORE_STR)
|
||||
continue;
|
||||
i = 2 + (int)strlen(o->name);
|
||||
if (o->valtype != '-')
|
||||
i += 1 + strlen(valtype2param(o));
|
||||
if (i < MAX_OPT_HELP_WIDTH && i > width)
|
||||
width = i;
|
||||
OPENSSL_assert(i < (int)sizeof(start));
|
||||
}
|
||||
|
||||
if (standard_prolog) {
|
||||
opt_printf_stderr("Usage: %s [options]\n", prog);
|
||||
if (list[0].name != OPT_SECTION_STR)
|
||||
opt_printf_stderr("Valid options are:\n", prog);
|
||||
}
|
||||
|
||||
/* Now let's print. */
|
||||
for (o = list; o->name; o++) {
|
||||
opt_print(o, width);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1508,7 +1508,8 @@ void print_ca_names(BIO *bio, SSL *s)
|
||||
int i;
|
||||
|
||||
if (sk == NULL || sk_X509_NAME_num(sk) == 0) {
|
||||
BIO_printf(bio, "---\nNo %s certificate CA names sent\n", cs);
|
||||
if (!SSL_is_server(s))
|
||||
BIO_printf(bio, "---\nNo %s certificate CA names sent\n", cs);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -238,8 +238,8 @@ int TerminalSocket (int FunctionCode, int *ReturnSocket)
|
||||
}
|
||||
|
||||
/*
|
||||
** Deassign the terminal channel
|
||||
*/
|
||||
** Deassign the terminal channel
|
||||
*/
|
||||
status = sys$dassgn (TerminalDeviceChan);
|
||||
if (! (status & 1)) {
|
||||
LogMessage ("TerminalSocket: SYS$DASSGN () - %08X", status);
|
||||
@@ -255,15 +255,15 @@ int TerminalSocket (int FunctionCode, int *ReturnSocket)
|
||||
close (TerminalSocketPair[1]);
|
||||
|
||||
/*
|
||||
** Return the initialized socket
|
||||
*/
|
||||
** Return the initialized socket
|
||||
*/
|
||||
*ReturnSocket = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
/*
|
||||
** Invalid function code
|
||||
*/
|
||||
** Invalid function code
|
||||
*/
|
||||
LogMessage ("TerminalSocket: Invalid Function Code - %d", FunctionCode);
|
||||
return TERM_SOCK_FAILURE;
|
||||
break;
|
||||
+739
@@ -0,0 +1,739 @@
|
||||
/*
|
||||
* Copyright 1995-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/evp.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/safestack.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include "apps.h"
|
||||
#include "app_params.h"
|
||||
#include "progs.h"
|
||||
#include "opt.h"
|
||||
|
||||
static int verbose = 0;
|
||||
|
||||
static void legacy_cipher_fn(const EVP_CIPHER *c,
|
||||
const char *from, const char *to, void *arg)
|
||||
{
|
||||
if (c != NULL) {
|
||||
BIO_printf(arg, " %s\n", EVP_CIPHER_name(c));
|
||||
} else {
|
||||
if (from == NULL)
|
||||
from = "<undefined>";
|
||||
if (to == NULL)
|
||||
to = "<undefined>";
|
||||
BIO_printf(arg, " %s => %s\n", from, to);
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_STACK_OF(EVP_CIPHER)
|
||||
static int cipher_cmp(const EVP_CIPHER * const *a,
|
||||
const EVP_CIPHER * const *b)
|
||||
{
|
||||
int ret = strcasecmp(EVP_CIPHER_name(*a), EVP_CIPHER_name(*b));
|
||||
|
||||
if (ret == 0)
|
||||
ret = strcmp(OSSL_PROVIDER_name(EVP_CIPHER_provider(*a)),
|
||||
OSSL_PROVIDER_name(EVP_CIPHER_provider(*b)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void collect_ciphers(EVP_CIPHER *cipher, void *stack)
|
||||
{
|
||||
STACK_OF(EVP_CIPHER) *cipher_stack = stack;
|
||||
|
||||
if (sk_EVP_CIPHER_push(cipher_stack, cipher) > 0)
|
||||
EVP_CIPHER_up_ref(cipher);
|
||||
}
|
||||
|
||||
static void list_ciphers(void)
|
||||
{
|
||||
STACK_OF(EVP_CIPHER) *ciphers = sk_EVP_CIPHER_new(cipher_cmp);
|
||||
int i;
|
||||
|
||||
BIO_printf(bio_out, "Legacy:\n");
|
||||
EVP_CIPHER_do_all_sorted(legacy_cipher_fn, bio_out);
|
||||
|
||||
BIO_printf(bio_out, "Provided:\n");
|
||||
EVP_CIPHER_do_all_ex(NULL, collect_ciphers, ciphers);
|
||||
sk_EVP_CIPHER_sort(ciphers);
|
||||
for (i = 0; i < sk_EVP_CIPHER_num(ciphers); i++) {
|
||||
const EVP_CIPHER *c = sk_EVP_CIPHER_value(ciphers, i);
|
||||
|
||||
BIO_printf(bio_out, " %s", EVP_CIPHER_name(c));
|
||||
BIO_printf(bio_out, " @ %s\n",
|
||||
OSSL_PROVIDER_name(EVP_CIPHER_provider(c)));
|
||||
if (verbose) {
|
||||
print_param_types("retrievable algorithm parameters",
|
||||
EVP_CIPHER_gettable_params(c), 4);
|
||||
print_param_types("retrievable operation parameters",
|
||||
EVP_CIPHER_CTX_gettable_params(c), 4);
|
||||
print_param_types("settable operation parameters",
|
||||
EVP_CIPHER_CTX_settable_params(c), 4);
|
||||
}
|
||||
}
|
||||
sk_EVP_CIPHER_pop_free(ciphers, EVP_CIPHER_free);
|
||||
}
|
||||
|
||||
static void list_md_fn(const EVP_MD *m,
|
||||
const char *from, const char *to, void *arg)
|
||||
{
|
||||
if (m != NULL) {
|
||||
BIO_printf(arg, " %s\n", EVP_MD_name(m));
|
||||
} else {
|
||||
if (from == NULL)
|
||||
from = "<undefined>";
|
||||
if (to == NULL)
|
||||
to = "<undefined>";
|
||||
BIO_printf((BIO *)arg, " %s => %s\n", from, to);
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_STACK_OF(EVP_MD)
|
||||
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));
|
||||
|
||||
if (ret == 0)
|
||||
ret = strcmp(OSSL_PROVIDER_name(EVP_MD_provider(*a)),
|
||||
OSSL_PROVIDER_name(EVP_MD_provider(*b)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void collect_digests(EVP_MD *md, void *stack)
|
||||
{
|
||||
STACK_OF(EVP_MD) *digest_stack = stack;
|
||||
|
||||
if (sk_EVP_MD_push(digest_stack, md) > 0)
|
||||
EVP_MD_up_ref(md);
|
||||
}
|
||||
|
||||
static void list_digests(void)
|
||||
{
|
||||
STACK_OF(EVP_MD) *digests = sk_EVP_MD_new(md_cmp);
|
||||
int i;
|
||||
|
||||
BIO_printf(bio_out, "Legacy:\n");
|
||||
EVP_MD_do_all_sorted(list_md_fn, bio_out);
|
||||
|
||||
BIO_printf(bio_out, "Provided:\n");
|
||||
EVP_MD_do_all_ex(NULL, collect_digests, digests);
|
||||
sk_EVP_MD_sort(digests);
|
||||
for (i = 0; i < sk_EVP_MD_num(digests); i++) {
|
||||
const EVP_MD *m = sk_EVP_MD_value(digests, i);
|
||||
|
||||
BIO_printf(bio_out, " %s", EVP_MD_name(m));
|
||||
BIO_printf(bio_out, " @ %s\n",
|
||||
OSSL_PROVIDER_name(EVP_MD_provider(m)));
|
||||
if (verbose) {
|
||||
print_param_types("retrievable algorithm parameters",
|
||||
EVP_MD_gettable_params(m), 4);
|
||||
print_param_types("retrievable operation parameters",
|
||||
EVP_MD_CTX_gettable_params(m), 4);
|
||||
print_param_types("settable operation parameters",
|
||||
EVP_MD_CTX_settable_params(m), 4);
|
||||
}
|
||||
}
|
||||
sk_EVP_MD_pop_free(digests, EVP_MD_free);
|
||||
}
|
||||
|
||||
DEFINE_STACK_OF(EVP_MAC)
|
||||
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));
|
||||
|
||||
if (ret == 0)
|
||||
ret = strcmp(OSSL_PROVIDER_name(EVP_MAC_provider(*a)),
|
||||
OSSL_PROVIDER_name(EVP_MAC_provider(*b)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void collect_macs(EVP_MAC *mac, void *stack)
|
||||
{
|
||||
STACK_OF(EVP_MAC) *mac_stack = stack;
|
||||
|
||||
if (sk_EVP_MAC_push(mac_stack, mac) > 0)
|
||||
EVP_MAC_up_ref(mac);
|
||||
}
|
||||
|
||||
static void list_macs(void)
|
||||
{
|
||||
STACK_OF(EVP_MAC) *macs = sk_EVP_MAC_new(mac_cmp);
|
||||
int i;
|
||||
|
||||
BIO_printf(bio_out, "Provided MACs:\n");
|
||||
EVP_MAC_do_all_ex(NULL, collect_macs, macs);
|
||||
sk_EVP_MAC_sort(macs);
|
||||
for (i = 0; i < sk_EVP_MAC_num(macs); i++) {
|
||||
const EVP_MAC *m = sk_EVP_MAC_value(macs, i);
|
||||
|
||||
BIO_printf(bio_out, " %s", EVP_MAC_name(m));
|
||||
BIO_printf(bio_out, " @ %s\n",
|
||||
OSSL_PROVIDER_name(EVP_MAC_provider(m)));
|
||||
|
||||
if (verbose) {
|
||||
print_param_types("retrievable algorithm parameters",
|
||||
EVP_MAC_gettable_params(m), 4);
|
||||
print_param_types("retrievable operation parameters",
|
||||
EVP_MAC_CTX_gettable_params(m), 4);
|
||||
print_param_types("settable operation parameters",
|
||||
EVP_MAC_CTX_settable_params(m), 4);
|
||||
}
|
||||
}
|
||||
sk_EVP_MAC_pop_free(macs, EVP_MAC_free);
|
||||
}
|
||||
|
||||
/*
|
||||
* KDFs and PRFs
|
||||
*/
|
||||
DEFINE_STACK_OF(EVP_KDF)
|
||||
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));
|
||||
|
||||
if (ret == 0)
|
||||
ret = strcmp(OSSL_PROVIDER_name(EVP_KDF_provider(*a)),
|
||||
OSSL_PROVIDER_name(EVP_KDF_provider(*b)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void collect_kdfs(EVP_KDF *kdf, void *stack)
|
||||
{
|
||||
STACK_OF(EVP_KDF) *kdf_stack = stack;
|
||||
|
||||
sk_EVP_KDF_push(kdf_stack, kdf);
|
||||
EVP_KDF_up_ref(kdf);
|
||||
}
|
||||
|
||||
static void list_kdfs(void)
|
||||
{
|
||||
STACK_OF(EVP_KDF) *kdfs = sk_EVP_KDF_new(kdf_cmp);
|
||||
int i;
|
||||
|
||||
BIO_printf(bio_out, "Provided KDFs and PDFs:\n");
|
||||
EVP_KDF_do_all_ex(NULL, collect_kdfs, kdfs);
|
||||
sk_EVP_KDF_sort(kdfs);
|
||||
for (i = 0; i < sk_EVP_KDF_num(kdfs); i++) {
|
||||
const EVP_KDF *m = sk_EVP_KDF_value(kdfs, i);
|
||||
|
||||
BIO_printf(bio_out, " %s", EVP_KDF_name(m));
|
||||
BIO_printf(bio_out, " @ %s\n",
|
||||
OSSL_PROVIDER_name(EVP_KDF_provider(m)));
|
||||
|
||||
if (verbose) {
|
||||
print_param_types("retrievable algorithm parameters",
|
||||
EVP_KDF_gettable_params(m), 4);
|
||||
print_param_types("retrievable operation parameters",
|
||||
EVP_KDF_CTX_gettable_params(m), 4);
|
||||
print_param_types("settable operation parameters",
|
||||
EVP_KDF_CTX_settable_params(m), 4);
|
||||
}
|
||||
}
|
||||
sk_EVP_KDF_pop_free(kdfs, EVP_KDF_free);
|
||||
}
|
||||
|
||||
static void list_missing_help(void)
|
||||
{
|
||||
const FUNCTION *fp;
|
||||
const OPTIONS *o;
|
||||
|
||||
for (fp = functions; fp->name != NULL; fp++) {
|
||||
if ((o = fp->help) != NULL) {
|
||||
/* If there is help, list what flags are not documented. */
|
||||
for ( ; o->name != NULL; o++) {
|
||||
if (o->helpstr == NULL)
|
||||
BIO_printf(bio_out, "%s %s\n", fp->name, o->name);
|
||||
}
|
||||
} else if (fp->func != dgst_main) {
|
||||
/* If not aliased to the dgst command, */
|
||||
BIO_printf(bio_out, "%s *\n", fp->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void list_objects(void)
|
||||
{
|
||||
int max_nid = OBJ_new_nid(0);
|
||||
int i;
|
||||
char *oid_buf = NULL;
|
||||
int oid_size = 0;
|
||||
|
||||
/* Skip 0, since that's NID_undef */
|
||||
for (i = 1; i < max_nid; i++) {
|
||||
const ASN1_OBJECT *obj = OBJ_nid2obj(i);
|
||||
const char *sn = OBJ_nid2sn(i);
|
||||
const char *ln = OBJ_nid2ln(i);
|
||||
int n = 0;
|
||||
|
||||
/*
|
||||
* If one of the retrieved objects somehow generated an error,
|
||||
* we ignore it. The check for NID_undef below will detect the
|
||||
* error and simply skip to the next NID.
|
||||
*/
|
||||
ERR_clear_error();
|
||||
|
||||
if (OBJ_obj2nid(obj) == NID_undef)
|
||||
continue;
|
||||
|
||||
if ((n = OBJ_obj2txt(NULL, 0, obj, 1)) == 0) {
|
||||
BIO_printf(bio_out, "# None-OID object: %s, %s\n", sn, ln);
|
||||
continue;
|
||||
}
|
||||
if (n < 0)
|
||||
break; /* Error */
|
||||
|
||||
if (n > oid_size) {
|
||||
oid_buf = OPENSSL_realloc(oid_buf, n + 1);
|
||||
if (oid_buf == NULL) {
|
||||
BIO_printf(bio_err, "ERROR: Memory allocation\n");
|
||||
break; /* Error */
|
||||
}
|
||||
oid_size = n + 1;
|
||||
}
|
||||
if (OBJ_obj2txt(oid_buf, oid_size, obj, 1) < 0)
|
||||
break; /* Error */
|
||||
if (ln == NULL || strcmp(sn, ln) == 0)
|
||||
BIO_printf(bio_out, "%s = %s\n", sn, oid_buf);
|
||||
else
|
||||
BIO_printf(bio_out, "%s = %s, %s\n", sn, ln, oid_buf);
|
||||
}
|
||||
|
||||
OPENSSL_free(oid_buf);
|
||||
}
|
||||
|
||||
static void list_options_for_command(const char *command)
|
||||
{
|
||||
const FUNCTION *fp;
|
||||
const OPTIONS *o;
|
||||
|
||||
for (fp = functions; fp->name != NULL; fp++)
|
||||
if (strcmp(fp->name, command) == 0)
|
||||
break;
|
||||
if (fp->name == NULL) {
|
||||
BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
|
||||
command);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((o = fp->help) == NULL)
|
||||
return;
|
||||
|
||||
for ( ; o->name != NULL; o++) {
|
||||
if (o->name == OPT_HELP_STR
|
||||
|| o->name == OPT_MORE_STR
|
||||
|| o->name[0] == '\0')
|
||||
continue;
|
||||
BIO_printf(bio_out, "%s %c\n", o->name, o->valtype);
|
||||
}
|
||||
}
|
||||
|
||||
static void list_type(FUNC_TYPE ft, int one)
|
||||
{
|
||||
FUNCTION *fp;
|
||||
int i = 0;
|
||||
DISPLAY_COLUMNS dc;
|
||||
|
||||
memset(&dc, 0, sizeof(dc));
|
||||
if (!one)
|
||||
calculate_columns(functions, &dc);
|
||||
|
||||
for (fp = functions; fp->name != NULL; fp++) {
|
||||
if (fp->type != ft)
|
||||
continue;
|
||||
if (one) {
|
||||
BIO_printf(bio_out, "%s\n", fp->name);
|
||||
} else {
|
||||
if (i % dc.columns == 0 && i > 0)
|
||||
BIO_printf(bio_out, "\n");
|
||||
BIO_printf(bio_out, "%-*s", dc.width, fp->name);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!one)
|
||||
BIO_printf(bio_out, "\n\n");
|
||||
}
|
||||
|
||||
static void list_pkey(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
|
||||
const EVP_PKEY_ASN1_METHOD *ameth;
|
||||
int pkey_id, pkey_base_id, pkey_flags;
|
||||
const char *pinfo, *pem_str;
|
||||
ameth = EVP_PKEY_asn1_get0(i);
|
||||
EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
|
||||
&pinfo, &pem_str, ameth);
|
||||
if (pkey_flags & ASN1_PKEY_ALIAS) {
|
||||
BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
|
||||
BIO_printf(bio_out, "\tAlias for: %s\n",
|
||||
OBJ_nid2ln(pkey_base_id));
|
||||
} else {
|
||||
BIO_printf(bio_out, "Name: %s\n", pinfo);
|
||||
BIO_printf(bio_out, "\tType: %s Algorithm\n",
|
||||
pkey_flags & ASN1_PKEY_DYNAMIC ?
|
||||
"External" : "Builtin");
|
||||
BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
|
||||
if (pem_str == NULL)
|
||||
pem_str = "(none)";
|
||||
BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void list_pkey_meth(void)
|
||||
{
|
||||
size_t i;
|
||||
size_t meth_count = EVP_PKEY_meth_get_count();
|
||||
|
||||
for (i = 0; i < meth_count; i++) {
|
||||
const EVP_PKEY_METHOD *pmeth = EVP_PKEY_meth_get0(i);
|
||||
int pkey_id, pkey_flags;
|
||||
|
||||
EVP_PKEY_meth_get0_info(&pkey_id, &pkey_flags, pmeth);
|
||||
BIO_printf(bio_out, "%s\n", OBJ_nid2ln(pkey_id));
|
||||
BIO_printf(bio_out, "\tType: %s Algorithm\n",
|
||||
pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin");
|
||||
}
|
||||
}
|
||||
|
||||
static void list_engines(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
ENGINE *e;
|
||||
|
||||
BIO_puts(bio_out, "Engines:\n");
|
||||
e = ENGINE_get_first();
|
||||
while (e) {
|
||||
BIO_printf(bio_out, "%s\n", ENGINE_get_id(e));
|
||||
e = ENGINE_get_next(e);
|
||||
}
|
||||
#else
|
||||
BIO_puts(bio_out, "Engine support is disabled.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void list_disabled(void)
|
||||
{
|
||||
BIO_puts(bio_out, "Disabled algorithms:\n");
|
||||
#ifdef OPENSSL_NO_ARIA
|
||||
BIO_puts(bio_out, "ARIA\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_BF
|
||||
BIO_puts(bio_out, "BF\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_BLAKE2
|
||||
BIO_puts(bio_out, "BLAKE2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_CAMELLIA
|
||||
BIO_puts(bio_out, "CAMELLIA\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_CAST
|
||||
BIO_puts(bio_out, "CAST\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_CMAC
|
||||
BIO_puts(bio_out, "CMAC\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_CMS
|
||||
BIO_puts(bio_out, "CMS\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_COMP
|
||||
BIO_puts(bio_out, "COMP\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_DES
|
||||
BIO_puts(bio_out, "DES\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_DGRAM
|
||||
BIO_puts(bio_out, "DGRAM\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_DH
|
||||
BIO_puts(bio_out, "DH\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_DSA
|
||||
BIO_puts(bio_out, "DSA\n");
|
||||
#endif
|
||||
#if defined(OPENSSL_NO_DTLS)
|
||||
BIO_puts(bio_out, "DTLS\n");
|
||||
#endif
|
||||
#if defined(OPENSSL_NO_DTLS1)
|
||||
BIO_puts(bio_out, "DTLS1\n");
|
||||
#endif
|
||||
#if defined(OPENSSL_NO_DTLS1_2)
|
||||
BIO_puts(bio_out, "DTLS1_2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_EC
|
||||
BIO_puts(bio_out, "EC\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_EC2M
|
||||
BIO_puts(bio_out, "EC2M\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_ENGINE
|
||||
BIO_puts(bio_out, "ENGINE\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_GOST
|
||||
BIO_puts(bio_out, "GOST\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_IDEA
|
||||
BIO_puts(bio_out, "IDEA\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_MD2
|
||||
BIO_puts(bio_out, "MD2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_MD4
|
||||
BIO_puts(bio_out, "MD4\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_MD5
|
||||
BIO_puts(bio_out, "MD5\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_MDC2
|
||||
BIO_puts(bio_out, "MDC2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_OCB
|
||||
BIO_puts(bio_out, "OCB\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_OCSP
|
||||
BIO_puts(bio_out, "OCSP\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_PSK
|
||||
BIO_puts(bio_out, "PSK\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_RC2
|
||||
BIO_puts(bio_out, "RC2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_RC4
|
||||
BIO_puts(bio_out, "RC4\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_RC5
|
||||
BIO_puts(bio_out, "RC5\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_RMD160
|
||||
BIO_puts(bio_out, "RMD160\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_RSA
|
||||
BIO_puts(bio_out, "RSA\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SCRYPT
|
||||
BIO_puts(bio_out, "SCRYPT\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SCTP
|
||||
BIO_puts(bio_out, "SCTP\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SEED
|
||||
BIO_puts(bio_out, "SEED\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SM2
|
||||
BIO_puts(bio_out, "SM2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SM3
|
||||
BIO_puts(bio_out, "SM3\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SM4
|
||||
BIO_puts(bio_out, "SM4\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SOCK
|
||||
BIO_puts(bio_out, "SOCK\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SRP
|
||||
BIO_puts(bio_out, "SRP\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SRTP
|
||||
BIO_puts(bio_out, "SRTP\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SSL3
|
||||
BIO_puts(bio_out, "SSL3\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_TLS1
|
||||
BIO_puts(bio_out, "TLS1\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_TLS1_1
|
||||
BIO_puts(bio_out, "TLS1_1\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_TLS1_2
|
||||
BIO_puts(bio_out, "TLS1_2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_WHIRLPOOL
|
||||
BIO_puts(bio_out, "WHIRLPOOL\n");
|
||||
#endif
|
||||
#ifndef ZLIB
|
||||
BIO_puts(bio_out, "ZLIB\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Unified enum for help and list commands. */
|
||||
typedef enum HELPLIST_CHOICE {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE, OPT_VERBOSE,
|
||||
OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
|
||||
OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
|
||||
OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_ENGINES, OPT_DISABLED,
|
||||
OPT_KDF_ALGORITHMS, OPT_MISSING_HELP, OPT_OBJECTS
|
||||
} HELPLIST_CHOICE;
|
||||
|
||||
const OPTIONS list_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"1", OPT_ONE, '-', "List in one column"},
|
||||
{"verbose", OPT_VERBOSE, '-', "Verbose listing"},
|
||||
{"commands", OPT_COMMANDS, '-', "List of standard commands"},
|
||||
{"digest-commands", OPT_DIGEST_COMMANDS, '-',
|
||||
"List of message digest commands"},
|
||||
{"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
|
||||
"List of message digest algorithms"},
|
||||
{"kdf-algorithms", OPT_KDF_ALGORITHMS, '-',
|
||||
"List of key derivation and pseudo random function algorithms"},
|
||||
{"mac-algorithms", OPT_MAC_ALGORITHMS, '-',
|
||||
"List of message authentication code algorithms"},
|
||||
{"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
|
||||
{"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
|
||||
"List of cipher algorithms"},
|
||||
{"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
|
||||
"List of public key algorithms"},
|
||||
{"public-key-methods", OPT_PK_METHOD, '-',
|
||||
"List of public key methods"},
|
||||
{"engines", OPT_ENGINES, '-',
|
||||
"List of loaded engines"},
|
||||
{"disabled", OPT_DISABLED, '-',
|
||||
"List of disabled features"},
|
||||
{"missing-help", OPT_MISSING_HELP, '-',
|
||||
"List missing detailed help strings"},
|
||||
{"options", OPT_OPTIONS, 's',
|
||||
"List options for specified command"},
|
||||
{"objects", OPT_OBJECTS, '-',
|
||||
"List built in objects (OID<->name mappings)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int list_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
HELPLIST_CHOICE o;
|
||||
int one = 0, done = 0;
|
||||
struct {
|
||||
unsigned int commands:1;
|
||||
unsigned int digest_commands:1;
|
||||
unsigned int digest_algorithms:1;
|
||||
unsigned int kdf_algorithms:1;
|
||||
unsigned int mac_algorithms:1;
|
||||
unsigned int cipher_commands:1;
|
||||
unsigned int cipher_algorithms:1;
|
||||
unsigned int pk_algorithms:1;
|
||||
unsigned int pk_method:1;
|
||||
unsigned int engines:1;
|
||||
unsigned int disabled:1;
|
||||
unsigned int missing_help:1;
|
||||
unsigned int objects:1;
|
||||
unsigned int options:1;
|
||||
} todo = { 0, };
|
||||
|
||||
verbose = 0; /* Clear a possible previous call */
|
||||
|
||||
prog = opt_init(argc, argv, list_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF: /* Never hit, but suppresses warning */
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
return 1;
|
||||
case OPT_HELP:
|
||||
opt_help(list_options);
|
||||
break;
|
||||
case OPT_ONE:
|
||||
one = 1;
|
||||
break;
|
||||
case OPT_COMMANDS:
|
||||
todo.commands = 1;
|
||||
break;
|
||||
case OPT_DIGEST_COMMANDS:
|
||||
todo.digest_commands = 1;
|
||||
break;
|
||||
case OPT_DIGEST_ALGORITHMS:
|
||||
todo.digest_algorithms = 1;
|
||||
break;
|
||||
case OPT_KDF_ALGORITHMS:
|
||||
todo.kdf_algorithms = 1;
|
||||
break;
|
||||
case OPT_MAC_ALGORITHMS:
|
||||
todo.mac_algorithms = 1;
|
||||
break;
|
||||
case OPT_CIPHER_COMMANDS:
|
||||
todo.cipher_commands = 1;
|
||||
break;
|
||||
case OPT_CIPHER_ALGORITHMS:
|
||||
todo.cipher_algorithms = 1;
|
||||
break;
|
||||
case OPT_PK_ALGORITHMS:
|
||||
todo.pk_algorithms = 1;
|
||||
break;
|
||||
case OPT_PK_METHOD:
|
||||
todo.pk_method = 1;
|
||||
break;
|
||||
case OPT_ENGINES:
|
||||
todo.engines = 1;
|
||||
break;
|
||||
case OPT_DISABLED:
|
||||
todo.disabled = 1;
|
||||
break;
|
||||
case OPT_MISSING_HELP:
|
||||
todo.missing_help = 1;
|
||||
break;
|
||||
case OPT_OBJECTS:
|
||||
todo.objects = 1;
|
||||
break;
|
||||
case OPT_OPTIONS:
|
||||
list_options_for_command(opt_arg());
|
||||
break;
|
||||
case OPT_VERBOSE:
|
||||
verbose = 1;
|
||||
break;
|
||||
}
|
||||
done = 1;
|
||||
}
|
||||
if (opt_num_rest() != 0) {
|
||||
BIO_printf(bio_err, "Extra arguments given.\n");
|
||||
goto opthelp;
|
||||
}
|
||||
|
||||
if (todo.commands)
|
||||
list_type(FT_general, one);
|
||||
if (todo.digest_commands)
|
||||
list_type(FT_md, one);
|
||||
if (todo.digest_algorithms)
|
||||
list_digests();
|
||||
if (todo.kdf_algorithms)
|
||||
list_kdfs();
|
||||
if (todo.mac_algorithms)
|
||||
list_macs();
|
||||
if (todo.cipher_commands)
|
||||
list_type(FT_cipher, one);
|
||||
if (todo.cipher_algorithms)
|
||||
list_ciphers();
|
||||
if (todo.pk_algorithms)
|
||||
list_pkey();
|
||||
if (todo.pk_method)
|
||||
list_pkey_meth();
|
||||
if (todo.engines)
|
||||
list_engines();
|
||||
if (todo.disabled)
|
||||
list_disabled();
|
||||
if (todo.missing_help)
|
||||
list_missing_help();
|
||||
if (todo.objects)
|
||||
list_objects();
|
||||
|
||||
if (!done)
|
||||
goto opthelp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
+22
-32
@@ -14,6 +14,7 @@
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/params.h>
|
||||
|
||||
#undef BUFSIZE
|
||||
#define BUFSIZE 1024*8
|
||||
@@ -28,8 +29,8 @@ const OPTIONS mac_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "mac_name\t\t MAC algorithm (See list "
|
||||
"-mac-algorithms)"},
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"macopt", OPT_MACOPT, 's', "MAC algorithm control parameters in n:v form. "
|
||||
"See 'Supported Controls' in the EVP_MAC_ docs"},
|
||||
{"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form. "
|
||||
"See 'PARAMETER NAMES' in the EVP_MAC_ docs"},
|
||||
{"in", OPT_IN, '<', "Input file to MAC (default is stdin)"},
|
||||
{"out", OPT_OUT, '>', "Output to filename rather than stdout"},
|
||||
{"binary", OPT_BIN, '-', "Output in binary format (Default is hexadecimal "
|
||||
@@ -37,29 +38,11 @@ const OPTIONS mac_options[] = {
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static int mac_ctrl_string(EVP_MAC_CTX *ctx, const char *value)
|
||||
{
|
||||
int rv;
|
||||
char *stmp, *vtmp = NULL;
|
||||
|
||||
stmp = OPENSSL_strdup(value);
|
||||
if (stmp == NULL)
|
||||
return -1;
|
||||
vtmp = strchr(stmp, ':');
|
||||
if (vtmp != NULL) {
|
||||
*vtmp = 0;
|
||||
vtmp++;
|
||||
}
|
||||
rv = EVP_MAC_ctrl_str(ctx, stmp, vtmp);
|
||||
OPENSSL_free(stmp);
|
||||
return rv;
|
||||
}
|
||||
|
||||
int mac_main(int argc, char **argv)
|
||||
{
|
||||
int ret = 1;
|
||||
char *prog;
|
||||
const EVP_MAC *mac = NULL;
|
||||
EVP_MAC *mac = NULL;
|
||||
OPTION_CHOICE o;
|
||||
EVP_MAC_CTX *ctx = NULL;
|
||||
STACK_OF(OPENSSL_STRING) *opts = NULL;
|
||||
@@ -109,7 +92,7 @@ opthelp:
|
||||
goto opthelp;
|
||||
}
|
||||
|
||||
mac = EVP_get_macbyname(argv[0]);
|
||||
mac = EVP_MAC_fetch(NULL, argv[0], NULL);
|
||||
if (mac == NULL) {
|
||||
BIO_printf(bio_err, "Invalid MAC name %s\n", argv[0]);
|
||||
goto opthelp;
|
||||
@@ -120,14 +103,21 @@ opthelp:
|
||||
goto err;
|
||||
|
||||
if (opts != NULL) {
|
||||
for (i = 0; i < sk_OPENSSL_STRING_num(opts); i++) {
|
||||
char *opt = sk_OPENSSL_STRING_value(opts, i);
|
||||
if (mac_ctrl_string(ctx, opt) <= 0) {
|
||||
BIO_printf(bio_err, "MAC parameter error '%s'\n", opt);
|
||||
ERR_print_errors(bio_err);
|
||||
goto err;
|
||||
}
|
||||
int ok = 1;
|
||||
OSSL_PARAM *params =
|
||||
app_params_new_from_opts(opts, EVP_MAC_CTX_settable_params(mac));
|
||||
|
||||
if (params == NULL)
|
||||
goto err;
|
||||
|
||||
if (!EVP_MAC_CTX_set_params(ctx, params)) {
|
||||
BIO_printf(bio_err, "MAC parameter error\n");
|
||||
ERR_print_errors(bio_err);
|
||||
ok = 0;
|
||||
}
|
||||
app_params_free(params);
|
||||
if (!ok)
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Use text mode for stdin */
|
||||
@@ -146,7 +136,6 @@ opthelp:
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
for (;;) {
|
||||
i = BIO_read(in, (char *)buf, BUFSIZE);
|
||||
if (i < 0) {
|
||||
@@ -161,7 +150,7 @@ opthelp:
|
||||
}
|
||||
}
|
||||
|
||||
if (!EVP_MAC_final(ctx, NULL, &len)) {
|
||||
if (!EVP_MAC_final(ctx, NULL, &len, 0)) {
|
||||
BIO_printf(bio_err, "EVP_MAC_final failed\n");
|
||||
goto err;
|
||||
}
|
||||
@@ -170,7 +159,7 @@ opthelp:
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!EVP_MAC_final(ctx, buf, &len)) {
|
||||
if (!EVP_MAC_final(ctx, buf, &len, BUFSIZE)) {
|
||||
BIO_printf(bio_err, "EVP_MAC_final failed\n");
|
||||
goto err;
|
||||
}
|
||||
@@ -195,5 +184,6 @@ err:
|
||||
BIO_free(in);
|
||||
BIO_free(out);
|
||||
EVP_MAC_CTX_free(ctx);
|
||||
EVP_MAC_free(mac);
|
||||
return ret;
|
||||
}
|
||||
+4
-2
@@ -1436,9 +1436,11 @@ static int do_responder(OCSP_REQUEST **preq, BIO **pcbio, BIO *acbio,
|
||||
*q = '\0';
|
||||
|
||||
/*
|
||||
* Skip "GET / HTTP..." requests often used by load-balancers
|
||||
* Skip "GET / HTTP..." requests often used by load-balancers. Note:
|
||||
* 'p' was incremented above to point to the first byte *after* the
|
||||
* leading slash, so with 'GET / ' it is now an empty string.
|
||||
*/
|
||||
if (p[1] == '\0')
|
||||
if (p[0] == '\0')
|
||||
goto out;
|
||||
|
||||
len = urldecode(p);
|
||||
|
||||
+1
-513
@@ -23,23 +23,13 @@
|
||||
# include <openssl/engine.h>
|
||||
#endif
|
||||
#include <openssl/err.h>
|
||||
#include "s_apps.h"
|
||||
/* Needed to get the other O_xxx flags. */
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
# include <unixio.h>
|
||||
#endif
|
||||
#include "apps.h"
|
||||
#define INCLUDE_FUNCTION_TABLE
|
||||
#include "progs.h"
|
||||
|
||||
/* Structure to hold the number of columns to be displayed and the
|
||||
* field width used to display them.
|
||||
*/
|
||||
typedef struct {
|
||||
int columns;
|
||||
int width;
|
||||
} DISPLAY_COLUMNS;
|
||||
|
||||
/* Special sentinel to exit the program. */
|
||||
#define EXIT_THE_PROGRAM (-1)
|
||||
|
||||
@@ -51,31 +41,12 @@ typedef struct {
|
||||
*/
|
||||
static LHASH_OF(FUNCTION) *prog_init(void);
|
||||
static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]);
|
||||
static void list_pkey(void);
|
||||
static void list_pkey_meth(void);
|
||||
static void list_type(FUNC_TYPE ft, int one);
|
||||
static void list_engines(void);
|
||||
static void list_disabled(void);
|
||||
char *default_config_file = NULL;
|
||||
|
||||
BIO *bio_in = NULL;
|
||||
BIO *bio_out = NULL;
|
||||
BIO *bio_err = NULL;
|
||||
|
||||
static void calculate_columns(DISPLAY_COLUMNS *dc)
|
||||
{
|
||||
FUNCTION *f;
|
||||
int len, maxlen = 0;
|
||||
|
||||
for (f = functions; f->name != NULL; ++f)
|
||||
if (f->type == FT_general || f->type == FT_md || f->type == FT_cipher)
|
||||
if ((len = strlen(f->name)) > maxlen)
|
||||
maxlen = len;
|
||||
|
||||
dc->width = maxlen + 2;
|
||||
dc->columns = (80 - 1) / dc->width;
|
||||
}
|
||||
|
||||
static int apps_startup(void)
|
||||
{
|
||||
#ifdef SIGPIPE
|
||||
@@ -408,256 +379,6 @@ int main(int argc, char *argv[])
|
||||
EXIT(ret);
|
||||
}
|
||||
|
||||
static void list_cipher_fn(const EVP_CIPHER *c,
|
||||
const char *from, const char *to, void *arg)
|
||||
{
|
||||
if (c != NULL) {
|
||||
BIO_printf(arg, "%s\n", EVP_CIPHER_name(c));
|
||||
} else {
|
||||
if (from == NULL)
|
||||
from = "<undefined>";
|
||||
if (to == NULL)
|
||||
to = "<undefined>";
|
||||
BIO_printf(arg, "%s => %s\n", from, to);
|
||||
}
|
||||
}
|
||||
|
||||
static void list_md_fn(const EVP_MD *m,
|
||||
const char *from, const char *to, void *arg)
|
||||
{
|
||||
if (m != NULL) {
|
||||
BIO_printf(arg, "%s\n", EVP_MD_name(m));
|
||||
} else {
|
||||
if (from == NULL)
|
||||
from = "<undefined>";
|
||||
if (to == NULL)
|
||||
to = "<undefined>";
|
||||
BIO_printf((BIO *)arg, "%s => %s\n", from, to);
|
||||
}
|
||||
}
|
||||
|
||||
static void list_mac_fn(const EVP_MAC *m,
|
||||
const char *from, const char *to, void *arg)
|
||||
{
|
||||
if (m != NULL) {
|
||||
BIO_printf(arg, "%s\n", EVP_MAC_name(m));
|
||||
} else {
|
||||
if (from == NULL)
|
||||
from = "<undefined>";
|
||||
if (to == NULL)
|
||||
to = "<undefined>";
|
||||
BIO_printf(arg, "%s => %s\n", from, to);
|
||||
}
|
||||
}
|
||||
|
||||
static void list_missing_help(void)
|
||||
{
|
||||
const FUNCTION *fp;
|
||||
const OPTIONS *o;
|
||||
|
||||
for (fp = functions; fp->name != NULL; fp++) {
|
||||
if ((o = fp->help) != NULL) {
|
||||
/* If there is help, list what flags are not documented. */
|
||||
for ( ; o->name != NULL; o++) {
|
||||
if (o->helpstr == NULL)
|
||||
BIO_printf(bio_out, "%s %s\n", fp->name, o->name);
|
||||
}
|
||||
} else if (fp->func != dgst_main) {
|
||||
/* If not aliased to the dgst command, */
|
||||
BIO_printf(bio_out, "%s *\n", fp->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void list_objects(void)
|
||||
{
|
||||
int max_nid = OBJ_new_nid(0);
|
||||
int i;
|
||||
char *oid_buf = NULL;
|
||||
int oid_size = 0;
|
||||
|
||||
/* Skip 0, since that's NID_undef */
|
||||
for (i = 1; i < max_nid; i++) {
|
||||
const ASN1_OBJECT *obj = OBJ_nid2obj(i);
|
||||
const char *sn = OBJ_nid2sn(i);
|
||||
const char *ln = OBJ_nid2ln(i);
|
||||
int n = 0;
|
||||
|
||||
/*
|
||||
* If one of the retrieved objects somehow generated an error,
|
||||
* we ignore it. The check for NID_undef below will detect the
|
||||
* error and simply skip to the next NID.
|
||||
*/
|
||||
ERR_clear_error();
|
||||
|
||||
if (OBJ_obj2nid(obj) == NID_undef)
|
||||
continue;
|
||||
|
||||
if ((n = OBJ_obj2txt(NULL, 0, obj, 1)) == 0) {
|
||||
BIO_printf(bio_out, "# None-OID object: %s, %s\n", sn, ln);
|
||||
continue;
|
||||
}
|
||||
if (n < 0)
|
||||
break; /* Error */
|
||||
|
||||
if (n > oid_size) {
|
||||
oid_buf = OPENSSL_realloc(oid_buf, n + 1);
|
||||
if (oid_buf == NULL) {
|
||||
BIO_printf(bio_err, "ERROR: Memory allocation\n");
|
||||
break; /* Error */
|
||||
}
|
||||
oid_size = n + 1;
|
||||
}
|
||||
if (OBJ_obj2txt(oid_buf, oid_size, obj, 1) < 0)
|
||||
break; /* Error */
|
||||
if (ln == NULL || strcmp(sn, ln) == 0)
|
||||
BIO_printf(bio_out, "%s = %s\n", sn, oid_buf);
|
||||
else
|
||||
BIO_printf(bio_out, "%s = %s, %s\n", sn, ln, oid_buf);
|
||||
}
|
||||
|
||||
OPENSSL_free(oid_buf);
|
||||
}
|
||||
|
||||
static void list_options_for_command(const char *command)
|
||||
{
|
||||
const FUNCTION *fp;
|
||||
const OPTIONS *o;
|
||||
|
||||
for (fp = functions; fp->name != NULL; fp++)
|
||||
if (strcmp(fp->name, command) == 0)
|
||||
break;
|
||||
if (fp->name == NULL) {
|
||||
BIO_printf(bio_err, "Invalid command '%s'; type \"help\" for a list.\n",
|
||||
command);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((o = fp->help) == NULL)
|
||||
return;
|
||||
|
||||
for ( ; o->name != NULL; o++) {
|
||||
if (o->name == OPT_HELP_STR
|
||||
|| o->name == OPT_MORE_STR
|
||||
|| o->name[0] == '\0')
|
||||
continue;
|
||||
BIO_printf(bio_out, "%s %c\n", o->name, o->valtype);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Unified enum for help and list commands. */
|
||||
typedef enum HELPLIST_CHOICE {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ONE,
|
||||
OPT_COMMANDS, OPT_DIGEST_COMMANDS, OPT_MAC_ALGORITHMS, OPT_OPTIONS,
|
||||
OPT_DIGEST_ALGORITHMS, OPT_CIPHER_COMMANDS, OPT_CIPHER_ALGORITHMS,
|
||||
OPT_PK_ALGORITHMS, OPT_PK_METHOD, OPT_ENGINES, OPT_DISABLED,
|
||||
OPT_MISSING_HELP, OPT_OBJECTS
|
||||
} HELPLIST_CHOICE;
|
||||
|
||||
const OPTIONS list_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"1", OPT_ONE, '-', "List in one column"},
|
||||
{"commands", OPT_COMMANDS, '-', "List of standard commands"},
|
||||
{"digest-commands", OPT_DIGEST_COMMANDS, '-',
|
||||
"List of message digest commands"},
|
||||
{"digest-algorithms", OPT_DIGEST_ALGORITHMS, '-',
|
||||
"List of message digest algorithms"},
|
||||
{"mac-algorithms", OPT_MAC_ALGORITHMS, '-',
|
||||
"List of message authentication code algorithms"},
|
||||
{"cipher-commands", OPT_CIPHER_COMMANDS, '-', "List of cipher commands"},
|
||||
{"cipher-algorithms", OPT_CIPHER_ALGORITHMS, '-',
|
||||
"List of cipher algorithms"},
|
||||
{"public-key-algorithms", OPT_PK_ALGORITHMS, '-',
|
||||
"List of public key algorithms"},
|
||||
{"public-key-methods", OPT_PK_METHOD, '-',
|
||||
"List of public key methods"},
|
||||
{"engines", OPT_ENGINES, '-',
|
||||
"List of loaded engines"},
|
||||
{"disabled", OPT_DISABLED, '-',
|
||||
"List of disabled features"},
|
||||
{"missing-help", OPT_MISSING_HELP, '-',
|
||||
"List missing detailed help strings"},
|
||||
{"options", OPT_OPTIONS, 's',
|
||||
"List options for specified command"},
|
||||
{"objects", OPT_OBJECTS, '-',
|
||||
"List built in objects (OID<->name mappings)"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int list_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
HELPLIST_CHOICE o;
|
||||
int one = 0, done = 0;
|
||||
|
||||
prog = opt_init(argc, argv, list_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF: /* Never hit, but suppresses warning */
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
return 1;
|
||||
case OPT_HELP:
|
||||
opt_help(list_options);
|
||||
break;
|
||||
case OPT_ONE:
|
||||
one = 1;
|
||||
break;
|
||||
case OPT_COMMANDS:
|
||||
list_type(FT_general, one);
|
||||
break;
|
||||
case OPT_DIGEST_COMMANDS:
|
||||
list_type(FT_md, one);
|
||||
break;
|
||||
case OPT_DIGEST_ALGORITHMS:
|
||||
EVP_MD_do_all_sorted(list_md_fn, bio_out);
|
||||
break;
|
||||
case OPT_MAC_ALGORITHMS:
|
||||
EVP_MAC_do_all_sorted(list_mac_fn, bio_out);
|
||||
break;
|
||||
case OPT_CIPHER_COMMANDS:
|
||||
list_type(FT_cipher, one);
|
||||
break;
|
||||
case OPT_CIPHER_ALGORITHMS:
|
||||
EVP_CIPHER_do_all_sorted(list_cipher_fn, bio_out);
|
||||
break;
|
||||
case OPT_PK_ALGORITHMS:
|
||||
list_pkey();
|
||||
break;
|
||||
case OPT_PK_METHOD:
|
||||
list_pkey_meth();
|
||||
break;
|
||||
case OPT_ENGINES:
|
||||
list_engines();
|
||||
break;
|
||||
case OPT_DISABLED:
|
||||
list_disabled();
|
||||
break;
|
||||
case OPT_MISSING_HELP:
|
||||
list_missing_help();
|
||||
break;
|
||||
case OPT_OBJECTS:
|
||||
list_objects();
|
||||
break;
|
||||
case OPT_OPTIONS:
|
||||
list_options_for_command(opt_arg());
|
||||
break;
|
||||
}
|
||||
done = 1;
|
||||
}
|
||||
if (opt_num_rest() != 0) {
|
||||
BIO_printf(bio_err, "Extra arguments given.\n");
|
||||
goto opthelp;
|
||||
}
|
||||
|
||||
if (!done)
|
||||
goto opthelp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef enum HELP_CHOICE {
|
||||
OPT_hERR = -1, OPT_hEOF = 0, OPT_hHELP
|
||||
} HELP_CHOICE;
|
||||
@@ -705,7 +426,7 @@ int help_main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
calculate_columns(&dc);
|
||||
calculate_columns(functions, &dc);
|
||||
BIO_printf(bio_err, "Standard commands");
|
||||
i = 0;
|
||||
tp = FT_none;
|
||||
@@ -735,32 +456,6 @@ int help_main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void list_type(FUNC_TYPE ft, int one)
|
||||
{
|
||||
FUNCTION *fp;
|
||||
int i = 0;
|
||||
DISPLAY_COLUMNS dc;
|
||||
|
||||
memset(&dc, 0, sizeof(dc));
|
||||
if (!one)
|
||||
calculate_columns(&dc);
|
||||
|
||||
for (fp = functions; fp->name != NULL; fp++) {
|
||||
if (fp->type != ft)
|
||||
continue;
|
||||
if (one) {
|
||||
BIO_printf(bio_out, "%s\n", fp->name);
|
||||
} else {
|
||||
if (i % dc.columns == 0 && i > 0)
|
||||
BIO_printf(bio_out, "\n");
|
||||
BIO_printf(bio_out, "%-*s", dc.width, fp->name);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!one)
|
||||
BIO_printf(bio_out, "\n\n");
|
||||
}
|
||||
|
||||
static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
|
||||
{
|
||||
FUNCTION f, *fp;
|
||||
@@ -806,51 +501,6 @@ static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void list_pkey(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < EVP_PKEY_asn1_get_count(); i++) {
|
||||
const EVP_PKEY_ASN1_METHOD *ameth;
|
||||
int pkey_id, pkey_base_id, pkey_flags;
|
||||
const char *pinfo, *pem_str;
|
||||
ameth = EVP_PKEY_asn1_get0(i);
|
||||
EVP_PKEY_asn1_get0_info(&pkey_id, &pkey_base_id, &pkey_flags,
|
||||
&pinfo, &pem_str, ameth);
|
||||
if (pkey_flags & ASN1_PKEY_ALIAS) {
|
||||
BIO_printf(bio_out, "Name: %s\n", OBJ_nid2ln(pkey_id));
|
||||
BIO_printf(bio_out, "\tAlias for: %s\n",
|
||||
OBJ_nid2ln(pkey_base_id));
|
||||
} else {
|
||||
BIO_printf(bio_out, "Name: %s\n", pinfo);
|
||||
BIO_printf(bio_out, "\tType: %s Algorithm\n",
|
||||
pkey_flags & ASN1_PKEY_DYNAMIC ?
|
||||
"External" : "Builtin");
|
||||
BIO_printf(bio_out, "\tOID: %s\n", OBJ_nid2ln(pkey_id));
|
||||
if (pem_str == NULL)
|
||||
pem_str = "(none)";
|
||||
BIO_printf(bio_out, "\tPEM string: %s\n", pem_str);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void list_pkey_meth(void)
|
||||
{
|
||||
size_t i;
|
||||
size_t meth_count = EVP_PKEY_meth_get_count();
|
||||
|
||||
for (i = 0; i < meth_count; i++) {
|
||||
const EVP_PKEY_METHOD *pmeth = EVP_PKEY_meth_get0(i);
|
||||
int pkey_id, pkey_flags;
|
||||
|
||||
EVP_PKEY_meth_get0_info(&pkey_id, &pkey_flags, pmeth);
|
||||
BIO_printf(bio_out, "%s\n", OBJ_nid2ln(pkey_id));
|
||||
BIO_printf(bio_out, "\tType: %s Algorithm\n",
|
||||
pkey_flags & ASN1_PKEY_DYNAMIC ? "External" : "Builtin");
|
||||
}
|
||||
}
|
||||
|
||||
static int function_cmp(const FUNCTION * a, const FUNCTION * b)
|
||||
{
|
||||
return strncmp(a->name, b->name, 8);
|
||||
@@ -871,168 +521,6 @@ static int SortFnByName(const void *_f1, const void *_f2)
|
||||
return strcmp(f1->name, f2->name);
|
||||
}
|
||||
|
||||
static void list_engines(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
ENGINE *e;
|
||||
|
||||
BIO_puts(bio_out, "Engines:\n");
|
||||
e = ENGINE_get_first();
|
||||
while (e) {
|
||||
BIO_printf(bio_out, "%s\n", ENGINE_get_id(e));
|
||||
e = ENGINE_get_next(e);
|
||||
}
|
||||
#else
|
||||
BIO_puts(bio_out, "Engine support is disabled.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void list_disabled(void)
|
||||
{
|
||||
BIO_puts(bio_out, "Disabled algorithms:\n");
|
||||
#ifdef OPENSSL_NO_ARIA
|
||||
BIO_puts(bio_out, "ARIA\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_BF
|
||||
BIO_puts(bio_out, "BF\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_BLAKE2
|
||||
BIO_puts(bio_out, "BLAKE2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_CAMELLIA
|
||||
BIO_puts(bio_out, "CAMELLIA\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_CAST
|
||||
BIO_puts(bio_out, "CAST\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_CMAC
|
||||
BIO_puts(bio_out, "CMAC\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_CMS
|
||||
BIO_puts(bio_out, "CMS\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_COMP
|
||||
BIO_puts(bio_out, "COMP\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_DES
|
||||
BIO_puts(bio_out, "DES\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_DGRAM
|
||||
BIO_puts(bio_out, "DGRAM\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_DH
|
||||
BIO_puts(bio_out, "DH\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_DSA
|
||||
BIO_puts(bio_out, "DSA\n");
|
||||
#endif
|
||||
#if defined(OPENSSL_NO_DTLS)
|
||||
BIO_puts(bio_out, "DTLS\n");
|
||||
#endif
|
||||
#if defined(OPENSSL_NO_DTLS1)
|
||||
BIO_puts(bio_out, "DTLS1\n");
|
||||
#endif
|
||||
#if defined(OPENSSL_NO_DTLS1_2)
|
||||
BIO_puts(bio_out, "DTLS1_2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_EC
|
||||
BIO_puts(bio_out, "EC\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_EC2M
|
||||
BIO_puts(bio_out, "EC2M\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_ENGINE
|
||||
BIO_puts(bio_out, "ENGINE\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_GOST
|
||||
BIO_puts(bio_out, "GOST\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_IDEA
|
||||
BIO_puts(bio_out, "IDEA\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_MD2
|
||||
BIO_puts(bio_out, "MD2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_MD4
|
||||
BIO_puts(bio_out, "MD4\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_MD5
|
||||
BIO_puts(bio_out, "MD5\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_MDC2
|
||||
BIO_puts(bio_out, "MDC2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_OCB
|
||||
BIO_puts(bio_out, "OCB\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_OCSP
|
||||
BIO_puts(bio_out, "OCSP\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_PSK
|
||||
BIO_puts(bio_out, "PSK\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_RC2
|
||||
BIO_puts(bio_out, "RC2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_RC4
|
||||
BIO_puts(bio_out, "RC4\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_RC5
|
||||
BIO_puts(bio_out, "RC5\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_RMD160
|
||||
BIO_puts(bio_out, "RMD160\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_RSA
|
||||
BIO_puts(bio_out, "RSA\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SCRYPT
|
||||
BIO_puts(bio_out, "SCRYPT\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SCTP
|
||||
BIO_puts(bio_out, "SCTP\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SEED
|
||||
BIO_puts(bio_out, "SEED\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SM2
|
||||
BIO_puts(bio_out, "SM2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SM3
|
||||
BIO_puts(bio_out, "SM3\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SM4
|
||||
BIO_puts(bio_out, "SM4\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SOCK
|
||||
BIO_puts(bio_out, "SOCK\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SRP
|
||||
BIO_puts(bio_out, "SRP\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SRTP
|
||||
BIO_puts(bio_out, "SRTP\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_SSL3
|
||||
BIO_puts(bio_out, "SSL3\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_TLS1
|
||||
BIO_puts(bio_out, "TLS1\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_TLS1_1
|
||||
BIO_puts(bio_out, "TLS1_1\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_TLS1_2
|
||||
BIO_puts(bio_out, "TLS1_2\n");
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_WHIRLPOOL
|
||||
BIO_puts(bio_out, "WHIRLPOOL\n");
|
||||
#endif
|
||||
#ifndef ZLIB
|
||||
BIO_puts(bio_out, "ZLIB\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static LHASH_OF(FUNCTION) *prog_init(void)
|
||||
{
|
||||
static LHASH_OF(FUNCTION) *ret = NULL;
|
||||
|
||||
+38
-26
@@ -41,6 +41,7 @@ int dump_certs_pkeys_bags(BIO *out, const STACK_OF(PKCS12_SAFEBAG) *bags,
|
||||
int dump_certs_pkeys_bag(BIO *out, const PKCS12_SAFEBAG *bags,
|
||||
const char *pass, int passlen,
|
||||
int options, char *pempass, const EVP_CIPHER *enc);
|
||||
void print_attribute(BIO *out, const ASN1_TYPE *av);
|
||||
int print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst,
|
||||
const char *name);
|
||||
void hex_prin(BIO *out, unsigned char *buf, int len);
|
||||
@@ -878,6 +879,38 @@ int cert_load(BIO *in, STACK_OF(X509) *sk)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Generalised x509 attribute value print */
|
||||
|
||||
void print_attribute(BIO *out, const ASN1_TYPE *av)
|
||||
{
|
||||
char *value;
|
||||
|
||||
switch (av->type) {
|
||||
case V_ASN1_BMPSTRING:
|
||||
value = OPENSSL_uni2asc(av->value.bmpstring->data,
|
||||
av->value.bmpstring->length);
|
||||
BIO_printf(out, "%s\n", value);
|
||||
OPENSSL_free(value);
|
||||
break;
|
||||
|
||||
case V_ASN1_OCTET_STRING:
|
||||
hex_prin(out, av->value.octet_string->data,
|
||||
av->value.octet_string->length);
|
||||
BIO_printf(out, "\n");
|
||||
break;
|
||||
|
||||
case V_ASN1_BIT_STRING:
|
||||
hex_prin(out, av->value.bit_string->data,
|
||||
av->value.bit_string->length);
|
||||
BIO_printf(out, "\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
BIO_printf(out, "<Unsupported tag %d>\n", av->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generalised attribute print: handle PKCS#8 and bag attributes */
|
||||
|
||||
int print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst,
|
||||
@@ -885,8 +918,7 @@ int print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst,
|
||||
{
|
||||
X509_ATTRIBUTE *attr;
|
||||
ASN1_TYPE *av;
|
||||
char *value;
|
||||
int i, attr_nid;
|
||||
int i, j, attr_nid;
|
||||
if (!attrlst) {
|
||||
BIO_printf(out, "%s: <No Attributes>\n", name);
|
||||
return 1;
|
||||
@@ -910,30 +942,10 @@ int print_attribs(BIO *out, const STACK_OF(X509_ATTRIBUTE) *attrlst,
|
||||
}
|
||||
|
||||
if (X509_ATTRIBUTE_count(attr)) {
|
||||
av = X509_ATTRIBUTE_get0_type(attr, 0);
|
||||
switch (av->type) {
|
||||
case V_ASN1_BMPSTRING:
|
||||
value = OPENSSL_uni2asc(av->value.bmpstring->data,
|
||||
av->value.bmpstring->length);
|
||||
BIO_printf(out, "%s\n", value);
|
||||
OPENSSL_free(value);
|
||||
break;
|
||||
|
||||
case V_ASN1_OCTET_STRING:
|
||||
hex_prin(out, av->value.octet_string->data,
|
||||
av->value.octet_string->length);
|
||||
BIO_printf(out, "\n");
|
||||
break;
|
||||
|
||||
case V_ASN1_BIT_STRING:
|
||||
hex_prin(out, av->value.bit_string->data,
|
||||
av->value.bit_string->length);
|
||||
BIO_printf(out, "\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
BIO_printf(out, "<Unsupported tag %d>\n", av->type);
|
||||
break;
|
||||
for (j = 0; j < X509_ATTRIBUTE_count(attr); j++)
|
||||
{
|
||||
av = X509_ATTRIBUTE_get0_type(attr, j);
|
||||
print_attribute(out, av);
|
||||
}
|
||||
} else {
|
||||
BIO_printf(out, "<No Values>\n");
|
||||
|
||||
+1
-2
@@ -398,8 +398,7 @@ int pkeyutl_main(int argc, char **argv)
|
||||
if (!rawin
|
||||
&& buf_inlen > EVP_MAX_MD_SIZE
|
||||
&& (pkey_op == EVP_PKEY_OP_SIGN
|
||||
|| pkey_op == EVP_PKEY_OP_VERIFY
|
||||
|| pkey_op == EVP_PKEY_OP_VERIFYRECOVER)) {
|
||||
|| pkey_op == EVP_PKEY_OP_VERIFY)) {
|
||||
BIO_printf(bio_err,
|
||||
"Error: The input data looks too long to be a hash\n");
|
||||
goto end;
|
||||
|
||||
+400
@@ -0,0 +1,400 @@
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by apps/progs.pl
|
||||
*
|
||||
* Copyright 1995-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 "progs.h"
|
||||
|
||||
FUNCTION functions[] = {
|
||||
{FT_general, "asn1parse", asn1parse_main, asn1parse_options},
|
||||
{FT_general, "ca", ca_main, ca_options},
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
{FT_general, "ciphers", ciphers_main, ciphers_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CMS
|
||||
{FT_general, "cms", cms_main, cms_options},
|
||||
#endif
|
||||
{FT_general, "crl", crl_main, crl_options},
|
||||
{FT_general, "crl2pkcs7", crl2pkcs7_main, crl2pkcs7_options},
|
||||
{FT_general, "dgst", dgst_main, dgst_options},
|
||||
#ifndef OPENSSL_NO_DH
|
||||
{FT_general, "dhparam", dhparam_main, dhparam_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
{FT_general, "dsa", dsa_main, dsa_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
{FT_general, "dsaparam", dsaparam_main, dsaparam_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
{FT_general, "ec", ec_main, ec_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_EC
|
||||
{FT_general, "ecparam", ecparam_main, ecparam_options},
|
||||
#endif
|
||||
{FT_general, "enc", enc_main, enc_options},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{FT_general, "engine", engine_main, engine_options},
|
||||
#endif
|
||||
{FT_general, "errstr", errstr_main, errstr_options},
|
||||
{FT_general, "fipsinstall", fipsinstall_main, fipsinstall_options},
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
{FT_general, "gendsa", gendsa_main, gendsa_options},
|
||||
#endif
|
||||
{FT_general, "genpkey", genpkey_main, genpkey_options},
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
{FT_general, "genrsa", genrsa_main, genrsa_options},
|
||||
#endif
|
||||
{FT_general, "help", help_main, help_options},
|
||||
{FT_general, "info", info_main, info_options},
|
||||
{FT_general, "kdf", kdf_main, kdf_options},
|
||||
{FT_general, "list", list_main, list_options},
|
||||
{FT_general, "mac", mac_main, mac_options},
|
||||
{FT_general, "nseq", nseq_main, nseq_options},
|
||||
#ifndef OPENSSL_NO_OCSP
|
||||
{FT_general, "ocsp", ocsp_main, ocsp_options},
|
||||
#endif
|
||||
{FT_general, "passwd", passwd_main, passwd_options},
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_general, "pkcs12", pkcs12_main, pkcs12_options},
|
||||
#endif
|
||||
{FT_general, "pkcs7", pkcs7_main, pkcs7_options},
|
||||
{FT_general, "pkcs8", pkcs8_main, pkcs8_options},
|
||||
{FT_general, "pkey", pkey_main, pkey_options},
|
||||
{FT_general, "pkeyparam", pkeyparam_main, pkeyparam_options},
|
||||
{FT_general, "pkeyutl", pkeyutl_main, pkeyutl_options},
|
||||
{FT_general, "prime", prime_main, prime_options},
|
||||
{FT_general, "provider", provider_main, provider_options},
|
||||
{FT_general, "rand", rand_main, rand_options},
|
||||
{FT_general, "rehash", rehash_main, rehash_options},
|
||||
{FT_general, "req", req_main, req_options},
|
||||
{FT_general, "rsa", rsa_main, rsa_options},
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
{FT_general, "rsautl", rsautl_main, rsautl_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
{FT_general, "s_client", s_client_main, s_client_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
{FT_general, "s_server", s_server_main, s_server_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
{FT_general, "s_time", s_time_main, s_time_options},
|
||||
#endif
|
||||
{FT_general, "sess_id", sess_id_main, sess_id_options},
|
||||
{FT_general, "smime", smime_main, smime_options},
|
||||
{FT_general, "speed", speed_main, speed_options},
|
||||
{FT_general, "spkac", spkac_main, spkac_options},
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
{FT_general, "srp", srp_main, srp_options},
|
||||
#endif
|
||||
{FT_general, "storeutl", storeutl_main, storeutl_options},
|
||||
#ifndef OPENSSL_NO_TS
|
||||
{FT_general, "ts", ts_main, ts_options},
|
||||
#endif
|
||||
{FT_general, "verify", verify_main, verify_options},
|
||||
{FT_general, "version", version_main, version_options},
|
||||
{FT_general, "x509", x509_main, x509_options},
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
{FT_md, "md2", dgst_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD4
|
||||
{FT_md, "md4", dgst_main},
|
||||
#endif
|
||||
{FT_md, "md5", dgst_main},
|
||||
#ifndef OPENSSL_NO_GOST
|
||||
{FT_md, "gost", dgst_main},
|
||||
#endif
|
||||
{FT_md, "sha1", dgst_main},
|
||||
{FT_md, "sha224", dgst_main},
|
||||
{FT_md, "sha256", dgst_main},
|
||||
{FT_md, "sha384", dgst_main},
|
||||
{FT_md, "sha512", dgst_main},
|
||||
{FT_md, "sha512-224", dgst_main},
|
||||
{FT_md, "sha512-256", dgst_main},
|
||||
{FT_md, "sha3-224", dgst_main},
|
||||
{FT_md, "sha3-256", dgst_main},
|
||||
{FT_md, "sha3-384", dgst_main},
|
||||
{FT_md, "sha3-512", dgst_main},
|
||||
{FT_md, "shake128", dgst_main},
|
||||
{FT_md, "shake256", dgst_main},
|
||||
#ifndef OPENSSL_NO_MDC2
|
||||
{FT_md, "mdc2", dgst_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RMD160
|
||||
{FT_md, "rmd160", dgst_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BLAKE2
|
||||
{FT_md, "blake2b512", dgst_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BLAKE2
|
||||
{FT_md, "blake2s256", dgst_main},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM3
|
||||
{FT_md, "sm3", dgst_main},
|
||||
#endif
|
||||
{FT_cipher, "aes-128-cbc", enc_main, enc_options},
|
||||
{FT_cipher, "aes-128-ecb", enc_main, enc_options},
|
||||
{FT_cipher, "aes-192-cbc", enc_main, enc_options},
|
||||
{FT_cipher, "aes-192-ecb", enc_main, enc_options},
|
||||
{FT_cipher, "aes-256-cbc", enc_main, enc_options},
|
||||
{FT_cipher, "aes-256-ecb", enc_main, enc_options},
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-128-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-128-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-128-ctr", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-128-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-128-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-128-cfb1", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-128-cfb8", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-192-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-192-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-192-ctr", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-192-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-192-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-192-cfb1", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-192-cfb8", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-256-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-256-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-256-ctr", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-256-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-256-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-256-cfb1", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_ARIA
|
||||
{FT_cipher, "aria-256-cfb8", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FT_cipher, "camellia-128-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FT_cipher, "camellia-128-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FT_cipher, "camellia-192-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FT_cipher, "camellia-192-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FT_cipher, "camellia-256-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAMELLIA
|
||||
{FT_cipher, "camellia-256-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
{FT_cipher, "base64", enc_main, enc_options},
|
||||
#ifdef ZLIB
|
||||
{FT_cipher, "zlib", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des3", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "desx", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
{FT_cipher, "idea", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
{FT_cipher, "seed", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
{FT_cipher, "rc4", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
{FT_cipher, "rc4-40", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
{FT_cipher, "rc2", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
{FT_cipher, "bf", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
{FT_cipher, "cast", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
{FT_cipher, "rc5", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-ede", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-ede3", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-ede-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-ede3-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-ede-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-ede3-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-ede-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DES
|
||||
{FT_cipher, "des-ede3-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
{FT_cipher, "idea-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
{FT_cipher, "idea-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
{FT_cipher, "idea-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_IDEA
|
||||
{FT_cipher, "idea-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
{FT_cipher, "seed-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
{FT_cipher, "seed-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
{FT_cipher, "seed-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SEED
|
||||
{FT_cipher, "seed-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
{FT_cipher, "rc2-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
{FT_cipher, "rc2-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
{FT_cipher, "rc2-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
{FT_cipher, "rc2-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
{FT_cipher, "rc2-64-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC2
|
||||
{FT_cipher, "rc2-40-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
{FT_cipher, "bf-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
{FT_cipher, "bf-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
{FT_cipher, "bf-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_BF
|
||||
{FT_cipher, "bf-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
{FT_cipher, "cast5-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
{FT_cipher, "cast5-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
{FT_cipher, "cast5-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
{FT_cipher, "cast5-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_CAST
|
||||
{FT_cipher, "cast-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
{FT_cipher, "rc5-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
{FT_cipher, "rc5-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
{FT_cipher, "rc5-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_RC5
|
||||
{FT_cipher, "rc5-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM4
|
||||
{FT_cipher, "sm4-cbc", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM4
|
||||
{FT_cipher, "sm4-ecb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM4
|
||||
{FT_cipher, "sm4-cfb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM4
|
||||
{FT_cipher, "sm4-ofb", enc_main, enc_options},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM4
|
||||
{FT_cipher, "sm4-ctr", enc_main, enc_options},
|
||||
#endif
|
||||
{0, NULL, NULL}
|
||||
};
|
||||
+132
-122
@@ -14,6 +14,10 @@ use warnings;
|
||||
use lib '.';
|
||||
use configdata qw/@disablables %unified_info/;
|
||||
|
||||
my $opt = shift @ARGV;
|
||||
die "Unrecognised option, must be -C or -H\n"
|
||||
unless ($opt eq '-H' || $opt eq '-C');
|
||||
|
||||
my %commands = ();
|
||||
my $cmdre = qr/^\s*int\s+([a-z_][a-z0-9_]*)_main\(\s*int\s+argc\s*,/;
|
||||
my $apps_openssl = shift @ARGV;
|
||||
@@ -38,7 +42,8 @@ foreach my $filename (@openssl_source) {
|
||||
|
||||
@ARGV = sort keys %commands;
|
||||
|
||||
print <<"EOF";
|
||||
if ($opt eq '-H') {
|
||||
print <<"EOF";
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by apps/progs.pl
|
||||
@@ -51,134 +56,139 @@ print <<"EOF";
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/lhash.h>
|
||||
#include "opt.h"
|
||||
|
||||
typedef enum FUNC_TYPE {
|
||||
FT_none, FT_general, FT_md, FT_cipher, FT_pkey,
|
||||
FT_md_alg, FT_cipher_alg
|
||||
} FUNC_TYPE;
|
||||
|
||||
typedef struct function_st {
|
||||
FUNC_TYPE type;
|
||||
const char *name;
|
||||
int (*func)(int argc, char *argv[]);
|
||||
const OPTIONS *help;
|
||||
} FUNCTION;
|
||||
|
||||
DEFINE_LHASH_OF(FUNCTION);
|
||||
#include "function.h"
|
||||
|
||||
EOF
|
||||
|
||||
foreach (@ARGV) {
|
||||
printf "extern int %s_main(int argc, char *argv[]);\n", $_;
|
||||
}
|
||||
print "\n";
|
||||
|
||||
foreach (@ARGV) {
|
||||
printf "extern const OPTIONS %s_options[];\n", $_;
|
||||
}
|
||||
print "\n";
|
||||
|
||||
my %cmd_disabler = (
|
||||
ciphers => "sock",
|
||||
genrsa => "rsa",
|
||||
rsautl => "rsa",
|
||||
gendsa => "dsa",
|
||||
dsaparam => "dsa",
|
||||
gendh => "dh",
|
||||
dhparam => "dh",
|
||||
ecparam => "ec",
|
||||
pkcs12 => "des",
|
||||
);
|
||||
|
||||
print "#ifdef INCLUDE_FUNCTION_TABLE\n";
|
||||
print "static FUNCTION functions[] = {\n";
|
||||
foreach my $cmd ( @ARGV ) {
|
||||
my $str = " {FT_general, \"$cmd\", ${cmd}_main, ${cmd}_options},\n";
|
||||
if ($cmd =~ /^s_/) {
|
||||
print "#ifndef OPENSSL_NO_SOCK\n${str}#endif\n";
|
||||
} elsif (grep { $cmd eq $_ } @disablables) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($cmd) . "\n${str}#endif\n";
|
||||
} elsif (my $disabler = $cmd_disabler{$cmd}) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($disabler) . "\n${str}#endif\n";
|
||||
} else {
|
||||
print $str;
|
||||
foreach (@ARGV) {
|
||||
printf "extern int %s_main(int argc, char *argv[]);\n", $_;
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
|
||||
my %md_disabler = (
|
||||
blake2b512 => "blake2",
|
||||
blake2s256 => "blake2",
|
||||
);
|
||||
foreach my $cmd (
|
||||
"md2", "md4", "md5",
|
||||
"gost",
|
||||
"sha1", "sha224", "sha256", "sha384",
|
||||
"sha512", "sha512-224", "sha512-256",
|
||||
"sha3-224", "sha3-256", "sha3-384", "sha3-512",
|
||||
"shake128", "shake256",
|
||||
"mdc2", "rmd160", "blake2b512", "blake2s256",
|
||||
"sm3"
|
||||
) {
|
||||
my $str = " {FT_md, \"$cmd\", dgst_main},\n";
|
||||
if (grep { $cmd eq $_ } @disablables) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($cmd) . "\n${str}#endif\n";
|
||||
} elsif (my $disabler = $md_disabler{$cmd}) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($disabler) . "\n${str}#endif\n";
|
||||
} else {
|
||||
print $str;
|
||||
foreach (@ARGV) {
|
||||
printf "extern const OPTIONS %s_options[];\n", $_;
|
||||
}
|
||||
print "\n";
|
||||
print "extern FUNCTION functions[];\n";
|
||||
}
|
||||
|
||||
my %cipher_disabler = (
|
||||
des3 => "des",
|
||||
desx => "des",
|
||||
cast5 => "cast",
|
||||
);
|
||||
foreach my $cmd (
|
||||
"aes-128-cbc", "aes-128-ecb",
|
||||
"aes-192-cbc", "aes-192-ecb",
|
||||
"aes-256-cbc", "aes-256-ecb",
|
||||
"aria-128-cbc", "aria-128-cfb",
|
||||
"aria-128-ctr", "aria-128-ecb", "aria-128-ofb",
|
||||
"aria-128-cfb1", "aria-128-cfb8",
|
||||
"aria-192-cbc", "aria-192-cfb",
|
||||
"aria-192-ctr", "aria-192-ecb", "aria-192-ofb",
|
||||
"aria-192-cfb1", "aria-192-cfb8",
|
||||
"aria-256-cbc", "aria-256-cfb",
|
||||
"aria-256-ctr", "aria-256-ecb", "aria-256-ofb",
|
||||
"aria-256-cfb1", "aria-256-cfb8",
|
||||
"camellia-128-cbc", "camellia-128-ecb",
|
||||
"camellia-192-cbc", "camellia-192-ecb",
|
||||
"camellia-256-cbc", "camellia-256-ecb",
|
||||
"base64", "zlib",
|
||||
"des", "des3", "desx", "idea", "seed", "rc4", "rc4-40",
|
||||
"rc2", "bf", "cast", "rc5",
|
||||
"des-ecb", "des-ede", "des-ede3",
|
||||
"des-cbc", "des-ede-cbc","des-ede3-cbc",
|
||||
"des-cfb", "des-ede-cfb","des-ede3-cfb",
|
||||
"des-ofb", "des-ede-ofb","des-ede3-ofb",
|
||||
"idea-cbc","idea-ecb", "idea-cfb", "idea-ofb",
|
||||
"seed-cbc","seed-ecb", "seed-cfb", "seed-ofb",
|
||||
"rc2-cbc", "rc2-ecb", "rc2-cfb","rc2-ofb", "rc2-64-cbc", "rc2-40-cbc",
|
||||
"bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb",
|
||||
"cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
|
||||
"cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb",
|
||||
"sm4-cbc", "sm4-ecb", "sm4-cfb", "sm4-ofb", "sm4-ctr"
|
||||
) {
|
||||
my $str = " {FT_cipher, \"$cmd\", enc_main, enc_options},\n";
|
||||
(my $algo = $cmd) =~ s/-.*//g;
|
||||
if ($cmd eq "zlib") {
|
||||
print "#ifdef ZLIB\n${str}#endif\n";
|
||||
} elsif (grep { $algo eq $_ } @disablables) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($algo) . "\n${str}#endif\n";
|
||||
} elsif (my $disabler = $cipher_disabler{$algo}) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($disabler) . "\n${str}#endif\n";
|
||||
} else {
|
||||
print $str;
|
||||
if ($opt eq '-C') {
|
||||
print <<"EOF";
|
||||
/*
|
||||
* WARNING: do not edit!
|
||||
* Generated by apps/progs.pl
|
||||
*
|
||||
* Copyright 1995-$YEAR 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 "progs.h"
|
||||
|
||||
EOF
|
||||
|
||||
my %cmd_disabler = (
|
||||
ciphers => "sock",
|
||||
genrsa => "rsa",
|
||||
rsautl => "rsa",
|
||||
gendsa => "dsa",
|
||||
dsaparam => "dsa",
|
||||
gendh => "dh",
|
||||
dhparam => "dh",
|
||||
ecparam => "ec",
|
||||
pkcs12 => "des",
|
||||
);
|
||||
|
||||
print "FUNCTION functions[] = {\n";
|
||||
foreach my $cmd ( @ARGV ) {
|
||||
my $str =
|
||||
" {FT_general, \"$cmd\", ${cmd}_main, ${cmd}_options},\n";
|
||||
if ($cmd =~ /^s_/) {
|
||||
print "#ifndef OPENSSL_NO_SOCK\n${str}#endif\n";
|
||||
} elsif (grep { $cmd eq $_ } @disablables) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($cmd) . "\n${str}#endif\n";
|
||||
} elsif (my $disabler = $cmd_disabler{$cmd}) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($disabler) . "\n${str}#endif\n";
|
||||
} else {
|
||||
print $str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print " {0, NULL, NULL}\n};\n";
|
||||
print "#endif\n";
|
||||
my %md_disabler = (
|
||||
blake2b512 => "blake2",
|
||||
blake2s256 => "blake2",
|
||||
);
|
||||
foreach my $cmd (
|
||||
"md2", "md4", "md5",
|
||||
"gost",
|
||||
"sha1", "sha224", "sha256", "sha384",
|
||||
"sha512", "sha512-224", "sha512-256",
|
||||
"sha3-224", "sha3-256", "sha3-384", "sha3-512",
|
||||
"shake128", "shake256",
|
||||
"mdc2", "rmd160", "blake2b512", "blake2s256",
|
||||
"sm3"
|
||||
) {
|
||||
my $str = " {FT_md, \"$cmd\", dgst_main},\n";
|
||||
if (grep { $cmd eq $_ } @disablables) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($cmd) . "\n${str}#endif\n";
|
||||
} elsif (my $disabler = $md_disabler{$cmd}) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($disabler) . "\n${str}#endif\n";
|
||||
} else {
|
||||
print $str;
|
||||
}
|
||||
}
|
||||
|
||||
my %cipher_disabler = (
|
||||
des3 => "des",
|
||||
desx => "des",
|
||||
cast5 => "cast",
|
||||
);
|
||||
foreach my $cmd (
|
||||
"aes-128-cbc", "aes-128-ecb",
|
||||
"aes-192-cbc", "aes-192-ecb",
|
||||
"aes-256-cbc", "aes-256-ecb",
|
||||
"aria-128-cbc", "aria-128-cfb",
|
||||
"aria-128-ctr", "aria-128-ecb", "aria-128-ofb",
|
||||
"aria-128-cfb1", "aria-128-cfb8",
|
||||
"aria-192-cbc", "aria-192-cfb",
|
||||
"aria-192-ctr", "aria-192-ecb", "aria-192-ofb",
|
||||
"aria-192-cfb1", "aria-192-cfb8",
|
||||
"aria-256-cbc", "aria-256-cfb",
|
||||
"aria-256-ctr", "aria-256-ecb", "aria-256-ofb",
|
||||
"aria-256-cfb1", "aria-256-cfb8",
|
||||
"camellia-128-cbc", "camellia-128-ecb",
|
||||
"camellia-192-cbc", "camellia-192-ecb",
|
||||
"camellia-256-cbc", "camellia-256-ecb",
|
||||
"base64", "zlib",
|
||||
"des", "des3", "desx", "idea", "seed", "rc4", "rc4-40",
|
||||
"rc2", "bf", "cast", "rc5",
|
||||
"des-ecb", "des-ede", "des-ede3",
|
||||
"des-cbc", "des-ede-cbc","des-ede3-cbc",
|
||||
"des-cfb", "des-ede-cfb","des-ede3-cfb",
|
||||
"des-ofb", "des-ede-ofb","des-ede3-ofb",
|
||||
"idea-cbc","idea-ecb", "idea-cfb", "idea-ofb",
|
||||
"seed-cbc","seed-ecb", "seed-cfb", "seed-ofb",
|
||||
"rc2-cbc", "rc2-ecb", "rc2-cfb","rc2-ofb", "rc2-64-cbc", "rc2-40-cbc",
|
||||
"bf-cbc", "bf-ecb", "bf-cfb", "bf-ofb",
|
||||
"cast5-cbc","cast5-ecb", "cast5-cfb","cast5-ofb",
|
||||
"cast-cbc", "rc5-cbc", "rc5-ecb", "rc5-cfb", "rc5-ofb",
|
||||
"sm4-cbc", "sm4-ecb", "sm4-cfb", "sm4-ofb", "sm4-ctr"
|
||||
) {
|
||||
my $str = " {FT_cipher, \"$cmd\", enc_main, enc_options},\n";
|
||||
(my $algo = $cmd) =~ s/-.*//g;
|
||||
if ($cmd eq "zlib") {
|
||||
print "#ifdef ZLIB\n${str}#endif\n";
|
||||
} elsif (grep { $algo eq $_ } @disablables) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($algo) . "\n${str}#endif\n";
|
||||
} elsif (my $disabler = $cipher_disabler{$algo}) {
|
||||
print "#ifndef OPENSSL_NO_" . uc($disabler) . "\n${str}#endif\n";
|
||||
} else {
|
||||
print $str;
|
||||
}
|
||||
}
|
||||
|
||||
print " {0, NULL, NULL}\n};\n";
|
||||
}
|
||||
+287
@@ -0,0 +1,287 @@
|
||||
/*
|
||||
* 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/opensslconf.h>
|
||||
|
||||
#include "apps.h"
|
||||
#include "app_params.h"
|
||||
#include "progs.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/safestack.h>
|
||||
#include <openssl/provider.h>
|
||||
#include <openssl/core.h>
|
||||
#include <openssl/core_numbers.h>
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_V = 100, OPT_VV, OPT_VVV
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS provider_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] provider...\n"},
|
||||
{OPT_HELP_STR, 1, '-', " provider... Providers to load\n"},
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"v", OPT_V, '-', "List the algorithm names of specified provider"},
|
||||
{"vv", OPT_VV, '-', "List the algorithm names of specified providers,"},
|
||||
{OPT_MORE_STR, 0, '-', "categorised by operation type"},
|
||||
{"vvv", OPT_VVV, '-', "List the algorithm names of specified provider"},
|
||||
{OPT_MORE_STR, 0, '-', "one at a time, and list all known parameters"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
typedef struct info_st INFO;
|
||||
typedef struct meta_st META;
|
||||
|
||||
struct info_st {
|
||||
const char *name;
|
||||
void *method;
|
||||
const OSSL_PARAM *gettable_params;
|
||||
const OSSL_PARAM *gettable_ctx_params;
|
||||
const OSSL_PARAM *settable_ctx_params;
|
||||
};
|
||||
|
||||
struct meta_st {
|
||||
int first; /* For prints */
|
||||
int total;
|
||||
int indent;
|
||||
int subindent;
|
||||
int verbose;
|
||||
const char *label;
|
||||
OSSL_PROVIDER *prov;
|
||||
void (*fn)(META *meta, INFO *info);
|
||||
};
|
||||
|
||||
static void print_caps(META *meta, INFO *info)
|
||||
{
|
||||
switch (meta->verbose) {
|
||||
case 1:
|
||||
BIO_printf(bio_out, meta->first ? "%s" : " %s", info->name);
|
||||
break;
|
||||
case 2:
|
||||
if (meta->first) {
|
||||
if (meta->total > 0)
|
||||
BIO_printf(bio_out, "\n");
|
||||
BIO_printf(bio_out, "%*s%ss:", meta->indent, "", meta->label);
|
||||
}
|
||||
BIO_printf(bio_out, " %s", info->name);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
BIO_printf(bio_out, "%*s%s %s\n", meta->indent, "", meta->label,
|
||||
info->name);
|
||||
print_param_types("retrievable algorithm parameters",
|
||||
info->gettable_params, meta->subindent);
|
||||
print_param_types("retrievable operation parameters",
|
||||
info->gettable_ctx_params, meta->subindent);
|
||||
print_param_types("settable operation parameters",
|
||||
info->settable_ctx_params, meta->subindent);
|
||||
break;
|
||||
}
|
||||
meta->first = 0;
|
||||
}
|
||||
|
||||
static void do_method(void *method, const char *name,
|
||||
const OSSL_PARAM *gettable_params,
|
||||
const OSSL_PARAM *gettable_ctx_params,
|
||||
const OSSL_PARAM *settable_ctx_params,
|
||||
META *meta)
|
||||
{
|
||||
INFO info;
|
||||
|
||||
info.name = name;
|
||||
info.method = method;
|
||||
info.gettable_params = gettable_params;
|
||||
info.gettable_ctx_params = gettable_ctx_params;
|
||||
info.settable_ctx_params = settable_ctx_params;
|
||||
meta->fn(meta, &info);
|
||||
meta->total++;
|
||||
}
|
||||
|
||||
static void do_cipher(EVP_CIPHER *cipher, void *meta)
|
||||
{
|
||||
do_method(cipher, EVP_CIPHER_name(cipher),
|
||||
EVP_CIPHER_gettable_params(cipher),
|
||||
EVP_CIPHER_CTX_gettable_params(cipher),
|
||||
EVP_CIPHER_CTX_settable_params(cipher),
|
||||
meta);
|
||||
}
|
||||
|
||||
static void do_digest(EVP_MD *digest, void *meta)
|
||||
{
|
||||
do_method(digest, EVP_MD_name(digest),
|
||||
EVP_MD_gettable_params(digest),
|
||||
EVP_MD_CTX_gettable_params(digest),
|
||||
EVP_MD_CTX_settable_params(digest),
|
||||
meta);
|
||||
}
|
||||
|
||||
static void do_mac(EVP_MAC *mac, void *meta)
|
||||
{
|
||||
do_method(mac, EVP_MAC_name(mac),
|
||||
EVP_MAC_gettable_params(mac),
|
||||
EVP_MAC_CTX_gettable_params(mac),
|
||||
EVP_MAC_CTX_settable_params(mac),
|
||||
meta);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO(3.0) Enable when KEYMGMT and KEYEXCH have gettables and settables
|
||||
*/
|
||||
#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_ctx_params(keymgmt),
|
||||
EVP_KEYMGMT_settable_ctx_params(keymgmt),
|
||||
meta);
|
||||
}
|
||||
|
||||
static void do_keyexch(EVP_KEYEXCH *keyexch, void *meta)
|
||||
{
|
||||
do_method(keyexch, EVP_KEYEXCH_name(keyexch),
|
||||
EVP_KEYEXCH_gettable_params(keyexch),
|
||||
EVP_KEYEXCH_gettable_ctx_params(keyexch),
|
||||
EVP_KEYEXCH_settable_ctx_params(keyexch),
|
||||
meta);
|
||||
}
|
||||
#endif
|
||||
|
||||
int provider_main(int argc, char **argv)
|
||||
{
|
||||
int ret = 1, i;
|
||||
int verbose = 0;
|
||||
STACK_OF(OPENSSL_CSTRING) *providers = sk_OPENSSL_CSTRING_new_null();
|
||||
OPTION_CHOICE o;
|
||||
char *prog;
|
||||
|
||||
prog = opt_init(argc, argv, provider_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
default: /* Catching OPT_ERR & covering OPT_EOF which isn't possible */
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(provider_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_VVV:
|
||||
case OPT_VV:
|
||||
case OPT_V:
|
||||
/* Convert to an integer from one to four. */
|
||||
i = (int)(o - OPT_V) + 1;
|
||||
if (verbose < i)
|
||||
verbose = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allow any trailing parameters as provider names. */
|
||||
argc = opt_num_rest();
|
||||
argv = opt_rest();
|
||||
for ( ; *argv; argv++) {
|
||||
if (**argv == '-') {
|
||||
BIO_printf(bio_err, "%s: Cannot mix flags and provider names.\n",
|
||||
prog);
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
}
|
||||
sk_OPENSSL_CSTRING_push(providers, *argv);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
for (i = 0; i < sk_OPENSSL_CSTRING_num(providers); i++) {
|
||||
const char *name = sk_OPENSSL_CSTRING_value(providers, i);
|
||||
OSSL_PROVIDER *prov = OSSL_PROVIDER_load(NULL, name);
|
||||
|
||||
if (prov != NULL) {
|
||||
BIO_printf(bio_out, verbose == 0 ? "%s\n" : "[ %s ]\n", name);
|
||||
|
||||
if (verbose > 0) {
|
||||
META data;
|
||||
|
||||
data.total = 0;
|
||||
data.first = 1;
|
||||
data.verbose = verbose;
|
||||
data.prov = prov;
|
||||
data.fn = print_caps;
|
||||
|
||||
switch (verbose) {
|
||||
case 1:
|
||||
BIO_printf(bio_out, " ");
|
||||
break;
|
||||
case 2:
|
||||
data.indent = 4;
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
data.indent = 4;
|
||||
data.subindent = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
if (verbose > 1) {
|
||||
data.first = 1;
|
||||
data.label = "Cipher";
|
||||
}
|
||||
EVP_CIPHER_do_all_ex(NULL, do_cipher, &data);
|
||||
if (verbose > 1) {
|
||||
data.first = 1;
|
||||
data.label = "Digest";
|
||||
}
|
||||
EVP_MD_do_all_ex(NULL, do_digest, &data);
|
||||
if (verbose > 1) {
|
||||
data.first = 1;
|
||||
data.label = "MAC";
|
||||
}
|
||||
EVP_MAC_do_all_ex(NULL, do_mac, &data);
|
||||
|
||||
/*
|
||||
* TODO(3.0) Enable when KEYMGMT and KEYEXCH have do_all_ex functions
|
||||
*/
|
||||
#if 0
|
||||
if (verbose > 1) {
|
||||
data.first = 1;
|
||||
data.label = "Key manager";
|
||||
}
|
||||
EVP_KEYMGMT_do_all_ex(NULL, do_keymgmt, &data);
|
||||
if (verbose > 1) {
|
||||
data.first = 1;
|
||||
data.label = "Key exchange";
|
||||
}
|
||||
EVP_KEYEXCH_do_all_ex(NULL, do_keyexch, &data);
|
||||
#endif
|
||||
|
||||
switch (verbose) {
|
||||
default:
|
||||
break;
|
||||
case 2:
|
||||
case 1:
|
||||
BIO_printf(bio_out, "\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
OSSL_PROVIDER_unload(prov);
|
||||
} else {
|
||||
ERR_print_errors(bio_err);
|
||||
ret = 1;
|
||||
/*
|
||||
* Just because one provider module failed, there's no reason to
|
||||
* stop, if there are more to try.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
ERR_print_errors(bio_err);
|
||||
sk_OPENSSL_CSTRING_free(providers);
|
||||
return ret;
|
||||
}
|
||||
@@ -227,7 +227,6 @@ int rsa_main(int argc, char **argv)
|
||||
|
||||
while ((err = ERR_peek_error()) != 0 &&
|
||||
ERR_GET_LIB(err) == ERR_LIB_RSA &&
|
||||
ERR_GET_FUNC(err) == RSA_F_RSA_CHECK_KEY_EX &&
|
||||
ERR_GET_REASON(err) != ERR_R_MALLOC_FAILURE) {
|
||||
BIO_printf(out, "RSA key error: %s\n",
|
||||
ERR_reason_error_string(err));
|
||||
|
||||
+1
-1
@@ -3104,7 +3104,7 @@ int s_client_main(int argc, char **argv)
|
||||
BIO_printf(bio_err, "RENEGOTIATING\n");
|
||||
SSL_renegotiate(con);
|
||||
cbuf_len = 0;
|
||||
} else if (!c_ign_eof && (cbuf[0] == 'K' || cbuf[0] == 'k' )
|
||||
} else if (!c_ign_eof && (cbuf[0] == 'K' || cbuf[0] == 'k' )
|
||||
&& cmdletters) {
|
||||
BIO_printf(bio_err, "KEYUPDATE\n");
|
||||
SSL_key_update(con,
|
||||
|
||||
+1
-1
@@ -470,7 +470,7 @@ static int ssl_servername_cb(SSL *s, int *ad, void *arg)
|
||||
BIO_printf(p->biodebug, "Hostname in TLS extension: \"");
|
||||
while ((uc = *cp++) != 0)
|
||||
BIO_printf(p->biodebug,
|
||||
isascii(uc) && isprint(uc) ? "%c" : "\\x%02x", uc);
|
||||
(((uc) & ~127) == 0) && isprint(uc) ? "%c" : "\\x%02x", uc);
|
||||
BIO_printf(p->biodebug, "\"\n");
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -3114,7 +3114,6 @@ int speed_main(int argc, char **argv)
|
||||
if (error == ERR_peek_last_error() && /* oldest and latest errors match */
|
||||
/* check that the error origin matches */
|
||||
ERR_GET_LIB(error) == ERR_LIB_EVP &&
|
||||
ERR_GET_FUNC(error) == EVP_F_INT_CTX_NEW &&
|
||||
ERR_GET_REASON(error) == EVP_R_UNSUPPORTED_ALGORITHM)
|
||||
ERR_get_error(); /* pop error from queue */
|
||||
if (ERR_peek_error()) {
|
||||
@@ -3364,6 +3363,7 @@ int speed_main(int argc, char **argv)
|
||||
printf("%s ", BF_options());
|
||||
#endif
|
||||
printf("\n%s\n", OpenSSL_version(OPENSSL_CFLAGS));
|
||||
printf("%s\n", OpenSSL_version(OPENSSL_CPU_INFO));
|
||||
}
|
||||
|
||||
if (pr_header) {
|
||||
@@ -3638,7 +3638,7 @@ static int do_multi(int multi, int size_num)
|
||||
close(fd[1]);
|
||||
mr = 1;
|
||||
usertime = 0;
|
||||
free(fds);
|
||||
OPENSSL_free(fds);
|
||||
return 0;
|
||||
}
|
||||
printf("Forked child %d\n", n);
|
||||
@@ -3750,7 +3750,7 @@ static int do_multi(int multi, int size_num)
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
free(fds);
|
||||
OPENSSL_free(fds);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
+11
-45
@@ -33,7 +33,7 @@
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_B, OPT_D, OPT_E, OPT_M, OPT_F, OPT_O, OPT_P, OPT_V, OPT_A, OPT_R
|
||||
OPT_B, OPT_D, OPT_E, OPT_M, OPT_F, OPT_O, OPT_P, OPT_V, OPT_A, OPT_R, OPT_C
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS version_options[] = {
|
||||
@@ -48,24 +48,15 @@ const OPTIONS version_options[] = {
|
||||
{"p", OPT_P, '-', "Show target build platform"},
|
||||
{"r", OPT_R, '-', "Show random seeding options"},
|
||||
{"v", OPT_V, '-', "Show library version"},
|
||||
{"c", OPT_C, '-', "Show CPU settings info"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
#if defined(OPENSSL_RAND_SEED_DEVRANDOM) || defined(OPENSSL_RAND_SEED_EGD)
|
||||
static void printlist(const char *prefix, const char **dev)
|
||||
{
|
||||
printf("%s (", prefix);
|
||||
for ( ; *dev != NULL; dev++)
|
||||
printf(" \"%s\"", *dev);
|
||||
printf(" )");
|
||||
}
|
||||
#endif
|
||||
|
||||
int version_main(int argc, char **argv)
|
||||
{
|
||||
int ret = 1, dirty = 0, seed = 0;
|
||||
int cflags = 0, version = 0, date = 0, options = 0, platform = 0, dir = 0;
|
||||
int engdir = 0, moddir = 0;
|
||||
int engdir = 0, moddir = 0, cpuinfo = 0;
|
||||
char *prog;
|
||||
OPTION_CHOICE o;
|
||||
|
||||
@@ -108,9 +99,12 @@ opthelp:
|
||||
case OPT_V:
|
||||
dirty = version = 1;
|
||||
break;
|
||||
case OPT_C:
|
||||
dirty = cpuinfo = 1;
|
||||
break;
|
||||
case OPT_A:
|
||||
seed = options = cflags = version = date = platform
|
||||
= dir = engdir = moddir
|
||||
= dir = engdir = moddir = cpuinfo
|
||||
= 1;
|
||||
break;
|
||||
}
|
||||
@@ -158,39 +152,11 @@ opthelp:
|
||||
if (moddir)
|
||||
printf("%s\n", OpenSSL_version(OPENSSL_MODULES_DIR));
|
||||
if (seed) {
|
||||
printf("Seeding source:");
|
||||
#ifdef OPENSSL_RAND_SEED_RTDSC
|
||||
printf(" rtdsc");
|
||||
#endif
|
||||
#ifdef OPENSSL_RAND_SEED_RDCPU
|
||||
printf(" rdrand ( rdseed rdrand )");
|
||||
#endif
|
||||
#ifdef OPENSSL_RAND_SEED_LIBRANDOM
|
||||
printf(" C-library-random");
|
||||
#endif
|
||||
#ifdef OPENSSL_RAND_SEED_GETRANDOM
|
||||
printf(" getrandom-syscall");
|
||||
#endif
|
||||
#ifdef OPENSSL_RAND_SEED_DEVRANDOM
|
||||
{
|
||||
static const char *dev[] = { DEVRANDOM, NULL };
|
||||
printlist(" random-device", dev);
|
||||
}
|
||||
#endif
|
||||
#ifdef OPENSSL_RAND_SEED_EGD
|
||||
{
|
||||
static const char *dev[] = { DEVRANDOM_EGD, NULL };
|
||||
printlist(" EGD", dev);
|
||||
}
|
||||
#endif
|
||||
#ifdef OPENSSL_RAND_SEED_NONE
|
||||
printf(" none");
|
||||
#endif
|
||||
#ifdef OPENSSL_RAND_SEED_OS
|
||||
printf(" os-specific");
|
||||
#endif
|
||||
printf("\n");
|
||||
const char *src = OPENSSL_info(OPENSSL_INFO_SEED_SOURCE);
|
||||
printf("Seeding source: %s\n", src ? src : "N/A");
|
||||
}
|
||||
if (cpuinfo)
|
||||
printf("%s\n", OpenSSL_version(OPENSSL_CPU_INFO));
|
||||
ret = 0;
|
||||
end:
|
||||
return ret;
|
||||
|
||||
+2
-2
@@ -53,9 +53,9 @@ test_script:
|
||||
- ps: >-
|
||||
If ($env:Configuration -Match "shared" -or $env:EXTENDED_TESTS) {
|
||||
if ($env:EXTENDED_TESTS) {
|
||||
cmd /c "nmake test V=1 2>&1"
|
||||
cmd /c "nmake test HARNESS_VERBOSE_FAILURE=yes 2>&1"
|
||||
} Else {
|
||||
cmd /c "nmake test V=1 TESTS=-test_fuzz 2>&1"
|
||||
cmd /c "nmake test HARNESS_VERBOSE_FAILURE=yes TESTS=-test_fuzz 2>&1"
|
||||
}
|
||||
}
|
||||
- ps: >-
|
||||
|
||||
@@ -0,0 +1,418 @@
|
||||
#! {- $config{HASHBANGPERL} -}
|
||||
# -*- mode: perl -*-
|
||||
{-
|
||||
sub out_item {
|
||||
my $ref = shift;
|
||||
# Available options:
|
||||
# indent => callers indentation (int)
|
||||
# delimiters => 1 if outer delimiters should be added
|
||||
my %opts = @_;
|
||||
|
||||
my $indent = $opts{indent} // 0;
|
||||
# Indentation of the whole structure, where applicable
|
||||
my $nlindent1 = "\n" . ' ' x $indent;
|
||||
# Indentation of individual items, where applicable
|
||||
my $nlindent2 = "\n" . ' ' x ($indent + 4);
|
||||
|
||||
my $product; # Finished product, or reference to a function that
|
||||
# produces a string, given $_
|
||||
# The following are only used when $product is a function reference
|
||||
my $delim_l; # Left delimiter of structure
|
||||
my $delim_r; # Right delimiter of structure
|
||||
my $separator; # Item separator
|
||||
my @items; # Items to iterate over
|
||||
|
||||
if (ref($ref) eq "ARRAY") {
|
||||
if (scalar @$ref == 0) {
|
||||
$product = $opts{delimiters} ? '[]' : '';
|
||||
} else {
|
||||
$product = sub {
|
||||
out_item(\$_, delimiters => 1, indent => $indent + 4)
|
||||
};
|
||||
$delim_l = ($opts{delimiters} ? '[' : '').$nlindent2;
|
||||
$delim_r = $nlindent1.($opts{delimiters} ? ']' : '');
|
||||
$separator = ",$nlindent2";
|
||||
@items = @$ref;
|
||||
}
|
||||
} elsif (ref($ref) eq "HASH") {
|
||||
if (scalar keys %$ref == 0) {
|
||||
$product = $opts{delimiters} ? '{}' : '';
|
||||
} else {
|
||||
$product = sub {
|
||||
quotify1($_) . " => "
|
||||
. out_item($ref->{$_}, delimiters => 1, indent => $indent + 4)
|
||||
};
|
||||
$delim_l = ($opts{delimiters} ? '{' : '').$nlindent2;
|
||||
$delim_r = $nlindent1.($opts{delimiters} ? '}' : '');
|
||||
$separator = ",$nlindent2";
|
||||
@items = sort keys %$ref;
|
||||
}
|
||||
} elsif (ref($ref) eq "SCALAR") {
|
||||
$product = defined $$ref ? quotify1 $$ref : "undef";
|
||||
} else {
|
||||
$product = defined $ref ? quotify1 $ref : "undef";
|
||||
}
|
||||
|
||||
if (ref($product) eq "CODE") {
|
||||
$delim_l . join($separator, map { &$product } @items) . $delim_r;
|
||||
} else {
|
||||
$product;
|
||||
}
|
||||
}
|
||||
|
||||
# We must make sourcedir() return an absolute path, because configdata.pm
|
||||
# may be loaded as a module from any script in any directory, making
|
||||
# relative paths untrustable. Because the result is used with 'use lib',
|
||||
# we must ensure that it returns a Unix style path. Cwd::abs_path does
|
||||
# that (File::Spec::Functions::rel2abs return O/S specific paths)
|
||||
use File::Spec::Functions;
|
||||
use Cwd qw(abs_path);
|
||||
sub sourcedir {
|
||||
return abs_path(catdir($config{sourcedir}, @_));
|
||||
}
|
||||
sub sourcefile {
|
||||
return abs_path(catfile($config{sourcedir}, @_));
|
||||
}
|
||||
-}
|
||||
package configdata;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(
|
||||
%config %target %disabled %withargs %unified_info
|
||||
@disablables @disablables_int
|
||||
);
|
||||
|
||||
our %config = ({- out_item(\%config); -});
|
||||
our %target = ({- out_item(\%target); -});
|
||||
our @disablables = ({- out_item(\@disablables) -});
|
||||
our @disablables_int = ({- out_item(\@disablables_int) -});
|
||||
our %disabled = ({- out_item(\%disabled); -});
|
||||
our %withargs = ({- out_item(\%withargs); -});
|
||||
our %unified_info = ({- out_item(\%unified_info); -});
|
||||
|
||||
# Unexported, only used by OpenSSL::Test::Utils::available_protocols()
|
||||
our %available_protocols = (
|
||||
tls => [{- out_item(\@tls) -}],
|
||||
dtls => [{- out_item(\@dtls) -}],
|
||||
);
|
||||
|
||||
# The following data is only used when this files is use as a script
|
||||
my @makevars = ({- out_item(\@makevars); -});
|
||||
my %disabled_info = ({- out_item(\%disabled_info); -});
|
||||
my @user_crossable = qw( {- join (' ', @user_crossable) -} );
|
||||
|
||||
# If run directly, we can give some answers, and even reconfigure
|
||||
unless (caller) {
|
||||
use Getopt::Long;
|
||||
use File::Spec::Functions;
|
||||
use File::Basename;
|
||||
use Pod::Usage;
|
||||
|
||||
my $here = dirname($0);
|
||||
|
||||
if (scalar @ARGV == 0) {
|
||||
# With no arguments, re-create the build file
|
||||
|
||||
use lib '{- sourcedir('util', 'perl') -}';
|
||||
use OpenSSL::fallback '{- sourcefile('external', 'perl', 'MODULES.txt') -}';
|
||||
use OpenSSL::Template;
|
||||
|
||||
my $prepend = <<"_____";
|
||||
use File::Spec::Functions;
|
||||
use lib '{- sourcedir('util', 'perl') -}';
|
||||
_____
|
||||
$prepend .= <<"_____" if defined $target{perl_platform};
|
||||
use lib '{- sourcedir('Configurations') -}';
|
||||
use lib '{- $config{builddir} -}';
|
||||
use platform;
|
||||
_____
|
||||
|
||||
my @autowarntext = (
|
||||
'WARNING: do not edit!',
|
||||
"Generated by configdata.pm from "
|
||||
.join(", ", @{$config{build_file_templates}})
|
||||
);
|
||||
|
||||
print 'Creating ',$target{build_file},"\n";
|
||||
open BUILDFILE, ">$target{build_file}.new"
|
||||
or die "Trying to create $target{build_file}.new: $!";
|
||||
foreach (@{$config{build_file_templates}}) {
|
||||
my $tmpl = OpenSSL::Template->new(TYPE => 'FILE',
|
||||
SOURCE => $_);
|
||||
$tmpl->fill_in(FILENAME => $_,
|
||||
OUTPUT => \*BUILDFILE,
|
||||
HASH => { config => \%config,
|
||||
target => \%target,
|
||||
disabled => \%disabled,
|
||||
withargs => \%withargs,
|
||||
unified_info => \%unified_info,
|
||||
autowarntext => \@autowarntext },
|
||||
PREPEND => $prepend,
|
||||
# To ensure that global variables and functions
|
||||
# defined in one template stick around for the
|
||||
# next, making them combinable
|
||||
PACKAGE => 'OpenSSL::safe')
|
||||
or die $Text::Template::ERROR;
|
||||
}
|
||||
close BUILDFILE;
|
||||
rename("$target{build_file}.new", $target{build_file})
|
||||
or die "Trying to rename $target{build_file}.new to $target{build_file}: $!";
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
my $dump = undef;
|
||||
my $cmdline = undef;
|
||||
my $options = undef;
|
||||
my $target = undef;
|
||||
my $envvars = undef;
|
||||
my $makevars = undef;
|
||||
my $buildparams = undef;
|
||||
my $reconf = undef;
|
||||
my $verbose = undef;
|
||||
my $help = undef;
|
||||
my $man = undef;
|
||||
GetOptions('dump|d' => \$dump,
|
||||
'command-line|c' => \$cmdline,
|
||||
'options|o' => \$options,
|
||||
'target|t' => \$target,
|
||||
'environment|e' => \$envvars,
|
||||
'make-variables|m' => \$makevars,
|
||||
'build-parameters|b' => \$buildparams,
|
||||
'reconfigure|reconf|r' => \$reconf,
|
||||
'verbose|v' => \$verbose,
|
||||
'help' => \$help,
|
||||
'man' => \$man)
|
||||
or die "Errors in command line arguments\n";
|
||||
|
||||
if (scalar @ARGV > 0) {
|
||||
print STDERR <<"_____";
|
||||
Unrecognised arguments.
|
||||
For more information, do '$0 --help'
|
||||
_____
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if ($help) {
|
||||
pod2usage(-exitval => 0,
|
||||
-verbose => 1);
|
||||
}
|
||||
if ($man) {
|
||||
pod2usage(-exitval => 0,
|
||||
-verbose => 2);
|
||||
}
|
||||
if ($dump || $cmdline) {
|
||||
print "\nCommand line (with current working directory = $here):\n\n";
|
||||
print ' ',join(' ',
|
||||
$config{PERL},
|
||||
catfile($config{sourcedir}, 'Configure'),
|
||||
@{$config{perlargv}}), "\n";
|
||||
print "\nPerl information:\n\n";
|
||||
print ' ',$config{perl_cmd},"\n";
|
||||
print ' ',$config{perl_version},' for ',$config{perl_archname},"\n";
|
||||
}
|
||||
if ($dump || $options) {
|
||||
my $longest = 0;
|
||||
my $longest2 = 0;
|
||||
foreach my $what (@disablables) {
|
||||
$longest = length($what) if $longest < length($what);
|
||||
$longest2 = length($disabled{$what})
|
||||
if $disabled{$what} && $longest2 < length($disabled{$what});
|
||||
}
|
||||
print "\nEnabled features:\n\n";
|
||||
foreach my $what (@disablables) {
|
||||
print " $what\n" unless $disabled{$what};
|
||||
}
|
||||
print "\nDisabled features:\n\n";
|
||||
foreach my $what (@disablables) {
|
||||
if ($disabled{$what}) {
|
||||
print " $what", ' ' x ($longest - length($what) + 1),
|
||||
"[$disabled{$what}]", ' ' x ($longest2 - length($disabled{$what}) + 1);
|
||||
print $disabled_info{$what}->{macro}
|
||||
if $disabled_info{$what}->{macro};
|
||||
print ' (skip ',
|
||||
join(', ', @{$disabled_info{$what}->{skipped}}),
|
||||
')'
|
||||
if $disabled_info{$what}->{skipped};
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($dump || $target) {
|
||||
print "\nConfig target attributes:\n\n";
|
||||
foreach (sort keys %target) {
|
||||
next if $_ =~ m|^_| || $_ eq 'template';
|
||||
my $quotify = sub {
|
||||
map { (my $x = $_) =~ s|([\\\$\@"])|\\$1|g; "\"$x\""} @_;
|
||||
};
|
||||
print ' ', $_, ' => ';
|
||||
if (ref($target{$_}) eq "ARRAY") {
|
||||
print '[ ', join(', ', $quotify->(@{$target{$_}})), " ],\n";
|
||||
} else {
|
||||
print $quotify->($target{$_}), ",\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($dump || $envvars) {
|
||||
print "\nRecorded environment:\n\n";
|
||||
foreach (sort keys %{$config{perlenv}}) {
|
||||
print ' ',$_,' = ',($config{perlenv}->{$_} || ''),"\n";
|
||||
}
|
||||
}
|
||||
if ($dump || $makevars) {
|
||||
print "\nMakevars:\n\n";
|
||||
foreach my $var (@makevars) {
|
||||
my $prefix = '';
|
||||
$prefix = $config{CROSS_COMPILE}
|
||||
if grep { $var eq $_ } @user_crossable;
|
||||
$prefix //= '';
|
||||
print ' ',$var,' ' x (16 - length $var),'= ',
|
||||
(ref $config{$var} eq 'ARRAY'
|
||||
? join(' ', @{$config{$var}})
|
||||
: $prefix.$config{$var}),
|
||||
"\n"
|
||||
if defined $config{$var};
|
||||
}
|
||||
|
||||
my @buildfile = ($config{builddir}, $config{build_file});
|
||||
unshift @buildfile, $here
|
||||
unless file_name_is_absolute($config{builddir});
|
||||
my $buildfile = canonpath(catdir(@buildfile));
|
||||
print <<"_____";
|
||||
|
||||
NOTE: These variables only represent the configuration view. The build file
|
||||
template may have processed these variables further, please have a look at the
|
||||
build file for more exact data:
|
||||
$buildfile
|
||||
_____
|
||||
}
|
||||
if ($dump || $buildparams) {
|
||||
my @buildfile = ($config{builddir}, $config{build_file});
|
||||
unshift @buildfile, $here
|
||||
unless file_name_is_absolute($config{builddir});
|
||||
print "\nbuild file:\n\n";
|
||||
print " ", canonpath(catfile(@buildfile)),"\n";
|
||||
|
||||
print "\nbuild file templates:\n\n";
|
||||
foreach (@{$config{build_file_templates}}) {
|
||||
my @tmpl = ($_);
|
||||
unshift @tmpl, $here
|
||||
unless file_name_is_absolute($config{sourcedir});
|
||||
print ' ',canonpath(catfile(@tmpl)),"\n";
|
||||
}
|
||||
}
|
||||
if ($reconf) {
|
||||
if ($verbose) {
|
||||
print 'Reconfiguring with: ', join(' ',@{$config{perlargv}}), "\n";
|
||||
foreach (sort keys %{$config{perlenv}}) {
|
||||
print ' ',$_,' = ',($config{perlenv}->{$_} || ""),"\n";
|
||||
}
|
||||
}
|
||||
|
||||
chdir $here;
|
||||
exec $^X,catfile($config{sourcedir}, 'Configure'),'reconf';
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
configdata.pm - configuration data for OpenSSL builds
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
Interactive:
|
||||
|
||||
perl configdata.pm [options]
|
||||
|
||||
As data bank module:
|
||||
|
||||
use configdata;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module can be used in two modes, interactively and as a module containing
|
||||
all the data recorded by OpenSSL's Configure script.
|
||||
|
||||
When used interactively, simply run it as any perl script.
|
||||
If run with no arguments, it will rebuild the build file (Makefile or
|
||||
corresponding).
|
||||
With at least one option, it will instead get the information you ask for, or
|
||||
re-run the configuration process.
|
||||
See L</OPTIONS> below for more information.
|
||||
|
||||
When loaded as a module, you get a few databanks with useful information to
|
||||
perform build related tasks. The databanks are:
|
||||
|
||||
%config Configured things.
|
||||
%target The OpenSSL config target with all inheritances
|
||||
resolved.
|
||||
%disabled The features that are disabled.
|
||||
@disablables The list of features that can be disabled.
|
||||
%withargs All data given through --with-THING options.
|
||||
%unified_info All information that was computed from the build.info
|
||||
files.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 4
|
||||
|
||||
=item B<--help>
|
||||
|
||||
Print a brief help message and exit.
|
||||
|
||||
=item B<--man>
|
||||
|
||||
Print the manual page and exit.
|
||||
|
||||
=item B<--dump> | B<-d>
|
||||
|
||||
Print all relevant configuration data. This is equivalent to B<--command-line>
|
||||
B<--options> B<--target> B<--environment> B<--make-variables>
|
||||
B<--build-parameters>.
|
||||
|
||||
=item B<--command-line> | B<-c>
|
||||
|
||||
Print the current configuration command line.
|
||||
|
||||
=item B<--options> | B<-o>
|
||||
|
||||
Print the features, both enabled and disabled, and display defined macro and
|
||||
skipped directories where applicable.
|
||||
|
||||
=item B<--target> | B<-t>
|
||||
|
||||
Print the config attributes for this config target.
|
||||
|
||||
=item B<--environment> | B<-e>
|
||||
|
||||
Print the environment variables and their values at the time of configuration.
|
||||
|
||||
=item B<--make-variables> | B<-m>
|
||||
|
||||
Print the main make variables generated in the current configuration
|
||||
|
||||
=item B<--build-parameters> | B<-b>
|
||||
|
||||
Print the build parameters, i.e. build file and build file templates.
|
||||
|
||||
=item B<--reconfigure> | B<--reconf> | B<-r>
|
||||
|
||||
Re-run the configuration process.
|
||||
|
||||
=item B<--verbose> | B<-v>
|
||||
|
||||
Verbose output.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
EOF
|
||||
@@ -198,9 +198,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open OUT,">$output";
|
||||
*STDOUT=*OUT;
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],$x86only = $ARGV[$#ARGV] eq "386");
|
||||
&static_label("AES_Te");
|
||||
|
||||
@@ -39,9 +39,10 @@
|
||||
# Profiler-assisted and platform-specific optimization resulted in 16%
|
||||
# improvement on Cortex A8 core and ~21.5 cycles per byte.
|
||||
|
||||
$flavour = shift;
|
||||
if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; }
|
||||
else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} }
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
if ($flavour && $flavour ne "void") {
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
@@ -49,9 +50,10 @@ if ($flavour && $flavour ne "void") {
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
} else {
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
}
|
||||
|
||||
$s0="r0";
|
||||
|
||||
@@ -37,8 +37,7 @@
|
||||
# cost of 8x increased pressure on L1D. 8x because you'd have
|
||||
# to interleave both Te and Td tables...
|
||||
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
($TEA,$TEB)=("A5","B5");
|
||||
($KPA,$KPB)=("A3","B1");
|
||||
|
||||
@@ -65,8 +65,12 @@
|
||||
# ($t0,$t1,$t2,$t3,$t8,$t9)=map("\$$_",(12..15,24,25));
|
||||
# ($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7)=map("\$$_",(16..23));
|
||||
# ($gp,$sp,$fp,$ra)=map("\$$_",(28..31));
|
||||
#
|
||||
$flavour = shift || "o32"; # supported flavours are o32,n32,64,nubi32,nubi64
|
||||
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
$flavour ||= "o32"; # supported flavours are o32,n32,64,nubi32,nubi64
|
||||
|
||||
if ($flavour =~ /64|n32/i) {
|
||||
$PTR_LA="dla";
|
||||
@@ -95,17 +99,13 @@ $pf = ($flavour =~ /nubi/i) ? $t0 : $t2;
|
||||
|
||||
$big_endian=(`echo MIPSEB | $ENV{CC} -E -`=~/MIPSEB/)?0:1 if ($ENV{CC});
|
||||
|
||||
for (@ARGV) { $output=$_ if (/\w[\w\-]*\.\w+$/); }
|
||||
open STDOUT,">$output";
|
||||
|
||||
if (!defined($big_endian))
|
||||
{ $big_endian=(unpack('L',pack('N',1))==1); }
|
||||
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
|
||||
my ($MSB,$LSB)=(0,3); # automatically converted to little-endian
|
||||
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
$code.=<<___;
|
||||
#include "mips_arch.h"
|
||||
|
||||
|
||||
@@ -28,9 +28,12 @@
|
||||
#
|
||||
# Special thanks to polarhome.com for providing HP-UX account.
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
open STDOUT,">$output";
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
if ($flavour =~ /64/) {
|
||||
$LEVEL ="2.0W";
|
||||
|
||||
@@ -36,7 +36,10 @@
|
||||
# ppc_AES_encrypt_compact operates at 42 cycles per byte, while
|
||||
# ppc_AES_decrypt_compact - at 55 (in 64-bit build).
|
||||
|
||||
$flavour = shift;
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
if ($flavour =~ /64/) {
|
||||
$SIZE_T =8;
|
||||
@@ -59,7 +62,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||
die "can't locate ppc-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
|
||||
open STDOUT,"| $^X $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
|
||||
$FRAME=32*$SIZE_T;
|
||||
|
||||
|
||||
@@ -89,7 +89,10 @@
|
||||
# instructions, which deliver ~70% improvement at 8KB block size over
|
||||
# vanilla km-based code, 37% - at most like 512-bytes block size.
|
||||
|
||||
$flavour = shift;
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
if ($flavour =~ /3[12]/) {
|
||||
$SIZE_T=4;
|
||||
@@ -99,8 +102,7 @@ if ($flavour =~ /3[12]/) {
|
||||
$g="g";
|
||||
}
|
||||
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
|
||||
$softonly=0; # allow hardware support
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@
|
||||
# optimal decrypt procedure]. Compared to GNU C generated code both
|
||||
# procedures are more than 60% faster:-)
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
$frame="STACK_FRAME";
|
||||
$bias="STACK_BIAS";
|
||||
|
||||
@@ -33,9 +33,10 @@
|
||||
#
|
||||
# (*) with hyper-threading off
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -44,7 +45,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$verticalspin=1; # unlike 32-bit version $verticalspin performs
|
||||
|
||||
@@ -33,8 +33,7 @@
|
||||
# instructions and improve single-block and short-input performance
|
||||
# with misaligned data.
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
{
|
||||
my ($inp,$out,$key,$rounds,$tmp,$mask) = map("%o$_",(0..5));
|
||||
|
||||
@@ -42,9 +42,10 @@
|
||||
# (*) Sandy/Ivy Bridge are known to handle high interleave factors
|
||||
# suboptimally;
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -74,7 +75,8 @@ if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
# void aesni_multi_cbc_encrypt (
|
||||
|
||||
@@ -88,9 +88,10 @@
|
||||
# (**) Execution is fully dominated by integer code sequence and
|
||||
# SIMD still hardly shows [in single-process benchmark;-]
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -114,7 +115,8 @@ $shaext=1; ### set to zero if compiling for 1.0.1
|
||||
|
||||
$stitched_decrypt=0;
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
# void aesni_cbc_sha1_enc(const void *inp,
|
||||
|
||||
@@ -44,9 +44,10 @@
|
||||
# -evp aes-256-cbc-hmac-sha256' will vary by percent or two;
|
||||
# (***) these are SHAEXT results;
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -77,7 +78,8 @@ if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([
|
||||
$shaext=$avx; ### set to zero if compiling for 1.0.1
|
||||
$avx=1 if (!$shaext && $avx);
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$func="aesni_cbc_sha256_enc";
|
||||
|
||||
@@ -76,9 +76,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open OUT,">$output";
|
||||
*STDOUT=*OUT;
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0]);
|
||||
|
||||
|
||||
@@ -192,9 +192,10 @@ $PREFIX="aesni"; # if $PREFIX is set to "AES", the script
|
||||
# generates drop-in replacement for
|
||||
# crypto/aes/asm/aes-x86_64.pl:-)
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -203,7 +204,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$movkey = $PREFIX eq "aesni" ? "movups" : "movups";
|
||||
|
||||
@@ -43,7 +43,10 @@
|
||||
# POWER9[le] 4.02/0.86 0.84 1.05
|
||||
# POWER9[be] 3.99/0.78 0.79 0.97
|
||||
|
||||
$flavour = shift;
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
if ($flavour =~ /64/) {
|
||||
$SIZE_T =8;
|
||||
@@ -70,7 +73,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||
die "can't locate ppc-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
|
||||
open STDOUT,"| $^X $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
|
||||
$FRAME=8*$SIZE_T;
|
||||
$prefix="aes_p8";
|
||||
|
||||
@@ -75,8 +75,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "sparcv9_modes.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
$::evp=1; # if $evp is set to 0, script generates module with
|
||||
# AES_[en|de]crypt, AES_set_[en|de]crypt_key and AES_cbc_encrypt entry
|
||||
|
||||
@@ -56,15 +56,18 @@
|
||||
# (**) numbers after slash are for 32-bit code, which is 3x-
|
||||
# interleaved;
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$prefix="aes_v8";
|
||||
|
||||
@@ -50,9 +50,10 @@
|
||||
# April-August 2013
|
||||
# Add CBC, CTR and XTS subroutines and adapt for kernel use; courtesy of Ard.
|
||||
|
||||
$flavour = shift;
|
||||
if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; }
|
||||
else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} }
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
if ($flavour && $flavour ne "void") {
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
@@ -60,9 +61,10 @@ if ($flavour && $flavour ne "void") {
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open STDOUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
} else {
|
||||
open STDOUT,">$output";
|
||||
$output and open STDOUT,">$output";
|
||||
}
|
||||
|
||||
my ($inp,$out,$len,$key)=("r0","r1","r2","r3");
|
||||
|
||||
@@ -97,9 +97,10 @@
|
||||
#
|
||||
# <appro@openssl.org>
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -108,7 +109,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
my ($inp,$out,$len,$key,$ivp)=("%rdi","%rsi","%rdx","%rcx");
|
||||
|
||||
@@ -38,15 +38,18 @@
|
||||
# code, but it's constant-time and therefore preferred;
|
||||
# (***) presented for reference/comparison purposes;
|
||||
|
||||
$flavour = shift;
|
||||
while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {}
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
|
||||
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$code.=<<___;
|
||||
|
||||
@@ -35,7 +35,10 @@
|
||||
# (**) Inadequate POWER6 performance is due to astronomic AltiVec
|
||||
# latency, 9 cycles per simple logical operation.
|
||||
|
||||
$flavour = shift;
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
if ($flavour =~ /64/) {
|
||||
$SIZE_T =8;
|
||||
@@ -61,7 +64,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
|
||||
die "can't locate ppc-xlate.pl";
|
||||
|
||||
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
|
||||
open STDOUT,"| $^X $xlate $flavour \"$output\""
|
||||
|| die "can't call $xlate: $!";
|
||||
|
||||
$code.=<<___;
|
||||
.machine "any"
|
||||
|
||||
@@ -58,9 +58,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
|
||||
$output = pop;
|
||||
open OUT,">$output";
|
||||
*STDOUT=*OUT;
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],$x86only = $ARGV[$#ARGV] eq "386");
|
||||
|
||||
|
||||
@@ -54,9 +54,10 @@
|
||||
#
|
||||
# <appro@openssl.org>
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
|
||||
|
||||
@@ -65,7 +66,8 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
|
||||
die "can't locate x86_64-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
|
||||
open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$PREFIX="vpaes";
|
||||
|
||||
+24
-27
@@ -67,51 +67,48 @@ DEFINE[../../providers/fips]=$AESDEF
|
||||
|
||||
GENERATE[aes-ia64.s]=asm/aes-ia64.S
|
||||
|
||||
GENERATE[aes-586.s]=asm/aes-586.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[aes-586.s]=asm/aes-586.pl
|
||||
DEPEND[aes-586.s]=../perlasm/x86asm.pl
|
||||
GENERATE[vpaes-x86.s]=asm/vpaes-x86.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[vpaes-x86.s]=asm/vpaes-x86.pl
|
||||
DEPEND[vpaes-586.s]=../perlasm/x86asm.pl
|
||||
GENERATE[aesni-x86.s]=asm/aesni-x86.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[aesni-x86.s]=asm/aesni-x86.pl
|
||||
DEPEND[aesni-586.s]=../perlasm/x86asm.pl
|
||||
|
||||
GENERATE[aes-x86_64.s]=asm/aes-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[vpaes-x86_64.s]=asm/vpaes-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[bsaes-x86_64.s]=asm/bsaes-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesni-x86_64.s]=asm/aesni-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesni-sha1-x86_64.s]=asm/aesni-sha1-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesni-sha256-x86_64.s]=asm/aesni-sha256-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesni-mb-x86_64.s]=asm/aesni-mb-x86_64.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-x86_64.s]=asm/aes-x86_64.pl
|
||||
GENERATE[vpaes-x86_64.s]=asm/vpaes-x86_64.pl
|
||||
GENERATE[bsaes-x86_64.s]=asm/bsaes-x86_64.pl
|
||||
GENERATE[aesni-x86_64.s]=asm/aesni-x86_64.pl
|
||||
GENERATE[aesni-sha1-x86_64.s]=asm/aesni-sha1-x86_64.pl
|
||||
GENERATE[aesni-sha256-x86_64.s]=asm/aesni-sha256-x86_64.pl
|
||||
GENERATE[aesni-mb-x86_64.s]=asm/aesni-mb-x86_64.pl
|
||||
|
||||
GENERATE[aes-sparcv9.S]=asm/aes-sparcv9.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-sparcv9.S]=asm/aes-sparcv9.pl
|
||||
INCLUDE[aes-sparcv9.o]=..
|
||||
GENERATE[aest4-sparcv9.S]=asm/aest4-sparcv9.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aest4-sparcv9.S]=asm/aest4-sparcv9.pl
|
||||
INCLUDE[aest4-sparcv9.o]=..
|
||||
DEPEND[aest4-sparcv9.S]=../perlasm/sparcv9_modes.pl
|
||||
GENERATE[aesfx-sparcv9.S]=asm/aesfx-sparcv9.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesfx-sparcv9.S]=asm/aesfx-sparcv9.pl
|
||||
INCLUDE[aesfx-sparcv9.o]=..
|
||||
|
||||
GENERATE[aes-ppc.s]=asm/aes-ppc.pl $(PERLASM_SCHEME)
|
||||
GENERATE[vpaes-ppc.s]=asm/vpaes-ppc.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesp8-ppc.s]=asm/aesp8-ppc.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-ppc.s]=asm/aes-ppc.pl
|
||||
GENERATE[vpaes-ppc.s]=asm/vpaes-ppc.pl
|
||||
GENERATE[aesp8-ppc.s]=asm/aesp8-ppc.pl
|
||||
|
||||
GENERATE[aes-parisc.s]=asm/aes-parisc.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-parisc.s]=asm/aes-parisc.pl
|
||||
|
||||
GENERATE[aes-mips.S]=asm/aes-mips.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-mips.S]=asm/aes-mips.pl
|
||||
INCLUDE[aes-mips.o]=..
|
||||
|
||||
GENERATE[aesv8-armx.S]=asm/aesv8-armx.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aesv8-armx.S]=asm/aesv8-armx.pl
|
||||
INCLUDE[aesv8-armx.o]=..
|
||||
GENERATE[vpaes-armv8.S]=asm/vpaes-armv8.pl $(PERLASM_SCHEME)
|
||||
GENERATE[vpaes-armv8.S]=asm/vpaes-armv8.pl
|
||||
|
||||
GENERATE[aes-armv4.S]=asm/aes-armv4.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-armv4.S]=asm/aes-armv4.pl
|
||||
INCLUDE[aes-armv4.o]=..
|
||||
GENERATE[bsaes-armv7.S]=asm/bsaes-armv7.pl $(PERLASM_SCHEME)
|
||||
GENERATE[bsaes-armv7.S]=asm/bsaes-armv7.pl
|
||||
INCLUDE[bsaes-armv7.o]=..
|
||||
|
||||
GENERATE[aes-s390x.S]=asm/aes-s390x.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-s390x.S]=asm/aes-s390x.pl
|
||||
INCLUDE[aes-s390x.o]=..
|
||||
|
||||
GENERATE[aes-c64xplus.S]=asm/aes-c64xplus.pl $(PERLASM_SCHEME)
|
||||
GENERATE[aes-c64xplus.S]=asm/aes-c64xplus.pl
|
||||
@@ -7,8 +7,7 @@
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
print <<'___';
|
||||
.text
|
||||
|
||||
+1
-1
@@ -1007,7 +1007,7 @@ static void sl2(ARIA_c128 o, const ARIA_u128 *x, const ARIA_u128 *y)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < ARIA_BLOCK_SIZE; i += 4) {
|
||||
o[i ] = sb3[x->c[i ] ^ y->c[i ]];
|
||||
o[i ] = sb3[x->c[i ] ^ y->c[i ]];
|
||||
o[i + 1] = sb4[x->c[i + 1] ^ y->c[i + 1]];
|
||||
o[i + 2] = sb1[x->c[i + 2] ^ y->c[i + 2]];
|
||||
o[i + 3] = sb2[x->c[i + 3] ^ y->c[i + 3]];
|
||||
|
||||
@@ -7,15 +7,18 @@
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
|
||||
( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$code.=<<___;
|
||||
|
||||
@@ -7,15 +7,18 @@
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
# $output is the last argument if it looks like a file (it has an extension)
|
||||
# $flavour is the first argument if it doesn't look like a file
|
||||
$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
|
||||
$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
|
||||
|
||||
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
|
||||
( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
|
||||
( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or
|
||||
die "can't locate arm-xlate.pl";
|
||||
|
||||
open OUT,"| \"$^X\" $xlate $flavour $output";
|
||||
open OUT,"| \"$^X\" $xlate $flavour \"$output\""
|
||||
or die "can't call $xlate: $!";
|
||||
*STDOUT=*OUT;
|
||||
|
||||
$code.=<<___;
|
||||
|
||||
@@ -129,6 +129,9 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
|
||||
int idx;
|
||||
ASN1_STRING_TABLE fnd;
|
||||
|
||||
/* "stable" can be impacted by config, so load the config file first */
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
|
||||
|
||||
fnd.nid = nid;
|
||||
if (stable) {
|
||||
idx = sk_ASN1_STRING_TABLE_find(stable, &fnd);
|
||||
|
||||
+24
-19
@@ -79,7 +79,11 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
char *a;
|
||||
int n, i, i2, l, o, min_l = 11, strict = 0, end = 6, btz = 5, md;
|
||||
struct tm tmp;
|
||||
|
||||
#if defined(CHARSET_EBCDIC)
|
||||
const char upper_z = 0x5A, num_zero = 0x30, period = 0x2E, minus = 0x2D, plus = 0x2B;
|
||||
#else
|
||||
const char upper_z = 'Z', num_zero = '0', period = '.', minus = '-', plus = '+';
|
||||
#endif
|
||||
/*
|
||||
* ASN1_STRING_FLAG_X509_TIME is used to enforce RFC 5280
|
||||
* time string format, in which:
|
||||
@@ -120,20 +124,20 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
if (l < min_l)
|
||||
goto err;
|
||||
for (i = 0; i < end; i++) {
|
||||
if (!strict && (i == btz) && ((a[o] == 'Z') || (a[o] == '+') || (a[o] == '-'))) {
|
||||
if (!strict && (i == btz) && ((a[o] == upper_z) || (a[o] == plus) || (a[o] == minus))) {
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
if (!ossl_isdigit(a[o]))
|
||||
if (!ascii_isdigit(a[o]))
|
||||
goto err;
|
||||
n = a[o] - '0';
|
||||
n = a[o] - num_zero;
|
||||
/* incomplete 2-digital number */
|
||||
if (++o == l)
|
||||
goto err;
|
||||
|
||||
if (!ossl_isdigit(a[o]))
|
||||
if (!ascii_isdigit(a[o]))
|
||||
goto err;
|
||||
n = (n * 10) + a[o] - '0';
|
||||
n = (n * 10) + a[o] - num_zero;
|
||||
/* no more bytes to read, but we haven't seen time-zone yet */
|
||||
if (++o == l)
|
||||
goto err;
|
||||
@@ -185,14 +189,14 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
* Optional fractional seconds: decimal point followed by one or more
|
||||
* digits.
|
||||
*/
|
||||
if (d->type == V_ASN1_GENERALIZEDTIME && a[o] == '.') {
|
||||
if (d->type == V_ASN1_GENERALIZEDTIME && a[o] == period) {
|
||||
if (strict)
|
||||
/* RFC 5280 forbids fractional seconds */
|
||||
goto err;
|
||||
if (++o == l)
|
||||
goto err;
|
||||
i = o;
|
||||
while ((o < l) && ossl_isdigit(a[o]))
|
||||
while ((o < l) && ascii_isdigit(a[o]))
|
||||
o++;
|
||||
/* Must have at least one digit after decimal point */
|
||||
if (i == o)
|
||||
@@ -207,10 +211,10 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
* 'o' can point to '\0' is either the subsequent if or the first
|
||||
* else if is true.
|
||||
*/
|
||||
if (a[o] == 'Z') {
|
||||
if (a[o] == upper_z) {
|
||||
o++;
|
||||
} else if (!strict && ((a[o] == '+') || (a[o] == '-'))) {
|
||||
int offsign = a[o] == '-' ? 1 : -1;
|
||||
} else if (!strict && ((a[o] == plus) || (a[o] == minus))) {
|
||||
int offsign = a[o] == minus ? 1 : -1;
|
||||
int offset = 0;
|
||||
|
||||
o++;
|
||||
@@ -223,13 +227,13 @@ int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d)
|
||||
if (o + 4 != l)
|
||||
goto err;
|
||||
for (i = end; i < end + 2; i++) {
|
||||
if (!ossl_isdigit(a[o]))
|
||||
if (!ascii_isdigit(a[o]))
|
||||
goto err;
|
||||
n = a[o] - '0';
|
||||
n = a[o] - num_zero;
|
||||
o++;
|
||||
if (!ossl_isdigit(a[o]))
|
||||
if (!ascii_isdigit(a[o]))
|
||||
goto err;
|
||||
n = (n * 10) + a[o] - '0';
|
||||
n = (n * 10) + a[o] - num_zero;
|
||||
i2 = (d->type == V_ASN1_UTCTIME) ? i + 1 : i;
|
||||
if ((n < min[i2]) || (n > max[i2]))
|
||||
goto err;
|
||||
@@ -300,7 +304,7 @@ ASN1_TIME *asn1_time_from_tm(ASN1_TIME *s, struct tm *ts, int type)
|
||||
ts->tm_mday, ts->tm_hour, ts->tm_min,
|
||||
ts->tm_sec);
|
||||
|
||||
#ifdef CHARSET_EBCDIC_not
|
||||
#ifdef CHARSET_EBCDIC
|
||||
ebcdic2ascii(tmps->data, tmps->data, tmps->length);
|
||||
#endif
|
||||
return tmps;
|
||||
@@ -467,6 +471,7 @@ int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
|
||||
char *v;
|
||||
int gmt = 0, l;
|
||||
struct tm stm;
|
||||
const char upper_z = 0x5A, period = 0x2E;
|
||||
|
||||
if (!asn1_time_to_tm(&stm, tm)) {
|
||||
/* asn1_time_to_tm will check the time type */
|
||||
@@ -475,7 +480,7 @@ int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
|
||||
|
||||
l = tm->length;
|
||||
v = (char *)tm->data;
|
||||
if (v[l - 1] == 'Z')
|
||||
if (v[l - 1] == upper_z)
|
||||
gmt = 1;
|
||||
|
||||
if (tm->type == V_ASN1_GENERALIZEDTIME) {
|
||||
@@ -486,10 +491,10 @@ int ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)
|
||||
* Try to parse fractional seconds. '14' is the place of
|
||||
* 'fraction point' in a GeneralizedTime string.
|
||||
*/
|
||||
if (tm->length > 15 && v[14] == '.') {
|
||||
if (tm->length > 15 && v[14] == period) {
|
||||
f = &v[14];
|
||||
f_len = 1;
|
||||
while (14 + f_len < l && ossl_isdigit(f[f_len]))
|
||||
while (14 + f_len < l && ascii_isdigit(f[f_len]))
|
||||
++f_len;
|
||||
}
|
||||
|
||||
|
||||
+1
-145
@@ -13,148 +13,6 @@
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
static const ERR_STRING_DATA ASN1_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_A2D_ASN1_OBJECT, 0), "a2d_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_A2I_ASN1_INTEGER, 0), "a2i_ASN1_INTEGER"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_A2I_ASN1_STRING, 0), "a2i_ASN1_STRING"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_APPEND_EXP, 0), "append_exp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_BIO_INIT, 0), "asn1_bio_init"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_BIT_STRING_SET_BIT, 0),
|
||||
"ASN1_BIT_STRING_set_bit"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_CB, 0), "asn1_cb"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_CHECK_TLEN, 0), "asn1_check_tlen"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_COLLECT, 0), "asn1_collect"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_D2I_EX_PRIMITIVE, 0),
|
||||
"asn1_d2i_ex_primitive"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_D2I_FP, 0), "ASN1_d2i_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_D2I_READ_BIO, 0), "asn1_d2i_read_bio"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DIGEST, 0), "ASN1_digest"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DO_ADB, 0), "asn1_do_adb"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DO_LOCK, 0), "asn1_do_lock"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_DUP, 0), "ASN1_dup"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ENC_SAVE, 0), "asn1_enc_save"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_EX_C2I, 0), "asn1_ex_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_FIND_END, 0), "asn1_find_end"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GENERALIZEDTIME_ADJ, 0),
|
||||
"ASN1_GENERALIZEDTIME_adj"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GENERATE_V3, 0), "ASN1_generate_v3"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GET_INT64, 0), "asn1_get_int64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GET_OBJECT, 0), "ASN1_get_object"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_GET_UINT64, 0), "asn1_get_uint64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_I2D_BIO, 0), "ASN1_i2d_bio"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_I2D_FP, 0), "ASN1_i2d_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_D2I_FP, 0), "ASN1_item_d2i_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_DUP, 0), "ASN1_item_dup"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_EMBED_D2I, 0),
|
||||
"asn1_item_embed_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_EMBED_NEW, 0),
|
||||
"asn1_item_embed_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_FLAGS_I2D, 0),
|
||||
"asn1_item_flags_i2d"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_I2D_BIO, 0), "ASN1_item_i2d_bio"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_I2D_FP, 0), "ASN1_item_i2d_fp"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_PACK, 0), "ASN1_item_pack"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_SIGN, 0), "ASN1_item_sign"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_SIGN_CTX, 0),
|
||||
"ASN1_item_sign_ctx"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_UNPACK, 0), "ASN1_item_unpack"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_ITEM_VERIFY, 0), "ASN1_item_verify"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_MBSTRING_NCOPY, 0),
|
||||
"ASN1_mbstring_ncopy"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_OBJECT_NEW, 0), "ASN1_OBJECT_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_OUTPUT_DATA, 0), "asn1_output_data"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_PCTX_NEW, 0), "ASN1_PCTX_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_PRIMITIVE_NEW, 0),
|
||||
"asn1_primitive_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_SCTX_NEW, 0), "ASN1_SCTX_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_SIGN, 0), "ASN1_sign"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STR2TYPE, 0), "asn1_str2type"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_GET_INT64, 0),
|
||||
"asn1_string_get_int64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_GET_UINT64, 0),
|
||||
"asn1_string_get_uint64"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_SET, 0), "ASN1_STRING_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_TABLE_ADD, 0),
|
||||
"ASN1_STRING_TABLE_add"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_TO_BN, 0), "asn1_string_to_bn"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_STRING_TYPE_NEW, 0),
|
||||
"ASN1_STRING_type_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TEMPLATE_EX_D2I, 0),
|
||||
"asn1_template_ex_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TEMPLATE_NEW, 0), "asn1_template_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, 0),
|
||||
"asn1_template_noexp_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TIME_ADJ, 0), "ASN1_TIME_adj"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING, 0),
|
||||
"ASN1_TYPE_get_int_octetstring"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_TYPE_GET_OCTETSTRING, 0),
|
||||
"ASN1_TYPE_get_octetstring"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_UTCTIME_ADJ, 0), "ASN1_UTCTIME_adj"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_ASN1_VERIFY, 0), "ASN1_verify"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_B64_READ_ASN1, 0), "b64_read_asn1"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_B64_WRITE_ASN1, 0), "B64_write_ASN1"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_BIO_NEW_NDEF, 0), "BIO_new_NDEF"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_BITSTR_CB, 0), "bitstr_cb"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_BN_TO_ASN1_STRING, 0), "bn_to_asn1_string"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_ASN1_BIT_STRING, 0),
|
||||
"c2i_ASN1_BIT_STRING"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_ASN1_INTEGER, 0), "c2i_ASN1_INTEGER"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_ASN1_OBJECT, 0), "c2i_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_IBUF, 0), "c2i_ibuf"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_C2I_UINT64_INT, 0), "c2i_uint64_int"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_COLLECT_DATA, 0), "collect_data"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_ASN1_OBJECT, 0), "d2i_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_ASN1_UINTEGER, 0), "d2i_ASN1_UINTEGER"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_AUTOPRIVATEKEY, 0),
|
||||
"d2i_AutoPrivateKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_KEYPARAMS, 0), "d2i_KeyParams"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_PRIVATEKEY, 0), "d2i_PrivateKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_D2I_PUBLICKEY, 0), "d2i_PublicKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_DO_BUF, 0), "do_buf"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_DO_CREATE, 0), "do_create"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_DO_DUMP, 0), "do_dump"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_DO_TCREATE, 0), "do_tcreate"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2A_ASN1_OBJECT, 0), "i2a_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_ASN1_BIO_STREAM, 0),
|
||||
"i2d_ASN1_bio_stream"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_ASN1_OBJECT, 0), "i2d_ASN1_OBJECT"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_DSA_PUBKEY, 0), "i2d_DSA_PUBKEY"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_EC_PUBKEY, 0), "i2d_EC_PUBKEY"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_KEYPARAMS, 0), "i2d_KeyParams"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_PRIVATEKEY, 0), "i2d_PrivateKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_PUBLICKEY, 0), "i2d_PublicKey"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_I2D_RSA_PUBKEY, 0), "i2d_RSA_PUBKEY"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_LONG_C2I, 0), "long_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_NDEF_PREFIX, 0), "ndef_prefix"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_NDEF_SUFFIX, 0), "ndef_suffix"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_OID_MODULE_INIT, 0), "oid_module_init"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PARSE_TAGGING, 0), "parse_tagging"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE2_SET_IV, 0), "PKCS5_pbe2_set_iv"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE2_SET_SCRYPT, 0),
|
||||
"PKCS5_pbe2_set_scrypt"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE_SET, 0), "PKCS5_pbe_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBE_SET0_ALGOR, 0),
|
||||
"PKCS5_pbe_set0_algor"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_PBKDF2_SET, 0), "PKCS5_pbkdf2_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_PKCS5_SCRYPT_SET, 0), "pkcs5_scrypt_set"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_SMIME_READ_ASN1, 0), "SMIME_read_ASN1"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_SMIME_TEXT, 0), "SMIME_text"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_STABLE_GET, 0), "stable_get"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_STBL_MODULE_INIT, 0), "stbl_module_init"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_UINT32_C2I, 0), "uint32_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_UINT32_NEW, 0), "uint32_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_UINT64_C2I, 0), "uint64_c2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_UINT64_NEW, 0), "uint64_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_CRL_ADD0_REVOKED, 0),
|
||||
"X509_CRL_add0_revoked"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_INFO_NEW, 0), "X509_INFO_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_NAME_ENCODE, 0), "x509_name_encode"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_NAME_EX_D2I, 0), "x509_name_ex_d2i"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_NAME_EX_NEW, 0), "x509_name_ex_new"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, ASN1_F_X509_PKEY_NEW, 0), "X509_PKEY_new"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static const ERR_STRING_DATA ASN1_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ADDING_OBJECT), "adding object"},
|
||||
{ERR_PACK(ERR_LIB_ASN1, 0, ASN1_R_ASN1_PARSE_ERROR), "asn1 parse error"},
|
||||
@@ -343,10 +201,8 @@ static const ERR_STRING_DATA ASN1_str_reasons[] = {
|
||||
int ERR_load_ASN1_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
if (ERR_func_error_string(ASN1_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings_const(ASN1_str_functs);
|
||||
if (ERR_reason_error_string(ASN1_str_reasons[0].error) == NULL)
|
||||
ERR_load_strings_const(ASN1_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -184,6 +184,8 @@ static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg)
|
||||
return 0;
|
||||
|
||||
derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it);
|
||||
if (derlen < 0)
|
||||
return 0;
|
||||
if ((p = OPENSSL_malloc(derlen)) == NULL) {
|
||||
ASN1err(ASN1_F_NDEF_SUFFIX, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
|
||||
@@ -52,10 +52,6 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
|
||||
else
|
||||
asn1_cb = 0;
|
||||
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_push(it->sname ? it->sname : "asn1_item_embed_new");
|
||||
#endif
|
||||
|
||||
switch (it->itype) {
|
||||
|
||||
case ASN1_ITYPE_EXTERN:
|
||||
@@ -85,9 +81,6 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
|
||||
if (!i)
|
||||
goto auxerr;
|
||||
if (i == 2) {
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -110,9 +103,6 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
|
||||
if (!i)
|
||||
goto auxerr;
|
||||
if (i == 2) {
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -141,27 +131,18 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
|
||||
goto auxerr2;
|
||||
break;
|
||||
}
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return 1;
|
||||
|
||||
memerr2:
|
||||
asn1_item_embed_free(pval, it, embed);
|
||||
memerr:
|
||||
ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ERR_R_MALLOC_FAILURE);
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
auxerr2:
|
||||
asn1_item_embed_free(pval, it, embed);
|
||||
auxerr:
|
||||
ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ASN1_R_AUX_ERROR);
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -219,10 +200,6 @@ static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
|
||||
*pval = NULL;
|
||||
return 1;
|
||||
}
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_push(tt->field_name
|
||||
? tt->field_name : "asn1_template_new");
|
||||
#endif
|
||||
/* If SET OF or SEQUENCE OF, its a STACK */
|
||||
if (tt->flags & ASN1_TFLG_SK_MASK) {
|
||||
STACK_OF(ASN1_VALUE) *skval;
|
||||
@@ -239,9 +216,6 @@ static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
|
||||
/* Otherwise pass it back to the item routine */
|
||||
ret = asn1_item_embed_new(pval, it, embed);
|
||||
done:
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
OPENSSL_mem_debug_pop();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
+14
-3
@@ -130,9 +130,20 @@ static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it)
|
||||
{
|
||||
if (!*pval)
|
||||
bn_secure_new(pval, it);
|
||||
return bn_c2i(pval, cont, len, utype, free_cont, it);
|
||||
int ret;
|
||||
BIGNUM *bn;
|
||||
|
||||
if (!*pval && !bn_secure_new(pval, it))
|
||||
return 0;
|
||||
|
||||
ret = bn_c2i(pval, cont, len, utype, free_cont, it);
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
/* Set constant-time flag for all secure BIGNUMS */
|
||||
bn = (BIGNUM *)*pval;
|
||||
BN_set_flags(bn, BN_FLG_CONSTTIME);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bn_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* A simple ASN.1 DER encoder/decoder for DSA-Sig-Value and ECDSA-Sig-Value.
|
||||
*
|
||||
* DSA-Sig-Value ::= SEQUENCE {
|
||||
* r INTEGER,
|
||||
* s INTEGER
|
||||
* }
|
||||
*
|
||||
* ECDSA-Sig-Value ::= SEQUENCE {
|
||||
* r INTEGER,
|
||||
* s INTEGER
|
||||
* }
|
||||
*/
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/bn.h>
|
||||
#include "internal/asn1_dsa.h"
|
||||
#include "internal/packet.h"
|
||||
|
||||
#define ID_SEQUENCE 0x30
|
||||
#define ID_INTEGER 0x02
|
||||
|
||||
/*
|
||||
* Outputs the encoding of the length octets for a DER value with a content
|
||||
* length of cont_len bytes to pkt. The maximum supported content length is
|
||||
* 65535 (0xffff) bytes.
|
||||
*
|
||||
* Returns 1 on success or 0 on error.
|
||||
*/
|
||||
int encode_der_length(WPACKET *pkt, size_t cont_len)
|
||||
{
|
||||
if (cont_len > 0xffff)
|
||||
return 0; /* Too large for supported length encodings */
|
||||
|
||||
if (cont_len > 0xff) {
|
||||
if (!WPACKET_put_bytes_u8(pkt, 0x82)
|
||||
|| !WPACKET_put_bytes_u16(pkt, cont_len))
|
||||
return 0;
|
||||
} else {
|
||||
if (cont_len > 0x7f
|
||||
&& !WPACKET_put_bytes_u8(pkt, 0x81))
|
||||
return 0;
|
||||
if (!WPACKET_put_bytes_u8(pkt, cont_len))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Outputs the DER encoding of a positive ASN.1 INTEGER to pkt.
|
||||
*
|
||||
* Results in an error if n is negative or too large.
|
||||
*
|
||||
* Returns 1 on success or 0 on error.
|
||||
*/
|
||||
int encode_der_integer(WPACKET *pkt, const BIGNUM *n)
|
||||
{
|
||||
unsigned char *bnbytes;
|
||||
size_t cont_len;
|
||||
|
||||
if (BN_is_negative(n))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Calculate the ASN.1 INTEGER DER content length for n.
|
||||
* This is the number of whole bytes required to represent n (i.e. rounded
|
||||
* down), plus one.
|
||||
* If n is zero then the content is a single zero byte (length = 1).
|
||||
* If the number of bits of n is a multiple of 8 then an extra zero padding
|
||||
* byte is included to ensure that the value is still treated as positive
|
||||
* in the INTEGER two's complement representation.
|
||||
*/
|
||||
cont_len = BN_num_bits(n) / 8 + 1;
|
||||
|
||||
if (!WPACKET_start_sub_packet(pkt)
|
||||
|| !WPACKET_put_bytes_u8(pkt, ID_INTEGER)
|
||||
|| !encode_der_length(pkt, cont_len)
|
||||
|| !WPACKET_allocate_bytes(pkt, cont_len, &bnbytes)
|
||||
|| !WPACKET_close(pkt))
|
||||
return 0;
|
||||
|
||||
if (bnbytes != NULL
|
||||
&& BN_bn2binpad(n, bnbytes, (int)cont_len) != (int)cont_len)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Outputs the DER encoding of a DSA-Sig-Value or ECDSA-Sig-Value to pkt. pkt
|
||||
* may be initialised with a NULL buffer which enables pkt to be used to
|
||||
* calulate how many bytes would be needed.
|
||||
*
|
||||
* Returns 1 on success or 0 on error.
|
||||
*/
|
||||
int encode_der_dsa_sig(WPACKET *pkt, const BIGNUM *r, const BIGNUM *s)
|
||||
{
|
||||
WPACKET tmppkt, *dummypkt;
|
||||
size_t cont_len;
|
||||
int isnull = WPACKET_is_null_buf(pkt);
|
||||
|
||||
if (!WPACKET_start_sub_packet(pkt))
|
||||
return 0;
|
||||
|
||||
if (!isnull) {
|
||||
if (!WPACKET_init_null(&tmppkt, 0))
|
||||
return 0;
|
||||
dummypkt = &tmppkt;
|
||||
} else {
|
||||
/* If the input packet has a NULL buffer, we don't need a dummy packet */
|
||||
dummypkt = pkt;
|
||||
}
|
||||
|
||||
/* Calculate the content length */
|
||||
if (!encode_der_integer(dummypkt, r)
|
||||
|| !encode_der_integer(dummypkt, s)
|
||||
|| !WPACKET_get_length(dummypkt, &cont_len)
|
||||
|| (!isnull && !WPACKET_finish(dummypkt))) {
|
||||
if (!isnull)
|
||||
WPACKET_cleanup(dummypkt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add the tag and length bytes */
|
||||
if (!WPACKET_put_bytes_u8(pkt, ID_SEQUENCE)
|
||||
|| !encode_der_length(pkt, cont_len)
|
||||
/*
|
||||
* Really encode the integers. We already wrote to the main pkt
|
||||
* if it had a NULL buffer, so don't do it again
|
||||
*/
|
||||
|| (!isnull && !encode_der_integer(pkt, r))
|
||||
|| (!isnull && !encode_der_integer(pkt, s))
|
||||
|| !WPACKET_close(pkt))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decodes the DER length octets in pkt and initialises subpkt with the
|
||||
* following bytes of that length.
|
||||
*
|
||||
* Returns 1 on success or 0 on failure.
|
||||
*/
|
||||
int decode_der_length(PACKET *pkt, PACKET *subpkt)
|
||||
{
|
||||
unsigned int byte;
|
||||
|
||||
if (!PACKET_get_1(pkt, &byte))
|
||||
return 0;
|
||||
|
||||
if (byte < 0x80)
|
||||
return PACKET_get_sub_packet(pkt, subpkt, (size_t)byte);
|
||||
if (byte == 0x81)
|
||||
return PACKET_get_length_prefixed_1(pkt, subpkt);
|
||||
if (byte == 0x82)
|
||||
return PACKET_get_length_prefixed_2(pkt, subpkt);
|
||||
|
||||
/* Too large, invalid, or not DER. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decodes a single ASN.1 INTEGER value from pkt, which must be DER encoded,
|
||||
* and updates n with the decoded value.
|
||||
*
|
||||
* The BIGNUM, n, must have already been allocated by calling BN_new().
|
||||
* pkt must not be NULL.
|
||||
*
|
||||
* An attempt to consume more than len bytes results in an error.
|
||||
* Returns 1 on success or 0 on error.
|
||||
*
|
||||
* If the PACKET is supposed to only contain a single INTEGER value with no
|
||||
* trailing garbage then it is up to the caller to verify that all bytes
|
||||
* were consumed.
|
||||
*/
|
||||
int decode_der_integer(PACKET *pkt, BIGNUM *n)
|
||||
{
|
||||
PACKET contpkt, tmppkt;
|
||||
unsigned int tag, tmp;
|
||||
|
||||
/* Check we have an integer and get the content bytes */
|
||||
if (!PACKET_get_1(pkt, &tag)
|
||||
|| tag != ID_INTEGER
|
||||
|| !decode_der_length(pkt, &contpkt))
|
||||
return 0;
|
||||
|
||||
/* Peek ahead at the first bytes to check for proper encoding */
|
||||
tmppkt = contpkt;
|
||||
/* The INTEGER must be positive */
|
||||
if (!PACKET_get_1(&tmppkt, &tmp)
|
||||
|| (tmp & 0x80) != 0)
|
||||
return 0;
|
||||
/* If there a zero padding byte the next byte must have the msb set */
|
||||
if (PACKET_remaining(&tmppkt) > 0 && tmp == 0) {
|
||||
if (!PACKET_get_1(&tmppkt, &tmp)
|
||||
|| (tmp & 0x80) == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (BN_bin2bn(PACKET_data(&contpkt),
|
||||
(int)PACKET_remaining(&contpkt), n) == NULL)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decodes a single DSA-Sig-Value or ECDSA-Sig-Value from *ppin, which must be
|
||||
* DER encoded, updates r and s with the decoded values, and increments *ppin
|
||||
* past the data that was consumed.
|
||||
*
|
||||
* The BIGNUMs, r and s, must have already been allocated by calls to BN_new().
|
||||
* ppin and *ppin must not be NULL.
|
||||
*
|
||||
* An attempt to consume more than len bytes results in an error.
|
||||
* Returns the number of bytes of input consumed or 0 if an error occurs.
|
||||
*
|
||||
* If the buffer is supposed to only contain a single [EC]DSA-Sig-Value with no
|
||||
* trailing garbage then it is up to the caller to verify that all bytes
|
||||
* were consumed.
|
||||
*/
|
||||
size_t decode_der_dsa_sig(BIGNUM *r, BIGNUM *s, const unsigned char **ppin,
|
||||
size_t len)
|
||||
{
|
||||
size_t consumed;
|
||||
PACKET pkt, contpkt;
|
||||
unsigned int tag;
|
||||
|
||||
if (!PACKET_buf_init(&pkt, *ppin, len)
|
||||
|| !PACKET_get_1(&pkt, &tag)
|
||||
|| tag != ID_SEQUENCE
|
||||
|| !decode_der_length(&pkt, &contpkt)
|
||||
|| !decode_der_integer(&contpkt, r)
|
||||
|| !decode_der_integer(&contpkt, s)
|
||||
|| PACKET_remaining(&contpkt) != 0)
|
||||
return 0;
|
||||
|
||||
consumed = PACKET_data(&pkt) - *ppin;
|
||||
*ppin += consumed;
|
||||
return consumed;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-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
|
||||
@@ -13,19 +13,6 @@
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
static const ERR_STRING_DATA ASYNC_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_CTX_NEW, 0), "async_ctx_new"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_INIT_THREAD, 0),
|
||||
"ASYNC_init_thread"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_JOB_NEW, 0), "async_job_new"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_PAUSE_JOB, 0), "ASYNC_pause_job"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_START_FUNC, 0), "async_start_func"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_START_JOB, 0), "ASYNC_start_job"},
|
||||
{ERR_PACK(ERR_LIB_ASYNC, ASYNC_F_ASYNC_WAIT_CTX_SET_WAIT_FD, 0),
|
||||
"ASYNC_WAIT_CTX_set_wait_fd"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static const ERR_STRING_DATA ASYNC_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_ASYNC, 0, ASYNC_R_FAILED_TO_SET_POOL),
|
||||
"failed to set pool"},
|
||||
@@ -42,10 +29,8 @@ static const ERR_STRING_DATA ASYNC_str_reasons[] = {
|
||||
int ERR_load_ASYNC_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
if (ERR_func_error_string(ASYNC_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings_const(ASYNC_str_functs);
|
||||
if (ERR_reason_error_string(ASYNC_str_reasons[0].error) == NULL)
|
||||
ERR_load_strings_const(ASYNC_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -12,8 +12,7 @@ push(@INC,"${dir}","${dir}../../perlasm");
|
||||
require "x86asm.pl";
|
||||
require "cbc.pl";
|
||||
|
||||
$output = pop;
|
||||
open STDOUT,">$output";
|
||||
$output = pop and open STDOUT,">$output";
|
||||
|
||||
&asm_init($ARGV[0],$ARGV[$#ARGV] eq "386");
|
||||
|
||||
|
||||
@@ -13,6 +13,5 @@ ENDIF
|
||||
|
||||
SOURCE[../../libcrypto]=bf_skey.c bf_ecb.c bf_cfb64.c bf_ofb64.c $BFASM
|
||||
|
||||
GENERATE[bf-586.s]=asm/bf-586.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
GENERATE[bf-586.s]=asm/bf-586.pl
|
||||
DEPEND[bf-586.s]=../perlasm/x86asm.pl ../perlasm/cbc.pl
|
||||
+27
-25
@@ -207,7 +207,8 @@ static int addr_strings(const BIO_ADDR *ap, int numeric,
|
||||
flags)) != 0) {
|
||||
# ifdef EAI_SYSTEM
|
||||
if (ret == EAI_SYSTEM) {
|
||||
SYSerr(SYS_F_GETNAMEINFO, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling getnameinfo()");
|
||||
BIOerr(BIO_F_ADDR_STRINGS, ERR_R_SYS_LIB);
|
||||
} else
|
||||
# endif
|
||||
@@ -675,7 +676,7 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
|
||||
if (1) {
|
||||
#ifdef AI_PASSIVE
|
||||
int gai_ret = 0;
|
||||
int gai_ret = 0, old_ret = 0;
|
||||
struct addrinfo hints;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
@@ -683,12 +684,12 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
hints.ai_family = family;
|
||||
hints.ai_socktype = socktype;
|
||||
hints.ai_protocol = protocol;
|
||||
#ifdef AI_ADDRCONFIG
|
||||
#ifdef AF_UNSPEC
|
||||
# ifdef AI_ADDRCONFIG
|
||||
# ifdef AF_UNSPEC
|
||||
if (family == AF_UNSPEC)
|
||||
#endif
|
||||
# endif
|
||||
hints.ai_flags |= AI_ADDRCONFIG;
|
||||
#endif
|
||||
# endif
|
||||
|
||||
if (lookup_type == BIO_LOOKUP_SERVER)
|
||||
hints.ai_flags |= AI_PASSIVE;
|
||||
@@ -700,29 +701,30 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
switch ((gai_ret = getaddrinfo(host, service, &hints, res))) {
|
||||
# ifdef EAI_SYSTEM
|
||||
case EAI_SYSTEM:
|
||||
SYSerr(SYS_F_GETADDRINFO, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling getaddrinfo()");
|
||||
BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_SYS_LIB);
|
||||
break;
|
||||
# endif
|
||||
# ifdef EAI_MEMORY
|
||||
case EAI_MEMORY:
|
||||
BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_MALLOC_FAILURE);
|
||||
break;
|
||||
# endif
|
||||
case 0:
|
||||
ret = 1; /* Success */
|
||||
break;
|
||||
# if (defined(EAI_FAMILY) || defined(EAI_ADDRFAMILY)) && defined(AI_ADDRCONFIG)
|
||||
# ifdef EAI_FAMILY
|
||||
case EAI_FAMILY:
|
||||
# endif
|
||||
# ifdef EAI_ADDRFAMILY
|
||||
case EAI_ADDRFAMILY:
|
||||
# endif
|
||||
default:
|
||||
# if defined(AI_ADDRCONFIG) && defined(AI_NUMERICHOST)
|
||||
if (hints.ai_flags & AI_ADDRCONFIG) {
|
||||
hints.ai_flags &= ~AI_ADDRCONFIG;
|
||||
hints.ai_flags |= AI_NUMERICHOST;
|
||||
old_ret = gai_ret;
|
||||
goto retry;
|
||||
}
|
||||
# endif
|
||||
/* fall through */
|
||||
default:
|
||||
BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_SYS_LIB);
|
||||
ERR_add_error_data(1, gai_strerror(gai_ret));
|
||||
ERR_add_error_data(1, gai_strerror(old_ret ? old_ret : gai_ret));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -804,12 +806,15 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
*/
|
||||
# if defined(OPENSSL_SYS_VXWORKS)
|
||||
/* h_errno doesn't exist on VxWorks */
|
||||
SYSerr(SYS_F_GETHOSTBYNAME, 1000 );
|
||||
ERR_raise_data(ERR_LIB_SYS, 1000,
|
||||
"calling gethostbyname()");
|
||||
# else
|
||||
SYSerr(SYS_F_GETHOSTBYNAME, 1000 + h_errno);
|
||||
ERR_raise_data(ERR_LIB_SYS, 1000 + h_errno,
|
||||
"calling gethostbyname()");
|
||||
# endif
|
||||
#else
|
||||
SYSerr(SYS_F_GETHOSTBYNAME, WSAGetLastError());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling gethostbyname()");
|
||||
#endif
|
||||
ret = 0;
|
||||
goto err;
|
||||
@@ -855,11 +860,8 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
se = getservbyname(service, proto);
|
||||
|
||||
if (se == NULL) {
|
||||
#ifndef OPENSSL_SYS_WINDOWS
|
||||
SYSerr(SYS_F_GETSERVBYNAME, errno);
|
||||
#else
|
||||
SYSerr(SYS_F_GETSERVBYNAME, WSAGetLastError());
|
||||
#endif
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling getservbyname()");
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
|
||||
+12
-9
@@ -120,8 +120,6 @@ int BIO_sock_init(void)
|
||||
static struct WSAData wsa_state;
|
||||
|
||||
if (!wsa_init_done) {
|
||||
int err;
|
||||
|
||||
wsa_init_done = 1;
|
||||
memset(&wsa_state, 0, sizeof(wsa_state));
|
||||
/*
|
||||
@@ -131,8 +129,8 @@ int BIO_sock_init(void)
|
||||
* probed at run-time with DSO_global_lookup.
|
||||
*/
|
||||
if (WSAStartup(0x0202, &wsa_state) != 0) {
|
||||
err = WSAGetLastError();
|
||||
SYSerr(SYS_F_WSASTARTUP, err);
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling wsastartup()");
|
||||
BIOerr(BIO_F_BIO_SOCK_INIT, BIO_R_WSASTARTUP);
|
||||
return -1;
|
||||
}
|
||||
@@ -192,7 +190,8 @@ int BIO_socket_ioctl(int fd, long type, void *arg)
|
||||
i = ioctlsocket(fd, type, ARG);
|
||||
# endif /* __DJGPP__ */
|
||||
if (i < 0)
|
||||
SYSerr(SYS_F_IOCTLSOCKET, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling ioctlsocket()");
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -243,7 +242,8 @@ int BIO_accept(int sock, char **ip_port)
|
||||
ret = -2;
|
||||
goto end;
|
||||
}
|
||||
SYSerr(SYS_F_ACCEPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling accept()");
|
||||
BIOerr(BIO_F_BIO_ACCEPT, BIO_R_ACCEPT_ERROR);
|
||||
goto end;
|
||||
}
|
||||
@@ -308,7 +308,8 @@ int BIO_socket_nbio(int s, int mode)
|
||||
|
||||
l = fcntl(s, F_GETFL, 0);
|
||||
if (l == -1) {
|
||||
SYSerr(SYS_F_FCNTL, get_last_sys_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fcntl()");
|
||||
ret = -1;
|
||||
} else {
|
||||
# if defined(O_NONBLOCK)
|
||||
@@ -326,7 +327,8 @@ int BIO_socket_nbio(int s, int mode)
|
||||
ret = fcntl(s, F_SETFL, l);
|
||||
|
||||
if (ret < 0) {
|
||||
SYSerr(SYS_F_FCNTL, get_last_sys_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fcntl()");
|
||||
}
|
||||
}
|
||||
# else
|
||||
@@ -349,7 +351,8 @@ int BIO_sock_info(int sock,
|
||||
ret = getsockname(sock, BIO_ADDR_sockaddr_noconst(info->addr),
|
||||
&addr_len);
|
||||
if (ret == -1) {
|
||||
SYSerr(SYS_F_GETSOCKNAME, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling getsockname()");
|
||||
BIOerr(BIO_F_BIO_SOCK_INFO, BIO_R_GETSOCKNAME_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+24
-12
@@ -46,7 +46,8 @@ int BIO_socket(int domain, int socktype, int protocol, int options)
|
||||
|
||||
sock = socket(domain, socktype, protocol);
|
||||
if (sock == -1) {
|
||||
SYSerr(SYS_F_SOCKET, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling socket()");
|
||||
BIOerr(BIO_F_BIO_SOCKET, BIO_R_UNABLE_TO_CREATE_SOCKET);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
@@ -89,7 +90,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
|
||||
if (options & BIO_SOCK_KEEPALIVE) {
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_CONNECT, BIO_R_UNABLE_TO_KEEPALIVE);
|
||||
return 0;
|
||||
}
|
||||
@@ -98,7 +100,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
|
||||
if (options & BIO_SOCK_NODELAY) {
|
||||
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_CONNECT, BIO_R_UNABLE_TO_NODELAY);
|
||||
return 0;
|
||||
}
|
||||
@@ -107,7 +110,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
|
||||
if (connect(sock, BIO_ADDR_sockaddr(addr),
|
||||
BIO_ADDR_sockaddr_size(addr)) == -1) {
|
||||
if (!BIO_sock_should_retry(-1)) {
|
||||
SYSerr(SYS_F_CONNECT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling connect()");
|
||||
BIOerr(BIO_F_BIO_CONNECT, BIO_R_CONNECT_ERROR);
|
||||
}
|
||||
return 0;
|
||||
@@ -150,7 +154,8 @@ int BIO_bind(int sock, const BIO_ADDR *addr, int options)
|
||||
if (options & BIO_SOCK_REUSEADDR) {
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_BIND, BIO_R_UNABLE_TO_REUSEADDR);
|
||||
return 0;
|
||||
}
|
||||
@@ -158,7 +163,8 @@ int BIO_bind(int sock, const BIO_ADDR *addr, int options)
|
||||
# endif
|
||||
|
||||
if (bind(sock, BIO_ADDR_sockaddr(addr), BIO_ADDR_sockaddr_size(addr)) != 0) {
|
||||
SYSerr(SYS_F_BIND, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling bind()");
|
||||
BIOerr(BIO_F_BIO_BIND, BIO_R_UNABLE_TO_BIND_SOCKET);
|
||||
return 0;
|
||||
}
|
||||
@@ -217,7 +223,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
||||
if (getsockopt(sock, SOL_SOCKET, SO_TYPE,
|
||||
(void *)&socktype, &socktype_len) != 0
|
||||
|| socktype_len != sizeof(socktype)) {
|
||||
SYSerr(SYS_F_GETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling getsockopt()");
|
||||
BIOerr(BIO_F_BIO_LISTEN, BIO_R_GETTING_SOCKTYPE);
|
||||
return 0;
|
||||
}
|
||||
@@ -228,7 +235,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
||||
if (options & BIO_SOCK_KEEPALIVE) {
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_KEEPALIVE);
|
||||
return 0;
|
||||
}
|
||||
@@ -237,7 +245,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
||||
if (options & BIO_SOCK_NODELAY) {
|
||||
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_NODELAY);
|
||||
return 0;
|
||||
}
|
||||
@@ -252,7 +261,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
||||
on = options & BIO_SOCK_V6_ONLY ? 1 : 0;
|
||||
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
(const void *)&on, sizeof(on)) != 0) {
|
||||
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling setsockopt()");
|
||||
BIOerr(BIO_F_BIO_LISTEN, BIO_R_LISTEN_V6_ONLY);
|
||||
return 0;
|
||||
}
|
||||
@@ -263,7 +273,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
|
||||
return 0;
|
||||
|
||||
if (socktype != SOCK_DGRAM && listen(sock, MAX_LISTEN) == -1) {
|
||||
SYSerr(SYS_F_LISTEN, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling listen()");
|
||||
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_LISTEN_SOCKET);
|
||||
return 0;
|
||||
}
|
||||
@@ -290,7 +301,8 @@ int BIO_accept_ex(int accept_sock, BIO_ADDR *addr_, int options)
|
||||
BIO_ADDR_sockaddr_noconst(addr), &len);
|
||||
if (accepted_sock == -1) {
|
||||
if (!BIO_sock_should_retry(accepted_sock)) {
|
||||
SYSerr(SYS_F_ACCEPT, get_last_socket_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling accept()");
|
||||
BIOerr(BIO_F_BIO_ACCEPT_EX, BIO_R_ACCEPT_ERROR);
|
||||
}
|
||||
return INVALID_SOCKET;
|
||||
|
||||
+2
-64
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-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
|
||||
@@ -13,66 +13,6 @@
|
||||
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
|
||||
static const ERR_STRING_DATA BIO_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_ACPT_STATE, 0), "acpt_state"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_ADDRINFO_WRAP, 0), "addrinfo_wrap"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_ADDR_STRINGS, 0), "addr_strings"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ACCEPT, 0), "BIO_accept"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ACCEPT_EX, 0), "BIO_accept_ex"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ACCEPT_NEW, 0), "BIO_ACCEPT_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ADDR_NEW, 0), "BIO_ADDR_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_BIND, 0), "BIO_bind"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CALLBACK_CTRL, 0), "BIO_callback_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CONNECT, 0), "BIO_connect"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CONNECT_NEW, 0), "BIO_CONNECT_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CTRL, 0), "BIO_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GETS, 0), "BIO_gets"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GET_HOST_IP, 0), "BIO_get_host_ip"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GET_NEW_INDEX, 0), "BIO_get_new_index"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GET_PORT, 0), "BIO_get_port"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LISTEN, 0), "BIO_listen"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LOOKUP, 0), "BIO_lookup"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LOOKUP_EX, 0), "BIO_lookup_ex"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_MAKE_PAIR, 0), "bio_make_pair"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_METH_NEW, 0), "BIO_meth_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW, 0), "BIO_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_DGRAM_SCTP, 0), "BIO_new_dgram_sctp"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_FILE, 0), "BIO_new_file"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_MEM_BUF, 0), "BIO_new_mem_buf"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NREAD, 0), "BIO_nread"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NREAD0, 0), "BIO_nread0"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NWRITE, 0), "BIO_nwrite"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NWRITE0, 0), "BIO_nwrite0"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_PARSE_HOSTSERV, 0), "BIO_parse_hostserv"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_PUTS, 0), "BIO_puts"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_READ, 0), "BIO_read"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_READ_EX, 0), "BIO_read_ex"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_READ_INTERN, 0), "bio_read_intern"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCKET, 0), "BIO_socket"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCKET_NBIO, 0), "BIO_socket_nbio"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCK_INFO, 0), "BIO_sock_info"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCK_INIT, 0), "BIO_sock_init"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_WRITE, 0), "BIO_write"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_WRITE_EX, 0), "BIO_write_ex"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_WRITE_INTERN, 0), "bio_write_intern"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_BUFFER_CTRL, 0), "buffer_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_CONN_CTRL, 0), "conn_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_CONN_STATE, 0), "conn_state"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_DGRAM_SCTP_NEW, 0), "dgram_sctp_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_DGRAM_SCTP_READ, 0), "dgram_sctp_read"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_DGRAM_SCTP_WRITE, 0), "dgram_sctp_write"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_DOAPR_OUTCH, 0), "doapr_outch"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_FILE_CTRL, 0), "file_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_FILE_READ, 0), "file_read"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_LINEBUFFER_CTRL, 0), "linebuffer_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_LINEBUFFER_NEW, 0), "linebuffer_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_MEM_WRITE, 0), "mem_write"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_NBIOF_NEW, 0), "nbiof_new"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_SLG_WRITE, 0), "slg_write"},
|
||||
{ERR_PACK(ERR_LIB_BIO, BIO_F_SSL_NEW, 0), "SSL_new"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static const ERR_STRING_DATA BIO_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_BIO, 0, BIO_R_ACCEPT_ERROR), "accept error"},
|
||||
{ERR_PACK(ERR_LIB_BIO, 0, BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET),
|
||||
@@ -136,10 +76,8 @@ static const ERR_STRING_DATA BIO_str_reasons[] = {
|
||||
int ERR_load_BIO_strings(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_ERR
|
||||
if (ERR_func_error_string(BIO_str_functs[0].error) == NULL) {
|
||||
ERR_load_strings_const(BIO_str_functs);
|
||||
if (ERR_reason_error_string(BIO_str_reasons[0].error) == NULL)
|
||||
ERR_load_strings_const(BIO_str_reasons);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -226,10 +226,9 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
|
||||
BIO_ADDRINFO_socktype(c->addr_iter),
|
||||
BIO_ADDRINFO_protocol(c->addr_iter), 0);
|
||||
if (ret == (int)INVALID_SOCKET) {
|
||||
SYSerr(SYS_F_SOCKET, get_last_socket_error());
|
||||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_addr,
|
||||
" service=", c->param_serv);
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling socket(%s, %s)",
|
||||
c->param_addr, c->param_serv);
|
||||
BIOerr(BIO_F_ACPT_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET);
|
||||
goto exit_loop;
|
||||
}
|
||||
|
||||
+9
-12
@@ -138,10 +138,9 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
||||
BIO_ADDRINFO_socktype(c->addr_iter),
|
||||
BIO_ADDRINFO_protocol(c->addr_iter), 0);
|
||||
if (ret == (int)INVALID_SOCKET) {
|
||||
SYSerr(SYS_F_SOCKET, get_last_socket_error());
|
||||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_hostname,
|
||||
" service=", c->param_service);
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling socket(%s, %s)",
|
||||
c->param_hostname, c->param_service);
|
||||
BIOerr(BIO_F_CONN_STATE, BIO_R_UNABLE_TO_CREATE_SOCKET);
|
||||
goto exit_loop;
|
||||
}
|
||||
@@ -170,10 +169,9 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
||||
ERR_clear_error();
|
||||
break;
|
||||
} else {
|
||||
SYSerr(SYS_F_CONNECT, get_last_socket_error());
|
||||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_hostname,
|
||||
" service=", c->param_service);
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
|
||||
"calling connect(%s, %s)",
|
||||
c->param_hostname, c->param_service);
|
||||
BIOerr(BIO_F_CONN_STATE, BIO_R_CONNECT_ERROR);
|
||||
}
|
||||
goto exit_loop;
|
||||
@@ -186,10 +184,9 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
|
||||
i = BIO_sock_error(b->num);
|
||||
if (i) {
|
||||
BIO_clear_retry_flags(b);
|
||||
SYSerr(SYS_F_CONNECT, i);
|
||||
ERR_add_error_data(4,
|
||||
"hostname=", c->param_hostname,
|
||||
" service=", c->param_service);
|
||||
ERR_raise_data(ERR_LIB_SYS, i,
|
||||
"calling connect(%s, %s)",
|
||||
c->param_hostname, c->param_service);
|
||||
BIOerr(BIO_F_CONN_STATE, BIO_R_NBIO_CONNECT_ERROR);
|
||||
ret = 0;
|
||||
goto exit_loop;
|
||||
|
||||
+19
-6
@@ -53,6 +53,8 @@ static int dgram_sctp_puts(BIO *h, const char *str);
|
||||
static long dgram_sctp_ctrl(BIO *h, int cmd, long arg1, void *arg2);
|
||||
static int dgram_sctp_new(BIO *h);
|
||||
static int dgram_sctp_free(BIO *data);
|
||||
static int dgram_sctp_wait_for_dry(BIO *b);
|
||||
static int dgram_sctp_msg_waiting(BIO *b);
|
||||
# ifdef SCTP_AUTHENTICATION_EVENT
|
||||
static void dgram_sctp_handle_auth_free_key_event(BIO *b, union sctp_notification
|
||||
*snp);
|
||||
@@ -124,7 +126,7 @@ typedef struct bio_dgram_sctp_data_st {
|
||||
struct bio_dgram_sctp_sndinfo sndinfo;
|
||||
struct bio_dgram_sctp_rcvinfo rcvinfo;
|
||||
struct bio_dgram_sctp_prinfo prinfo;
|
||||
void (*handle_notifications) (BIO *bio, void *context, void *buf);
|
||||
BIO_dgram_sctp_notification_handler_fn handle_notifications;
|
||||
void *notification_context;
|
||||
int in_handshake;
|
||||
int ccs_rcvd;
|
||||
@@ -1562,6 +1564,10 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
else
|
||||
data->save_shutdown = 0;
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_SCTP_WAIT_FOR_DRY:
|
||||
return dgram_sctp_wait_for_dry(b);
|
||||
case BIO_CTRL_DGRAM_SCTP_MSG_WAITING:
|
||||
return dgram_sctp_msg_waiting(b);
|
||||
|
||||
default:
|
||||
/*
|
||||
@@ -1574,11 +1580,8 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
}
|
||||
|
||||
int BIO_dgram_sctp_notification_cb(BIO *b,
|
||||
void (*handle_notifications) (BIO *bio,
|
||||
void
|
||||
*context,
|
||||
void *buf),
|
||||
void *context)
|
||||
BIO_dgram_sctp_notification_handler_fn handle_notifications,
|
||||
void *context)
|
||||
{
|
||||
bio_dgram_sctp_data *data = (bio_dgram_sctp_data *) b->ptr;
|
||||
|
||||
@@ -1605,6 +1608,11 @@ int BIO_dgram_sctp_notification_cb(BIO *b,
|
||||
* 1 when dry
|
||||
*/
|
||||
int BIO_dgram_sctp_wait_for_dry(BIO *b)
|
||||
{
|
||||
return (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SCTP_WAIT_FOR_DRY, 0, NULL);
|
||||
}
|
||||
|
||||
static int dgram_sctp_wait_for_dry(BIO *b)
|
||||
{
|
||||
int is_dry = 0;
|
||||
int sockflags = 0;
|
||||
@@ -1763,6 +1771,11 @@ int BIO_dgram_sctp_wait_for_dry(BIO *b)
|
||||
}
|
||||
|
||||
int BIO_dgram_sctp_msg_waiting(BIO *b)
|
||||
{
|
||||
return (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SCTP_MSG_WAITING, 0, NULL);
|
||||
}
|
||||
|
||||
static int dgram_sctp_msg_waiting(BIO *b)
|
||||
{
|
||||
int n, sockflags;
|
||||
union sctp_notification snp;
|
||||
|
||||
+38
-40
@@ -7,10 +7,7 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef HEADER_BSS_FILE_C
|
||||
# define HEADER_BSS_FILE_C
|
||||
|
||||
# if defined(__linux) || defined(__sun) || defined(__hpux)
|
||||
#if defined(__linux) || defined(__sun) || defined(__hpux)
|
||||
/*
|
||||
* Following definition aliases fopen to fopen64 on above mentioned
|
||||
* platforms. This makes it possible to open and sequentially access files
|
||||
@@ -23,17 +20,17 @@
|
||||
* of 32-bit platforms which allow for sequential access of large files
|
||||
* without extra "magic" comprise *BSD, Darwin, IRIX...
|
||||
*/
|
||||
# ifndef _FILE_OFFSET_BITS
|
||||
# define _FILE_OFFSET_BITS 64
|
||||
# endif
|
||||
# ifndef _FILE_OFFSET_BITS
|
||||
# define _FILE_OFFSET_BITS 64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
# include <errno.h>
|
||||
# include "bio_lcl.h"
|
||||
# include <openssl/err.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "bio_lcl.h"
|
||||
#include <openssl/err.h>
|
||||
|
||||
# if !defined(OPENSSL_NO_STDIO)
|
||||
#if !defined(OPENSSL_NO_STDIO)
|
||||
|
||||
static int file_write(BIO *h, const char *buf, int num);
|
||||
static int file_read(BIO *h, char *buf, int size);
|
||||
@@ -69,12 +66,13 @@ BIO *BIO_new_file(const char *filename, const char *mode)
|
||||
fp_flags |= BIO_FP_TEXT;
|
||||
|
||||
if (file == NULL) {
|
||||
SYSerr(SYS_F_FOPEN, get_last_sys_error());
|
||||
ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fopen(%s, %s)",
|
||||
filename, mode);
|
||||
if (errno == ENOENT
|
||||
# ifdef ENXIO
|
||||
#ifdef ENXIO
|
||||
|| errno == ENXIO
|
||||
# endif
|
||||
#endif
|
||||
)
|
||||
BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);
|
||||
else
|
||||
@@ -149,7 +147,8 @@ static int file_read(BIO *b, char *out, int outl)
|
||||
if (ret == 0
|
||||
&& (b->flags & BIO_FLAGS_UPLINK_INTERNAL
|
||||
? UP_ferror((FILE *)b->ptr) : ferror((FILE *)b->ptr))) {
|
||||
SYSerr(SYS_F_FREAD, get_last_sys_error());
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fread()");
|
||||
BIOerr(BIO_F_FILE_READ, ERR_R_SYS_LIB);
|
||||
ret = -1;
|
||||
}
|
||||
@@ -212,33 +211,33 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
b->shutdown = (int)num & BIO_CLOSE;
|
||||
b->ptr = ptr;
|
||||
b->init = 1;
|
||||
# if BIO_FLAGS_UPLINK_INTERNAL!=0
|
||||
# if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)
|
||||
# define _IOB_ENTRIES 20
|
||||
# endif
|
||||
# if BIO_FLAGS_UPLINK_INTERNAL!=0
|
||||
# if defined(__MINGW32__) && defined(__MSVCRT__) && !defined(_IOB_ENTRIES)
|
||||
# define _IOB_ENTRIES 20
|
||||
# endif
|
||||
/* Safety net to catch purely internal BIO_set_fp calls */
|
||||
# if defined(_MSC_VER) && _MSC_VER>=1900
|
||||
# if defined(_MSC_VER) && _MSC_VER>=1900
|
||||
if (ptr == stdin || ptr == stdout || ptr == stderr)
|
||||
BIO_clear_flags(b, BIO_FLAGS_UPLINK_INTERNAL);
|
||||
# elif defined(_IOB_ENTRIES)
|
||||
# elif defined(_IOB_ENTRIES)
|
||||
if ((size_t)ptr >= (size_t)stdin &&
|
||||
(size_t)ptr < (size_t)(stdin + _IOB_ENTRIES))
|
||||
BIO_clear_flags(b, BIO_FLAGS_UPLINK_INTERNAL);
|
||||
# endif
|
||||
# endif
|
||||
# ifdef UP_fsetmod
|
||||
# endif
|
||||
# ifdef UP_fsetmod
|
||||
if (b->flags & BIO_FLAGS_UPLINK_INTERNAL)
|
||||
UP_fsetmod(b->ptr, (char)((num & BIO_FP_TEXT) ? 't' : 'b'));
|
||||
else
|
||||
# endif
|
||||
# endif
|
||||
{
|
||||
# if defined(OPENSSL_SYS_WINDOWS)
|
||||
# if defined(OPENSSL_SYS_WINDOWS)
|
||||
int fd = _fileno((FILE *)ptr);
|
||||
if (num & BIO_FP_TEXT)
|
||||
_setmode(fd, _O_TEXT);
|
||||
else
|
||||
_setmode(fd, _O_BINARY);
|
||||
# elif defined(OPENSSL_SYS_MSDOS)
|
||||
# elif defined(OPENSSL_SYS_MSDOS)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
/* Set correct text/binary mode */
|
||||
if (num & BIO_FP_TEXT)
|
||||
@@ -251,11 +250,11 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
} else
|
||||
_setmode(fd, _O_BINARY);
|
||||
}
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
int fd = fileno((FILE *)ptr);
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
setmode(fd, O_BINARY);
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_FILENAME:
|
||||
@@ -277,19 +276,20 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
|
||||
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
OPENSSL_strlcat(p, "b", sizeof(p));
|
||||
else
|
||||
OPENSSL_strlcat(p, "t", sizeof(p));
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
# elif defined(OPENSSL_SYS_WIN32_CYGWIN)
|
||||
if (!(num & BIO_FP_TEXT))
|
||||
OPENSSL_strlcat(p, "b", sizeof(p));
|
||||
# endif
|
||||
# endif
|
||||
fp = openssl_fopen(ptr, p);
|
||||
if (fp == NULL) {
|
||||
SYSerr(SYS_F_FOPEN, get_last_sys_error());
|
||||
ERR_add_error_data(5, "fopen('", ptr, "','", p, "')");
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fopen(%s, %s)",
|
||||
ptr, p);
|
||||
BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);
|
||||
ret = 0;
|
||||
break;
|
||||
@@ -316,8 +316,8 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
st = b->flags & BIO_FLAGS_UPLINK_INTERNAL
|
||||
? UP_fflush(b->ptr) : fflush((FILE *)b->ptr);
|
||||
if (st == EOF) {
|
||||
SYSerr(SYS_F_FFLUSH, get_last_sys_error());
|
||||
ERR_add_error_data(1, "fflush()");
|
||||
ERR_raise_data(ERR_LIB_SYS, get_last_sys_error(),
|
||||
"calling fflush()");
|
||||
BIOerr(BIO_F_FILE_CTRL, ERR_R_SYS_LIB);
|
||||
ret = 0;
|
||||
}
|
||||
@@ -422,6 +422,4 @@ BIO *BIO_new_file(const char *filename, const char *mode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
# endif /* OPENSSL_NO_STDIO */
|
||||
|
||||
#endif /* HEADER_BSS_FILE_C */
|
||||
#endif /* OPENSSL_NO_STDIO */
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 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
|
||||
*/
|
||||
|
||||
#ifndef OPENSSL_NO_BLAKE2
|
||||
|
||||
# include <openssl/evp.h>
|
||||
# include "internal/blake2.h"
|
||||
# include "internal/cryptlib.h"
|
||||
# include "internal/evp_int.h"
|
||||
|
||||
/* typedef EVP_MAC_IMPL */
|
||||
struct evp_mac_impl_st {
|
||||
BLAKE2B_CTX ctx;
|
||||
BLAKE2B_PARAM params;
|
||||
unsigned char key[BLAKE2B_KEYBYTES];
|
||||
};
|
||||
|
||||
static EVP_MAC_IMPL *blake2b_mac_new(void)
|
||||
{
|
||||
EVP_MAC_IMPL *macctx = OPENSSL_zalloc(sizeof(*macctx));
|
||||
if (macctx != NULL) {
|
||||
blake2b_param_init(&macctx->params);
|
||||
/* ctx initialization is deferred to blake2b_init() */
|
||||
}
|
||||
return macctx;
|
||||
}
|
||||
|
||||
static void blake2b_mac_free(EVP_MAC_IMPL *macctx)
|
||||
{
|
||||
if (macctx != NULL) {
|
||||
OPENSSL_cleanse(macctx->key, sizeof(macctx->key));
|
||||
OPENSSL_free(macctx);
|
||||
}
|
||||
}
|
||||
|
||||
static EVP_MAC_IMPL *blake2b_mac_dup(const EVP_MAC_IMPL *src)
|
||||
{
|
||||
EVP_MAC_IMPL *dst;
|
||||
|
||||
dst = OPENSSL_zalloc(sizeof(*dst));
|
||||
if (dst == NULL)
|
||||
return NULL;
|
||||
|
||||
*dst = *src;
|
||||
return dst;
|
||||
}
|
||||
|
||||
static int blake2b_mac_init(EVP_MAC_IMPL *macctx)
|
||||
{
|
||||
/* Check key has been set */
|
||||
if (macctx->params.key_length == 0) {
|
||||
EVPerr(EVP_F_BLAKE2B_MAC_INIT, EVP_R_NO_KEY_SET);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return blake2b_init_key(&macctx->ctx, &macctx->params, macctx->key);
|
||||
}
|
||||
|
||||
static int blake2b_mac_update(EVP_MAC_IMPL *macctx, const unsigned char *data,
|
||||
size_t datalen)
|
||||
{
|
||||
return blake2b_update(&macctx->ctx, data, datalen);
|
||||
}
|
||||
|
||||
static int blake2b_mac_final(EVP_MAC_IMPL *macctx, unsigned char *out)
|
||||
{
|
||||
return blake2b_final(out, &macctx->ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* ALL Ctrl functions should be set before init().
|
||||
*/
|
||||
static int blake2b_mac_ctrl(EVP_MAC_IMPL *macctx, int cmd, va_list args)
|
||||
{
|
||||
const unsigned char *p;
|
||||
size_t len;
|
||||
size_t size;
|
||||
|
||||
switch (cmd) {
|
||||
case EVP_MAC_CTRL_SET_SIZE:
|
||||
size = va_arg(args, size_t);
|
||||
if (size < 1 || size > BLAKE2B_OUTBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2B_MAC_CTRL, EVP_R_NOT_XOF_OR_INVALID_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2b_param_set_digest_length(&macctx->params, (uint8_t)size);
|
||||
return 1;
|
||||
|
||||
case EVP_MAC_CTRL_SET_KEY:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
if (len < 1 || len > BLAKE2B_KEYBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2B_MAC_CTRL, EVP_R_INVALID_KEY_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2b_param_set_key_length(&macctx->params, (uint8_t)len);
|
||||
memcpy(macctx->key, p, len);
|
||||
memset(macctx->key + len, 0, BLAKE2B_KEYBYTES - len);
|
||||
return 1;
|
||||
|
||||
case EVP_MAC_CTRL_SET_CUSTOM:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
if (len > BLAKE2B_PERSONALBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2B_MAC_CTRL, EVP_R_INVALID_CUSTOM_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2b_param_set_personal(&macctx->params, p, len);
|
||||
return 1;
|
||||
|
||||
case EVP_MAC_CTRL_SET_SALT:
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
if (len > BLAKE2B_SALTBYTES) {
|
||||
EVPerr(EVP_F_BLAKE2B_MAC_CTRL, EVP_R_INVALID_SALT_LENGTH);
|
||||
return 0;
|
||||
}
|
||||
blake2b_param_set_salt(&macctx->params, p, len);
|
||||
return 1;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
static int blake2b_mac_ctrl_int(EVP_MAC_IMPL *macctx, int cmd, ...)
|
||||
{
|
||||
int rv;
|
||||
va_list args;
|
||||
|
||||
va_start(args, cmd);
|
||||
rv = blake2b_mac_ctrl(macctx, cmd, args);
|
||||
va_end(args);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int blake2b_mac_ctrl_str_cb(void *macctx, int cmd, void *buf, size_t buflen)
|
||||
{
|
||||
return blake2b_mac_ctrl_int(macctx, cmd, buf, buflen);
|
||||
}
|
||||
|
||||
static int blake2b_mac_ctrl_str(EVP_MAC_IMPL *macctx, const char *type,
|
||||
const char *value)
|
||||
{
|
||||
if (value == NULL)
|
||||
return 0;
|
||||
|
||||
if (strcmp(type, "outlen") == 0)
|
||||
return blake2b_mac_ctrl_int(macctx, EVP_MAC_CTRL_SET_SIZE, (size_t)atoi(value));
|
||||
if (strcmp(type, "key") == 0)
|
||||
return EVP_str2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_KEY,
|
||||
value);
|
||||
if (strcmp(type, "hexkey") == 0)
|
||||
return EVP_hex2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_KEY,
|
||||
value);
|
||||
if (strcmp(type, "custom") == 0)
|
||||
return EVP_str2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_CUSTOM,
|
||||
value);
|
||||
if (strcmp(type, "hexcustom") == 0)
|
||||
return EVP_hex2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_CUSTOM,
|
||||
value);
|
||||
if (strcmp(type, "salt") == 0)
|
||||
return EVP_str2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_SALT,
|
||||
value);
|
||||
if (strcmp(type, "hexsalt") == 0)
|
||||
return EVP_hex2ctrl(blake2b_mac_ctrl_str_cb, macctx, EVP_MAC_CTRL_SET_SALT,
|
||||
value);
|
||||
return -2;
|
||||
}
|
||||
|
||||
static size_t blake2b_mac_size(EVP_MAC_IMPL *macctx)
|
||||
{
|
||||
return macctx->params.digest_length;
|
||||
}
|
||||
|
||||
const EVP_MAC blake2b_mac_meth = {
|
||||
EVP_MAC_BLAKE2B,
|
||||
blake2b_mac_new,
|
||||
blake2b_mac_dup,
|
||||
blake2b_mac_free,
|
||||
blake2b_mac_size,
|
||||
blake2b_mac_init,
|
||||
blake2b_mac_update,
|
||||
blake2b_mac_final,
|
||||
blake2b_mac_ctrl,
|
||||
blake2b_mac_ctrl_str
|
||||
};
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user