Latest update
This commit is contained in:
@@ -9,6 +9,23 @@
|
||||
|
||||
Changes between 1.1.1 and 3.0.0 [xx XXX xxxx]
|
||||
|
||||
*) Added support for enabling instrumentation through trace output.
|
||||
This is left to application control, by allowing it to register BIOs as
|
||||
channels for a number of tracing and debugging categories.
|
||||
|
||||
The 'openssl' application has been expanded to enable any of the types
|
||||
available via environment variables defined by the user, and serves as
|
||||
one possible example on how to use this functionality.
|
||||
[Richard Levitte & Matthias St. Pierre]
|
||||
|
||||
*) Added build tests for C++. These are generated files that only do one
|
||||
thing, to include one public OpenSSL head file each. This tests that
|
||||
the public header files can be usefully included in a C++ application.
|
||||
|
||||
This test isn't enabled by default. It can be enabled with the option
|
||||
'enable-buildtest-c++'.
|
||||
[Richard Levitte]
|
||||
|
||||
*) Added property based algorithm implementation selection framework to
|
||||
the core.
|
||||
[Paul Dale]
|
||||
|
||||
@@ -1725,7 +1725,7 @@ my %targets = (
|
||||
|
||||
disable => add('pinshared'),
|
||||
|
||||
apps_aux_src => "vms_term_sock.c",
|
||||
apps_aux_src => "vms_term_sock.c vms_decc_argv.c",
|
||||
apps_init_src => "vms_decc_init.c",
|
||||
},
|
||||
|
||||
|
||||
@@ -18,7 +18,8 @@ my %targets = (
|
||||
"debug-erbridge" => {
|
||||
inherit_from => [ 'BASE_unix', "x86_64_asm" ],
|
||||
cc => "gcc",
|
||||
cflags => combine("$gcc_devteam_warn -DBN_DEBUG -DCONF_DEBUG -m64 -DL_ENDIAN -DTERMIO -g",
|
||||
cflags => combine(join(' ', @{$gcc_devteam_warn{CFLAGS}}),
|
||||
"-DBN_DEBUG -DCONF_DEBUG -m64 -DL_ENDIAN -DTERMIO -g",
|
||||
threads("-D_REENTRANT")),
|
||||
ex_libs => add(" ","-ldl"),
|
||||
bn_ops => "SIXTY_FOUR_BIT_LONG",
|
||||
@@ -80,7 +81,8 @@ my %targets = (
|
||||
"debug-test-64-clang" => {
|
||||
inherit_from => [ 'BASE_unix', "x86_64_asm" ],
|
||||
cc => "clang",
|
||||
cflags => combine("$gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
|
||||
cflags => combine(join(' ', @{$gcc_devteam_warn{CFLAGS}}),
|
||||
"-Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
|
||||
threads("${BSDthreads}")),
|
||||
bn_ops => "SIXTY_FOUR_BIT_LONG",
|
||||
thread_scheme => "pthreads",
|
||||
@@ -92,7 +94,9 @@ my %targets = (
|
||||
"darwin64-debug-test-64-clang" => {
|
||||
inherit_from => [ 'BASE_unix', "x86_64_asm" ],
|
||||
cc => "clang",
|
||||
cflags => combine("-arch x86_64 -DL_ENDIAN $gcc_devteam_warn -Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
|
||||
cflags => combine("-arch x86_64 -DL_ENDIAN",
|
||||
join(' ', @{$gcc_devteam_warn{CFLAGS}}),
|
||||
"-Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_SAFESTACK -DDEBUG_UNUSED -g3 -O3 -pipe",
|
||||
threads("${BSDthreads}")),
|
||||
sys_id => "MACOSX",
|
||||
bn_ops => "SIXTY_FOUR_BIT_LONG",
|
||||
|
||||
@@ -231,8 +231,8 @@ LIB_CPPFLAGS={- our $lib_cppflags =
|
||||
join(' ', $target{lib_cppflags} || (),
|
||||
$target{shared_cppflag} || (),
|
||||
(map { '-D'.$_ }
|
||||
@{$config{lib_defines}},
|
||||
@{$config{shared_defines}}),
|
||||
@{$config{lib_defines} || ()},
|
||||
@{$config{shared_defines} || ()}),
|
||||
@{$config{lib_cppflags}},
|
||||
@{$config{shared_cppflag}});
|
||||
join(' ', $lib_cppflags,
|
||||
@@ -256,6 +256,9 @@ LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
|
||||
LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
|
||||
DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
|
||||
$target{module_cppflags} || (),
|
||||
(map { '-D'.$_ }
|
||||
@{$config{dso_defines} || ()},
|
||||
@{$config{module_defines} || ()}),
|
||||
@{$config{dso_cppflags}},
|
||||
@{$config{module_cppflags}},
|
||||
'$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
|
||||
@@ -276,6 +279,7 @@ DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
|
||||
'$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
|
||||
DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
|
||||
BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
|
||||
(map { '-D'.$_ } @{$config{bin_defines} || ()}),
|
||||
@{$config{bin_cppflags}},
|
||||
'$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
|
||||
BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
|
||||
|
||||
@@ -120,22 +120,27 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [-Dxxx] [-lx
|
||||
# code, so we just tell compiler to be pedantic about everything
|
||||
# but 'long long' type.
|
||||
|
||||
my $gcc_devteam_warn = "-DDEBUG_UNUSED"
|
||||
. " -DPEDANTIC -pedantic -Wno-long-long"
|
||||
. " -Wall"
|
||||
. " -Wextra"
|
||||
. " -Wno-unused-parameter"
|
||||
. " -Wno-missing-field-initializers"
|
||||
. " -Wswitch"
|
||||
. " -Wsign-compare"
|
||||
. " -Wmissing-prototypes"
|
||||
. " -Wstrict-prototypes"
|
||||
. " -Wshadow"
|
||||
. " -Wformat"
|
||||
. " -Wtype-limits"
|
||||
. " -Wundef"
|
||||
. " -Werror"
|
||||
;
|
||||
my %gcc_devteam_warn = ();
|
||||
{
|
||||
my @common = qw( -DDEBUG_UNUSED
|
||||
-DPEDANTIC -pedantic -Wno-long-long
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-unused-parameter
|
||||
-Wno-missing-field-initializers
|
||||
-Wswitch
|
||||
-Wsign-compare
|
||||
-Wshadow
|
||||
-Wformat
|
||||
-Wtype-limits
|
||||
-Wundef
|
||||
-Werror );
|
||||
%gcc_devteam_warn = (
|
||||
CFLAGS => [ @common, qw( -Wmissing-prototypes
|
||||
-Wstrict-prototypes ) ],
|
||||
CXXFLAGS => [ @common ]
|
||||
);
|
||||
}
|
||||
|
||||
# These are used in addition to $gcc_devteam_warn when the compiler is clang.
|
||||
# TODO(openssl-team): fix problems and investigate if (at least) the
|
||||
@@ -145,19 +150,20 @@ my $gcc_devteam_warn = "-DDEBUG_UNUSED"
|
||||
# -Wlanguage-extension-token -- no, we use asm()
|
||||
# -Wunused-macros -- no, too tricky for BN and _XOPEN_SOURCE etc
|
||||
# -Wextended-offsetof -- no, needed in CMS ASN1 code
|
||||
# -Wunused-function -- no, it forces header use of safestack et al
|
||||
# DEFINE macros
|
||||
my $clang_devteam_warn = ""
|
||||
. " -Wswitch-default"
|
||||
. " -Wno-parentheses-equality"
|
||||
. " -Wno-language-extension-token"
|
||||
. " -Wno-extended-offsetof"
|
||||
. " -Wconditional-uninitialized"
|
||||
. " -Wincompatible-pointer-types-discards-qualifiers"
|
||||
. " -Wmissing-variable-declarations"
|
||||
. " -Wno-unknown-warning-option"
|
||||
. " -Wno-unused-function"
|
||||
;
|
||||
my %clang_devteam_warn = ();
|
||||
{
|
||||
my @common = qw( -Wswitch-default
|
||||
-Wno-parentheses-equality
|
||||
-Wno-language-extension-token
|
||||
-Wno-extended-offsetof
|
||||
-Wconditional-uninitialized
|
||||
-Wincompatible-pointer-types-discards-qualifiers
|
||||
-Wno-unknown-warning-option );
|
||||
%clang_devteam_warn = (
|
||||
CFLAGS => [ @common, qw( -Wmissing-variable-declarations ) ],
|
||||
CXXFLAGS => [ @common ]
|
||||
);
|
||||
}
|
||||
|
||||
# This adds backtrace information to the memory leak info. Is only used
|
||||
# when crypto-mdebug-backtrace is enabled.
|
||||
@@ -335,6 +341,7 @@ my @disablables = (
|
||||
"autoload-config",
|
||||
"bf",
|
||||
"blake2",
|
||||
"buildtest-c++",
|
||||
"camellia",
|
||||
"capieng",
|
||||
"cast",
|
||||
@@ -368,7 +375,6 @@ my @disablables = (
|
||||
"fuzz-afl",
|
||||
"gost",
|
||||
"heartbeats",
|
||||
"hw(-.+)?",
|
||||
"idea",
|
||||
"makedepend",
|
||||
"md2",
|
||||
@@ -380,6 +386,7 @@ my @disablables = (
|
||||
"pinshared",
|
||||
"ocb",
|
||||
"ocsp",
|
||||
"padlockeng",
|
||||
"pic",
|
||||
"poly1305",
|
||||
"posix-io",
|
||||
@@ -410,6 +417,7 @@ my @disablables = (
|
||||
"tests",
|
||||
"threads",
|
||||
"tls",
|
||||
"trace",
|
||||
"ts",
|
||||
"ubsan",
|
||||
"ui-console",
|
||||
@@ -428,6 +436,8 @@ foreach my $proto ((@tls, @dtls))
|
||||
my %deprecated_disablables = (
|
||||
"ssl2" => undef,
|
||||
"buf-freelists" => undef,
|
||||
"hw" => "hw", # causes cascade, but no macro
|
||||
"hw-padlock" => "padlockeng",
|
||||
"ripemd" => "rmd160",
|
||||
"ui" => "ui-console",
|
||||
);
|
||||
@@ -436,6 +446,7 @@ my %deprecated_disablables = (
|
||||
|
||||
our %disabled = ( # "what" => "comment"
|
||||
"asan" => "default",
|
||||
"buildtest-c++" => "default",
|
||||
"crypto-mdebug" => "default",
|
||||
"crypto-mdebug-backtrace" => "default",
|
||||
"devcryptoeng" => "default",
|
||||
@@ -489,7 +500,9 @@ my @disable_cascades = (
|
||||
# Without position independent code, there can be no shared libraries or DSOs
|
||||
"pic" => [ "shared" ],
|
||||
"shared" => [ "dynamic-engine" ],
|
||||
"engine" => [ "afalgeng", "devcryptoeng" ],
|
||||
|
||||
"engine" => [ grep /eng$/, @disablables ],
|
||||
"hw" => [ "padlockeng" ],
|
||||
|
||||
# no-autoalginit is only useful when building non-shared
|
||||
"autoalginit" => [ "shared", "apps" ],
|
||||
@@ -548,18 +561,18 @@ my %user = (
|
||||
AS => undef,
|
||||
ASFLAGS => [],
|
||||
CC => env('CC'),
|
||||
CFLAGS => [],
|
||||
CFLAGS => [ env('CFLAGS') || () ],
|
||||
CXX => env('CXX'),
|
||||
CXXFLAGS => [],
|
||||
CXXFLAGS => [ env('CXXFLAGS') || () ],
|
||||
CPP => undef,
|
||||
CPPFLAGS => [], # -D, -I, -Wp,
|
||||
CPPFLAGS => [ env('CPPFLAGS') || () ], # -D, -I, -Wp,
|
||||
CPPDEFINES => [], # Alternative for -D
|
||||
CPPINCLUDES => [], # Alternative for -I
|
||||
CROSS_COMPILE => env('CROSS_COMPILE'),
|
||||
HASHBANGPERL=> env('HASHBANGPERL') || env('PERL'),
|
||||
LD => undef,
|
||||
LDFLAGS => [], # -L, -Wl,
|
||||
LDLIBS => [], # -l
|
||||
LDFLAGS => [ env('LDFLAGS') || () ], # -L, -Wl,
|
||||
LDLIBS => [ env('LDLIBS') || () ], # -l
|
||||
MT => undef,
|
||||
MTFLAGS => [],
|
||||
PERL => env('PERL') || ($^O ne "VMS" ? $^X : "perl"),
|
||||
@@ -668,8 +681,9 @@ while (@argvcopy)
|
||||
if (/^(no|disable|enable)-(.+)$/)
|
||||
{
|
||||
my $word = $2;
|
||||
if (!exists $deprecated_disablables{$word}
|
||||
&& !grep { $word =~ /^${_}$/ } @disablables)
|
||||
if ($word !~ m|hw(?:-.+)| # special treatment for hw regexp opt
|
||||
&& !exists $deprecated_disablables{$word}
|
||||
&& !grep { $word eq $_ } @disablables)
|
||||
{
|
||||
$unsupported_options{$_} = 1;
|
||||
next;
|
||||
@@ -723,6 +737,10 @@ while (@argvcopy)
|
||||
$disabled{$deprecated_disablables{$1}} = "option";
|
||||
}
|
||||
}
|
||||
elsif ($1 =~ m|hw(?:-.+)|) # deprecate hw options in regexp form
|
||||
{
|
||||
$deprecated_options{$_} = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$disabled{$1} = "option";
|
||||
@@ -1187,10 +1205,14 @@ $config{build_file} = env('BUILDFILE') || $target{build_file} || "Makefile";
|
||||
my %skipdir = ();
|
||||
my %disabled_info = (); # For configdata.pm
|
||||
foreach my $what (sort keys %disabled) {
|
||||
# There are deprecated disablables that translate to themselves.
|
||||
# They cause disabling cascades, but should otherwise not regiter.
|
||||
next if $deprecated_disablables{$what};
|
||||
|
||||
$config{options} .= " no-$what";
|
||||
|
||||
if (!grep { $what eq $_ } ( 'dso', 'threads', 'shared', 'pic',
|
||||
'dynamic-engine', 'makedepend',
|
||||
if (!grep { $what eq $_ } ( 'buildtest-c++', 'dso', 'threads', 'shared',
|
||||
'pic', 'dynamic-engine', 'makedepend',
|
||||
'zlib-dynamic', 'zlib', 'sse2' )) {
|
||||
(my $WHAT = uc $what) =~ s|-|_|g;
|
||||
my $skipdir = $what;
|
||||
@@ -1418,14 +1440,17 @@ unless ($disabled{asm}) {
|
||||
push @{$config{lib_defines}}, "X25519_ASM";
|
||||
}
|
||||
if ($target{padlock_asm_src} ne $table{DEFAULTS}->{padlock_asm_src}) {
|
||||
push @{$config{lib_defines}}, "PADLOCK_ASM";
|
||||
push @{$config{dso_defines}}, "PADLOCK_ASM";
|
||||
}
|
||||
if ($target{poly1305_asm_src} ne "") {
|
||||
push @{$config{lib_defines}}, "POLY1305_ASM";
|
||||
}
|
||||
}
|
||||
|
||||
my %predefined = compiler_predefined($config{CROSS_COMPILE}.$config{CC});
|
||||
my %predefined_C = compiler_predefined($config{CROSS_COMPILE}.$config{CC});
|
||||
my %predefined_CXX = $config{CXX}
|
||||
? compiler_predefined($config{CROSS_COMPILE}.$config{CXX})
|
||||
: ();
|
||||
|
||||
# Check for makedepend capabilities.
|
||||
if (!$disabled{makedepend}) {
|
||||
@@ -1433,8 +1458,8 @@ if (!$disabled{makedepend}) {
|
||||
# For VC- and vms- targets, there's nothing more to do here. The
|
||||
# functionality is hard coded in the corresponding build files for
|
||||
# cl (Windows) and CC/DECC (VMS).
|
||||
} elsif (($predefined{__GNUC__} // -1) >= 3
|
||||
&& !($predefined{__APPLE_CC__} && !$predefined{__clang__})) {
|
||||
} elsif (($predefined_C{__GNUC__} // -1) >= 3
|
||||
&& !($predefined_C{__APPLE_CC__} && !$predefined_C{__clang__})) {
|
||||
# We know that GNU C version 3 and up as well as all clang
|
||||
# versions support dependency generation, but Xcode did not
|
||||
# handle $cc -M before clang support (but claims __GNUC__ = 3)
|
||||
@@ -1447,9 +1472,9 @@ if (!$disabled{makedepend}) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!$disabled{asm} && !$predefined{__MACH__} && $^O ne 'VMS') {
|
||||
if (!$disabled{asm} && !$predefined_C{__MACH__} && $^O ne 'VMS') {
|
||||
# probe for -Wa,--noexecstack option...
|
||||
if ($predefined{__clang__}) {
|
||||
if ($predefined_C{__clang__}) {
|
||||
# clang has builtin assembler, which doesn't recognize --help,
|
||||
# but it apparently recognizes the option in question on all
|
||||
# supported platforms even when it's meaningless. In other words
|
||||
@@ -1507,24 +1532,35 @@ $config{openssl_api_defines} = [
|
||||
"OPENSSL_MIN_API=".($apitable->{$config{api} // ""} // -1)
|
||||
];
|
||||
|
||||
my @strict_warnings_collection=();
|
||||
my %strict_warnings_collection=( CFLAGS => [], CXXFLAGS => []);
|
||||
if ($strict_warnings)
|
||||
{
|
||||
my $wopt;
|
||||
my $gccver = $predefined{__GNUC__} // -1;
|
||||
my $gccver = $predefined_C{__GNUC__} // -1;
|
||||
my $gxxver = $predefined_CXX{__GNUC__} // -1;
|
||||
|
||||
die "ERROR --strict-warnings requires gcc[>=4] or gcc-alike"
|
||||
warn "WARNING --strict-warnings requires gcc[>=4] or gcc-alike"
|
||||
unless $gccver >= 4;
|
||||
push @strict_warnings_collection, (split /\s+/, $gcc_devteam_warn);
|
||||
push @strict_warnings_collection, (split /\s+/, $clang_devteam_warn)
|
||||
if (defined($predefined{__clang__}));
|
||||
warn "WARNING --strict-warnings requires g++[>=4] or g++-alike"
|
||||
unless $gxxver >= 4;
|
||||
foreach (qw(CFLAGS CXXFLAGS))
|
||||
{
|
||||
push @{$strict_warnings_collection{$_}},
|
||||
@{$gcc_devteam_warn{$_}};
|
||||
}
|
||||
push @{$strict_warnings_collection{CFLAGS}},
|
||||
@{$clang_devteam_warn{CFLAGS}}
|
||||
if (defined($predefined_C{__clang__}));
|
||||
push @{$strict_warnings_collection{CXXFLAGS}},
|
||||
@{$clang_devteam_warn{CXXFLAGS}}
|
||||
if (defined($predefined_CXX{__clang__}));
|
||||
}
|
||||
foreach (qw(CFLAGS CXXFLAGS))
|
||||
foreach my $idx (qw(CFLAGS CXXFLAGS))
|
||||
{
|
||||
$useradd{$_} = [ map { $_ eq '--ossl-strict-warnings'
|
||||
? @strict_warnings_collection
|
||||
: ( $_ ) }
|
||||
@{$useradd{$_}} ];
|
||||
$useradd{$idx} = [ map { $_ eq '--ossl-strict-warnings'
|
||||
? @{$strict_warnings_collection{$idx}}
|
||||
: ( $_ ) }
|
||||
@{$useradd{$idx}} ];
|
||||
}
|
||||
|
||||
unless ($disabled{"crypto-mdebug-backtrace"})
|
||||
|
||||
@@ -296,6 +296,19 @@
|
||||
Typically OpenSSL will automatically load a system config
|
||||
file which configures default ssl options.
|
||||
|
||||
enable-buildtest-c++
|
||||
While testing, generate C++ buildtest files that
|
||||
simply check that the public OpenSSL header files
|
||||
are usable standalone with C++.
|
||||
|
||||
Enabling this option demands extra care. For any
|
||||
compiler flag given directly as configuration
|
||||
option, you must ensure that it's valid for both
|
||||
the C and the C++ compiler. If not, the C++ build
|
||||
test will most likely break. As an alternative,
|
||||
you can use the language specific variables, CFLAGS
|
||||
and CXXFLAGS.
|
||||
|
||||
no-capieng
|
||||
Don't build the CAPI engine. This option will be forced if
|
||||
on a platform that does not support CAPI.
|
||||
@@ -396,9 +409,6 @@
|
||||
available if the GOST algorithms are also available through
|
||||
loading an externally supplied engine.
|
||||
|
||||
no-hw-padlock
|
||||
Don't build the padlock engine.
|
||||
|
||||
no-makedepend
|
||||
Don't generate dependencies.
|
||||
|
||||
@@ -413,6 +423,11 @@
|
||||
no-ocsp
|
||||
Don't build support for OCSP.
|
||||
|
||||
no-padlockeng
|
||||
no-hw-padlock
|
||||
Don't build the padlock engine.
|
||||
('no-hw-padlock' is deprecated and should not be used)
|
||||
|
||||
no-pic
|
||||
Don't build with support for Position Independent Code.
|
||||
|
||||
@@ -674,6 +689,11 @@
|
||||
CC=gcc CROSS_COMPILE=x86_64-w64-mingw32- \
|
||||
./config -DCOOKIE
|
||||
|
||||
If CC is set, it is advisable to also set CXX to ensure
|
||||
both C and C++ compilers are in the same "family". This
|
||||
becomes relevant with 'enable-external-tests' and
|
||||
'enable-buildtest-c++'.
|
||||
|
||||
reconf
|
||||
reconfigure
|
||||
Reconfigure from earlier data. This fetches the previous
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
Major changes between OpenSSL 1.1.1 and OpenSSL 3.0.0 [under development]
|
||||
|
||||
o Add support for enabling instrumentation through trace and debug
|
||||
output.
|
||||
o Changed our version number scheme and set the next major release to
|
||||
3.0.0
|
||||
o Added EVP_MAC, an EVP layer MAC API, and a generic EVP_PKEY to EVP_MAC
|
||||
|
||||
+8
-6
@@ -2243,8 +2243,6 @@ BIO *dup_bio_in(int format)
|
||||
BIO_NOCLOSE | (FMT_istext(format) ? BIO_FP_TEXT : 0));
|
||||
}
|
||||
|
||||
static BIO_METHOD *prefix_method = NULL;
|
||||
|
||||
BIO *dup_bio_out(int format)
|
||||
{
|
||||
BIO *b = BIO_new_fp(stdout,
|
||||
@@ -2256,10 +2254,9 @@ BIO *dup_bio_out(int format)
|
||||
b = BIO_push(BIO_new(BIO_f_linebuffer()), b);
|
||||
#endif
|
||||
|
||||
if (FMT_istext(format) && (prefix = getenv("HARNESS_OSSL_PREFIX")) != NULL) {
|
||||
if (prefix_method == NULL)
|
||||
prefix_method = apps_bf_prefix();
|
||||
b = BIO_push(BIO_new(prefix_method), b);
|
||||
if (FMT_istext(format)
|
||||
&& (prefix = getenv("HARNESS_OSSL_PREFIX")) != NULL) {
|
||||
b = BIO_push(BIO_new(apps_bf_prefix()), b);
|
||||
BIO_ctrl(b, PREFIX_CTRL_SET_PREFIX, 0, prefix);
|
||||
}
|
||||
|
||||
@@ -2277,8 +2274,13 @@ BIO *dup_bio_err(int format)
|
||||
return b;
|
||||
}
|
||||
|
||||
/*
|
||||
* Because the prefix method is created dynamically, we must also be able
|
||||
* to destroy it.
|
||||
*/
|
||||
void destroy_prefix_method(void)
|
||||
{
|
||||
BIO_METHOD *prefix_method = apps_bf_prefix();
|
||||
BIO_meth_free(prefix_method);
|
||||
prefix_method = NULL;
|
||||
}
|
||||
|
||||
@@ -722,7 +722,7 @@ end_of_options:
|
||||
|
||||
/*****************************************************************/
|
||||
if (req || gencrl) {
|
||||
if (spkac_file != NULL) {
|
||||
if (spkac_file != NULL && outfile != NULL) {
|
||||
output_der = 1;
|
||||
batch = 1;
|
||||
}
|
||||
|
||||
+1
-12
@@ -32,6 +32,7 @@
|
||||
# include "apps_ui.h"
|
||||
# include "opt.h"
|
||||
# include "fmt.h"
|
||||
# include "platform.h"
|
||||
|
||||
# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE)
|
||||
# define openssl_fdset(a,b) FD_SET((unsigned int)a, b)
|
||||
@@ -97,18 +98,6 @@ typedef struct args_st {
|
||||
char **argv;
|
||||
} ARGS;
|
||||
|
||||
/*
|
||||
* VMS C only for now, implemented in vms_decc_init.c
|
||||
* If other C compilers forget to terminate argv with NULL, this function
|
||||
* can be re-used.
|
||||
*/
|
||||
char **copy_argv(int *argc, char *argv[]);
|
||||
/*
|
||||
* Win32-specific argv initialization that splits OS-supplied UNICODE
|
||||
* command line string to array of UTF8-encoded strings.
|
||||
*/
|
||||
void win32_utf8argv(int *argc, char **argv[]);
|
||||
|
||||
/* We need both wrap and the "real" function because libcrypto uses both. */
|
||||
int wrap_password_callback(char *buf, int bufsiz, int verify, void *cb_data);
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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 HEADER_PLATFORM_H
|
||||
# define HEADER_PLATFORM_H
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
|
||||
# if defined(OPENSSL_SYS_VMS) && defined(__DECC)
|
||||
/*
|
||||
* VMS C only for now, implemented in vms_decc_init.c
|
||||
* If other C compilers forget to terminate argv with NULL, this function
|
||||
* can be re-used.
|
||||
*/
|
||||
char **copy_argv(int *argc, char *argv[]);
|
||||
# endif
|
||||
|
||||
# ifdef _WIN32
|
||||
/*
|
||||
* Win32-specific argv initialization that splits OS-supplied UNICODE
|
||||
* command line string to array of UTF8-encoded strings.
|
||||
*/
|
||||
void win32_utf8argv(int *argc, char **argv[]);
|
||||
# endif
|
||||
|
||||
#endif
|
||||
+115
-4
@@ -13,6 +13,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/trace.h>
|
||||
#include <openssl/lhash.h>
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/x509.h>
|
||||
@@ -93,7 +94,6 @@ static int apps_startup(void)
|
||||
static void apps_shutdown(void)
|
||||
{
|
||||
destroy_ui_method();
|
||||
destroy_prefix_method();
|
||||
}
|
||||
|
||||
static char *make_config_name(void)
|
||||
@@ -117,11 +117,114 @@ static char *make_config_name(void)
|
||||
return p;
|
||||
}
|
||||
|
||||
typedef struct tracedata_st {
|
||||
BIO *bio;
|
||||
unsigned int ingroup:1;
|
||||
} tracedata;
|
||||
|
||||
static size_t internal_trace_cb(const char *buf, size_t cnt,
|
||||
int category, int cmd, void *vdata)
|
||||
{
|
||||
int ret;
|
||||
tracedata *trace_data = vdata;
|
||||
int set_prefix = 0;
|
||||
|
||||
switch (cmd) {
|
||||
case OSSL_TRACE_CTRL_BEGIN:
|
||||
trace_data->ingroup = 1;
|
||||
set_prefix = 1;
|
||||
break;
|
||||
case OSSL_TRACE_CTRL_DURING:
|
||||
if (!trace_data->ingroup)
|
||||
set_prefix = 1;
|
||||
break;
|
||||
case OSSL_TRACE_CTRL_END:
|
||||
trace_data->ingroup = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (set_prefix) {
|
||||
union {
|
||||
CRYPTO_THREAD_ID tid;
|
||||
unsigned long ltid;
|
||||
} tid;
|
||||
char buffer[256];
|
||||
|
||||
tid.ltid = 0;
|
||||
tid.tid = CRYPTO_THREAD_get_current_id();
|
||||
|
||||
BIO_snprintf(buffer, sizeof(buffer), "TRACE[%lx]:%s: ", tid.ltid,
|
||||
OSSL_trace_get_category_name(category));
|
||||
BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX,
|
||||
strlen(buffer), buffer);
|
||||
}
|
||||
ret = BIO_write(trace_data->bio, buf, cnt);
|
||||
|
||||
return ret < 0 ? 0 : ret;
|
||||
}
|
||||
|
||||
DEFINE_STACK_OF(tracedata)
|
||||
static STACK_OF(tracedata) *trace_data_stack;
|
||||
|
||||
static void tracedata_free(tracedata *data)
|
||||
{
|
||||
BIO_free_all(data->bio);
|
||||
OPENSSL_free(data);
|
||||
}
|
||||
|
||||
static STACK_OF(tracedata) *trace_data_stack;
|
||||
|
||||
static void cleanup_trace(void)
|
||||
{
|
||||
sk_tracedata_pop_free(trace_data_stack, tracedata_free);
|
||||
}
|
||||
|
||||
static void setup_trace(const char *str)
|
||||
{
|
||||
char *val;
|
||||
|
||||
trace_data_stack = sk_tracedata_new_null();
|
||||
val = OPENSSL_strdup(str);
|
||||
|
||||
if (val != NULL) {
|
||||
char *valp = val;
|
||||
char *item;
|
||||
|
||||
for (valp = val; (item = strtok(valp, ",")) != NULL; valp = NULL) {
|
||||
int category = OSSL_trace_get_category_num(item);
|
||||
|
||||
if (category >= 0) {
|
||||
BIO *channel = BIO_push(BIO_new(apps_bf_prefix()),
|
||||
dup_bio_err(FORMAT_TEXT));
|
||||
tracedata *trace_data = OPENSSL_zalloc(sizeof(*trace_data));
|
||||
|
||||
if (trace_data == NULL
|
||||
|| (trace_data->bio = channel) == NULL
|
||||
|| OSSL_trace_set_callback(category, internal_trace_cb,
|
||||
trace_data) == 0
|
||||
|| sk_tracedata_push(trace_data_stack, trace_data) == 0) {
|
||||
OSSL_trace_set_callback(category, NULL, NULL);
|
||||
BIO_free_all(channel);
|
||||
fprintf(stderr,
|
||||
"warning: unable to setup trace callback for category '%s'.\n",
|
||||
item);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"warning: unknown trace category: '%s'.\n",
|
||||
item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OPENSSL_free(val);
|
||||
atexit(cleanup_trace);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FUNCTION f, *fp;
|
||||
LHASH_OF(FUNCTION) *prog = NULL;
|
||||
char **copied_argv = NULL;
|
||||
char *p, *pname;
|
||||
char buf[1024];
|
||||
const char *prompt;
|
||||
@@ -138,7 +241,7 @@ int main(int argc, char *argv[])
|
||||
bio_err = dup_bio_err(FORMAT_TEXT);
|
||||
|
||||
#if defined(OPENSSL_SYS_VMS) && defined(__DECC)
|
||||
copied_argv = argv = copy_argv(&argc, argv);
|
||||
argv = copy_argv(&argc, argv);
|
||||
#elif defined(_WIN32)
|
||||
/*
|
||||
* Replace argv[] with UTF-8 encoded strings.
|
||||
@@ -146,6 +249,15 @@ int main(int argc, char *argv[])
|
||||
win32_utf8argv(&argc, &argv);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We use the prefix method to get the trace output we want. Since some
|
||||
* trace outputs happen with OPENSSL_cleanup(), which is run automatically
|
||||
* after exit(), we need to destroy the prefix method as late as possible.
|
||||
*/
|
||||
atexit(destroy_prefix_method);
|
||||
|
||||
setup_trace(getenv("OPENSSL_TRACE"));
|
||||
|
||||
p = getenv("OPENSSL_DEBUG_MEMORY");
|
||||
if (p != NULL && strcmp(p, "on") == 0)
|
||||
CRYPTO_set_mem_debug(1);
|
||||
@@ -252,7 +364,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
ret = 1;
|
||||
end:
|
||||
OPENSSL_free(copied_argv);
|
||||
OPENSSL_free(default_config_file);
|
||||
lh_FUNCTION_free(prog);
|
||||
OPENSSL_free(arg.argv);
|
||||
|
||||
+155
-17
@@ -22,7 +22,7 @@
|
||||
static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize,
|
||||
const char *keyfile, int keyform, int key_type,
|
||||
char *passinarg, int pkey_op, ENGINE *e,
|
||||
const int impl);
|
||||
const int impl, EVP_PKEY **ppkey);
|
||||
|
||||
static int setup_peer(EVP_PKEY_CTX *ctx, int peerform, const char *file,
|
||||
ENGINE *e);
|
||||
@@ -31,6 +31,11 @@ static int do_keyop(EVP_PKEY_CTX *ctx, int pkey_op,
|
||||
unsigned char *out, size_t *poutlen,
|
||||
const unsigned char *in, size_t inlen);
|
||||
|
||||
static int do_raw_keyop(int pkey_op, EVP_PKEY_CTX *ctx,
|
||||
const EVP_MD *md, EVP_PKEY *pkey, BIO *in,
|
||||
unsigned char *sig, int siglen,
|
||||
unsigned char **out, size_t *poutlen);
|
||||
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_ENGINE, OPT_ENGINE_IMPL, OPT_IN, OPT_OUT,
|
||||
@@ -38,12 +43,16 @@ typedef enum OPTION_choice {
|
||||
OPT_VERIFY, OPT_VERIFYRECOVER, OPT_REV, OPT_ENCRYPT, OPT_DECRYPT,
|
||||
OPT_DERIVE, OPT_SIGFILE, OPT_INKEY, OPT_PEERKEY, OPT_PASSIN,
|
||||
OPT_PEERFORM, OPT_KEYFORM, OPT_PKEYOPT, OPT_PKEYOPT_PASSIN, OPT_KDF,
|
||||
OPT_KDFLEN, OPT_R_ENUM
|
||||
OPT_KDFLEN, OPT_R_ENUM,
|
||||
OPT_RAWIN, OPT_DIGEST
|
||||
} OPTION_CHOICE;
|
||||
|
||||
const OPTIONS pkeyutl_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||
{"rawin", OPT_RAWIN, '-', "Indicate the input data is in raw form"},
|
||||
{"digest", OPT_DIGEST, 's',
|
||||
"Specify the digest algorithm when signing the raw input data"},
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"pubin", OPT_PUBIN, '-', "Input is a public key"},
|
||||
{"certin", OPT_CERTIN, '-', "Input is a cert with a public key"},
|
||||
@@ -82,6 +91,7 @@ int pkeyutl_main(int argc, char **argv)
|
||||
BIO *in = NULL, *out = NULL;
|
||||
ENGINE *e = NULL;
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
char *infile = NULL, *outfile = NULL, *sigfile = NULL, *passinarg = NULL;
|
||||
char hexdump = 0, asn1parse = 0, rev = 0, *prog;
|
||||
unsigned char *buf_in = NULL, *buf_out = NULL, *sig = NULL;
|
||||
@@ -97,6 +107,8 @@ int pkeyutl_main(int argc, char **argv)
|
||||
int kdflen = 0;
|
||||
STACK_OF(OPENSSL_STRING) *pkeyopts = NULL;
|
||||
STACK_OF(OPENSSL_STRING) *pkeyopts_passin = NULL;
|
||||
int rawin = 0;
|
||||
const EVP_MD *md = NULL;
|
||||
|
||||
prog = opt_init(argc, argv, pkeyutl_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
@@ -203,12 +215,39 @@ int pkeyutl_main(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
case OPT_RAWIN:
|
||||
rawin = 1;
|
||||
break;
|
||||
case OPT_DIGEST:
|
||||
if (!opt_md(opt_arg(), &md))
|
||||
goto end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
if (argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
if (rawin && pkey_op != EVP_PKEY_OP_SIGN && pkey_op != EVP_PKEY_OP_VERIFY) {
|
||||
BIO_printf(bio_err,
|
||||
"%s: -rawin can only be used with -sign or -verify\n",
|
||||
prog);
|
||||
goto opthelp;
|
||||
}
|
||||
|
||||
if (md != NULL && !rawin) {
|
||||
BIO_printf(bio_err,
|
||||
"%s: -digest can only be used with -rawin\n",
|
||||
prog);
|
||||
goto opthelp;
|
||||
}
|
||||
|
||||
if (rawin && rev) {
|
||||
BIO_printf(bio_err, "%s: -rev cannot be used with raw input\n",
|
||||
prog);
|
||||
goto opthelp;
|
||||
}
|
||||
|
||||
if (kdfalg != NULL) {
|
||||
if (kdflen == 0) {
|
||||
BIO_printf(bio_err,
|
||||
@@ -225,7 +264,7 @@ int pkeyutl_main(int argc, char **argv)
|
||||
goto opthelp;
|
||||
}
|
||||
ctx = init_ctx(kdfalg, &keysize, inkey, keyform, key_type,
|
||||
passinarg, pkey_op, e, engine_impl);
|
||||
passinarg, pkey_op, e, engine_impl, &pkey);
|
||||
if (ctx == NULL) {
|
||||
BIO_printf(bio_err, "%s: Error initializing context\n", prog);
|
||||
ERR_print_errors(bio_err);
|
||||
@@ -327,7 +366,8 @@ int pkeyutl_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (in != NULL) {
|
||||
/* Raw input data is handled elsewhere */
|
||||
if (in != NULL && !rawin) {
|
||||
/* Read the input data */
|
||||
buf_inlen = bio_to_mem(&buf_in, keysize * 10, in);
|
||||
if (buf_inlen < 0) {
|
||||
@@ -346,8 +386,9 @@ int pkeyutl_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Sanity check the input */
|
||||
if (buf_inlen > EVP_MAX_MD_SIZE
|
||||
/* Sanity check the input if the input is not raw */
|
||||
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)) {
|
||||
@@ -357,8 +398,13 @@ int pkeyutl_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (pkey_op == EVP_PKEY_OP_VERIFY) {
|
||||
rv = EVP_PKEY_verify(ctx, sig, (size_t)siglen,
|
||||
buf_in, (size_t)buf_inlen);
|
||||
if (rawin) {
|
||||
rv = do_raw_keyop(pkey_op, ctx, md, pkey, in, sig, siglen,
|
||||
NULL, 0);
|
||||
} else {
|
||||
rv = EVP_PKEY_verify(ctx, sig, (size_t)siglen,
|
||||
buf_in, (size_t)buf_inlen);
|
||||
}
|
||||
if (rv == 1) {
|
||||
BIO_puts(out, "Signature Verified Successfully\n");
|
||||
ret = 0;
|
||||
@@ -371,14 +417,20 @@ int pkeyutl_main(int argc, char **argv)
|
||||
buf_outlen = kdflen;
|
||||
rv = 1;
|
||||
} else {
|
||||
rv = do_keyop(ctx, pkey_op, NULL, (size_t *)&buf_outlen,
|
||||
buf_in, (size_t)buf_inlen);
|
||||
}
|
||||
if (rv > 0 && buf_outlen != 0) {
|
||||
buf_out = app_malloc(buf_outlen, "buffer output");
|
||||
rv = do_keyop(ctx, pkey_op,
|
||||
buf_out, (size_t *)&buf_outlen,
|
||||
buf_in, (size_t)buf_inlen);
|
||||
if (rawin) {
|
||||
/* rawin allocates the buffer in do_raw_keyop() */
|
||||
rv = do_raw_keyop(pkey_op, ctx, md, pkey, in, NULL, 0,
|
||||
&buf_out, (size_t *)&buf_outlen);
|
||||
} else {
|
||||
rv = do_keyop(ctx, pkey_op, NULL, (size_t *)&buf_outlen,
|
||||
buf_in, (size_t)buf_inlen);
|
||||
if (rv > 0 && buf_outlen != 0) {
|
||||
buf_out = app_malloc(buf_outlen, "buffer output");
|
||||
rv = do_keyop(ctx, pkey_op,
|
||||
buf_out, (size_t *)&buf_outlen,
|
||||
buf_in, (size_t)buf_inlen);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rv <= 0) {
|
||||
if (pkey_op != EVP_PKEY_OP_DERIVE) {
|
||||
@@ -416,7 +468,7 @@ int pkeyutl_main(int argc, char **argv)
|
||||
static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize,
|
||||
const char *keyfile, int keyform, int key_type,
|
||||
char *passinarg, int pkey_op, ENGINE *e,
|
||||
const int engine_impl)
|
||||
const int engine_impl, EVP_PKEY **ppkey)
|
||||
{
|
||||
EVP_PKEY *pkey = NULL;
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
@@ -476,8 +528,26 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize,
|
||||
} else {
|
||||
if (pkey == NULL)
|
||||
goto end;
|
||||
|
||||
#ifndef OPENSSL_NO_EC
|
||||
/* SM2 needs a special treatment */
|
||||
if (EVP_PKEY_id(pkey) == EVP_PKEY_EC) {
|
||||
EC_KEY *eckey = NULL;
|
||||
const EC_GROUP *group = NULL;
|
||||
int nid;
|
||||
|
||||
if ((eckey = EVP_PKEY_get0_EC_KEY(pkey)) == NULL
|
||||
|| (group = EC_KEY_get0_group(eckey)) == NULL
|
||||
|| (nid = EC_GROUP_get_curve_name(group)) == 0)
|
||||
goto end;
|
||||
if (nid == NID_sm2)
|
||||
EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2);
|
||||
}
|
||||
#endif
|
||||
*pkeysize = EVP_PKEY_size(pkey);
|
||||
ctx = EVP_PKEY_CTX_new(pkey, impl);
|
||||
if (ppkey != NULL)
|
||||
*ppkey = pkey;
|
||||
EVP_PKEY_free(pkey);
|
||||
}
|
||||
|
||||
@@ -574,3 +644,71 @@ static int do_keyop(EVP_PKEY_CTX *ctx, int pkey_op,
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define TBUF_MAXSIZE 2048
|
||||
|
||||
static int do_raw_keyop(int pkey_op, EVP_PKEY_CTX *ctx,
|
||||
const EVP_MD *md, EVP_PKEY *pkey, BIO *in,
|
||||
unsigned char *sig, int siglen,
|
||||
unsigned char **out, size_t *poutlen)
|
||||
{
|
||||
int rv = 0;
|
||||
EVP_MD_CTX *mctx = NULL;
|
||||
unsigned char tbuf[TBUF_MAXSIZE];
|
||||
int tbuf_len = 0;
|
||||
|
||||
if ((mctx = EVP_MD_CTX_new()) == NULL) {
|
||||
BIO_printf(bio_err, "Error: out of memory\n");
|
||||
return rv;
|
||||
}
|
||||
EVP_MD_CTX_set_pkey_ctx(mctx, ctx);
|
||||
|
||||
switch(pkey_op) {
|
||||
case EVP_PKEY_OP_VERIFY:
|
||||
if (EVP_DigestVerifyInit(mctx, NULL, md, NULL, pkey) != 1)
|
||||
goto end;
|
||||
for (;;) {
|
||||
tbuf_len = BIO_read(in, tbuf, TBUF_MAXSIZE);
|
||||
if (tbuf_len == 0)
|
||||
break;
|
||||
if (tbuf_len < 0) {
|
||||
BIO_printf(bio_err, "Error reading raw input data\n");
|
||||
goto end;
|
||||
}
|
||||
rv = EVP_DigestVerifyUpdate(mctx, tbuf, (size_t)tbuf_len);
|
||||
if (rv != 1) {
|
||||
BIO_printf(bio_err, "Error verifying raw input data\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
rv = EVP_DigestVerifyFinal(mctx, sig, (size_t)siglen);
|
||||
break;
|
||||
case EVP_PKEY_OP_SIGN:
|
||||
if (EVP_DigestSignInit(mctx, NULL, md, NULL, pkey) != 1)
|
||||
goto end;
|
||||
for (;;) {
|
||||
tbuf_len = BIO_read(in, tbuf, TBUF_MAXSIZE);
|
||||
if (tbuf_len == 0)
|
||||
break;
|
||||
if (tbuf_len < 0) {
|
||||
BIO_printf(bio_err, "Error reading raw input data\n");
|
||||
goto end;
|
||||
}
|
||||
rv = EVP_DigestSignUpdate(mctx, tbuf, (size_t)tbuf_len);
|
||||
if (rv != 1) {
|
||||
BIO_printf(bio_err, "Error signing raw input data\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
rv = EVP_DigestSignFinal(mctx, NULL, poutlen);
|
||||
if (rv == 1 && out != NULL) {
|
||||
*out = app_malloc(*poutlen, "buffer output");
|
||||
rv = EVP_DigestSignFinal(mctx, *out, poutlen);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
end:
|
||||
EVP_MD_CTX_free(mctx);
|
||||
return rv;
|
||||
}
|
||||
+3
-3
@@ -38,6 +38,7 @@ typedef unsigned int u_int;
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/ocsp.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/trace.h>
|
||||
#include <openssl/async.h>
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
# include <openssl/srp.h>
|
||||
@@ -1521,6 +1522,7 @@ int s_client_main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (count4or6 >= 2) {
|
||||
BIO_printf(bio_err, "%s: Can't use both -4 and -6\n", prog);
|
||||
goto opthelp;
|
||||
@@ -3321,8 +3323,7 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
BIO_printf(bio_err, "Using Kernel TLS for sending\n");
|
||||
#endif
|
||||
|
||||
#ifdef SSL_DEBUG
|
||||
{
|
||||
if (OSSL_TRACE_ENABLED(TLS)) {
|
||||
/* Print out local port of connection: useful for debugging */
|
||||
int sock;
|
||||
union BIO_sock_info_u info;
|
||||
@@ -3335,7 +3336,6 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
}
|
||||
BIO_ADDR_free(info.addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_NEXTPROTONEG)
|
||||
if (next_proto.status != -1) {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2015-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 <stdlib.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include "platform.h" /* for copy_argv() */
|
||||
#include "apps.h" /* for app_malloc() */
|
||||
|
||||
char **newargv = NULL;
|
||||
|
||||
static void cleanup_argv(void)
|
||||
{
|
||||
OPENSSL_free(newargv);
|
||||
newargv = NULL;
|
||||
}
|
||||
|
||||
char **copy_argv(int *argc, char *argv[])
|
||||
{
|
||||
/*-
|
||||
* The note below is for historical purpose. On VMS now we always
|
||||
* copy argv "safely."
|
||||
*
|
||||
* 2011-03-22 SMS.
|
||||
* If we have 32-bit pointers everywhere, then we're safe, and
|
||||
* we bypass this mess, as on non-VMS systems.
|
||||
* Problem 1: Compaq/HP C before V7.3 always used 32-bit
|
||||
* pointers for argv[].
|
||||
* Fix 1: For a 32-bit argv[], when we're using 64-bit pointers
|
||||
* everywhere else, we always allocate and use a 64-bit
|
||||
* duplicate of argv[].
|
||||
* Problem 2: Compaq/HP C V7.3 (Alpha, IA64) before ECO1 failed
|
||||
* to NULL-terminate a 64-bit argv[]. (As this was written, the
|
||||
* compiler ECO was available only on IA64.)
|
||||
* Fix 2: Unless advised not to (VMS_TRUST_ARGV), we test a
|
||||
* 64-bit argv[argc] for NULL, and, if necessary, use a
|
||||
* (properly) NULL-terminated (64-bit) duplicate of argv[].
|
||||
* The same code is used in either case to duplicate argv[].
|
||||
* Some of these decisions could be handled in preprocessing,
|
||||
* but the code tends to get even uglier, and the penalty for
|
||||
* deciding at compile- or run-time is tiny.
|
||||
*/
|
||||
|
||||
int i, count = *argc;
|
||||
char **p = newargv;
|
||||
|
||||
cleanup_argv();
|
||||
|
||||
newargv = app_malloc(sizeof(*newargv) * (count + 1), "argv copy");
|
||||
if (newargv == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Register automatic cleanup on first use */
|
||||
if (p == NULL)
|
||||
OPENSSL_atexit(cleanup_argv);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
newargv[i] = argv[i];
|
||||
newargv[i] = NULL;
|
||||
*argc = i;
|
||||
return newargv;
|
||||
}
|
||||
@@ -25,8 +25,6 @@
|
||||
# include <stdlib.h>
|
||||
# include <unixlib.h>
|
||||
|
||||
# include "apps.h"
|
||||
|
||||
/* Global storage. */
|
||||
|
||||
/* Flag to sense if decc_init() was called. */
|
||||
@@ -63,42 +61,6 @@ decc_feat_t decc_feat_array[] = {
|
||||
};
|
||||
|
||||
|
||||
char **copy_argv(int *argc, char *argv[])
|
||||
{
|
||||
/*-
|
||||
* The note below is for historical purpose. On VMS now we always
|
||||
* copy argv "safely."
|
||||
*
|
||||
* 2011-03-22 SMS.
|
||||
* If we have 32-bit pointers everywhere, then we're safe, and
|
||||
* we bypass this mess, as on non-VMS systems.
|
||||
* Problem 1: Compaq/HP C before V7.3 always used 32-bit
|
||||
* pointers for argv[].
|
||||
* Fix 1: For a 32-bit argv[], when we're using 64-bit pointers
|
||||
* everywhere else, we always allocate and use a 64-bit
|
||||
* duplicate of argv[].
|
||||
* Problem 2: Compaq/HP C V7.3 (Alpha, IA64) before ECO1 failed
|
||||
* to NULL-terminate a 64-bit argv[]. (As this was written, the
|
||||
* compiler ECO was available only on IA64.)
|
||||
* Fix 2: Unless advised not to (VMS_TRUST_ARGV), we test a
|
||||
* 64-bit argv[argc] for NULL, and, if necessary, use a
|
||||
* (properly) NULL-terminated (64-bit) duplicate of argv[].
|
||||
* The same code is used in either case to duplicate argv[].
|
||||
* Some of these decisions could be handled in preprocessing,
|
||||
* but the code tends to get even uglier, and the penalty for
|
||||
* deciding at compile- or run-time is tiny.
|
||||
*/
|
||||
|
||||
int i, count = *argc;
|
||||
char **newargv = app_malloc(sizeof(*newargv) * (count + 1), "argv copy");
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
newargv[i] = argv[i];
|
||||
newargv[i] = NULL;
|
||||
*argc = i;
|
||||
return newargv;
|
||||
}
|
||||
|
||||
/* LIB$INITIALIZE initialization function. */
|
||||
|
||||
static void decc_init(void)
|
||||
|
||||
+13
-14
@@ -33,7 +33,7 @@
|
||||
#define DEF_DAYS 30
|
||||
|
||||
static int callb(int ok, X509_STORE_CTX *ctx);
|
||||
static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext,
|
||||
static int sign(X509 *x, EVP_PKEY *pkey, EVP_PKEY *fkey, int days, int clrext,
|
||||
const EVP_MD *digest, CONF *conf, const char *section,
|
||||
int preserve_dates);
|
||||
static int x509_certify(X509_STORE *ctx, const char *CAfile, const EVP_MD *digest,
|
||||
@@ -132,7 +132,7 @@ const OPTIONS x509_options[] = {
|
||||
{"CAform", OPT_CAFORM, 'F', "CA format - default PEM"},
|
||||
{"CAkeyform", OPT_CAKEYFORM, 'f', "CA key format - default PEM"},
|
||||
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
||||
{"force_pubkey", OPT_FORCE_PUBKEY, '<', "Force the Key to put inside certificate"},
|
||||
{"force_pubkey", OPT_FORCE_PUBKEY, '<', "Force the key to put inside certificate"},
|
||||
{"next_serial", OPT_NEXT_SERIAL, '-', "Increment current certificate serial number"},
|
||||
{"clrreject", OPT_CLRREJECT, '-',
|
||||
"Clears all the prohibited or rejected uses of the certificate"},
|
||||
@@ -574,18 +574,16 @@ int x509_main(int argc, char **argv)
|
||||
if (!set_cert_times(x, NULL, NULL, days))
|
||||
goto end;
|
||||
|
||||
if (fkey != NULL) {
|
||||
X509_set_pubkey(x, fkey);
|
||||
} else {
|
||||
pkey = X509_REQ_get0_pubkey(req);
|
||||
X509_set_pubkey(x, pkey);
|
||||
}
|
||||
if (!X509_set_pubkey(x, fkey != NULL ? fkey : X509_REQ_get0_pubkey(req)))
|
||||
goto end;
|
||||
} else {
|
||||
x = load_cert(infile, informat, "Certificate");
|
||||
if (x == NULL)
|
||||
goto end;
|
||||
if (fkey != NULL && !X509_set_pubkey(x, fkey))
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (x == NULL)
|
||||
goto end;
|
||||
if (CA_flag) {
|
||||
xca = load_cert(CAfile, CAformat, "CA Certificate");
|
||||
if (xca == NULL)
|
||||
@@ -799,7 +797,8 @@ int x509_main(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!sign(x, Upkey, days, clrext, digest, extconf, extsect, preserve_dates))
|
||||
if (!sign(x, Upkey, fkey, days, clrext, digest, extconf,
|
||||
extsect, preserve_dates))
|
||||
goto end;
|
||||
} else if (CA_flag == i) {
|
||||
BIO_printf(bio_err, "Getting CA Private Key\n");
|
||||
@@ -1054,8 +1053,8 @@ static int callb(int ok, X509_STORE_CTX *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
/* self sign */
|
||||
static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext,
|
||||
/* self-issue; self-sign unless a forced public key (fkey) is given */
|
||||
static int sign(X509 *x, EVP_PKEY *pkey, EVP_PKEY *fkey, int days, int clrext,
|
||||
const EVP_MD *digest, CONF *conf, const char *section,
|
||||
int preserve_dates)
|
||||
{
|
||||
@@ -1064,7 +1063,7 @@ static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext,
|
||||
goto err;
|
||||
if (!preserve_dates && !set_cert_times(x, NULL, NULL, days))
|
||||
goto err;
|
||||
if (!X509_set_pubkey(x, pkey))
|
||||
if (fkey == NULL && !X509_set_pubkey(x, pkey))
|
||||
goto err;
|
||||
if (clrext) {
|
||||
while (X509_get_ext_count(x) > 0)
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@
|
||||
|
||||
#ifndef NO_OLD_ASN1
|
||||
|
||||
void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x)
|
||||
void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, const void *x)
|
||||
{
|
||||
unsigned char *b, *p;
|
||||
const unsigned char *p2;
|
||||
@@ -46,7 +46,7 @@ void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x)
|
||||
* decode.
|
||||
*/
|
||||
|
||||
void *ASN1_item_dup(const ASN1_ITEM *it, void *x)
|
||||
void *ASN1_item_dup(const ASN1_ITEM *it, const void *x)
|
||||
{
|
||||
unsigned char *b = NULL;
|
||||
const unsigned char *p;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#ifndef NO_OLD_ASN1
|
||||
|
||||
# ifndef OPENSSL_NO_STDIO
|
||||
int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x)
|
||||
int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, const void *x)
|
||||
{
|
||||
BIO *b;
|
||||
int ret;
|
||||
@@ -31,7 +31,7 @@ int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x)
|
||||
}
|
||||
# endif
|
||||
|
||||
int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
|
||||
int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, const void *x)
|
||||
{
|
||||
char *b;
|
||||
unsigned char *p;
|
||||
@@ -68,7 +68,7 @@ int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x)
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x)
|
||||
int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, const void *x)
|
||||
{
|
||||
BIO *b;
|
||||
int ret;
|
||||
@@ -84,7 +84,7 @@ int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x)
|
||||
}
|
||||
#endif
|
||||
|
||||
int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x)
|
||||
int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, const void *x)
|
||||
{
|
||||
unsigned char *b = NULL;
|
||||
int i, j = 0, n, ret = 1;
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
|
||||
/* Internal ASN1 structures and functions: not for application use */
|
||||
|
||||
typedef const ASN1_VALUE const_ASN1_VALUE;
|
||||
SKM_DEFINE_STACK_OF(const_ASN1_VALUE, const ASN1_VALUE, ASN1_VALUE)
|
||||
|
||||
int asn1_time_to_tm(struct tm *tm, const ASN1_TIME *d);
|
||||
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d);
|
||||
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d);
|
||||
@@ -46,19 +49,22 @@ DEFINE_STACK_OF(MIME_HEADER)
|
||||
void asn1_string_embed_free(ASN1_STRING *a, int embed);
|
||||
|
||||
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
int asn1_get_choice_selector_const(const ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
|
||||
const ASN1_ITEM *it);
|
||||
|
||||
ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
|
||||
const ASN1_VALUE **asn1_get_const_field_ptr(const ASN1_VALUE **pval,
|
||||
const ASN1_TEMPLATE *tt);
|
||||
|
||||
const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
|
||||
const ASN1_TEMPLATE *asn1_do_adb(const ASN1_VALUE *val, const ASN1_TEMPLATE *tt,
|
||||
int nullerr);
|
||||
|
||||
int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it);
|
||||
|
||||
void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
|
||||
int asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it);
|
||||
int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
|
||||
const ASN1_ITEM *it);
|
||||
|
||||
@@ -64,6 +64,7 @@ static void mime_hdr_free(MIME_HEADER *hdr);
|
||||
|
||||
/* Output an ASN1 structure in BER format streaming if necessary */
|
||||
|
||||
/* unfortunately cannot constify this due to CMS_stream() and PKCS7_stream() */
|
||||
int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
@@ -311,6 +312,7 @@ int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
|
||||
|
||||
/* Handle output of ASN1 data */
|
||||
|
||||
/* cannot constify val because of CMS_dataFinal() */
|
||||
static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,7 @@ static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg);
|
||||
static int ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen,
|
||||
void *parg);
|
||||
|
||||
/* unfortunately cannot constify this due to CMS_stream() and PKCS7_stream() */
|
||||
BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
|
||||
{
|
||||
NDEF_SUPPORT *ndef_aux = NULL;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "internal/asn1_int.h"
|
||||
#include "internal/evp_int.h"
|
||||
|
||||
int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp)
|
||||
int i2d_PrivateKey(const EVP_PKEY *a, unsigned char **pp)
|
||||
{
|
||||
if (a->ameth && a->ameth->old_priv_encode) {
|
||||
return a->ameth->old_priv_encode(a, pp);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <openssl/dsa.h>
|
||||
#include <openssl/ec.h>
|
||||
|
||||
int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp)
|
||||
int i2d_PublicKey(const EVP_PKEY *a, unsigned char **pp)
|
||||
{
|
||||
switch (EVP_PKEY_id(a)) {
|
||||
#ifndef OPENSSL_NO_RSA
|
||||
|
||||
@@ -43,9 +43,9 @@ ASN1_BROKEN_SEQUENCE(NETSCAPE_ENCRYPTED_PKEY) = {
|
||||
ASN1_SIMPLE(NETSCAPE_ENCRYPTED_PKEY, enckey, X509_SIG)
|
||||
} static_ASN1_BROKEN_SEQUENCE_END(NETSCAPE_ENCRYPTED_PKEY)
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY,NETSCAPE_ENCRYPTED_PKEY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(NETSCAPE_ENCRYPTED_PKEY)
|
||||
DECLARE_ASN1_FUNCTIONS(NETSCAPE_ENCRYPTED_PKEY)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_name(NETSCAPE_ENCRYPTED_PKEY, NETSCAPE_ENCRYPTED_PKEY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_ENCRYPTED_PKEY)
|
||||
|
||||
ASN1_SEQUENCE(NETSCAPE_PKEY) = {
|
||||
ASN1_EMBED(NETSCAPE_PKEY, version, INT32),
|
||||
@@ -53,9 +53,9 @@ ASN1_SEQUENCE(NETSCAPE_PKEY) = {
|
||||
ASN1_SIMPLE(NETSCAPE_PKEY, private_key, ASN1_OCTET_STRING)
|
||||
} static_ASN1_SEQUENCE_END(NETSCAPE_PKEY)
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS_const(NETSCAPE_PKEY)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_const(NETSCAPE_PKEY,NETSCAPE_PKEY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(NETSCAPE_PKEY)
|
||||
DECLARE_ASN1_FUNCTIONS(NETSCAPE_PKEY)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_name(NETSCAPE_PKEY, NETSCAPE_PKEY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(NETSCAPE_PKEY)
|
||||
|
||||
# endif /* OPENSSL_NO_RC4 */
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
if (tt->flags & ASN1_TFLG_ADB_MASK) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(pval, tt, 0);
|
||||
seqtt = asn1_do_adb(*pval, tt, 0);
|
||||
if (seqtt == NULL)
|
||||
continue;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
@@ -328,7 +328,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
seqtt = asn1_do_adb(*pval, tt, 1);
|
||||
if (seqtt == NULL)
|
||||
goto err;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
@@ -394,7 +394,7 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
|
||||
*/
|
||||
for (; i < it->tcount; tt++, i++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
seqtt = asn1_do_adb(*pval, tt, 1);
|
||||
if (seqtt == NULL)
|
||||
goto err;
|
||||
if (seqtt->flags & ASN1_TFLG_OPTIONAL) {
|
||||
|
||||
+47
-43
@@ -16,16 +16,17 @@
|
||||
#include "internal/asn1_int.h"
|
||||
#include "asn1_locl.h"
|
||||
|
||||
static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
|
||||
static int asn1_i2d_ex_primitive(const ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_ITEM *it, int tag, int aclass);
|
||||
static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
|
||||
static int asn1_set_seq_out(STACK_OF(const_ASN1_VALUE) *sk,
|
||||
unsigned char **out,
|
||||
int skcontlen, const ASN1_ITEM *item,
|
||||
int do_sort, int iclass);
|
||||
static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
static int asn1_template_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_TEMPLATE *tt, int tag, int aclass);
|
||||
static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
|
||||
static int asn1_item_flags_i2d(const ASN1_VALUE *val, unsigned char **out,
|
||||
const ASN1_ITEM *it, int flags);
|
||||
static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
static int asn1_ex_i2c(const ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
const ASN1_ITEM *it);
|
||||
|
||||
/*
|
||||
@@ -33,13 +34,13 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
* indefinite length constructed encoding, where appropriate
|
||||
*/
|
||||
|
||||
int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out,
|
||||
int ASN1_item_ndef_i2d(const ASN1_VALUE *val, unsigned char **out,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
return asn1_item_flags_i2d(val, out, it, ASN1_TFLG_NDEF);
|
||||
}
|
||||
|
||||
int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
|
||||
int ASN1_item_i2d(const ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
|
||||
{
|
||||
return asn1_item_flags_i2d(val, out, it, 0);
|
||||
}
|
||||
@@ -51,7 +52,7 @@ int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
|
||||
* allocated and populated with the encoding.
|
||||
*/
|
||||
|
||||
static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
|
||||
static int asn1_item_flags_i2d(const ASN1_VALUE *val, unsigned char **out,
|
||||
const ASN1_ITEM *it, int flags)
|
||||
{
|
||||
if (out && !*out) {
|
||||
@@ -79,20 +80,22 @@ static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
|
||||
* performs the normal item handling: it can be used in external types.
|
||||
*/
|
||||
|
||||
int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_ITEM *it, int tag, int aclass)
|
||||
{
|
||||
const ASN1_TEMPLATE *tt = NULL;
|
||||
int i, seqcontlen, seqlen, ndef = 1;
|
||||
const ASN1_EXTERN_FUNCS *ef;
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
ASN1_aux_cb *asn1_cb = 0;
|
||||
ASN1_aux_const_cb *asn1_cb = NULL;
|
||||
|
||||
if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval)
|
||||
return 0;
|
||||
|
||||
if (aux && aux->asn1_cb)
|
||||
asn1_cb = aux->asn1_cb;
|
||||
if (aux != NULL) {
|
||||
asn1_cb = ((aux->flags & ASN1_AFLG_CONST_CB) != 0) ? aux->asn1_const_cb
|
||||
: (ASN1_aux_const_cb *)aux->asn1_cb; /* backward compatibility */
|
||||
}
|
||||
|
||||
switch (it->itype) {
|
||||
|
||||
@@ -108,12 +111,12 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
case ASN1_ITYPE_CHOICE:
|
||||
if (asn1_cb && !asn1_cb(ASN1_OP_I2D_PRE, pval, it, NULL))
|
||||
return 0;
|
||||
i = asn1_get_choice_selector(pval, it);
|
||||
i = asn1_get_choice_selector_const(pval, it);
|
||||
if ((i >= 0) && (i < it->tcount)) {
|
||||
ASN1_VALUE **pchval;
|
||||
const ASN1_VALUE **pchval;
|
||||
const ASN1_TEMPLATE *chtt;
|
||||
chtt = it->templates + i;
|
||||
pchval = asn1_get_field_ptr(pval, chtt);
|
||||
pchval = asn1_get_const_field_ptr(pval, chtt);
|
||||
return asn1_template_ex_i2d(pchval, out, chtt, -1, aclass);
|
||||
}
|
||||
/* Fixme: error condition if selector out of range */
|
||||
@@ -154,12 +157,12 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
/* First work out sequence content length */
|
||||
for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
const ASN1_VALUE **pseqval;
|
||||
int tmplen;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
seqtt = asn1_do_adb(*pval, tt, 1);
|
||||
if (!seqtt)
|
||||
return 0;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
pseqval = asn1_get_const_field_ptr(pval, seqtt);
|
||||
tmplen = asn1_template_ex_i2d(pseqval, NULL, seqtt, -1, aclass);
|
||||
if (tmplen == -1 || (tmplen > INT_MAX - seqcontlen))
|
||||
return -1;
|
||||
@@ -173,11 +176,11 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
ASN1_put_object(out, ndef, seqcontlen, tag, aclass);
|
||||
for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
const ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(*pval, tt, 1);
|
||||
if (!seqtt)
|
||||
return 0;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
pseqval = asn1_get_const_field_ptr(pval, seqtt);
|
||||
/* FIXME: check for errors in enhanced version */
|
||||
asn1_template_ex_i2d(pseqval, out, seqtt, -1, aclass);
|
||||
}
|
||||
@@ -194,11 +197,11 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
static int asn1_template_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_TEMPLATE *tt, int tag, int iclass)
|
||||
{
|
||||
int i, ret, flags, ttag, tclass, ndef;
|
||||
ASN1_VALUE *tval;
|
||||
const ASN1_VALUE *tval;
|
||||
flags = tt->flags;
|
||||
|
||||
/*
|
||||
@@ -250,10 +253,10 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
|
||||
if (flags & ASN1_TFLG_SK_MASK) {
|
||||
/* SET OF, SEQUENCE OF */
|
||||
STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval;
|
||||
STACK_OF(const_ASN1_VALUE) *sk = (STACK_OF(const_ASN1_VALUE) *)*pval;
|
||||
int isset, sktag, skaclass;
|
||||
int skcontlen, sklen;
|
||||
ASN1_VALUE *skitem;
|
||||
const ASN1_VALUE *skitem;
|
||||
|
||||
if (!*pval)
|
||||
return 0;
|
||||
@@ -283,9 +286,9 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
|
||||
/* Determine total length of items */
|
||||
skcontlen = 0;
|
||||
for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
|
||||
for (i = 0; i < sk_const_ASN1_VALUE_num(sk); i++) {
|
||||
int tmplen;
|
||||
skitem = sk_ASN1_VALUE_value(sk, i);
|
||||
skitem = sk_const_ASN1_VALUE_value(sk, i);
|
||||
tmplen = ASN1_item_ex_i2d(&skitem, NULL, ASN1_ITEM_ptr(tt->item),
|
||||
-1, iclass);
|
||||
if (tmplen == -1 || (skcontlen > INT_MAX - tmplen))
|
||||
@@ -351,7 +354,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
typedef struct {
|
||||
unsigned char *data;
|
||||
int length;
|
||||
ASN1_VALUE *field;
|
||||
const ASN1_VALUE *field;
|
||||
} DER_ENC;
|
||||
|
||||
static int der_cmp(const void *a, const void *b)
|
||||
@@ -367,20 +370,21 @@ static int der_cmp(const void *a, const void *b)
|
||||
|
||||
/* Output the content octets of SET OF or SEQUENCE OF */
|
||||
|
||||
static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
|
||||
static int asn1_set_seq_out(STACK_OF(const_ASN1_VALUE) *sk,
|
||||
unsigned char **out,
|
||||
int skcontlen, const ASN1_ITEM *item,
|
||||
int do_sort, int iclass)
|
||||
{
|
||||
int i;
|
||||
ASN1_VALUE *skitem;
|
||||
const ASN1_VALUE *skitem;
|
||||
unsigned char *tmpdat = NULL, *p = NULL;
|
||||
DER_ENC *derlst = NULL, *tder;
|
||||
if (do_sort) {
|
||||
/* Don't need to sort less than 2 items */
|
||||
if (sk_ASN1_VALUE_num(sk) < 2)
|
||||
if (sk_const_ASN1_VALUE_num(sk) < 2)
|
||||
do_sort = 0;
|
||||
else {
|
||||
derlst = OPENSSL_malloc(sk_ASN1_VALUE_num(sk)
|
||||
derlst = OPENSSL_malloc(sk_const_ASN1_VALUE_num(sk)
|
||||
* sizeof(*derlst));
|
||||
if (derlst == NULL)
|
||||
return 0;
|
||||
@@ -393,8 +397,8 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
|
||||
}
|
||||
/* If not sorting just output each item */
|
||||
if (!do_sort) {
|
||||
for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
|
||||
skitem = sk_ASN1_VALUE_value(sk, i);
|
||||
for (i = 0; i < sk_const_ASN1_VALUE_num(sk); i++) {
|
||||
skitem = sk_const_ASN1_VALUE_value(sk, i);
|
||||
ASN1_item_ex_i2d(&skitem, out, item, -1, iclass);
|
||||
}
|
||||
return 1;
|
||||
@@ -402,33 +406,33 @@ static int asn1_set_seq_out(STACK_OF(ASN1_VALUE) *sk, unsigned char **out,
|
||||
p = tmpdat;
|
||||
|
||||
/* Doing sort: build up a list of each member's DER encoding */
|
||||
for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {
|
||||
skitem = sk_ASN1_VALUE_value(sk, i);
|
||||
for (i = 0, tder = derlst; i < sk_const_ASN1_VALUE_num(sk); i++, tder++) {
|
||||
skitem = sk_const_ASN1_VALUE_value(sk, i);
|
||||
tder->data = p;
|
||||
tder->length = ASN1_item_ex_i2d(&skitem, &p, item, -1, iclass);
|
||||
tder->field = skitem;
|
||||
}
|
||||
|
||||
/* Now sort them */
|
||||
qsort(derlst, sk_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp);
|
||||
qsort(derlst, sk_const_ASN1_VALUE_num(sk), sizeof(*derlst), der_cmp);
|
||||
/* Output sorted DER encoding */
|
||||
p = *out;
|
||||
for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++) {
|
||||
for (i = 0, tder = derlst; i < sk_const_ASN1_VALUE_num(sk); i++, tder++) {
|
||||
memcpy(p, tder->data, tder->length);
|
||||
p += tder->length;
|
||||
}
|
||||
*out = p;
|
||||
/* If do_sort is 2 then reorder the STACK */
|
||||
if (do_sort == 2) {
|
||||
for (i = 0, tder = derlst; i < sk_ASN1_VALUE_num(sk); i++, tder++)
|
||||
(void)sk_ASN1_VALUE_set(sk, i, tder->field);
|
||||
for (i = 0, tder = derlst; i < sk_const_ASN1_VALUE_num(sk); i++, tder++)
|
||||
(void)sk_const_ASN1_VALUE_set(sk, i, tder->field);
|
||||
}
|
||||
OPENSSL_free(derlst);
|
||||
OPENSSL_free(tmpdat);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
|
||||
static int asn1_i2d_ex_primitive(const ASN1_VALUE **pval, unsigned char **out,
|
||||
const ASN1_ITEM *it, int tag, int aclass)
|
||||
{
|
||||
int len;
|
||||
@@ -488,7 +492,7 @@ static int asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
|
||||
|
||||
/* Produce content octets from a structure */
|
||||
|
||||
static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
static int asn1_ex_i2c(const ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
ASN1_BOOLEAN *tbool = NULL;
|
||||
@@ -521,7 +525,7 @@ static int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
|
||||
typ = (ASN1_TYPE *)*pval;
|
||||
utype = typ->type;
|
||||
*putype = utype;
|
||||
pval = &typ->value.asn1_value;
|
||||
pval = (const ASN1_VALUE **)&typ->value.asn1_value; /* actually is const */
|
||||
} else
|
||||
utype = *putype;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
|
||||
ASN1_VALUE **pseqval;
|
||||
|
||||
tt--;
|
||||
seqtt = asn1_do_adb(pval, tt, 0);
|
||||
seqtt = asn1_do_adb(*pval, tt, 0);
|
||||
if (!seqtt)
|
||||
continue;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
|
||||
+26
-26
@@ -101,15 +101,15 @@ void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags)
|
||||
|
||||
/* Main print routines */
|
||||
|
||||
static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
static int asn1_item_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
|
||||
const ASN1_ITEM *it,
|
||||
const char *fname, const char *sname,
|
||||
int nohdr, const ASN1_PCTX *pctx);
|
||||
|
||||
static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
static int asn1_template_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
|
||||
const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx);
|
||||
|
||||
static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
static int asn1_primitive_print(BIO *out, const ASN1_VALUE **fld,
|
||||
const ASN1_ITEM *it, int indent,
|
||||
const char *fname, const char *sname,
|
||||
const ASN1_PCTX *pctx);
|
||||
@@ -118,7 +118,7 @@ static int asn1_print_fsname(BIO *out, int indent,
|
||||
const char *fname, const char *sname,
|
||||
const ASN1_PCTX *pctx);
|
||||
|
||||
int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
|
||||
int ASN1_item_print(BIO *out, const ASN1_VALUE *ifld, int indent,
|
||||
const ASN1_ITEM *it, const ASN1_PCTX *pctx)
|
||||
{
|
||||
const char *sname;
|
||||
@@ -131,25 +131,25 @@ int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent,
|
||||
return asn1_item_print_ctx(out, &ifld, indent, it, NULL, sname, 0, pctx);
|
||||
}
|
||||
|
||||
static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
static int asn1_item_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
|
||||
const ASN1_ITEM *it,
|
||||
const char *fname, const char *sname,
|
||||
int nohdr, const ASN1_PCTX *pctx)
|
||||
{
|
||||
const ASN1_TEMPLATE *tt;
|
||||
const ASN1_EXTERN_FUNCS *ef;
|
||||
ASN1_VALUE **tmpfld;
|
||||
const ASN1_VALUE **tmpfld;
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
ASN1_aux_cb *asn1_cb;
|
||||
ASN1_aux_const_cb *asn1_cb = NULL;
|
||||
ASN1_PRINT_ARG parg;
|
||||
int i;
|
||||
if (aux && aux->asn1_cb) {
|
||||
if (aux != NULL) {
|
||||
parg.out = out;
|
||||
parg.indent = indent;
|
||||
parg.pctx = pctx;
|
||||
asn1_cb = aux->asn1_cb;
|
||||
} else
|
||||
asn1_cb = 0;
|
||||
asn1_cb = ((aux->flags & ASN1_AFLG_CONST_CB) != 0) ? aux->asn1_const_cb
|
||||
: (ASN1_aux_const_cb *)aux->asn1_cb; /* backward compatibility */
|
||||
}
|
||||
|
||||
if (((it->itype != ASN1_ITYPE_PRIMITIVE)
|
||||
|| (it->utype != V_ASN1_BOOLEAN)) && *fld == NULL) {
|
||||
@@ -195,7 +195,7 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
|
||||
case ASN1_ITYPE_CHOICE:
|
||||
/* CHOICE type, get selector */
|
||||
i = asn1_get_choice_selector(fld, it);
|
||||
i = asn1_get_choice_selector_const(fld, it);
|
||||
/* This should never happen... */
|
||||
if ((i < 0) || (i >= it->tcount)) {
|
||||
if (BIO_printf(out, "ERROR: selector [%d] invalid\n", i) <= 0)
|
||||
@@ -203,7 +203,7 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
return 1;
|
||||
}
|
||||
tt = it->templates + i;
|
||||
tmpfld = asn1_get_field_ptr(fld, tt);
|
||||
tmpfld = asn1_get_const_field_ptr(fld, tt);
|
||||
if (!asn1_template_print_ctx(out, tmpfld, indent, tt, pctx))
|
||||
return 0;
|
||||
break;
|
||||
@@ -233,10 +233,10 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
/* Print each field entry */
|
||||
for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
seqtt = asn1_do_adb(fld, tt, 1);
|
||||
seqtt = asn1_do_adb(*fld, tt, 1);
|
||||
if (!seqtt)
|
||||
return 0;
|
||||
tmpfld = asn1_get_field_ptr(fld, seqtt);
|
||||
tmpfld = asn1_get_const_field_ptr(fld, seqtt);
|
||||
if (!asn1_template_print_ctx(out, tmpfld,
|
||||
indent + 2, seqtt, pctx))
|
||||
return 0;
|
||||
@@ -261,12 +261,12 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
static int asn1_template_print_ctx(BIO *out, const ASN1_VALUE **fld, int indent,
|
||||
const ASN1_TEMPLATE *tt, const ASN1_PCTX *pctx)
|
||||
{
|
||||
int i, flags;
|
||||
const char *sname, *fname;
|
||||
ASN1_VALUE *tfld;
|
||||
const ASN1_VALUE *tfld;
|
||||
flags = tt->flags;
|
||||
if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME)
|
||||
sname = ASN1_ITEM_ptr(tt->item)->sname;
|
||||
@@ -282,14 +282,14 @@ static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
* a pointer to a field.
|
||||
*/
|
||||
if (flags & ASN1_TFLG_EMBED) {
|
||||
tfld = (ASN1_VALUE *)fld;
|
||||
tfld = (const ASN1_VALUE *)fld;
|
||||
fld = &tfld;
|
||||
}
|
||||
|
||||
if (flags & ASN1_TFLG_SK_MASK) {
|
||||
char *tname;
|
||||
ASN1_VALUE *skitem;
|
||||
STACK_OF(ASN1_VALUE) *stack;
|
||||
const ASN1_VALUE *skitem;
|
||||
STACK_OF(const_ASN1_VALUE) *stack;
|
||||
|
||||
/* SET OF, SEQUENCE OF */
|
||||
if (fname) {
|
||||
@@ -304,12 +304,12 @@ static int asn1_template_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
} else if (BIO_printf(out, "%*s%s:\n", indent, "", fname) <= 0)
|
||||
return 0;
|
||||
}
|
||||
stack = (STACK_OF(ASN1_VALUE) *)*fld;
|
||||
for (i = 0; i < sk_ASN1_VALUE_num(stack); i++) {
|
||||
stack = (STACK_OF(const_ASN1_VALUE) *)*fld;
|
||||
for (i = 0; i < sk_const_ASN1_VALUE_num(stack); i++) {
|
||||
if ((i > 0) && (BIO_puts(out, "\n") <= 0))
|
||||
return 0;
|
||||
|
||||
skitem = sk_ASN1_VALUE_value(stack, i);
|
||||
skitem = sk_const_ASN1_VALUE_value(stack, i);
|
||||
if (!asn1_item_print_ctx(out, &skitem, indent + 2,
|
||||
ASN1_ITEM_ptr(tt->item), NULL, NULL, 1,
|
||||
pctx))
|
||||
@@ -430,7 +430,7 @@ static int asn1_print_obstring(BIO *out, const ASN1_STRING *str, int indent)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
static int asn1_primitive_print(BIO *out, const ASN1_VALUE **fld,
|
||||
const ASN1_ITEM *it, int indent,
|
||||
const char *fname, const char *sname,
|
||||
const ASN1_PCTX *pctx)
|
||||
@@ -456,9 +456,9 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
str = (ASN1_STRING *)*fld;
|
||||
}
|
||||
if (utype == V_ASN1_ANY) {
|
||||
ASN1_TYPE *atype = (ASN1_TYPE *)*fld;
|
||||
const ASN1_TYPE *atype = (const ASN1_TYPE *)*fld;
|
||||
utype = atype->type;
|
||||
fld = &atype->value.asn1_value;
|
||||
fld = (const ASN1_VALUE **)&atype->value.asn1_value; /* actually is const */
|
||||
str = (ASN1_STRING *)*fld;
|
||||
if (pctx->flags & ASN1_PCTX_FLAGS_NO_ANY_TYPE)
|
||||
pname = NULL;
|
||||
|
||||
@@ -80,5 +80,5 @@ ASN1_ITEM_TEMPLATE(ASN1_SET_ANY) =
|
||||
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SET_OF, 0, ASN1_SET_ANY, ASN1_ANY)
|
||||
ASN1_ITEM_TEMPLATE_END(ASN1_SET_ANY)
|
||||
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ASN1_SEQUENCE_ANY, ASN1_SET_ANY, ASN1_SET_ANY)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(ASN1_SEQUENCE_ANY, ASN1_SET_ANY, ASN1_SET_ANY)
|
||||
+57
-25
@@ -29,6 +29,14 @@
|
||||
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
int *sel = offset2ptr(*pval, it->utype);
|
||||
|
||||
return *sel;
|
||||
}
|
||||
|
||||
int asn1_get_choice_selector_const(const ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
int *sel = offset2ptr(*pval, it->utype);
|
||||
|
||||
return *sel;
|
||||
}
|
||||
|
||||
@@ -40,6 +48,7 @@ int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
int *sel, ret;
|
||||
|
||||
sel = offset2ptr(*pval, it->utype);
|
||||
ret = *sel;
|
||||
*sel = value;
|
||||
@@ -66,7 +75,7 @@ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)
|
||||
&& (it->itype != ASN1_ITYPE_NDEF_SEQUENCE))
|
||||
return 0;
|
||||
aux = it->funcs;
|
||||
if (!aux || !(aux->flags & ASN1_AFLG_REFCOUNT))
|
||||
if (aux == NULL || (aux->flags & ASN1_AFLG_REFCOUNT) == 0)
|
||||
return 0;
|
||||
lck = offset2ptr(*pval, aux->ref_offset);
|
||||
lock = offset2ptr(*pval, aux->ref_lock);
|
||||
@@ -104,19 +113,33 @@ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)
|
||||
static ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
const ASN1_AUX *aux;
|
||||
if (!pval || !*pval)
|
||||
|
||||
if (pval == NULL || *pval == NULL)
|
||||
return NULL;
|
||||
aux = it->funcs;
|
||||
if (!aux || !(aux->flags & ASN1_AFLG_ENCODING))
|
||||
if (aux == NULL || (aux->flags & ASN1_AFLG_ENCODING) == 0)
|
||||
return NULL;
|
||||
return offset2ptr(*pval, aux->enc_offset);
|
||||
}
|
||||
|
||||
static const ASN1_ENCODING *asn1_get_const_enc_ptr(const ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
const ASN1_AUX *aux;
|
||||
|
||||
if (pval == NULL || *pval == NULL)
|
||||
return NULL;
|
||||
aux = it->funcs;
|
||||
if (aux == NULL || (aux->flags & ASN1_AFLG_ENCODING) == 0)
|
||||
return NULL;
|
||||
return offset2ptr(*pval, aux->enc_offset);
|
||||
}
|
||||
|
||||
void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
ASN1_ENCODING *enc;
|
||||
enc = asn1_get_enc_ptr(pval, it);
|
||||
if (enc) {
|
||||
ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it);
|
||||
|
||||
if (enc != NULL) {
|
||||
enc->enc = NULL;
|
||||
enc->len = 0;
|
||||
enc->modified = 1;
|
||||
@@ -125,9 +148,9 @@ void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
|
||||
void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
{
|
||||
ASN1_ENCODING *enc;
|
||||
enc = asn1_get_enc_ptr(pval, it);
|
||||
if (enc) {
|
||||
ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it);
|
||||
|
||||
if (enc != NULL) {
|
||||
OPENSSL_free(enc->enc);
|
||||
enc->enc = NULL;
|
||||
enc->len = 0;
|
||||
@@ -138,9 +161,9 @@ void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
ASN1_ENCODING *enc;
|
||||
enc = asn1_get_enc_ptr(pval, it);
|
||||
if (!enc)
|
||||
ASN1_ENCODING *enc = asn1_get_enc_ptr(pval, it);
|
||||
|
||||
if (enc == NULL)
|
||||
return 1;
|
||||
|
||||
OPENSSL_free(enc->enc);
|
||||
@@ -155,18 +178,18 @@ int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
|
||||
int asn1_enc_restore(int *len, unsigned char **out, const ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
ASN1_ENCODING *enc;
|
||||
enc = asn1_get_enc_ptr(pval, it);
|
||||
if (!enc || enc->modified)
|
||||
const ASN1_ENCODING *enc = asn1_get_const_enc_ptr(pval, it);
|
||||
|
||||
if (enc == NULL || enc->modified)
|
||||
return 0;
|
||||
if (out) {
|
||||
memcpy(*out, enc->enc, enc->len);
|
||||
*out += enc->len;
|
||||
}
|
||||
if (len)
|
||||
if (len != NULL)
|
||||
*len = enc->len;
|
||||
return 1;
|
||||
}
|
||||
@@ -174,8 +197,8 @@ int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
|
||||
/* Given an ASN1_TEMPLATE get a pointer to a field */
|
||||
ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
|
||||
{
|
||||
ASN1_VALUE **pvaltmp;
|
||||
pvaltmp = offset2ptr(*pval, tt->offset);
|
||||
ASN1_VALUE **pvaltmp = offset2ptr(*pval, tt->offset);
|
||||
|
||||
/*
|
||||
* NOTE for BOOLEAN types the field is just a plain int so we can't
|
||||
* return int **, so settle for (int *).
|
||||
@@ -183,31 +206,40 @@ ASN1_VALUE **asn1_get_field_ptr(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
|
||||
return pvaltmp;
|
||||
}
|
||||
|
||||
/* Given an ASN1_TEMPLATE get a const pointer to a field */
|
||||
const ASN1_VALUE **asn1_get_const_field_ptr(const ASN1_VALUE **pval,
|
||||
const ASN1_TEMPLATE *tt)
|
||||
{
|
||||
return offset2ptr(*pval, tt->offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle ANY DEFINED BY template, find the selector, look up the relevant
|
||||
* ASN1_TEMPLATE in the table and return it.
|
||||
*/
|
||||
|
||||
const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
|
||||
const ASN1_TEMPLATE *asn1_do_adb(const ASN1_VALUE *val,
|
||||
const ASN1_TEMPLATE *tt,
|
||||
int nullerr)
|
||||
{
|
||||
const ASN1_ADB *adb;
|
||||
const ASN1_ADB_TABLE *atbl;
|
||||
long selector;
|
||||
ASN1_VALUE **sfld;
|
||||
const ASN1_VALUE **sfld;
|
||||
int i;
|
||||
if (!(tt->flags & ASN1_TFLG_ADB_MASK))
|
||||
|
||||
if ((tt->flags & ASN1_TFLG_ADB_MASK) == 0)
|
||||
return tt;
|
||||
|
||||
/* Else ANY DEFINED BY ... get the table */
|
||||
adb = ASN1_ADB_ptr(tt->item);
|
||||
|
||||
/* Get the selector field */
|
||||
sfld = offset2ptr(*pval, adb->offset);
|
||||
sfld = offset2ptr(val, adb->offset);
|
||||
|
||||
/* Check if NULL */
|
||||
if (*sfld == NULL) {
|
||||
if (!adb->null_tt)
|
||||
if (adb->null_tt == NULL)
|
||||
goto err;
|
||||
return adb->null_tt;
|
||||
}
|
||||
@@ -216,7 +248,7 @@ const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
|
||||
* Convert type to a long: NB: don't check for NID_undef here because it
|
||||
* might be a legitimate value in the table
|
||||
*/
|
||||
if (tt->flags & ASN1_TFLG_ADB_OID)
|
||||
if ((tt->flags & ASN1_TFLG_ADB_OID) != 0)
|
||||
selector = OBJ_obj2nid((ASN1_OBJECT *)*sfld);
|
||||
else
|
||||
selector = ASN1_INTEGER_get((ASN1_INTEGER *)*sfld);
|
||||
|
||||
@@ -25,13 +25,13 @@ static int bn_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
static int bn_secure_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
|
||||
static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
static int bn_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it);
|
||||
static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it);
|
||||
static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it);
|
||||
static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int bn_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx);
|
||||
|
||||
static ASN1_PRIMITIVE_FUNCS bignum_pf = {
|
||||
@@ -91,7 +91,7 @@ static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
*pval = NULL;
|
||||
}
|
||||
|
||||
static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
static int bn_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
BIGNUM *bn;
|
||||
@@ -135,7 +135,7 @@ static int bn_secure_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
return bn_c2i(pval, cont, len, utype, free_cont, it);
|
||||
}
|
||||
|
||||
static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int bn_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
if (!BN_print(out, *(BIGNUM **)pval))
|
||||
|
||||
@@ -46,8 +46,8 @@ static void uint64_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
**(uint64_t **)pval = 0;
|
||||
}
|
||||
|
||||
static int uint64_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
static int uint64_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
uint64_t utmp;
|
||||
int neg = 0;
|
||||
@@ -71,7 +71,7 @@ static int uint64_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
}
|
||||
|
||||
static int uint64_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it)
|
||||
int utype, char *free_cont, const ASN1_ITEM *it)
|
||||
{
|
||||
uint64_t utmp = 0;
|
||||
char *cp;
|
||||
@@ -111,7 +111,7 @@ static int uint64_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int uint64_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int uint64_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED)
|
||||
@@ -141,8 +141,8 @@ static void uint32_clear(ASN1_VALUE **pval, const ASN1_ITEM *it)
|
||||
**(uint32_t **)pval = 0;
|
||||
}
|
||||
|
||||
static int uint32_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
static int uint32_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
uint32_t utmp;
|
||||
int neg = 0;
|
||||
@@ -173,7 +173,7 @@ static int uint32_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
#define ABS_INT32_MIN ((uint32_t)INT32_MAX + 1)
|
||||
|
||||
static int uint32_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it)
|
||||
int utype, char *free_cont, const ASN1_ITEM *it)
|
||||
{
|
||||
uint64_t utmp = 0;
|
||||
uint32_t utmp2 = 0;
|
||||
@@ -220,7 +220,7 @@ static int uint32_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int uint32_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int uint32_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
if ((it->size & INTxx_FLAG_SIGNED) == INTxx_FLAG_SIGNED)
|
||||
|
||||
@@ -25,11 +25,11 @@ NON_EMPTY_TRANSLATION_UNIT
|
||||
static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
||||
|
||||
static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
static int long_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it);
|
||||
static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it);
|
||||
static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int long_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx);
|
||||
|
||||
static ASN1_PRIMITIVE_FUNCS long_pf = {
|
||||
@@ -86,7 +86,7 @@ static int num_bits_ulong(unsigned long value)
|
||||
return (int)ret;
|
||||
}
|
||||
|
||||
static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
static int long_i2c(const ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it)
|
||||
{
|
||||
long ltmp;
|
||||
@@ -190,7 +190,7 @@ static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
static int long_print(BIO *out, const ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
long l;
|
||||
|
||||
+31
-41
@@ -7,6 +7,7 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/trace.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
@@ -87,48 +88,38 @@ struct bignum_ctx {
|
||||
int flags;
|
||||
};
|
||||
|
||||
/* Enable this to find BN_CTX bugs */
|
||||
#ifdef BN_CTX_DEBUG
|
||||
static const char *ctxdbg_cur = NULL;
|
||||
static void ctxdbg(BN_CTX *ctx)
|
||||
/* Debugging functionality */
|
||||
static void ctxdbg(BIO *channel, const char *text, BN_CTX *ctx)
|
||||
{
|
||||
unsigned int bnidx = 0, fpidx = 0;
|
||||
BN_POOL_ITEM *item = ctx->pool.head;
|
||||
BN_STACK *stack = &ctx->stack;
|
||||
fprintf(stderr, "(%16p): ", ctx);
|
||||
|
||||
BIO_printf(channel, "%s\n", text);
|
||||
BIO_printf(channel, " (%16p): ", (void*)ctx);
|
||||
while (bnidx < ctx->used) {
|
||||
fprintf(stderr, "%03x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);
|
||||
BIO_printf(channel, "%03x ",
|
||||
item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);
|
||||
if (!(bnidx % BN_CTX_POOL_SIZE))
|
||||
item = item->next;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
BIO_printf(channel, "\n");
|
||||
bnidx = 0;
|
||||
fprintf(stderr, " : ");
|
||||
BIO_printf(channel, " %16s : ", "");
|
||||
while (fpidx < stack->depth) {
|
||||
while (bnidx++ < stack->indexes[fpidx])
|
||||
fprintf(stderr, " ");
|
||||
fprintf(stderr, "^^^ ");
|
||||
BIO_printf(channel, " ");
|
||||
BIO_printf(channel, "^^^ ");
|
||||
bnidx++;
|
||||
fpidx++;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
BIO_printf(channel, "\n");
|
||||
}
|
||||
|
||||
# define CTXDBG_ENTRY(str, ctx) do { \
|
||||
ctxdbg_cur = (str); \
|
||||
fprintf(stderr,"Starting %s\n", ctxdbg_cur); \
|
||||
ctxdbg(ctx); \
|
||||
} while(0)
|
||||
# define CTXDBG_EXIT(ctx) do { \
|
||||
fprintf(stderr,"Ending %s\n", ctxdbg_cur); \
|
||||
ctxdbg(ctx); \
|
||||
} while(0)
|
||||
# define CTXDBG_RET(ctx,ret)
|
||||
#else
|
||||
# define CTXDBG_ENTRY(str, ctx)
|
||||
# define CTXDBG_EXIT(ctx)
|
||||
# define CTXDBG_RET(ctx,ret)
|
||||
#endif
|
||||
#define CTXDBG(str, ctx) \
|
||||
OSSL_TRACE_BEGIN(BN_CTX) { \
|
||||
ctxdbg(trc_out, str, ctx); \
|
||||
} OSSL_TRACE_END(BN_CTX)
|
||||
|
||||
|
||||
BN_CTX *BN_CTX_new(void)
|
||||
@@ -158,21 +149,20 @@ void BN_CTX_free(BN_CTX *ctx)
|
||||
{
|
||||
if (ctx == NULL)
|
||||
return;
|
||||
#ifdef BN_CTX_DEBUG
|
||||
{
|
||||
OSSL_TRACE_BEGIN(BN_CTX) {
|
||||
BN_POOL_ITEM *pool = ctx->pool.head;
|
||||
fprintf(stderr, "BN_CTX_free, stack-size=%d, pool-bignums=%d\n",
|
||||
ctx->stack.size, ctx->pool.size);
|
||||
fprintf(stderr, "dmaxs: ");
|
||||
BIO_printf(trc_out,
|
||||
"BN_CTX_free(): stack-size=%d, pool-bignums=%d\n",
|
||||
ctx->stack.size, ctx->pool.size);
|
||||
BIO_printf(trc_out, " dmaxs: ");
|
||||
while (pool) {
|
||||
unsigned loop = 0;
|
||||
while (loop < BN_CTX_POOL_SIZE)
|
||||
fprintf(stderr, "%02x ", pool->vals[loop++].dmax);
|
||||
BIO_printf(trc_out, "%02x ", pool->vals[loop++].dmax);
|
||||
pool = pool->next;
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
BIO_printf(trc_out, "\n");
|
||||
} OSSL_TRACE_END(BN_CTX);
|
||||
BN_STACK_finish(&ctx->stack);
|
||||
BN_POOL_finish(&ctx->pool);
|
||||
OPENSSL_free(ctx);
|
||||
@@ -180,7 +170,7 @@ void BN_CTX_free(BN_CTX *ctx)
|
||||
|
||||
void BN_CTX_start(BN_CTX *ctx)
|
||||
{
|
||||
CTXDBG_ENTRY("BN_CTX_start", ctx);
|
||||
CTXDBG("ENTER BN_CTX_start()", ctx);
|
||||
/* If we're already overflowing ... */
|
||||
if (ctx->err_stack || ctx->too_many)
|
||||
ctx->err_stack++;
|
||||
@@ -189,12 +179,12 @@ void BN_CTX_start(BN_CTX *ctx)
|
||||
BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);
|
||||
ctx->err_stack++;
|
||||
}
|
||||
CTXDBG_EXIT(ctx);
|
||||
CTXDBG("LEAVE BN_CTX_start()", ctx);
|
||||
}
|
||||
|
||||
void BN_CTX_end(BN_CTX *ctx)
|
||||
{
|
||||
CTXDBG_ENTRY("BN_CTX_end", ctx);
|
||||
CTXDBG("ENTER BN_CTX_end()", ctx);
|
||||
if (ctx->err_stack)
|
||||
ctx->err_stack--;
|
||||
else {
|
||||
@@ -206,14 +196,14 @@ void BN_CTX_end(BN_CTX *ctx)
|
||||
/* Unjam "too_many" in case "get" had failed */
|
||||
ctx->too_many = 0;
|
||||
}
|
||||
CTXDBG_EXIT(ctx);
|
||||
CTXDBG("LEAVE BN_CTX_end()", ctx);
|
||||
}
|
||||
|
||||
BIGNUM *BN_CTX_get(BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *ret;
|
||||
|
||||
CTXDBG_ENTRY("BN_CTX_get", ctx);
|
||||
CTXDBG("ENTER BN_CTX_get()", ctx);
|
||||
if (ctx->err_stack || ctx->too_many)
|
||||
return NULL;
|
||||
if ((ret = BN_POOL_get(&ctx->pool, ctx->flags)) == NULL) {
|
||||
@@ -230,7 +220,7 @@ BIGNUM *BN_CTX_get(BN_CTX *ctx)
|
||||
/* clear BN_FLG_CONSTTIME if leaked from previous frames */
|
||||
ret->flags &= (~BN_FLG_CONSTTIME);
|
||||
ctx->used++;
|
||||
CTXDBG_RET(ctx, ret);
|
||||
CTXDBG("LEAVE BN_CTX_get()", ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -536,6 +536,24 @@ int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen)
|
||||
return tolen;
|
||||
}
|
||||
|
||||
BIGNUM *BN_native2bn(const unsigned char *s, int len, BIGNUM *ret)
|
||||
{
|
||||
#ifdef B_ENDIAN
|
||||
return BN_bin2bn(s, len, ret);
|
||||
#else
|
||||
return BN_lebin2bn(s, len, ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
int BN_bn2nativepad(const BIGNUM *a, unsigned char *to, int tolen)
|
||||
{
|
||||
#ifdef B_ENDIAN
|
||||
return BN_bn2binpad(a, to, tolen);
|
||||
#else
|
||||
return BN_bn2lebinpad(a, to, tolen);
|
||||
#endif
|
||||
}
|
||||
|
||||
int BN_ucmp(const BIGNUM *a, const BIGNUM *b)
|
||||
{
|
||||
int i;
|
||||
@@ -695,6 +713,9 @@ int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
int i;
|
||||
BN_ULONG aa, bb;
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
|
||||
aa = a[n - 1];
|
||||
bb = b[n - 1];
|
||||
if (aa != bb)
|
||||
|
||||
@@ -13,6 +13,7 @@ SOURCE[../libcrypto]=\
|
||||
ebcdic.c uid.c o_time.c o_str.c o_dir.c o_fopen.c ctype.c \
|
||||
threads_pthread.c threads_win.c threads_none.c getenv.c \
|
||||
o_init.c o_fips.c mem_sec.c init.c context.c sparse_array.c \
|
||||
trace.c \
|
||||
{- $target{cpuid_asm_src} -} {- $target{uplink_aux_src} -}
|
||||
|
||||
DEPEND[cversion.o]=buildinf.h
|
||||
|
||||
+2
-2
@@ -45,14 +45,14 @@ CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BIO *cms_DigestedData_init_bio(CMS_ContentInfo *cms)
|
||||
BIO *cms_DigestedData_init_bio(const CMS_ContentInfo *cms)
|
||||
{
|
||||
CMS_DigestedData *dd;
|
||||
dd = cms->d.digestedData;
|
||||
return cms_DigestAlgorithm_init_bio(dd->digestAlgorithm);
|
||||
}
|
||||
|
||||
int cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify)
|
||||
int cms_DigestedData_do_final(const CMS_ContentInfo *cms, BIO *chain, int verify)
|
||||
{
|
||||
EVP_MD_CTX *mctx = EVP_MD_CTX_new();
|
||||
unsigned char md[EVP_MAX_MD_SIZE];
|
||||
|
||||
@@ -204,7 +204,7 @@ int CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,
|
||||
return cms_EncryptedContent_init(ec, ciph, key, keylen);
|
||||
}
|
||||
|
||||
BIO *cms_EncryptedData_init_bio(CMS_ContentInfo *cms)
|
||||
BIO *cms_EncryptedData_init_bio(const CMS_ContentInfo *cms)
|
||||
{
|
||||
CMS_EncryptedData *enc = cms->d.encryptedData;
|
||||
if (enc->encryptedContentInfo->cipher && enc->unprotectedAttrs)
|
||||
|
||||
@@ -289,7 +289,7 @@ int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey)
|
||||
|
||||
/* Encrypt content key in key transport recipient info */
|
||||
|
||||
static int cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms,
|
||||
static int cms_RecipientInfo_ktri_encrypt(const CMS_ContentInfo *cms,
|
||||
CMS_RecipientInfo *ri)
|
||||
{
|
||||
CMS_KeyTransRecipientInfo *ktri;
|
||||
@@ -610,7 +610,7 @@ int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,
|
||||
|
||||
/* Encrypt content key in KEK recipient info */
|
||||
|
||||
static int cms_RecipientInfo_kekri_encrypt(CMS_ContentInfo *cms,
|
||||
static int cms_RecipientInfo_kekri_encrypt(const CMS_ContentInfo *cms,
|
||||
CMS_RecipientInfo *ri)
|
||||
{
|
||||
CMS_EncryptedContentInfo *ec;
|
||||
@@ -755,7 +755,7 @@ int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri)
|
||||
}
|
||||
}
|
||||
|
||||
int CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri)
|
||||
int CMS_RecipientInfo_encrypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri)
|
||||
{
|
||||
switch (ri->type) {
|
||||
case CMS_RECIPINFO_TRANS:
|
||||
@@ -840,7 +840,7 @@ static void cms_env_set_version(CMS_EnvelopedData *env)
|
||||
env->version = 0;
|
||||
}
|
||||
|
||||
BIO *cms_EnvelopedData_init_bio(CMS_ContentInfo *cms)
|
||||
BIO *cms_EnvelopedData_init_bio(const CMS_ContentInfo *cms)
|
||||
{
|
||||
CMS_EncryptedContentInfo *ec;
|
||||
STACK_OF(CMS_RecipientInfo) *rinfos;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <openssl/cms.h>
|
||||
#include "cms_lcl.h"
|
||||
|
||||
/* unfortunately cannot constify BIO_new_NDEF() due to this and PKCS7_stream() */
|
||||
int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms)
|
||||
{
|
||||
ASN1_OCTET_STRING **pos;
|
||||
|
||||
@@ -363,7 +363,7 @@ static int cms_wrap_init(CMS_KeyAgreeRecipientInfo *kari,
|
||||
|
||||
/* Encrypt content key in key agreement recipient info */
|
||||
|
||||
int cms_RecipientInfo_kari_encrypt(CMS_ContentInfo *cms,
|
||||
int cms_RecipientInfo_kari_encrypt(const CMS_ContentInfo *cms,
|
||||
CMS_RecipientInfo *ri)
|
||||
{
|
||||
CMS_KeyAgreeRecipientInfo *kari;
|
||||
|
||||
@@ -368,8 +368,8 @@ BIO *cms_content_bio(CMS_ContentInfo *cms);
|
||||
CMS_ContentInfo *cms_Data_create(void);
|
||||
|
||||
CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md);
|
||||
BIO *cms_DigestedData_init_bio(CMS_ContentInfo *cms);
|
||||
int cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify);
|
||||
BIO *cms_DigestedData_init_bio(const CMS_ContentInfo *cms);
|
||||
int cms_DigestedData_do_final(const CMS_ContentInfo *cms, BIO *chain, int verify);
|
||||
|
||||
BIO *cms_SignedData_init_bio(CMS_ContentInfo *cms);
|
||||
int cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain);
|
||||
@@ -382,7 +382,7 @@ int cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid,
|
||||
int cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert);
|
||||
|
||||
CMS_ContentInfo *cms_CompressedData_create(int comp_nid);
|
||||
BIO *cms_CompressedData_init_bio(CMS_ContentInfo *cms);
|
||||
BIO *cms_CompressedData_init_bio(const CMS_ContentInfo *cms);
|
||||
|
||||
BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm);
|
||||
int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
|
||||
@@ -394,7 +394,7 @@ int cms_set1_ias(CMS_IssuerAndSerialNumber **pias, X509 *cert);
|
||||
int cms_set1_keyid(ASN1_OCTET_STRING **pkeyid, X509 *cert);
|
||||
|
||||
BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec);
|
||||
BIO *cms_EncryptedData_init_bio(CMS_ContentInfo *cms);
|
||||
BIO *cms_EncryptedData_init_bio(const CMS_ContentInfo *cms);
|
||||
int cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec,
|
||||
const EVP_CIPHER *cipher,
|
||||
const unsigned char *key, size_t keylen);
|
||||
@@ -403,18 +403,18 @@ int cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms);
|
||||
int cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src);
|
||||
ASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si);
|
||||
|
||||
BIO *cms_EnvelopedData_init_bio(CMS_ContentInfo *cms);
|
||||
BIO *cms_EnvelopedData_init_bio(const CMS_ContentInfo *cms);
|
||||
CMS_EnvelopedData *cms_get0_enveloped(CMS_ContentInfo *cms);
|
||||
int cms_env_asn1_ctrl(CMS_RecipientInfo *ri, int cmd);
|
||||
int cms_pkey_get_ri_type(EVP_PKEY *pk);
|
||||
/* KARI routines */
|
||||
int cms_RecipientInfo_kari_init(CMS_RecipientInfo *ri, X509 *recip,
|
||||
EVP_PKEY *pk, unsigned int flags);
|
||||
int cms_RecipientInfo_kari_encrypt(CMS_ContentInfo *cms,
|
||||
int cms_RecipientInfo_kari_encrypt(const CMS_ContentInfo *cms,
|
||||
CMS_RecipientInfo *ri);
|
||||
|
||||
/* PWRI routines */
|
||||
int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
|
||||
int cms_RecipientInfo_pwri_crypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
|
||||
int en_de);
|
||||
|
||||
DECLARE_ASN1_ITEM(CMS_CertificateChoices)
|
||||
|
||||
@@ -104,6 +104,7 @@ BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont)
|
||||
|
||||
}
|
||||
|
||||
/* unfortunately cannot constify SMIME_write_ASN1() due to this function */
|
||||
int CMS_dataFinal(CMS_ContentInfo *cms, BIO *cmsbio)
|
||||
{
|
||||
ASN1_OCTET_STRING **pos = CMS_get0_content(cms);
|
||||
|
||||
@@ -273,7 +273,7 @@ static int kek_wrap_key(unsigned char *out, size_t *outlen,
|
||||
|
||||
/* Encrypt/Decrypt content key in PWRI recipient info */
|
||||
|
||||
int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
|
||||
int cms_RecipientInfo_pwri_crypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
|
||||
int en_de)
|
||||
{
|
||||
CMS_EncryptedContentInfo *ec;
|
||||
|
||||
@@ -418,7 +418,7 @@ static int int_dh_param_copy(DH *to, const DH *from, int is_x942)
|
||||
return 1;
|
||||
}
|
||||
|
||||
DH *DHparams_dup(DH *dh)
|
||||
DH *DHparams_dup(const DH *dh)
|
||||
{
|
||||
DH *ret;
|
||||
ret = DH_new();
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ ASN1_SEQUENCE_cb(DHparams, dh_cb) = {
|
||||
ASN1_OPT_EMBED(DH, length, ZINT32),
|
||||
} ASN1_SEQUENCE_END_cb(DH, DHparams)
|
||||
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DH, DHparams, DHparams)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(DH, DHparams, DHparams)
|
||||
|
||||
/*
|
||||
* Internal only structures for handling X9.42 DH: this gets translated to or
|
||||
@@ -74,7 +74,7 @@ int_dhx942_dh *d2i_int_dhx(int_dhx942_dh **a,
|
||||
const unsigned char **pp, long length);
|
||||
int i2d_int_dhx(const int_dhx942_dh *a, unsigned char **pp);
|
||||
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(int_dhx942_dh, DHxparams, int_dhx)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(int_dhx942_dh, DHxparams, int_dhx)
|
||||
|
||||
/* Application public function: read in X9.42 DH parameters into DH structure */
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ static void pkey_dh_cleanup(EVP_PKEY_CTX *ctx)
|
||||
}
|
||||
|
||||
|
||||
static int pkey_dh_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
|
||||
static int pkey_dh_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src)
|
||||
{
|
||||
DH_PKEY_CTX *dctx, *sctx;
|
||||
if (!pkey_dh_init(dst))
|
||||
|
||||
@@ -19,7 +19,7 @@ ASN1_SEQUENCE(DSA_SIG) = {
|
||||
ASN1_SIMPLE(DSA_SIG, s, CBIGNUM)
|
||||
} static_ASN1_SEQUENCE_END(DSA_SIG)
|
||||
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA_SIG, DSA_SIG, DSA_SIG)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(DSA_SIG, DSA_SIG, DSA_SIG)
|
||||
|
||||
DSA_SIG *DSA_SIG_new(void)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ ASN1_SEQUENCE_cb(DSAPrivateKey, dsa_cb) = {
|
||||
ASN1_SIMPLE(DSA, priv_key, CBIGNUM)
|
||||
} static_ASN1_SEQUENCE_END_cb(DSA, DSAPrivateKey)
|
||||
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPrivateKey, DSAPrivateKey)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(DSA, DSAPrivateKey, DSAPrivateKey)
|
||||
|
||||
ASN1_SEQUENCE_cb(DSAparams, dsa_cb) = {
|
||||
ASN1_SIMPLE(DSA, p, BIGNUM),
|
||||
@@ -91,7 +91,7 @@ ASN1_SEQUENCE_cb(DSAparams, dsa_cb) = {
|
||||
ASN1_SIMPLE(DSA, g, BIGNUM),
|
||||
} static_ASN1_SEQUENCE_END_cb(DSA, DSAparams)
|
||||
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAparams, DSAparams)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(DSA, DSAparams, DSAparams)
|
||||
|
||||
ASN1_SEQUENCE_cb(DSAPublicKey, dsa_cb) = {
|
||||
ASN1_SIMPLE(DSA, pub_key, BIGNUM),
|
||||
@@ -100,9 +100,9 @@ ASN1_SEQUENCE_cb(DSAPublicKey, dsa_cb) = {
|
||||
ASN1_SIMPLE(DSA, g, BIGNUM)
|
||||
} static_ASN1_SEQUENCE_END_cb(DSA, DSAPublicKey)
|
||||
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAPublicKey, DSAPublicKey)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(DSA, DSAPublicKey, DSAPublicKey)
|
||||
|
||||
DSA *DSAparams_dup(DSA *dsa)
|
||||
DSA *DSAparams_dup(const DSA *dsa)
|
||||
{
|
||||
return ASN1_item_dup(ASN1_ITEM_rptr(DSAparams), dsa);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ static int pkey_dsa_init(EVP_PKEY_CTX *ctx)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pkey_dsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
|
||||
static int pkey_dsa_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src)
|
||||
{
|
||||
DSA_PKEY_CTX *dctx, *sctx;
|
||||
|
||||
|
||||
@@ -504,7 +504,12 @@ static int ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
|
||||
#endif
|
||||
|
||||
case ASN1_PKEY_CTRL_DEFAULT_MD_NID:
|
||||
*(int *)arg2 = NID_sha256;
|
||||
if (EVP_PKEY_id(pkey) == EVP_PKEY_SM2) {
|
||||
/* For SM2, the only valid digest-alg is SM3 */
|
||||
*(int *)arg2 = NID_sm3;
|
||||
} else {
|
||||
*(int *)arg2 = NID_sha256;
|
||||
}
|
||||
return 1;
|
||||
|
||||
case ASN1_PKEY_CTRL_SET1_TLS_ENCPT:
|
||||
|
||||
+11
-11
@@ -217,9 +217,9 @@ ASN1_CHOICE(ECPKPARAMETERS) = {
|
||||
ASN1_SIMPLE(ECPKPARAMETERS, value.implicitlyCA, ASN1_NULL)
|
||||
} ASN1_CHOICE_END(ECPKPARAMETERS)
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS_const(ECPKPARAMETERS)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_const(ECPKPARAMETERS, ECPKPARAMETERS)
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(ECPKPARAMETERS)
|
||||
DECLARE_ASN1_FUNCTIONS(ECPKPARAMETERS)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_name(ECPKPARAMETERS, ECPKPARAMETERS)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ECPKPARAMETERS)
|
||||
|
||||
ASN1_SEQUENCE(EC_PRIVATEKEY) = {
|
||||
ASN1_EMBED(EC_PRIVATEKEY, version, INT32),
|
||||
@@ -228,9 +228,9 @@ ASN1_SEQUENCE(EC_PRIVATEKEY) = {
|
||||
ASN1_EXP_OPT(EC_PRIVATEKEY, publicKey, ASN1_BIT_STRING, 1)
|
||||
} static_ASN1_SEQUENCE_END(EC_PRIVATEKEY)
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS_const(EC_PRIVATEKEY)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_const(EC_PRIVATEKEY, EC_PRIVATEKEY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(EC_PRIVATEKEY)
|
||||
DECLARE_ASN1_FUNCTIONS(EC_PRIVATEKEY)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_name(EC_PRIVATEKEY, EC_PRIVATEKEY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(EC_PRIVATEKEY)
|
||||
|
||||
/* some declarations of internal function */
|
||||
|
||||
@@ -968,7 +968,7 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out)
|
||||
int i2d_ECPrivateKey(const EC_KEY *a, unsigned char **out)
|
||||
{
|
||||
int ret = 0, ok = 0;
|
||||
unsigned char *priv= NULL, *pub= NULL;
|
||||
@@ -1040,7 +1040,7 @@ int i2d_ECPrivateKey(EC_KEY *a, unsigned char **out)
|
||||
return (ok ? ret : 0);
|
||||
}
|
||||
|
||||
int i2d_ECParameters(EC_KEY *a, unsigned char **out)
|
||||
int i2d_ECParameters(const EC_KEY *a, unsigned char **out)
|
||||
{
|
||||
if (a == NULL) {
|
||||
ECerr(EC_F_I2D_ECPARAMETERS, ERR_R_PASSED_NULL_PARAMETER);
|
||||
@@ -1142,9 +1142,9 @@ ASN1_SEQUENCE(ECDSA_SIG) = {
|
||||
ASN1_SIMPLE(ECDSA_SIG, s, CBIGNUM)
|
||||
} static_ASN1_SEQUENCE_END(ECDSA_SIG)
|
||||
|
||||
DECLARE_ASN1_FUNCTIONS_const(ECDSA_SIG)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_const(ECDSA_SIG, ECDSA_SIG)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(ECDSA_SIG, ECDSA_SIG, ECDSA_SIG)
|
||||
DECLARE_ASN1_FUNCTIONS(ECDSA_SIG)
|
||||
DECLARE_ASN1_ENCODE_FUNCTIONS_name(ECDSA_SIG, ECDSA_SIG)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(ECDSA_SIG, ECDSA_SIG, ECDSA_SIG)
|
||||
|
||||
ECDSA_SIG *ECDSA_SIG_new(void)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <openssl/bn.h>
|
||||
#include "internal/refcount.h"
|
||||
#include "internal/ec_int.h"
|
||||
#include "curve448/curve448_lcl.h"
|
||||
|
||||
#if defined(__SUNPRO_C)
|
||||
# if __SUNPRO_C >= 0x520
|
||||
|
||||
@@ -53,7 +53,7 @@ static int pkey_ec_init(EVP_PKEY_CTX *ctx)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pkey_ec_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
|
||||
static int pkey_ec_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src)
|
||||
{
|
||||
EC_PKEY_CTX *dctx, *sctx;
|
||||
if (!pkey_ec_init(dst))
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "internal/asn1_int.h"
|
||||
#include "internal/evp_int.h"
|
||||
#include "ec_lcl.h"
|
||||
#include "curve448/curve448_lcl.h"
|
||||
|
||||
#define X25519_BITS 253
|
||||
#define X25519_SECURITY_BITS 128
|
||||
|
||||
+6
-13
@@ -9,8 +9,7 @@
|
||||
|
||||
#include "eng_int.h"
|
||||
#include <openssl/conf.h>
|
||||
|
||||
/* #define ENGINE_CONF_DEBUG */
|
||||
#include <openssl/trace.h>
|
||||
|
||||
/* ENGINE config module */
|
||||
|
||||
@@ -50,9 +49,7 @@ static int int_engine_configure(const char *name, const char *value, const CONF
|
||||
int soft = 0;
|
||||
|
||||
name = skip_dot(name);
|
||||
#ifdef ENGINE_CONF_DEBUG
|
||||
fprintf(stderr, "Configuring engine %s\n", name);
|
||||
#endif
|
||||
OSSL_TRACE1(ENGINE_CONF, "Configuring engine %s\n", name);
|
||||
/* Value is a section containing ENGINE commands */
|
||||
ecmds = NCONF_get_section(cnf, value);
|
||||
|
||||
@@ -66,10 +63,8 @@ static int int_engine_configure(const char *name, const char *value, const CONF
|
||||
ecmd = sk_CONF_VALUE_value(ecmds, i);
|
||||
ctrlname = skip_dot(ecmd->name);
|
||||
ctrlvalue = ecmd->value;
|
||||
#ifdef ENGINE_CONF_DEBUG
|
||||
fprintf(stderr, "ENGINE conf: doing ctrl(%s,%s)\n", ctrlname,
|
||||
ctrlvalue);
|
||||
#endif
|
||||
OSSL_TRACE2(ENGINE_CONF, "ENGINE conf: doing ctrl(%s,%s)\n",
|
||||
ctrlname, ctrlvalue);
|
||||
|
||||
/* First handle some special pseudo ctrls */
|
||||
|
||||
@@ -153,10 +148,8 @@ static int int_engine_module_init(CONF_IMODULE *md, const CONF *cnf)
|
||||
STACK_OF(CONF_VALUE) *elist;
|
||||
CONF_VALUE *cval;
|
||||
int i;
|
||||
#ifdef ENGINE_CONF_DEBUG
|
||||
fprintf(stderr, "Called engine module: name %s, value %s\n",
|
||||
CONF_imodule_get_name(md), CONF_imodule_get_value(md));
|
||||
#endif
|
||||
OSSL_TRACE2(ENGINE_CONF, "Called engine module: name %s, value %s\n",
|
||||
CONF_imodule_get_name(md), CONF_imodule_get_value(md));
|
||||
/* Value is a section containing ENGINEs to configure */
|
||||
elist = NCONF_get_section(cnf, CONF_imodule_get_value(md));
|
||||
|
||||
|
||||
+17
-34
@@ -11,6 +11,7 @@
|
||||
#ifndef HEADER_ENGINE_INT_H
|
||||
# define HEADER_ENGINE_INT_H
|
||||
|
||||
# include <openssl/trace.h>
|
||||
# include "internal/cryptlib.h"
|
||||
# include "internal/engine.h"
|
||||
# include "internal/thread_once.h"
|
||||
@@ -19,27 +20,20 @@
|
||||
extern CRYPTO_RWLOCK *global_engine_lock;
|
||||
|
||||
/*
|
||||
* If we compile with this symbol defined, then both reference counts in the
|
||||
* ENGINE structure will be monitored with a line of output on stderr for
|
||||
* each change. This prints the engine's pointer address (truncated to
|
||||
* unsigned int), "struct" or "funct" to indicate the reference type, the
|
||||
* before and after reference count, and the file:line-number pair. The
|
||||
* "engine_ref_debug" statements must come *after* the change.
|
||||
* This prints the engine's pointer address (truncated to unsigned int),
|
||||
* "struct" or "funct" to indicate the reference type, the before and after
|
||||
* reference count, and the file:line-number pair. The "engine_ref_debug"
|
||||
* statements must come *after* the change.
|
||||
*/
|
||||
# ifdef ENGINE_REF_COUNT_DEBUG
|
||||
|
||||
# define engine_ref_debug(e, isfunct, diff) \
|
||||
fprintf(stderr, "engine: %08x %s from %d to %d (%s:%d)\n", \
|
||||
(unsigned int)(e), (isfunct ? "funct" : "struct"), \
|
||||
((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \
|
||||
((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
|
||||
(OPENSSL_FILE), (OPENSSL_LINE))
|
||||
|
||||
# else
|
||||
|
||||
# define engine_ref_debug(e, isfunct, diff)
|
||||
|
||||
# endif
|
||||
# define engine_ref_debug(e, isfunct, diff) \
|
||||
OSSL_TRACE6(ENGINE_REF_COUNT, \
|
||||
"engine: %p %s from %d to %d (%s:%d)\n", \
|
||||
(void *)(e), (isfunct ? "funct" : "struct"), \
|
||||
((isfunct) \
|
||||
? ((e)->funct_ref - (diff)) \
|
||||
: ((e)->struct_ref - (diff))), \
|
||||
((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
|
||||
(OPENSSL_FILE), (OPENSSL_LINE))
|
||||
|
||||
/*
|
||||
* Any code that will need cleanup operations should use these functions to
|
||||
@@ -58,14 +52,6 @@ void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb);
|
||||
/* We need stacks of ENGINEs for use in eng_table.c */
|
||||
DEFINE_STACK_OF(ENGINE)
|
||||
|
||||
/*
|
||||
* If this symbol is defined then engine_table_select(), the function that is
|
||||
* used by RSA, DSA (etc) code to select registered ENGINEs, cache defaults
|
||||
* and functional references (etc), will display debugging summaries to
|
||||
* stderr.
|
||||
*/
|
||||
/* #define ENGINE_TABLE_DEBUG */
|
||||
|
||||
/*
|
||||
* This represents an implementation table. Dependent code should instantiate
|
||||
* it as a (ENGINE_TABLE *) pointer value set initially to NULL.
|
||||
@@ -76,13 +62,10 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
|
||||
int setdefault);
|
||||
void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e);
|
||||
void engine_table_cleanup(ENGINE_TABLE **table);
|
||||
# ifndef ENGINE_TABLE_DEBUG
|
||||
ENGINE *engine_table_select(ENGINE_TABLE **table, int nid);
|
||||
# else
|
||||
ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
|
||||
ENGINE *engine_table_select_int(ENGINE_TABLE **table, int nid, const char *f,
|
||||
int l);
|
||||
# define engine_table_select(t,n) engine_table_select_tmp(t,n,OPENSSL_FILE,OPENSSL_LINE)
|
||||
# endif
|
||||
# define engine_table_select(t,n) \
|
||||
engine_table_select_int(t,n,OPENSSL_FILE,OPENSSL_LINE)
|
||||
typedef void (engine_table_doall_cb) (int nid, STACK_OF(ENGINE) *sk,
|
||||
ENGINE *def, void *arg);
|
||||
void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
|
||||
|
||||
+25
-32
@@ -10,6 +10,7 @@
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/lhash.h>
|
||||
#include <openssl/trace.h>
|
||||
#include "eng_int.h"
|
||||
|
||||
/* The type of the items in the table */
|
||||
@@ -189,29 +190,24 @@ void engine_table_cleanup(ENGINE_TABLE **table)
|
||||
}
|
||||
|
||||
/* return a functional reference for a given 'nid' */
|
||||
#ifndef ENGINE_TABLE_DEBUG
|
||||
ENGINE *engine_table_select(ENGINE_TABLE **table, int nid)
|
||||
#else
|
||||
ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
|
||||
ENGINE *engine_table_select_int(ENGINE_TABLE **table, int nid, const char *f,
|
||||
int l)
|
||||
#endif
|
||||
{
|
||||
ENGINE *ret = NULL;
|
||||
ENGINE_PILE tmplate, *fnd = NULL;
|
||||
int initres, loop = 0;
|
||||
|
||||
if (!(*table)) {
|
||||
#ifdef ENGINE_TABLE_DEBUG
|
||||
fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, nothing "
|
||||
"registered!\n", f, l, nid);
|
||||
#endif
|
||||
OSSL_TRACE3(ENGINE_TABLE,
|
||||
"%s:%d, nid=%d, nothing registered!\n",
|
||||
f, l, nid);
|
||||
return NULL;
|
||||
}
|
||||
ERR_set_mark();
|
||||
CRYPTO_THREAD_write_lock(global_engine_lock);
|
||||
/*
|
||||
* Check again inside the lock otherwise we could race against cleanup
|
||||
* operations. But don't worry about a fprintf(stderr).
|
||||
* operations. But don't worry about a debug printout
|
||||
*/
|
||||
if (!int_table_check(table, 0))
|
||||
goto end;
|
||||
@@ -220,10 +216,9 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
|
||||
if (!fnd)
|
||||
goto end;
|
||||
if (fnd->funct && engine_unlocked_init(fnd->funct)) {
|
||||
#ifdef ENGINE_TABLE_DEBUG
|
||||
fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using "
|
||||
"ENGINE '%s' cached\n", f, l, nid, fnd->funct->id);
|
||||
#endif
|
||||
OSSL_TRACE4(ENGINE_TABLE,
|
||||
"%s:%d, nid=%d, using ENGINE '%s' cached\n",
|
||||
f, l, nid, fnd->funct->id);
|
||||
ret = fnd->funct;
|
||||
goto end;
|
||||
}
|
||||
@@ -234,10 +229,10 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
|
||||
trynext:
|
||||
ret = sk_ENGINE_value(fnd->sk, loop++);
|
||||
if (!ret) {
|
||||
#ifdef ENGINE_TABLE_DEBUG
|
||||
fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, no "
|
||||
"registered implementations would initialise\n", f, l, nid);
|
||||
#endif
|
||||
OSSL_TRACE3(ENGINE_TABLE,
|
||||
"%s:%d, nid=%d, "
|
||||
"no registered implementations would initialise\n",
|
||||
f, l, nid);
|
||||
goto end;
|
||||
}
|
||||
/* Try to initialise the ENGINE? */
|
||||
@@ -252,15 +247,13 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
|
||||
if (fnd->funct)
|
||||
engine_unlocked_finish(fnd->funct, 0);
|
||||
fnd->funct = ret;
|
||||
#ifdef ENGINE_TABLE_DEBUG
|
||||
fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, "
|
||||
"setting default to '%s'\n", f, l, nid, ret->id);
|
||||
#endif
|
||||
OSSL_TRACE4(ENGINE_TABLE,
|
||||
"%s:%d, nid=%d, setting default to '%s'\n",
|
||||
f, l, nid, ret->id);
|
||||
}
|
||||
#ifdef ENGINE_TABLE_DEBUG
|
||||
fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using "
|
||||
"newly initialised '%s'\n", f, l, nid, ret->id);
|
||||
#endif
|
||||
OSSL_TRACE4(ENGINE_TABLE,
|
||||
"%s:%d, nid=%d, using newly initialised '%s'\n",
|
||||
f, l, nid, ret->id);
|
||||
goto end;
|
||||
}
|
||||
goto trynext;
|
||||
@@ -271,14 +264,14 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
|
||||
*/
|
||||
if (fnd)
|
||||
fnd->uptodate = 1;
|
||||
#ifdef ENGINE_TABLE_DEBUG
|
||||
if (ret)
|
||||
fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "
|
||||
"ENGINE '%s'\n", f, l, nid, ret->id);
|
||||
OSSL_TRACE4(ENGINE_TABLE,
|
||||
"%s:%d, nid=%d, caching ENGINE '%s'\n",
|
||||
f, l, nid, ret->id);
|
||||
else
|
||||
fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "
|
||||
"'no matching ENGINE'\n", f, l, nid);
|
||||
#endif
|
||||
OSSL_TRACE3(ENGINE_TABLE,
|
||||
"%s:%d, nid=%d, caching 'no matching ENGINE'\n",
|
||||
f, l, nid);
|
||||
CRYPTO_THREAD_unlock(global_engine_lock);
|
||||
/*
|
||||
* Whatever happened, any failed init()s are not failures in this
|
||||
|
||||
@@ -852,6 +852,10 @@ KDF_F_KDF_SCRYPT_CTRL_UINT32:121:kdf_scrypt_ctrl_uint32
|
||||
KDF_F_KDF_SCRYPT_CTRL_UINT64:122:kdf_scrypt_ctrl_uint64
|
||||
KDF_F_KDF_SCRYPT_DERIVE:123:kdf_scrypt_derive
|
||||
KDF_F_KDF_SCRYPT_NEW:124:kdf_scrypt_new
|
||||
KDF_F_KDF_SSHKDF_CTRL:130:kdf_sshkdf_ctrl
|
||||
KDF_F_KDF_SSHKDF_CTRL_STR:131:kdf_sshkdf_ctrl_str
|
||||
KDF_F_KDF_SSHKDF_DERIVE:132:kdf_sshkdf_derive
|
||||
KDF_F_KDF_SSHKDF_NEW:133:kdf_sshkdf_new
|
||||
KDF_F_KDF_TLS1_PRF_CTRL_STR:125:kdf_tls1_prf_ctrl_str
|
||||
KDF_F_KDF_TLS1_PRF_DERIVE:126:kdf_tls1_prf_derive
|
||||
KDF_F_KDF_TLS1_PRF_NEW:127:kdf_tls1_prf_new
|
||||
@@ -2353,6 +2357,9 @@ KDF_R_MISSING_PASS:110:missing pass
|
||||
KDF_R_MISSING_SALT:111:missing salt
|
||||
KDF_R_MISSING_SECRET:107:missing secret
|
||||
KDF_R_MISSING_SEED:106:missing seed
|
||||
KDF_R_MISSING_SESSION_ID:113:missing session id
|
||||
KDF_R_MISSING_TYPE:114:missing type
|
||||
KDF_R_MISSING_XCGHASH:115:missing xcghash
|
||||
KDF_R_UNKNOWN_PARAMETER_TYPE:103:unknown parameter type
|
||||
KDF_R_VALUE_ERROR:108:value error
|
||||
KDF_R_VALUE_MISSING:102:value missing
|
||||
@@ -2798,6 +2805,8 @@ SSL_R_MISSING_TMP_DH_KEY:171:missing tmp dh key
|
||||
SSL_R_MISSING_TMP_ECDH_KEY:311:missing tmp ecdh key
|
||||
SSL_R_MIXED_HANDSHAKE_AND_NON_HANDSHAKE_DATA:293:\
|
||||
mixed handshake and non handshake data
|
||||
SSL_R_MIXED_SPECIAL_OPERATOR_WITH_GROUPS:294:mixed special operator with groups
|
||||
SSL_R_NESTED_GROUP:295:nested group
|
||||
SSL_R_NOT_ON_RECORD_BOUNDARY:182:not on record boundary
|
||||
SSL_R_NOT_REPLACING_CERTIFICATE:289:not replacing certificate
|
||||
SSL_R_NOT_SERVER:284:not server
|
||||
@@ -2906,7 +2915,9 @@ SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES:242:unable to load ssl3 md5 routines
|
||||
SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES:243:unable to load ssl3 sha1 routines
|
||||
SSL_R_UNEXPECTED_CCS_MESSAGE:262:unexpected ccs message
|
||||
SSL_R_UNEXPECTED_END_OF_EARLY_DATA:178:unexpected end of early data
|
||||
SSL_R_UNEXPECTED_GROUP_CLOSE:296:unexpected group close
|
||||
SSL_R_UNEXPECTED_MESSAGE:244:unexpected message
|
||||
SSL_R_UNEXPECTED_OPERATOR_IN_GROUP:297:unexpected operator in group
|
||||
SSL_R_UNEXPECTED_RECORD:245:unexpected record
|
||||
SSL_R_UNINITIALIZED:276:uninitialized
|
||||
SSL_R_UNKNOWN_ALERT_TYPE:246:unknown alert type
|
||||
|
||||
@@ -20,7 +20,7 @@ ASN1_SEQUENCE(ESS_ISSUER_SERIAL) = {
|
||||
ASN1_SIMPLE(ESS_ISSUER_SERIAL, serial, ASN1_INTEGER)
|
||||
} static_ASN1_SEQUENCE_END(ESS_ISSUER_SERIAL)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(ESS_ISSUER_SERIAL)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ESS_ISSUER_SERIAL)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(ESS_ISSUER_SERIAL)
|
||||
|
||||
ASN1_SEQUENCE(ESS_CERT_ID) = {
|
||||
@@ -28,7 +28,7 @@ ASN1_SEQUENCE(ESS_CERT_ID) = {
|
||||
ASN1_OPT(ESS_CERT_ID, issuer_serial, ESS_ISSUER_SERIAL)
|
||||
} static_ASN1_SEQUENCE_END(ESS_CERT_ID)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(ESS_CERT_ID)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ESS_CERT_ID)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(ESS_CERT_ID)
|
||||
|
||||
ASN1_SEQUENCE(ESS_SIGNING_CERT) = {
|
||||
@@ -36,7 +36,7 @@ ASN1_SEQUENCE(ESS_SIGNING_CERT) = {
|
||||
ASN1_SEQUENCE_OF_OPT(ESS_SIGNING_CERT, policy_info, POLICYINFO)
|
||||
} static_ASN1_SEQUENCE_END(ESS_SIGNING_CERT)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(ESS_SIGNING_CERT)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ESS_SIGNING_CERT)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(ESS_SIGNING_CERT)
|
||||
|
||||
ASN1_SEQUENCE(ESS_CERT_ID_V2) = {
|
||||
@@ -45,7 +45,7 @@ ASN1_SEQUENCE(ESS_CERT_ID_V2) = {
|
||||
ASN1_OPT(ESS_CERT_ID_V2, issuer_serial, ESS_ISSUER_SERIAL)
|
||||
} static_ASN1_SEQUENCE_END(ESS_CERT_ID_V2)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(ESS_CERT_ID_V2)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ESS_CERT_ID_V2)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(ESS_CERT_ID_V2)
|
||||
|
||||
ASN1_SEQUENCE(ESS_SIGNING_CERT_V2) = {
|
||||
@@ -53,5 +53,5 @@ ASN1_SEQUENCE(ESS_SIGNING_CERT_V2) = {
|
||||
ASN1_SEQUENCE_OF_OPT(ESS_SIGNING_CERT_V2, policy_info, POLICYINFO)
|
||||
} static_ASN1_SEQUENCE_END(ESS_SIGNING_CERT_V2)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(ESS_SIGNING_CERT_V2)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ESS_SIGNING_CERT_V2)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(ESS_SIGNING_CERT_V2)
|
||||
+45
-2
@@ -44,6 +44,7 @@ typedef struct {
|
||||
int ivlen; /* IV length */
|
||||
int taglen;
|
||||
int iv_gen; /* It is OK to generate IVs */
|
||||
int iv_gen_rand; /* No IV was specified, so generate a rand IV */
|
||||
int tls_aad_len; /* TLS AAD length */
|
||||
uint64_t tls_enc_records; /* Number of TLS records encrypted */
|
||||
ctr128_f ctr;
|
||||
@@ -1396,7 +1397,7 @@ static int s390x_aes_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
(OPENSSL_s390xcap_P.kma[0] & \
|
||||
S390X_CAPBIT(S390X_AES_256)))
|
||||
|
||||
/* iv + padding length for iv lenghts != 12 */
|
||||
/* iv + padding length for iv lengths != 12 */
|
||||
# define S390X_gcm_ivpadlen(i) ((((i) + 15) >> 4 << 4) + 16)
|
||||
|
||||
/*-
|
||||
@@ -2890,7 +2891,7 @@ static int aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
|
||||
return 1;
|
||||
|
||||
case EVP_CTRL_GET_IV:
|
||||
if (gctx->iv_gen != 1)
|
||||
if (gctx->iv_gen != 1 && gctx->iv_gen_rand != 1)
|
||||
return 0;
|
||||
if (gctx->ivlen != arg)
|
||||
return 0;
|
||||
@@ -3202,10 +3203,35 @@ static int aes_gcm_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef FIPS_MODE
|
||||
/*
|
||||
* See SP800-38D (GCM) Section 8 "Uniqueness requirement on IVS and keys"
|
||||
*
|
||||
* See also 8.2.2 RBG-based construction.
|
||||
* Random construction consists of a free field (which can be NULL) and a
|
||||
* random field which will use a DRBG that can return at least 96 bits of
|
||||
* entropy strength. (The DRBG must be seeded by the FIPS module).
|
||||
*/
|
||||
static int aes_gcm_iv_generate(EVP_AES_GCM_CTX *gctx, int offset)
|
||||
{
|
||||
int sz = gctx->ivlen - offset;
|
||||
|
||||
/* Must be at least 96 bits */
|
||||
if (sz <= 0 || gctx->ivlen < 12)
|
||||
return 0;
|
||||
|
||||
/* Use DRBG to generate random iv */
|
||||
if (RAND_bytes(gctx->iv + offset, sz) <= 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
#endif /* FIPS_MODE */
|
||||
|
||||
static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
const unsigned char *in, size_t len)
|
||||
{
|
||||
EVP_AES_GCM_CTX *gctx = EVP_C_DATA(EVP_AES_GCM_CTX,ctx);
|
||||
|
||||
/* If not set up, return error */
|
||||
if (!gctx->key_set)
|
||||
return -1;
|
||||
@@ -3213,8 +3239,25 @@ static int aes_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
if (gctx->tls_aad_len >= 0)
|
||||
return aes_gcm_tls_cipher(ctx, out, in, len);
|
||||
|
||||
#ifdef FIPS_MODE
|
||||
/*
|
||||
* FIPS requires generation of AES-GCM IV's inside the FIPS module.
|
||||
* The IV can still be set externally (the security policy will state that
|
||||
* this is not FIPS compliant). There are some applications
|
||||
* where setting the IV externally is the only option available.
|
||||
*/
|
||||
if (!gctx->iv_set) {
|
||||
if (!ctx->encrypt || !aes_gcm_iv_generate(gctx, 0))
|
||||
return -1;
|
||||
CRYPTO_gcm128_setiv(&gctx->gcm, gctx->iv, gctx->ivlen);
|
||||
gctx->iv_set = 1;
|
||||
gctx->iv_gen_rand = 1;
|
||||
}
|
||||
#else
|
||||
if (!gctx->iv_set)
|
||||
return -1;
|
||||
#endif /* FIPS_MODE */
|
||||
|
||||
if (in) {
|
||||
if (out == NULL) {
|
||||
if (CRYPTO_gcm128_aad(&gctx->gcm, in, len))
|
||||
|
||||
@@ -30,6 +30,8 @@ typedef struct {
|
||||
|
||||
#define data(ctx) ((EVP_CHACHA_KEY *)(ctx)->cipher_data)
|
||||
|
||||
#define CHACHA20_POLY1305_MAX_IVLEN 12
|
||||
|
||||
static int chacha_init_key(EVP_CIPHER_CTX *ctx,
|
||||
const unsigned char user_key[CHACHA_KEY_SIZE],
|
||||
const unsigned char iv[CHACHA_CTR_SIZE], int enc)
|
||||
@@ -575,7 +577,7 @@ static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
|
||||
|
||||
case EVP_CTRL_AEAD_SET_IVLEN:
|
||||
if (actx->draft) return -1;
|
||||
if (arg <= 0 || arg > CHACHA_CTR_SIZE)
|
||||
if (arg <= 0 || arg > CHACHA20_POLY1305_MAX_IVLEN)
|
||||
return 0;
|
||||
actx->nonce_len = arg;
|
||||
return 1;
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx)
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
int EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, EVP_ENCODE_CTX *sctx)
|
||||
int EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, const EVP_ENCODE_CTX *sctx)
|
||||
{
|
||||
memcpy(dctx, sctx, sizeof(EVP_ENCODE_CTX));
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8)
|
||||
|
||||
/* Turn a private key into a PKCS8 structure */
|
||||
|
||||
PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey)
|
||||
PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(const EVP_PKEY *pkey)
|
||||
{
|
||||
PKCS8_PRIV_KEY_INFO *p8 = PKCS8_PRIV_KEY_INFO_new();
|
||||
if (p8 == NULL) {
|
||||
|
||||
@@ -29,7 +29,8 @@ static const EVP_KDF_METHOD *standard_methods[] = {
|
||||
&scrypt_kdf_meth,
|
||||
#endif
|
||||
&tls1_prf_kdf_meth,
|
||||
&hkdf_kdf_meth
|
||||
&hkdf_kdf_meth,
|
||||
&sshkdf_kdf_meth,
|
||||
};
|
||||
|
||||
DECLARE_OBJ_BSEARCH_CMP_FN(const EVP_KDF_METHOD *, const EVP_KDF_METHOD *,
|
||||
|
||||
@@ -48,7 +48,7 @@ void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx)
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
int EVP_MAC_CTX_copy(EVP_MAC_CTX *dst, EVP_MAC_CTX *src)
|
||||
int EVP_MAC_CTX_copy(EVP_MAC_CTX *dst, const EVP_MAC_CTX *src)
|
||||
{
|
||||
EVP_MAC_IMPL *macdata;
|
||||
|
||||
|
||||
+16
-25
@@ -14,16 +14,10 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include <openssl/hmac.h>
|
||||
#include <openssl/trace.h>
|
||||
#include "internal/evp_int.h"
|
||||
#include "evp_locl.h"
|
||||
|
||||
/* set this to print out info about the keygen algorithm */
|
||||
/* #define OPENSSL_DEBUG_PKCS5V2 */
|
||||
|
||||
#ifdef OPENSSL_DEBUG_PKCS5V2
|
||||
static void h__dump(const unsigned char *p, int len);
|
||||
#endif
|
||||
|
||||
int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
|
||||
const unsigned char *salt, int saltlen, int iter,
|
||||
const EVP_MD *digest, int keylen, unsigned char *out)
|
||||
@@ -55,15 +49,21 @@ int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
|
||||
|
||||
EVP_KDF_CTX_free(kctx);
|
||||
|
||||
# ifdef OPENSSL_DEBUG_PKCS5V2
|
||||
fprintf(stderr, "Password:\n");
|
||||
h__dump(pass, passlen);
|
||||
fprintf(stderr, "Salt:\n");
|
||||
h__dump(salt, saltlen);
|
||||
fprintf(stderr, "Iteration count %d\n", iter);
|
||||
fprintf(stderr, "Key:\n");
|
||||
h__dump(out, keylen);
|
||||
# endif
|
||||
OSSL_TRACE_BEGIN(PKCS5V2) {
|
||||
BIO_printf(trc_out, "Password:\n");
|
||||
BIO_hex_string(trc_out,
|
||||
0, passlen, pass, passlen);
|
||||
BIO_printf(trc_out, "\n");
|
||||
BIO_printf(trc_out, "Salt:\n");
|
||||
BIO_hex_string(trc_out,
|
||||
0, saltlen, salt, saltlen);
|
||||
BIO_printf(trc_out, "\n");
|
||||
BIO_printf(trc_out, "Iteration count %d\n", iter);
|
||||
BIO_printf(trc_out, "Key:\n");
|
||||
BIO_hex_string(trc_out,
|
||||
0, keylen, out, keylen);
|
||||
BIO_printf(trc_out, "\n");
|
||||
} OSSL_TRACE_END(PKCS5V2);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -200,12 +200,3 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
|
||||
PBKDF2PARAM_free(kdf);
|
||||
return rv;
|
||||
}
|
||||
|
||||
# ifdef OPENSSL_DEBUG_PKCS5V2
|
||||
static void h__dump(const unsigned char *p, int len)
|
||||
{
|
||||
for (; len--; p++)
|
||||
fprintf(stderr, "%02X ", *p);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
# endif
|
||||
+4
-4
@@ -460,7 +460,7 @@ int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)
|
||||
return ret;
|
||||
}
|
||||
|
||||
RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
|
||||
RSA *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey)
|
||||
{
|
||||
if (pkey->type != EVP_PKEY_RSA) {
|
||||
EVPerr(EVP_F_EVP_PKEY_GET0_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
|
||||
@@ -487,7 +487,7 @@ int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)
|
||||
return ret;
|
||||
}
|
||||
|
||||
DSA *EVP_PKEY_get0_DSA(EVP_PKEY *pkey)
|
||||
DSA *EVP_PKEY_get0_DSA(const EVP_PKEY *pkey)
|
||||
{
|
||||
if (pkey->type != EVP_PKEY_DSA) {
|
||||
EVPerr(EVP_F_EVP_PKEY_GET0_DSA, EVP_R_EXPECTING_A_DSA_KEY);
|
||||
@@ -515,7 +515,7 @@ int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key)
|
||||
return ret;
|
||||
}
|
||||
|
||||
EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
|
||||
EC_KEY *EVP_PKEY_get0_EC_KEY(const EVP_PKEY *pkey)
|
||||
{
|
||||
if (pkey->type != EVP_PKEY_EC) {
|
||||
EVPerr(EVP_F_EVP_PKEY_GET0_EC_KEY, EVP_R_EXPECTING_A_EC_KEY);
|
||||
@@ -543,7 +543,7 @@ int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)
|
||||
return ret;
|
||||
}
|
||||
|
||||
DH *EVP_PKEY_get0_DH(EVP_PKEY *pkey)
|
||||
DH *EVP_PKEY_get0_DH(const EVP_PKEY *pkey)
|
||||
{
|
||||
if (pkey->type != EVP_PKEY_DH && pkey->type != EVP_PKEY_DHX) {
|
||||
EVPerr(EVP_F_EVP_PKEY_GET0_DH, EVP_R_EXPECTING_A_DH_KEY);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include "internal/numbers.h"
|
||||
|
||||
#ifndef OPENSSL_NO_SCRYPT
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include "internal/numbers.h"
|
||||
#include "internal/evp_int.h"
|
||||
|
||||
static int pkey_kdf_init(EVP_PKEY_CTX *ctx)
|
||||
|
||||
@@ -71,7 +71,7 @@ static int pkey_mac_init(EVP_PKEY_CTX *ctx)
|
||||
|
||||
static void pkey_mac_cleanup(EVP_PKEY_CTX *ctx);
|
||||
|
||||
static int pkey_mac_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
|
||||
static int pkey_mac_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src)
|
||||
{
|
||||
MAC_PKEY_CTX *sctx, *dctx;
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e)
|
||||
return int_ctx_new(NULL, e, id);
|
||||
}
|
||||
|
||||
EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *pctx)
|
||||
EVP_PKEY_CTX *EVP_PKEY_CTX_dup(const EVP_PKEY_CTX *pctx)
|
||||
{
|
||||
EVP_PKEY_CTX *rctx;
|
||||
if (!pctx->pmeth || !pctx->pmeth->copy)
|
||||
@@ -472,7 +472,7 @@ void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data)
|
||||
ctx->data = data;
|
||||
}
|
||||
|
||||
void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx)
|
||||
void *EVP_PKEY_CTX_get_data(const EVP_PKEY_CTX *ctx)
|
||||
{
|
||||
return ctx->data;
|
||||
}
|
||||
@@ -505,7 +505,7 @@ void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
|
||||
|
||||
void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
|
||||
int (*copy) (EVP_PKEY_CTX *dst,
|
||||
EVP_PKEY_CTX *src))
|
||||
const EVP_PKEY_CTX *src))
|
||||
{
|
||||
pmeth->copy = copy;
|
||||
}
|
||||
@@ -675,7 +675,7 @@ void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth,
|
||||
|
||||
void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pcopy) (EVP_PKEY_CTX *dst,
|
||||
EVP_PKEY_CTX *src))
|
||||
const EVP_PKEY_CTX *src))
|
||||
{
|
||||
*pcopy = pmeth->copy;
|
||||
}
|
||||
|
||||
@@ -32,4 +32,6 @@ int ossl_init_thread_start(uint64_t opts);
|
||||
# define OPENSSL_INIT_THREAD_ERR_STATE 0x02
|
||||
# define OPENSSL_INIT_THREAD_RAND 0x04
|
||||
|
||||
int ossl_trace_init(void);
|
||||
void ossl_trace_cleanup(void);
|
||||
void ossl_malloc_setup_failures(void);
|
||||
@@ -44,7 +44,7 @@ struct evp_pkey_method_st {
|
||||
int pkey_id;
|
||||
int flags;
|
||||
int (*init) (EVP_PKEY_CTX *ctx);
|
||||
int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
|
||||
int (*copy) (EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src);
|
||||
void (*cleanup) (EVP_PKEY_CTX *ctx);
|
||||
int (*paramgen_init) (EVP_PKEY_CTX *ctx);
|
||||
int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
|
||||
@@ -168,6 +168,7 @@ extern const EVP_KDF_METHOD pbkdf2_kdf_meth;
|
||||
extern const EVP_KDF_METHOD scrypt_kdf_meth;
|
||||
extern const EVP_KDF_METHOD tls1_prf_kdf_meth;
|
||||
extern const EVP_KDF_METHOD hkdf_kdf_meth;
|
||||
extern const EVP_KDF_METHOD sshkdf_kdf_meth;
|
||||
|
||||
struct evp_md_st {
|
||||
int type;
|
||||
|
||||
@@ -39,25 +39,27 @@ extern "C" {
|
||||
return OPENSSL_SA_num((OPENSSL_SA *)sa); \
|
||||
} \
|
||||
static ossl_unused ossl_inline void ossl_sa_##type##_doall(const SPARSE_ARRAY_OF(type) *sa, \
|
||||
void (*leaf)(size_t, type *)) \
|
||||
void (*leaf)(ossl_uintmax_t, \
|
||||
type *)) \
|
||||
{ \
|
||||
OPENSSL_SA_doall((OPENSSL_SA *)sa, (void (*)(size_t, void *))leaf); \
|
||||
OPENSSL_SA_doall((OPENSSL_SA *)sa, (void (*)(ossl_uintmax_t, void *))leaf); \
|
||||
} \
|
||||
static ossl_unused ossl_inline \
|
||||
void ossl_sa_##type##_doall_arg(const SPARSE_ARRAY_OF(type) *sa, \
|
||||
void (*leaf)(size_t, type *, void *), \
|
||||
void (*leaf)(ossl_uintmax_t, type *, void *), \
|
||||
void *arg) \
|
||||
{ \
|
||||
OPENSSL_SA_doall_arg((OPENSSL_SA *)sa, (void (*)(size_t, void *, void *))leaf, \
|
||||
OPENSSL_SA_doall_arg((OPENSSL_SA *)sa, (void (*)(ossl_uintmax_t, void *, \
|
||||
void *))leaf, \
|
||||
arg); \
|
||||
} \
|
||||
static ossl_unused ossl_inline type *ossl_sa_##type##_get(const SPARSE_ARRAY_OF(type) *sa, \
|
||||
size_t n) \
|
||||
ossl_uintmax_t n) \
|
||||
{ \
|
||||
return (type *)OPENSSL_SA_get((OPENSSL_SA *)sa, n); \
|
||||
} \
|
||||
static ossl_unused ossl_inline int ossl_sa_##type##_set(SPARSE_ARRAY_OF(type) *sa, \
|
||||
size_t n, type *val) \
|
||||
ossl_uintmax_t n, type *val) \
|
||||
{ \
|
||||
return OPENSSL_SA_set((OPENSSL_SA *)sa, n, (void *)val); \
|
||||
} \
|
||||
@@ -68,11 +70,12 @@ OPENSSL_SA *OPENSSL_SA_new(void);
|
||||
void OPENSSL_SA_free(OPENSSL_SA *sa);
|
||||
void OPENSSL_SA_free_leaves(OPENSSL_SA *sa);
|
||||
size_t OPENSSL_SA_num(const OPENSSL_SA *sa);
|
||||
void OPENSSL_SA_doall(const OPENSSL_SA *sa, void (*leaf)(size_t, void *));
|
||||
void OPENSSL_SA_doall(const OPENSSL_SA *sa,
|
||||
void (*leaf)(ossl_uintmax_t, void *));
|
||||
void OPENSSL_SA_doall_arg(const OPENSSL_SA *sa,
|
||||
void (*leaf)(size_t, void *, void *), void *);
|
||||
void *OPENSSL_SA_get(const OPENSSL_SA *sa, size_t n);
|
||||
int OPENSSL_SA_set(OPENSSL_SA *sa, size_t n, void *val);
|
||||
void (*leaf)(ossl_uintmax_t, void *, void *), void *);
|
||||
void *OPENSSL_SA_get(const OPENSSL_SA *sa, ossl_uintmax_t n);
|
||||
int OPENSSL_SA_set(OPENSSL_SA *sa, ossl_uintmax_t n, void *val);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
|
||||
+68
-134
@@ -27,6 +27,7 @@
|
||||
#include "internal/dso_conf.h"
|
||||
#include "internal/dso.h"
|
||||
#include "internal/store.h"
|
||||
#include <openssl/trace.h>
|
||||
|
||||
static int stopped = 0;
|
||||
|
||||
@@ -90,9 +91,10 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_base)
|
||||
{
|
||||
CRYPTO_THREAD_LOCAL key;
|
||||
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_base: Setting up stop handlers\n");
|
||||
#endif
|
||||
if (ossl_trace_init() == 0)
|
||||
return 0;
|
||||
|
||||
OSSL_TRACE(INIT, "ossl_init_base: setting up stop handlers\n");
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
ossl_malloc_setup_failures();
|
||||
#endif
|
||||
@@ -107,9 +109,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_base)
|
||||
return 1;
|
||||
|
||||
err:
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_base not ok!\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT, "ossl_init_base failed!\n");
|
||||
CRYPTO_THREAD_lock_free(init_lock);
|
||||
init_lock = NULL;
|
||||
|
||||
@@ -158,9 +158,8 @@ DEFINE_RUN_ONCE_STATIC_ALT(ossl_init_no_register_atexit,
|
||||
static CRYPTO_ONCE load_crypto_nodelete = CRYPTO_ONCE_STATIC_INIT;
|
||||
DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_nodelete)
|
||||
{
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_load_crypto_nodelete()\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT, "ossl_init_load_crypto_nodelete()\n");
|
||||
|
||||
#if !defined(OPENSSL_NO_DSO) \
|
||||
&& !defined(OPENSSL_USE_NODELETE) \
|
||||
&& !defined(OPENSSL_NO_PINSHARED)
|
||||
@@ -174,10 +173,10 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_nodelete)
|
||||
| GET_MODULE_HANDLE_EX_FLAG_PIN,
|
||||
(void *)&base_inited, &handle);
|
||||
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: obtained DSO reference? %s\n",
|
||||
(ret == TRUE ? "No!" : "Yes."));
|
||||
# endif
|
||||
OSSL_TRACE1(INIT,
|
||||
"ossl_init_load_crypto_nodelete: "
|
||||
"obtained DSO reference? %s\n",
|
||||
(ret == TRUE ? "No!" : "Yes."));
|
||||
return (ret == TRUE) ? 1 : 0;
|
||||
}
|
||||
# else
|
||||
@@ -193,15 +192,13 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_nodelete)
|
||||
return 0;
|
||||
|
||||
dso = DSO_dsobyaddr(&base_inited, DSO_FLAG_NO_UNLOAD_ON_FREE);
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: obtained DSO reference? %s\n",
|
||||
(dso == NULL ? "No!" : "Yes."));
|
||||
/*
|
||||
* In case of No!, it is uncertain our exit()-handlers can still be
|
||||
* called. After dlclose() the whole library might have been unloaded
|
||||
* already.
|
||||
*/
|
||||
# endif
|
||||
OSSL_TRACE1(INIT, "obtained DSO reference? %s\n",
|
||||
(dso == NULL ? "No!" : "Yes."));
|
||||
DSO_free(dso);
|
||||
err_unshelve_state(err);
|
||||
}
|
||||
@@ -221,10 +218,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_strings)
|
||||
* pulling in all the error strings during static linking
|
||||
*/
|
||||
#if !defined(OPENSSL_NO_ERR) && !defined(OPENSSL_NO_AUTOERRINIT)
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_load_crypto_strings: "
|
||||
"err_load_crypto_strings_int()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "err_load_crypto_strings_int()\n");
|
||||
ret = err_load_crypto_strings_int();
|
||||
load_crypto_strings_inited = 1;
|
||||
#endif
|
||||
@@ -246,10 +240,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_add_all_ciphers)
|
||||
* pulling in all the ciphers during static linking
|
||||
*/
|
||||
#ifndef OPENSSL_NO_AUTOALGINIT
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_add_all_ciphers: "
|
||||
"openssl_add_all_ciphers_int()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "openssl_add_all_ciphers_int()\n");
|
||||
openssl_add_all_ciphers_int();
|
||||
#endif
|
||||
return 1;
|
||||
@@ -270,10 +261,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_add_all_digests)
|
||||
* pulling in all the ciphers during static linking
|
||||
*/
|
||||
#ifndef OPENSSL_NO_AUTOALGINIT
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_add_all_digests: "
|
||||
"openssl_add_all_digests()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "openssl_add_all_digests()\n");
|
||||
openssl_add_all_digests_int();
|
||||
#endif
|
||||
return 1;
|
||||
@@ -294,10 +282,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_add_all_macs)
|
||||
* pulling in all the macs during static linking
|
||||
*/
|
||||
#ifndef OPENSSL_NO_AUTOALGINIT
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_add_all_macs: "
|
||||
"openssl_add_all_macs_int()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "openssl_add_all_macs_int()\n");
|
||||
openssl_add_all_macs_int();
|
||||
#endif
|
||||
return 1;
|
||||
@@ -320,10 +305,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_config)
|
||||
}
|
||||
DEFINE_RUN_ONCE_STATIC_ALT(ossl_init_no_config, ossl_init_config)
|
||||
{
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr,
|
||||
"OPENSSL_INIT: ossl_init_config: openssl_no_config_int()\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT, "openssl_no_config_int()\n");
|
||||
openssl_no_config_int();
|
||||
config_inited = 1;
|
||||
return 1;
|
||||
@@ -333,9 +315,7 @@ static CRYPTO_ONCE async = CRYPTO_ONCE_STATIC_INIT;
|
||||
static int async_inited = 0;
|
||||
DEFINE_RUN_ONCE_STATIC(ossl_init_async)
|
||||
{
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_async: async_init()\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT, "async_init()\n");
|
||||
if (!async_init())
|
||||
return 0;
|
||||
async_inited = 1;
|
||||
@@ -346,22 +326,15 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_async)
|
||||
static CRYPTO_ONCE engine_openssl = CRYPTO_ONCE_STATIC_INIT;
|
||||
DEFINE_RUN_ONCE_STATIC(ossl_init_engine_openssl)
|
||||
{
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_engine_openssl: "
|
||||
"engine_load_openssl_int()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "engine_load_openssl_int()\n");
|
||||
engine_load_openssl_int();
|
||||
return 1;
|
||||
}
|
||||
|
||||
# ifndef OPENSSL_NO_RDRAND
|
||||
static CRYPTO_ONCE engine_rdrand = CRYPTO_ONCE_STATIC_INIT;
|
||||
DEFINE_RUN_ONCE_STATIC(ossl_init_engine_rdrand)
|
||||
{
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_engine_rdrand: "
|
||||
"engine_load_rdrand_int()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "engine_load_rdrand_int()\n");
|
||||
engine_load_rdrand_int();
|
||||
return 1;
|
||||
}
|
||||
@@ -369,10 +342,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_rdrand)
|
||||
static CRYPTO_ONCE engine_dynamic = CRYPTO_ONCE_STATIC_INIT;
|
||||
DEFINE_RUN_ONCE_STATIC(ossl_init_engine_dynamic)
|
||||
{
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_engine_dynamic: "
|
||||
"engine_load_dynamic_int()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "engine_load_dynamic_int()\n");
|
||||
engine_load_dynamic_int();
|
||||
return 1;
|
||||
}
|
||||
@@ -381,22 +351,16 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_dynamic)
|
||||
static CRYPTO_ONCE engine_devcrypto = CRYPTO_ONCE_STATIC_INIT;
|
||||
DEFINE_RUN_ONCE_STATIC(ossl_init_engine_devcrypto)
|
||||
{
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_engine_devcrypto: "
|
||||
"engine_load_devcrypto_int()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "engine_load_devcrypto_int()\n");
|
||||
engine_load_devcrypto_int();
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
# if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_PADLOCK)
|
||||
# if !defined(OPENSSL_NO_PADLOCKENG)
|
||||
static CRYPTO_ONCE engine_padlock = CRYPTO_ONCE_STATIC_INIT;
|
||||
DEFINE_RUN_ONCE_STATIC(ossl_init_engine_padlock)
|
||||
{
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_engine_padlock: "
|
||||
"engine_load_padlock_int()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "engine_load_padlock_int()\n");
|
||||
engine_load_padlock_int();
|
||||
return 1;
|
||||
}
|
||||
@@ -405,10 +369,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_padlock)
|
||||
static CRYPTO_ONCE engine_capi = CRYPTO_ONCE_STATIC_INIT;
|
||||
DEFINE_RUN_ONCE_STATIC(ossl_init_engine_capi)
|
||||
{
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_engine_capi: "
|
||||
"engine_load_capi_int()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "engine_load_capi_int()\n");
|
||||
engine_load_capi_int();
|
||||
return 1;
|
||||
}
|
||||
@@ -417,10 +378,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_engine_capi)
|
||||
static CRYPTO_ONCE engine_afalg = CRYPTO_ONCE_STATIC_INIT;
|
||||
DEFINE_RUN_ONCE_STATIC(ossl_init_engine_afalg)
|
||||
{
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_engine_afalg: "
|
||||
"engine_load_afalg_int()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "engine_load_afalg_int()\n");
|
||||
engine_load_afalg_int();
|
||||
return 1;
|
||||
}
|
||||
@@ -447,26 +405,17 @@ static void ossl_init_thread_stop(struct thread_local_inits_st *locals)
|
||||
return;
|
||||
|
||||
if (locals->async) {
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_stop: "
|
||||
"async_delete_thread_state()\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT, "async_delete_thread_state()\n");
|
||||
async_delete_thread_state();
|
||||
}
|
||||
|
||||
if (locals->err_state) {
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_stop: "
|
||||
"err_delete_thread_state()\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT, "err_delete_thread_state()\n");
|
||||
err_delete_thread_state();
|
||||
}
|
||||
|
||||
if (locals->rand) {
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_stop: "
|
||||
"drbg_delete_thread_state()\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT, "drbg_delete_thread_state()\n");
|
||||
drbg_delete_thread_state();
|
||||
}
|
||||
|
||||
@@ -492,26 +441,23 @@ int ossl_init_thread_start(uint64_t opts)
|
||||
return 0;
|
||||
|
||||
if (opts & OPENSSL_INIT_THREAD_ASYNC) {
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "
|
||||
"marking thread for async\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT,
|
||||
"ossl_init_thread_start: "
|
||||
"marking thread for async\n");
|
||||
locals->async = 1;
|
||||
}
|
||||
|
||||
if (opts & OPENSSL_INIT_THREAD_ERR_STATE) {
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "
|
||||
"marking thread for err_state\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT,
|
||||
"ossl_init_thread_start: "
|
||||
"marking thread for err_state\n");
|
||||
locals->err_state = 1;
|
||||
}
|
||||
|
||||
if (opts & OPENSSL_INIT_THREAD_RAND) {
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: ossl_init_thread_start: "
|
||||
"marking thread for rand\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT,
|
||||
"ossl_init_thread_start: "
|
||||
"marking thread for rand\n");
|
||||
locals->rand = 1;
|
||||
}
|
||||
|
||||
@@ -557,27 +503,18 @@ void OPENSSL_cleanup(void)
|
||||
|
||||
#ifndef OPENSSL_NO_COMP
|
||||
if (zlib_inited) {
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"comp_zlib_cleanup_int()\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: comp_zlib_cleanup_int()\n");
|
||||
comp_zlib_cleanup_int();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (async_inited) {
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"async_deinit()\n");
|
||||
# endif
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: async_deinit()\n");
|
||||
async_deinit();
|
||||
}
|
||||
|
||||
if (load_crypto_strings_inited) {
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"err_free_strings_int()\n");
|
||||
#endif
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: err_free_strings_int()\n");
|
||||
err_free_strings_int();
|
||||
}
|
||||
|
||||
@@ -585,28 +522,6 @@ void OPENSSL_cleanup(void)
|
||||
destructor_key.sane = -1;
|
||||
CRYPTO_THREAD_cleanup_local(&key);
|
||||
|
||||
#ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"rand_cleanup_int()\n");
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"conf_modules_free_int()\n");
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"engine_cleanup_int()\n");
|
||||
#endif
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"crypto_cleanup_all_ex_data_int()\n");
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"bio_sock_cleanup_int()\n");
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"bio_cleanup()\n");
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"evp_cleanup_int()\n");
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"obj_cleanup_int()\n");
|
||||
fprintf(stderr, "OPENSSL_INIT: OPENSSL_cleanup: "
|
||||
"err_cleanup()\n");
|
||||
#endif
|
||||
/*
|
||||
* Note that cleanup order is important:
|
||||
* - rand_cleanup_int could call an ENGINE's RAND cleanup function so
|
||||
@@ -618,21 +533,42 @@ void OPENSSL_cleanup(void)
|
||||
* - ENGINEs and additional EVP algorithms might use added OIDs names so
|
||||
* obj_cleanup_int() must be called last
|
||||
*/
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: rand_cleanup_int()\n");
|
||||
rand_cleanup_int();
|
||||
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: rand_drbg_cleanup_int()\n");
|
||||
rand_drbg_cleanup_int();
|
||||
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: conf_modules_free_int()\n");
|
||||
conf_modules_free_int();
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: engine_cleanup_int()\n");
|
||||
engine_cleanup_int();
|
||||
#endif
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: ossl_store_cleanup_int()\n");
|
||||
ossl_store_cleanup_int();
|
||||
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: crypto_cleanup_all_ex_data_int()\n");
|
||||
crypto_cleanup_all_ex_data_int();
|
||||
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: bio_cleanup()\n");
|
||||
bio_cleanup();
|
||||
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: evp_cleanup_int()\n");
|
||||
evp_cleanup_int();
|
||||
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: obj_cleanup_int()\n");
|
||||
obj_cleanup_int();
|
||||
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: err_int()\n");
|
||||
err_cleanup();
|
||||
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: CRYPTO_secure_malloc_done()\n");
|
||||
CRYPTO_secure_malloc_done();
|
||||
|
||||
OSSL_TRACE(INIT, "OPENSSL_cleanup: ossl_trace_cleanup()\n");
|
||||
ossl_trace_cleanup();
|
||||
|
||||
base_inited = 0;
|
||||
}
|
||||
|
||||
@@ -761,7 +697,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
|
||||
&& !RUN_ONCE(&engine_devcrypto, ossl_init_engine_devcrypto))
|
||||
return 0;
|
||||
# endif
|
||||
# if !defined(OPENSSL_NO_HW) && !defined(OPENSSL_NO_HW_PADLOCK)
|
||||
# if !defined(OPENSSL_NO_PADLOCKENG)
|
||||
if ((opts & OPENSSL_INIT_ENGINE_PADLOCK)
|
||||
&& !RUN_ONCE(&engine_padlock, ossl_init_engine_padlock))
|
||||
return 0;
|
||||
@@ -835,12 +771,10 @@ int OPENSSL_atexit(void (*handler)(void))
|
||||
|
||||
ERR_set_mark();
|
||||
dso = DSO_dsobyaddr(handlersym.sym, DSO_FLAG_NO_UNLOAD_ON_FREE);
|
||||
# ifdef OPENSSL_INIT_DEBUG
|
||||
fprintf(stderr,
|
||||
"OPENSSL_INIT: OPENSSL_atexit: obtained DSO reference? %s\n",
|
||||
(dso == NULL ? "No!" : "Yes."));
|
||||
/* See same code above in ossl_init_base() for an explanation. */
|
||||
# endif
|
||||
OSSL_TRACE1(INIT,
|
||||
"atexit: obtained DSO reference? %s\n",
|
||||
(dso == NULL ? "No!" : "Yes."));
|
||||
DSO_free(dso);
|
||||
ERR_pop_to_mark();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
LIBS=../../libcrypto
|
||||
SOURCE[../../libcrypto]=\
|
||||
tls1_prf.c kdf_err.c kdf_util.c hkdf.c scrypt.c pbkdf2.c
|
||||
tls1_prf.c kdf_err.c kdf_util.c hkdf.c scrypt.c pbkdf2.c sshkdf.c
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/numbers.h"
|
||||
#include "internal/evp_int.h"
|
||||
#include "kdf_local.h"
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ static const ERR_STRING_DATA KDF_str_functs[] = {
|
||||
"kdf_scrypt_ctrl_uint64"},
|
||||
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_SCRYPT_DERIVE, 0), "kdf_scrypt_derive"},
|
||||
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_SCRYPT_NEW, 0), "kdf_scrypt_new"},
|
||||
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_SSHKDF_CTRL, 0), "kdf_sshkdf_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_SSHKDF_CTRL_STR, 0),
|
||||
"kdf_sshkdf_ctrl_str"},
|
||||
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_SSHKDF_DERIVE, 0), "kdf_sshkdf_derive"},
|
||||
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_SSHKDF_NEW, 0), "kdf_sshkdf_new"},
|
||||
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_TLS1_PRF_CTRL_STR, 0),
|
||||
"kdf_tls1_prf_ctrl_str"},
|
||||
{ERR_PACK(ERR_LIB_KDF, KDF_F_KDF_TLS1_PRF_DERIVE, 0),
|
||||
@@ -70,6 +75,9 @@ static const ERR_STRING_DATA KDF_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_SALT), "missing salt"},
|
||||
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_SECRET), "missing secret"},
|
||||
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_SEED), "missing seed"},
|
||||
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_SESSION_ID), "missing session id"},
|
||||
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_TYPE), "missing type"},
|
||||
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_MISSING_XCGHASH), "missing xcghash"},
|
||||
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_UNKNOWN_PARAMETER_TYPE),
|
||||
"unknown parameter type"},
|
||||
{ERR_PACK(ERR_LIB_KDF, 0, KDF_R_VALUE_ERROR), "value error"},
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
* Copyright 2018-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (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 <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/kdf.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/numbers.h"
|
||||
#include "internal/evp_int.h"
|
||||
#include "kdf_local.h"
|
||||
|
||||
/* See RFC 4253, Section 7.2 */
|
||||
|
||||
static void kdf_sshkdf_reset(EVP_KDF_IMPL *impl);
|
||||
static int SSHKDF(const EVP_MD *evp_md,
|
||||
const unsigned char *key, size_t key_len,
|
||||
const unsigned char *xcghash, size_t xcghash_len,
|
||||
const unsigned char *session_id, size_t session_id_len,
|
||||
char type, unsigned char *okey, size_t okey_len);
|
||||
|
||||
struct evp_kdf_impl_st {
|
||||
const EVP_MD *md;
|
||||
unsigned char *key; /* K */
|
||||
size_t key_len;
|
||||
unsigned char *xcghash; /* H */
|
||||
size_t xcghash_len;
|
||||
char type; /* X */
|
||||
unsigned char *session_id;
|
||||
size_t session_id_len;
|
||||
};
|
||||
|
||||
static EVP_KDF_IMPL *kdf_sshkdf_new(void)
|
||||
{
|
||||
EVP_KDF_IMPL *impl;
|
||||
|
||||
if ((impl = OPENSSL_zalloc(sizeof(*impl))) == NULL)
|
||||
KDFerr(KDF_F_KDF_SSHKDF_NEW, ERR_R_MALLOC_FAILURE);
|
||||
return impl;
|
||||
}
|
||||
|
||||
static void kdf_sshkdf_free(EVP_KDF_IMPL *impl)
|
||||
{
|
||||
kdf_sshkdf_reset(impl);
|
||||
OPENSSL_free(impl);
|
||||
}
|
||||
|
||||
static void kdf_sshkdf_reset(EVP_KDF_IMPL *impl)
|
||||
{
|
||||
OPENSSL_clear_free(impl->key, impl->key_len);
|
||||
OPENSSL_clear_free(impl->xcghash, impl->xcghash_len);
|
||||
OPENSSL_clear_free(impl->session_id, impl->session_id_len);
|
||||
memset(impl, 0, sizeof(*impl));
|
||||
}
|
||||
|
||||
static int kdf_sshkdf_parse_buffer_arg(unsigned char **dst, size_t *dst_len,
|
||||
va_list args)
|
||||
{
|
||||
const unsigned char *p;
|
||||
size_t len;
|
||||
|
||||
p = va_arg(args, const unsigned char *);
|
||||
len = va_arg(args, size_t);
|
||||
OPENSSL_clear_free(*dst, *dst_len);
|
||||
*dst = OPENSSL_memdup(p, len);
|
||||
if (*dst == NULL)
|
||||
return 0;
|
||||
|
||||
*dst_len = len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int kdf_sshkdf_ctrl(EVP_KDF_IMPL *impl, int cmd, va_list args)
|
||||
{
|
||||
int t;
|
||||
|
||||
switch (cmd) {
|
||||
case EVP_KDF_CTRL_SET_MD:
|
||||
impl->md = va_arg(args, const EVP_MD *);
|
||||
if (impl->md == NULL)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
|
||||
case EVP_KDF_CTRL_SET_KEY:
|
||||
return kdf_sshkdf_parse_buffer_arg(&impl->key,
|
||||
&impl->key_len, args);
|
||||
|
||||
case EVP_KDF_CTRL_SET_SSHKDF_XCGHASH:
|
||||
return kdf_sshkdf_parse_buffer_arg(&impl->xcghash,
|
||||
&impl->xcghash_len, args);
|
||||
|
||||
case EVP_KDF_CTRL_SET_SSHKDF_SESSION_ID:
|
||||
return kdf_sshkdf_parse_buffer_arg(&impl->session_id,
|
||||
&impl->session_id_len, args);
|
||||
|
||||
case EVP_KDF_CTRL_SET_SSHKDF_TYPE:
|
||||
t = va_arg(args, int);
|
||||
if (t < 65 || t > 70) {
|
||||
KDFerr(KDF_F_KDF_SSHKDF_CTRL, KDF_R_VALUE_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
impl->type = (char)t;
|
||||
return 1;
|
||||
|
||||
default:
|
||||
return -2;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static int kdf_sshkdf_ctrl_str(EVP_KDF_IMPL *impl, const char *type,
|
||||
const char *value)
|
||||
{
|
||||
if (value == NULL) {
|
||||
KDFerr(KDF_F_KDF_SSHKDF_CTRL_STR, KDF_R_VALUE_MISSING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(type, "md") == 0)
|
||||
return kdf_md2ctrl(impl, kdf_sshkdf_ctrl, EVP_KDF_CTRL_SET_MD, value);
|
||||
|
||||
if (strcmp(type, "key") == 0)
|
||||
return kdf_str2ctrl(impl, kdf_sshkdf_ctrl,
|
||||
EVP_KDF_CTRL_SET_KEY, value);
|
||||
|
||||
if (strcmp(type, "hexkey") == 0)
|
||||
return kdf_hex2ctrl(impl, kdf_sshkdf_ctrl,
|
||||
EVP_KDF_CTRL_SET_KEY, value);
|
||||
|
||||
if (strcmp(type, "xcghash") == 0)
|
||||
return kdf_str2ctrl(impl, kdf_sshkdf_ctrl,
|
||||
EVP_KDF_CTRL_SET_SSHKDF_XCGHASH, value);
|
||||
|
||||
if (strcmp(type, "hexxcghash") == 0)
|
||||
return kdf_hex2ctrl(impl, kdf_sshkdf_ctrl,
|
||||
EVP_KDF_CTRL_SET_SSHKDF_XCGHASH, value);
|
||||
|
||||
if (strcmp(type, "session_id") == 0)
|
||||
return kdf_str2ctrl(impl, kdf_sshkdf_ctrl,
|
||||
EVP_KDF_CTRL_SET_SSHKDF_SESSION_ID, value);
|
||||
|
||||
if (strcmp(type, "hexsession_id") == 0)
|
||||
return kdf_hex2ctrl(impl, kdf_sshkdf_ctrl,
|
||||
EVP_KDF_CTRL_SET_SSHKDF_SESSION_ID, value);
|
||||
|
||||
if (strcmp(type, "type") == 0) {
|
||||
if (strlen(value) != 1) {
|
||||
KDFerr(KDF_F_KDF_SSHKDF_CTRL_STR, KDF_R_VALUE_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return call_ctrl(kdf_sshkdf_ctrl, impl, EVP_KDF_CTRL_SET_SSHKDF_TYPE,
|
||||
(int)value[0]);
|
||||
}
|
||||
|
||||
KDFerr(KDF_F_KDF_SSHKDF_CTRL_STR, KDF_R_UNKNOWN_PARAMETER_TYPE);
|
||||
return -2;
|
||||
}
|
||||
|
||||
static size_t kdf_sshkdf_size(EVP_KDF_IMPL *impl)
|
||||
{
|
||||
return SIZE_MAX;
|
||||
}
|
||||
|
||||
static int kdf_sshkdf_derive(EVP_KDF_IMPL *impl, unsigned char *key,
|
||||
size_t keylen)
|
||||
{
|
||||
if (impl->md == NULL) {
|
||||
KDFerr(KDF_F_KDF_SSHKDF_DERIVE, KDF_R_MISSING_MESSAGE_DIGEST);
|
||||
return 0;
|
||||
}
|
||||
if (impl->key == NULL) {
|
||||
KDFerr(KDF_F_KDF_SSHKDF_DERIVE, KDF_R_MISSING_KEY);
|
||||
return 0;
|
||||
}
|
||||
if (impl->xcghash == NULL) {
|
||||
KDFerr(KDF_F_KDF_SSHKDF_DERIVE, KDF_R_MISSING_XCGHASH);
|
||||
return 0;
|
||||
}
|
||||
if (impl->session_id == NULL) {
|
||||
KDFerr(KDF_F_KDF_SSHKDF_DERIVE, KDF_R_MISSING_SESSION_ID);
|
||||
return 0;
|
||||
}
|
||||
if (impl->type == 0) {
|
||||
KDFerr(KDF_F_KDF_SSHKDF_DERIVE, KDF_R_MISSING_TYPE);
|
||||
return 0;
|
||||
}
|
||||
return SSHKDF(impl->md, impl->key, impl->key_len,
|
||||
impl->xcghash, impl->xcghash_len,
|
||||
impl->session_id, impl->session_id_len,
|
||||
impl->type, key, keylen);
|
||||
}
|
||||
|
||||
const EVP_KDF_METHOD sshkdf_kdf_meth = {
|
||||
EVP_KDF_SSHKDF,
|
||||
kdf_sshkdf_new,
|
||||
kdf_sshkdf_free,
|
||||
kdf_sshkdf_reset,
|
||||
kdf_sshkdf_ctrl,
|
||||
kdf_sshkdf_ctrl_str,
|
||||
kdf_sshkdf_size,
|
||||
kdf_sshkdf_derive,
|
||||
};
|
||||
|
||||
static int SSHKDF(const EVP_MD *evp_md,
|
||||
const unsigned char *key, size_t key_len,
|
||||
const unsigned char *xcghash, size_t xcghash_len,
|
||||
const unsigned char *session_id, size_t session_id_len,
|
||||
char type, unsigned char *okey, size_t okey_len)
|
||||
{
|
||||
EVP_MD_CTX *md = NULL;
|
||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
||||
unsigned int dsize = 0;
|
||||
size_t cursize = 0;
|
||||
int ret = 0;
|
||||
|
||||
md = EVP_MD_CTX_new();
|
||||
if (md == NULL)
|
||||
return 0;
|
||||
|
||||
if (!EVP_DigestInit_ex(md, evp_md, NULL))
|
||||
goto out;
|
||||
|
||||
if (!EVP_DigestUpdate(md, key, key_len))
|
||||
goto out;
|
||||
|
||||
if (!EVP_DigestUpdate(md, xcghash, xcghash_len))
|
||||
goto out;
|
||||
|
||||
if (!EVP_DigestUpdate(md, &type, 1))
|
||||
goto out;
|
||||
|
||||
if (!EVP_DigestUpdate(md, session_id, session_id_len))
|
||||
goto out;
|
||||
|
||||
if (!EVP_DigestFinal_ex(md, digest, &dsize))
|
||||
goto out;
|
||||
|
||||
if (okey_len < dsize) {
|
||||
memcpy(okey, digest, okey_len);
|
||||
ret = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(okey, digest, dsize);
|
||||
|
||||
for (cursize = dsize; cursize < okey_len; cursize += dsize) {
|
||||
|
||||
if (!EVP_DigestInit_ex(md, evp_md, NULL))
|
||||
goto out;
|
||||
|
||||
if (!EVP_DigestUpdate(md, key, key_len))
|
||||
goto out;
|
||||
|
||||
if (!EVP_DigestUpdate(md, xcghash, xcghash_len))
|
||||
goto out;
|
||||
|
||||
if (!EVP_DigestUpdate(md, okey, cursize))
|
||||
goto out;
|
||||
|
||||
if (!EVP_DigestFinal_ex(md, digest, &dsize))
|
||||
goto out;
|
||||
|
||||
if (okey_len < cursize + dsize) {
|
||||
memcpy(okey + cursize, digest, okey_len - cursize);
|
||||
ret = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(okey + cursize, digest, dsize);
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
out:
|
||||
EVP_MD_CTX_free(md);
|
||||
OPENSSL_cleanse(digest, EVP_MAX_MD_SIZE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
+22
-3
@@ -223,7 +223,26 @@ int openssl_strerror_r(int errnum, char *buf, size_t buflen)
|
||||
#if defined(_MSC_VER) && _MSC_VER>=1400
|
||||
return !strerror_s(buf, buflen, errnum);
|
||||
#elif defined(_GNU_SOURCE)
|
||||
return strerror_r(errnum, buf, buflen) != NULL;
|
||||
char *err;
|
||||
|
||||
/*
|
||||
* GNU strerror_r may not actually set buf.
|
||||
* It can return a pointer to some (immutable) static string in which case
|
||||
* buf is left unused.
|
||||
*/
|
||||
err = strerror_r(errnum, buf, buflen);
|
||||
if (err == NULL)
|
||||
return 0;
|
||||
/*
|
||||
* If err is statically allocated, err != buf and we need to copy the data.
|
||||
* If err points somewhere inside buf, OPENSSL_strlcpy can handle this,
|
||||
* since src and dest are not annotated with __restrict and the function
|
||||
* reads src byte for byte and writes to dest.
|
||||
* If err == buf we do not have to copy anything.
|
||||
*/
|
||||
if (err != buf)
|
||||
OPENSSL_strlcpy(buf, err, buflen);
|
||||
return 1;
|
||||
#elif (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \
|
||||
(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600)
|
||||
/*
|
||||
@@ -234,6 +253,7 @@ int openssl_strerror_r(int errnum, char *buf, size_t buflen)
|
||||
return !strerror_r(errnum, buf, buflen);
|
||||
#else
|
||||
char *err;
|
||||
|
||||
/* Fall back to non-thread safe strerror()...its all we can do */
|
||||
if (buflen < 2)
|
||||
return 0;
|
||||
@@ -241,8 +261,7 @@ int openssl_strerror_r(int errnum, char *buf, size_t buflen)
|
||||
/* Can this ever happen? */
|
||||
if (err == NULL)
|
||||
return 0;
|
||||
strncpy(buf, err, buflen - 1);
|
||||
buf[buflen - 1] = '\0';
|
||||
OPENSSL_strlcpy(buf, err, buflen);
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
@@ -1079,7 +1079,7 @@ static const unsigned char so[7767] = {
|
||||
0x28,0xCC,0x45,0x03,0x04, /* [ 7761] OBJ_gmac */
|
||||
};
|
||||
|
||||
#define NUM_NID 1204
|
||||
#define NUM_NID 1205
|
||||
static const ASN1_OBJECT nid_objs[NUM_NID] = {
|
||||
{"UNDEF", "undefined", NID_undef},
|
||||
{"rsadsi", "RSA Data Security, Inc.", NID_rsadsi, 6, &so[0]},
|
||||
@@ -2284,10 +2284,11 @@ static const ASN1_OBJECT nid_objs[NUM_NID] = {
|
||||
{"AES-256-SIV", "aes-256-siv", NID_aes_256_siv},
|
||||
{"BLAKE2BMAC", "blake2bmac", NID_blake2bmac},
|
||||
{"BLAKE2SMAC", "blake2smac", NID_blake2smac},
|
||||
{"SSHKDF", "sshkdf", NID_sshkdf},
|
||||
{"ChaCha20-Poly1305-D", "chacha20-poly1305-draft", NID_chacha20_poly1305_draft},
|
||||
};
|
||||
|
||||
#define NUM_SN 1195
|
||||
#define NUM_SN 1196
|
||||
static const unsigned int sn_objs[NUM_SN] = {
|
||||
364, /* "AD_DVCS" */
|
||||
419, /* "AES-128-CBC" */
|
||||
@@ -2410,7 +2411,7 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
417, /* "CSPName" */
|
||||
1019, /* "ChaCha20" */
|
||||
1018, /* "ChaCha20-Poly1305" */
|
||||
1203, /* "ChaCha20-Poly1305-D" */
|
||||
1204, /* "ChaCha20-Poly1305-D" */
|
||||
367, /* "CrlID" */
|
||||
391, /* "DC" */
|
||||
31, /* "DES-CBC" */
|
||||
@@ -2574,6 +2575,7 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
167, /* "SMIME-CAPS" */
|
||||
100, /* "SN" */
|
||||
1006, /* "SNILS" */
|
||||
1203, /* "SSHKDF" */
|
||||
16, /* "ST" */
|
||||
143, /* "SXNetID" */
|
||||
1062, /* "SipHash" */
|
||||
@@ -3486,7 +3488,7 @@ static const unsigned int sn_objs[NUM_SN] = {
|
||||
1093, /* "x509ExtAdmission" */
|
||||
};
|
||||
|
||||
#define NUM_LN 1195
|
||||
#define NUM_LN 1196
|
||||
static const unsigned int ln_objs[NUM_LN] = {
|
||||
363, /* "AD Time Stamping" */
|
||||
405, /* "ANSI X9.62" */
|
||||
@@ -3870,7 +3872,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
883, /* "certificateRevocationList" */
|
||||
1019, /* "chacha20" */
|
||||
1018, /* "chacha20-poly1305" */
|
||||
1203, /* "chacha20-poly1305-draft" */
|
||||
1204, /* "chacha20-poly1305-draft" */
|
||||
54, /* "challengePassword" */
|
||||
407, /* "characteristic-two-field" */
|
||||
395, /* "clearance" */
|
||||
@@ -4637,6 +4639,7 @@ static const unsigned int ln_objs[NUM_LN] = {
|
||||
1139, /* "sm4-ctr" */
|
||||
1133, /* "sm4-ecb" */
|
||||
1135, /* "sm4-ofb" */
|
||||
1203, /* "sshkdf" */
|
||||
16, /* "stateOrProvinceName" */
|
||||
660, /* "streetAddress" */
|
||||
498, /* "subtreeMaximumQuality" */
|
||||
|
||||
@@ -1200,4 +1200,5 @@ aes_192_siv 1199
|
||||
aes_256_siv 1200
|
||||
blake2bmac 1201
|
||||
blake2smac 1202
|
||||
chacha20_poly1305_draft 1203
|
||||
sshkdf 1203
|
||||
chacha20_poly1305_draft 1204
|
||||
@@ -1610,6 +1610,9 @@ secg-scheme 14 3 : dhSinglePass-cofactorDH-sha512kdf-scheme
|
||||
# NID for HKDF
|
||||
: HKDF : hkdf
|
||||
|
||||
# NID for SSHKDF
|
||||
: SSHKDF : sshkdf
|
||||
|
||||
# RFC 4556
|
||||
1 3 6 1 5 2 3 : id-pkinit
|
||||
id-pkinit 4 : pkInitClientAuth : PKINIT Client Auth
|
||||
|
||||
@@ -28,7 +28,7 @@ static int i2r_object(const X509V3_EXT_METHOD *method, void *obj, BIO *out,
|
||||
int indent);
|
||||
|
||||
static void *ocsp_nonce_new(void);
|
||||
static int i2d_ocsp_nonce(void *a, unsigned char **pp);
|
||||
static int i2d_ocsp_nonce(const void *a, unsigned char **pp);
|
||||
static void *d2i_ocsp_nonce(void *a, const unsigned char **pp, long length);
|
||||
static void ocsp_nonce_free(void *a);
|
||||
static int i2r_ocsp_nonce(const X509V3_EXT_METHOD *method, void *nonce,
|
||||
@@ -170,9 +170,9 @@ static void *ocsp_nonce_new(void)
|
||||
return ASN1_OCTET_STRING_new();
|
||||
}
|
||||
|
||||
static int i2d_ocsp_nonce(void *a, unsigned char **pp)
|
||||
static int i2d_ocsp_nonce(const void *a, unsigned char **pp)
|
||||
{
|
||||
ASN1_OCTET_STRING *os = a;
|
||||
const ASN1_OCTET_STRING *os = a;
|
||||
if (pp) {
|
||||
memcpy(*pp, os->data, os->length);
|
||||
*pp += os->length;
|
||||
|
||||
+12
-12
@@ -16,12 +16,12 @@
|
||||
#include <openssl/pkcs12.h>
|
||||
#include <openssl/pem.h>
|
||||
|
||||
static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder,
|
||||
static int do_pk8pkey(BIO *bp, const EVP_PKEY *x, int isder,
|
||||
int nid, const EVP_CIPHER *enc,
|
||||
char *kstr, int klen, pem_password_cb *cb, void *u);
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder,
|
||||
static int do_pk8pkey_fp(FILE *bp, const EVP_PKEY *x, int isder,
|
||||
int nid, const EVP_CIPHER *enc,
|
||||
char *kstr, int klen, pem_password_cb *cb, void *u);
|
||||
#endif
|
||||
@@ -32,35 +32,35 @@ static int do_pk8pkey_fp(FILE *bp, EVP_PKEY *x, int isder,
|
||||
* uses PKCS#5 v1.5 PBE algorithms whereas the others use PKCS#5 v2.0.
|
||||
*/
|
||||
|
||||
int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
|
||||
int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, const EVP_PKEY *x, int nid,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u)
|
||||
{
|
||||
return do_pk8pkey(bp, x, 0, nid, NULL, kstr, klen, cb, u);
|
||||
}
|
||||
|
||||
int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
int PEM_write_bio_PKCS8PrivateKey(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u)
|
||||
{
|
||||
return do_pk8pkey(bp, x, 0, -1, enc, kstr, klen, cb, u);
|
||||
}
|
||||
|
||||
int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
int i2d_PKCS8PrivateKey_bio(BIO *bp, const EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u)
|
||||
{
|
||||
return do_pk8pkey(bp, x, 1, -1, enc, kstr, klen, cb, u);
|
||||
}
|
||||
|
||||
int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
|
||||
int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, const EVP_PKEY *x, int nid,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u)
|
||||
{
|
||||
return do_pk8pkey(bp, x, 1, nid, NULL, kstr, klen, cb, u);
|
||||
}
|
||||
|
||||
static int do_pk8pkey(BIO *bp, EVP_PKEY *x, int isder, int nid,
|
||||
static int do_pk8pkey(BIO *bp, const EVP_PKEY *x, int isder, int nid,
|
||||
const EVP_CIPHER *enc, char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u)
|
||||
{
|
||||
@@ -147,34 +147,34 @@ EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
|
||||
int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
int i2d_PKCS8PrivateKey_fp(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
char *kstr, int klen, pem_password_cb *cb, void *u)
|
||||
{
|
||||
return do_pk8pkey_fp(fp, x, 1, -1, enc, kstr, klen, cb, u);
|
||||
}
|
||||
|
||||
int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
|
||||
int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, const EVP_PKEY *x, int nid,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u)
|
||||
{
|
||||
return do_pk8pkey_fp(fp, x, 1, nid, NULL, kstr, klen, cb, u);
|
||||
}
|
||||
|
||||
int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
|
||||
int PEM_write_PKCS8PrivateKey_nid(FILE *fp, const EVP_PKEY *x, int nid,
|
||||
char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u)
|
||||
{
|
||||
return do_pk8pkey_fp(fp, x, 0, nid, NULL, kstr, klen, cb, u);
|
||||
}
|
||||
|
||||
int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
int PEM_write_PKCS8PrivateKey(FILE *fp, const EVP_PKEY *x, const EVP_CIPHER *enc,
|
||||
char *kstr, int klen, pem_password_cb *cb,
|
||||
void *u)
|
||||
{
|
||||
return do_pk8pkey_fp(fp, x, 0, -1, enc, kstr, klen, cb, u);
|
||||
}
|
||||
|
||||
static int do_pk8pkey_fp(FILE *fp, EVP_PKEY *x, int isder, int nid,
|
||||
static int do_pk8pkey_fp(FILE *fp, const EVP_PKEY *x, int isder, int nid,
|
||||
const EVP_CIPHER *enc, char *kstr, int klen,
|
||||
pem_password_cb *cb, void *u)
|
||||
{
|
||||
|
||||
@@ -10,11 +10,7 @@
|
||||
#include <stdio.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/pkcs12.h>
|
||||
|
||||
/* Define this to dump decrypted output to files called DERnnn */
|
||||
/*
|
||||
* #define OPENSSL_DEBUG_DECRYPT
|
||||
*/
|
||||
#include <openssl/trace.h>
|
||||
|
||||
/*
|
||||
* Encrypt/Decrypt a buffer based on password and algor, result in a
|
||||
@@ -95,18 +91,11 @@ void *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it,
|
||||
return NULL;
|
||||
}
|
||||
p = out;
|
||||
#ifdef OPENSSL_DEBUG_DECRYPT
|
||||
{
|
||||
FILE *op;
|
||||
|
||||
char fname[30];
|
||||
static int fnm = 1;
|
||||
sprintf(fname, "DER%d", fnm++);
|
||||
op = fopen(fname, "wb");
|
||||
fwrite(p, 1, outlen, op);
|
||||
fclose(op);
|
||||
}
|
||||
#endif
|
||||
OSSL_TRACE_BEGIN(PKCS12_DECRYPT) {
|
||||
BIO_printf(trc_out, "\n");
|
||||
BIO_dump(trc_out, out, outlen);
|
||||
BIO_printf(trc_out, "\n");
|
||||
} OSSL_TRACE_END(PKCS12_DECRYPT);
|
||||
ret = ASN1_item_d2i(NULL, &p, outlen, it);
|
||||
if (zbuf)
|
||||
OPENSSL_cleanse(out, outlen);
|
||||
|
||||
+15
-33
@@ -11,16 +11,7 @@
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/pkcs12.h>
|
||||
#include <openssl/bn.h>
|
||||
|
||||
/* Uncomment out this line to get debugging info about key generation */
|
||||
/*
|
||||
* #define OPENSSL_DEBUG_KEYGEN
|
||||
*/
|
||||
#ifdef OPENSSL_DEBUG_KEYGEN
|
||||
# include <openssl/bio.h>
|
||||
extern BIO *bio_err;
|
||||
void h__dump(unsigned char *p, int len);
|
||||
#endif
|
||||
#include <openssl/trace.h>
|
||||
|
||||
/* PKCS12 compatible key/IV generation */
|
||||
#ifndef min
|
||||
@@ -82,23 +73,22 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
|
||||
int i, j, u, v;
|
||||
int ret = 0;
|
||||
EVP_MD_CTX *ctx = NULL;
|
||||
#ifdef OPENSSL_DEBUG_KEYGEN
|
||||
unsigned char *tmpout = out;
|
||||
int tmpn = n;
|
||||
#endif
|
||||
|
||||
ctx = EVP_MD_CTX_new();
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
|
||||
#ifdef OPENSSL_DEBUG_KEYGEN
|
||||
fprintf(stderr, "KEYGEN DEBUG\n");
|
||||
fprintf(stderr, "ID %d, ITER %d\n", id, iter);
|
||||
fprintf(stderr, "Password (length %d):\n", passlen);
|
||||
h__dump(pass, passlen);
|
||||
fprintf(stderr, "Salt (length %d):\n", saltlen);
|
||||
h__dump(salt, saltlen);
|
||||
#endif
|
||||
OSSL_TRACE_BEGIN(PKCS12_KEYGEN) {
|
||||
BIO_printf(trc_out, "PKCS12_key_gen_uni(): ID %d, ITER %d\n", id, iter);
|
||||
BIO_printf(trc_out, "Password (length %d):\n", passlen);
|
||||
BIO_hex_string(trc_out, 0, passlen, pass, passlen);
|
||||
BIO_printf(trc_out, "\n");
|
||||
BIO_printf(trc_out, "Salt (length %d):\n", saltlen);
|
||||
BIO_hex_string(trc_out, 0, saltlen, salt, saltlen);
|
||||
BIO_printf(trc_out, "\n");
|
||||
} OSSL_TRACE_END(PKCS12_KEYGEN);
|
||||
v = EVP_MD_block_size(md_type);
|
||||
u = EVP_MD_size(md_type);
|
||||
if (u < 0 || v <= 0)
|
||||
@@ -136,10 +126,11 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
|
||||
}
|
||||
memcpy(out, Ai, min(n, u));
|
||||
if (u >= n) {
|
||||
#ifdef OPENSSL_DEBUG_KEYGEN
|
||||
fprintf(stderr, "Output KEY (length %d)\n", tmpn);
|
||||
h__dump(tmpout, tmpn);
|
||||
#endif
|
||||
OSSL_TRACE_BEGIN(PKCS12_KEYGEN) {
|
||||
BIO_printf(trc_out, "Output KEY (length %d)\n", tmpn);
|
||||
BIO_hex_string(trc_out, 0, tmpn, tmpout, tmpn);
|
||||
BIO_printf(trc_out, "\n");
|
||||
} OSSL_TRACE_END(PKCS12_KEYGEN);
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
@@ -172,12 +163,3 @@ int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef OPENSSL_DEBUG_KEYGEN
|
||||
void h__dump(unsigned char *p, int len)
|
||||
{
|
||||
for (; len--; p++)
|
||||
fprintf(stderr, "%02X", *p);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
#endif
|
||||
@@ -219,13 +219,13 @@ char *OPENSSL_uni2utf8(const unsigned char *uni, int unilen)
|
||||
return asctmp;
|
||||
}
|
||||
|
||||
int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12)
|
||||
int i2d_PKCS12_bio(BIO *bp, const PKCS12 *p12)
|
||||
{
|
||||
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(PKCS12), bp, p12);
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12)
|
||||
int i2d_PKCS12_fp(FILE *fp, const PKCS12 *p12)
|
||||
{
|
||||
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(PKCS12), fp, p12);
|
||||
}
|
||||
|
||||
@@ -544,6 +544,7 @@ int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* unfortunately cannot constify BIO_new_NDEF() due to this and CMS_stream() */
|
||||
int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7)
|
||||
{
|
||||
ASN1_OCTET_STRING *os = NULL;
|
||||
|
||||
@@ -131,7 +131,7 @@ static void impl_cache_free(QUERY *elem)
|
||||
OPENSSL_free(elem);
|
||||
}
|
||||
|
||||
static void alg_cleanup(size_t idx, ALGORITHM *a)
|
||||
static void alg_cleanup(ossl_uintmax_t idx, ALGORITHM *a)
|
||||
{
|
||||
if (a != NULL) {
|
||||
sk_IMPLEMENTATION_pop_free(a->impls, &impl_free);
|
||||
@@ -143,11 +143,12 @@ static void alg_cleanup(size_t idx, ALGORITHM *a)
|
||||
|
||||
OSSL_METHOD_STORE *ossl_method_store_new(void)
|
||||
{
|
||||
OSSL_METHOD_STORE *res = OPENSSL_zalloc(sizeof(*res));
|
||||
OSSL_METHOD_STORE *res;
|
||||
|
||||
if (!RUN_ONCE(&method_store_init_flag, do_method_store_init))
|
||||
return 0;
|
||||
|
||||
res = OPENSSL_zalloc(sizeof(*res));
|
||||
if (res != NULL) {
|
||||
if ((res->algs = ossl_sa_ALGORITHM_new()) == NULL) {
|
||||
OPENSSL_free(res);
|
||||
@@ -355,7 +356,7 @@ int ossl_method_store_set_global_properties(OSSL_METHOD_STORE *store,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void impl_cache_flush_alg(size_t idx, ALGORITHM *alg)
|
||||
static void impl_cache_flush_alg(ossl_uintmax_t idx, ALGORITHM *alg)
|
||||
{
|
||||
lh_QUERY_doall(alg->cache, &impl_cache_free);
|
||||
lh_QUERY_flush(alg->cache);
|
||||
@@ -412,7 +413,8 @@ static void impl_cache_flush_cache(QUERY *c, IMPL_CACHE_FLUSH *state)
|
||||
state->nelem++;
|
||||
}
|
||||
|
||||
static void impl_cache_flush_one_alg(size_t idx, ALGORITHM *alg, void *v)
|
||||
static void impl_cache_flush_one_alg(ossl_uintmax_t idx, ALGORITHM *alg,
|
||||
void *v)
|
||||
{
|
||||
IMPL_CACHE_FLUSH *state = (IMPL_CACHE_FLUSH *)v;
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ static OSSL_PROPERTY_LIST *stack_to_property_list(STACK_OF(PROPERTY_DEFINITION)
|
||||
int i;
|
||||
|
||||
r = OPENSSL_malloc(sizeof(*r)
|
||||
+ (n == 0 ? 0 : n - 1) * sizeof(r->properties[0]));
|
||||
+ (n <= 0 ? 0 : n - 1) * sizeof(r->properties[0]));
|
||||
if (r != NULL) {
|
||||
sk_PROPERTY_DEFINITION_sort(sk);
|
||||
|
||||
|
||||
+26
-3
@@ -19,7 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include "internal/dso.h"
|
||||
#if defined(__linux)
|
||||
# include <sys/syscall.h>
|
||||
# include <asm/unistd.h>
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
# include <sys/types.h>
|
||||
@@ -324,8 +324,8 @@ static ssize_t syscall_random(void *buf, size_t buflen)
|
||||
# endif
|
||||
|
||||
/* Linux supports this since version 3.17 */
|
||||
# if defined(__linux) && defined(SYS_getrandom)
|
||||
return syscall(SYS_getrandom, buf, buflen, 0);
|
||||
# if defined(__linux) && defined(__NR_getrandom)
|
||||
return syscall(__NR_getrandom, buf, buflen, 0);
|
||||
# elif (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(KERN_ARND)
|
||||
return sysctl_random(buf, buflen);
|
||||
# else
|
||||
@@ -510,6 +510,29 @@ size_t rand_pool_acquire_entropy(RAND_POOL *pool)
|
||||
bytes_needed = rand_pool_bytes_needed(pool, 1 /*entropy_factor*/);
|
||||
{
|
||||
size_t i;
|
||||
#ifdef DEVRANDOM_WAIT
|
||||
static int wait_done = 0;
|
||||
|
||||
/*
|
||||
* On some implementations reading from /dev/urandom is possible
|
||||
* before it is initialized. Therefore we wait for /dev/random
|
||||
* to be readable to make sure /dev/urandom is initialized.
|
||||
*/
|
||||
if (!wait_done && bytes_needed > 0) {
|
||||
int f = open(DEVRANDOM_WAIT, O_RDONLY);
|
||||
|
||||
if (f >= 0) {
|
||||
fd_set fds;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(f, &fds);
|
||||
while (select(f+1, &fds, NULL, NULL, NULL) < 0
|
||||
&& errno == EINTR);
|
||||
close(f);
|
||||
}
|
||||
wait_done = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; bytes_needed > 0 && i < OSSL_NELEM(random_device_paths); i++) {
|
||||
ssize_t bytes = 0;
|
||||
|
||||
@@ -106,16 +106,16 @@ ASN1_SEQUENCE_cb(RSA_OAEP_PARAMS, rsa_oaep_cb) = {
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)
|
||||
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPrivateKey, RSAPrivateKey)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(RSA, RSAPrivateKey, RSAPrivateKey)
|
||||
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(RSA, RSAPublicKey, RSAPublicKey)
|
||||
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(RSA, RSAPublicKey, RSAPublicKey)
|
||||
|
||||
RSA *RSAPublicKey_dup(RSA *rsa)
|
||||
RSA *RSAPublicKey_dup(const RSA *rsa)
|
||||
{
|
||||
return ASN1_item_dup(ASN1_ITEM_rptr(RSAPublicKey), rsa);
|
||||
}
|
||||
|
||||
RSA *RSAPrivateKey_dup(RSA *rsa)
|
||||
RSA *RSAPrivateKey_dup(const RSA *rsa)
|
||||
{
|
||||
return ASN1_item_dup(ASN1_ITEM_rptr(RSAPrivateKey), rsa);
|
||||
}
|
||||
@@ -70,7 +70,7 @@ static int pkey_rsa_init(EVP_PKEY_CTX *ctx)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pkey_rsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
|
||||
static int pkey_rsa_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src)
|
||||
{
|
||||
RSA_PKEY_CTX *dctx, *sctx;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ static void pkey_sm2_cleanup(EVP_PKEY_CTX *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static int pkey_sm2_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
|
||||
static int pkey_sm2_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src)
|
||||
{
|
||||
SM2_PKEY_CTX *dctx, *sctx;
|
||||
|
||||
@@ -248,6 +248,9 @@ static int pkey_sm2_ctrl_str(EVP_PKEY_CTX *ctx,
|
||||
else
|
||||
return -2;
|
||||
return EVP_PKEY_CTX_set_ec_param_enc(ctx, param_enc);
|
||||
} else if (strcmp(type, "sm2_id") == 0) {
|
||||
return pkey_sm2_ctrl(ctx, EVP_PKEY_CTRL_SET1_ID,
|
||||
(int)strlen(value), (void *)value);
|
||||
}
|
||||
|
||||
return -2;
|
||||
|
||||
+15
-13
@@ -29,7 +29,7 @@
|
||||
* at a cost in time.
|
||||
*
|
||||
* The library builder is also permitted to define other sizes in the closed
|
||||
* interval [2, sizeof(size_t) * 8].
|
||||
* interval [2, sizeof(ossl_uintmax_t) * 8].
|
||||
*/
|
||||
#ifndef OPENSSL_SA_BLOCK_BITS
|
||||
# ifdef OPENSSL_SMALL_FOOTPRINT
|
||||
@@ -49,13 +49,13 @@
|
||||
*/
|
||||
#define SA_BLOCK_MAX (1 << OPENSSL_SA_BLOCK_BITS)
|
||||
#define SA_BLOCK_MASK (SA_BLOCK_MAX - 1)
|
||||
#define SA_BLOCK_MAX_LEVELS (((int)sizeof(size_t) * 8 \
|
||||
#define SA_BLOCK_MAX_LEVELS (((int)sizeof(ossl_uintmax_t) * 8 \
|
||||
+ OPENSSL_SA_BLOCK_BITS - 1) \
|
||||
/ OPENSSL_SA_BLOCK_BITS)
|
||||
|
||||
struct sparse_array_st {
|
||||
int levels;
|
||||
size_t top;
|
||||
ossl_uintmax_t top;
|
||||
size_t nelem;
|
||||
void **nodes;
|
||||
};
|
||||
@@ -68,11 +68,11 @@ OPENSSL_SA *OPENSSL_SA_new(void)
|
||||
}
|
||||
|
||||
static void sa_doall(const OPENSSL_SA *sa, void (*node)(void **),
|
||||
void (*leaf)(size_t, void *, void *), void *arg)
|
||||
void (*leaf)(ossl_uintmax_t, void *, void *), void *arg)
|
||||
{
|
||||
int i[SA_BLOCK_MAX_LEVELS];
|
||||
void *nodes[SA_BLOCK_MAX_LEVELS];
|
||||
size_t idx = 0;
|
||||
ossl_uintmax_t idx = 0;
|
||||
int l = 0;
|
||||
|
||||
i[0] = 0;
|
||||
@@ -107,7 +107,7 @@ static void sa_free_node(void **p)
|
||||
OPENSSL_free(p);
|
||||
}
|
||||
|
||||
static void sa_free_leaf(size_t n, void *p, void *arg)
|
||||
static void sa_free_leaf(ossl_uintmax_t n, void *p, void *arg)
|
||||
{
|
||||
OPENSSL_free(p);
|
||||
}
|
||||
@@ -126,15 +126,16 @@ void OPENSSL_SA_free_leaves(OPENSSL_SA *sa)
|
||||
|
||||
/* Wrap this in a structure to avoid compiler warnings */
|
||||
struct trampoline_st {
|
||||
void (*func)(size_t, void *);
|
||||
void (*func)(ossl_uintmax_t, void *);
|
||||
};
|
||||
|
||||
static void trampoline(size_t n, void *l, void *arg)
|
||||
static void trampoline(ossl_uintmax_t n, void *l, void *arg)
|
||||
{
|
||||
((const struct trampoline_st *)arg)->func(n, l);
|
||||
}
|
||||
|
||||
void OPENSSL_SA_doall(const OPENSSL_SA *sa, void (*leaf)(size_t, void *))
|
||||
void OPENSSL_SA_doall(const OPENSSL_SA *sa, void (*leaf)(ossl_uintmax_t,
|
||||
void *))
|
||||
{
|
||||
struct trampoline_st tramp;
|
||||
|
||||
@@ -144,7 +145,8 @@ void OPENSSL_SA_doall(const OPENSSL_SA *sa, void (*leaf)(size_t, void *))
|
||||
}
|
||||
|
||||
void OPENSSL_SA_doall_arg(const OPENSSL_SA *sa,
|
||||
void (*leaf)(size_t, void *, void *), void *arg)
|
||||
void (*leaf)(ossl_uintmax_t, void *, void *),
|
||||
void *arg)
|
||||
{
|
||||
if (sa != NULL)
|
||||
sa_doall(sa, NULL, leaf, arg);
|
||||
@@ -155,7 +157,7 @@ size_t OPENSSL_SA_num(const OPENSSL_SA *sa)
|
||||
return sa == NULL ? 0 : sa->nelem;
|
||||
}
|
||||
|
||||
void *OPENSSL_SA_get(const OPENSSL_SA *sa, size_t n)
|
||||
void *OPENSSL_SA_get(const OPENSSL_SA *sa, ossl_uintmax_t n)
|
||||
{
|
||||
int level;
|
||||
void **p, *r = NULL;
|
||||
@@ -178,10 +180,10 @@ static ossl_inline void **alloc_node(void)
|
||||
return OPENSSL_zalloc(SA_BLOCK_MAX * sizeof(void *));
|
||||
}
|
||||
|
||||
int OPENSSL_SA_set(OPENSSL_SA *sa, size_t posn, void *val)
|
||||
int OPENSSL_SA_set(OPENSSL_SA *sa, ossl_uintmax_t posn, void *val)
|
||||
{
|
||||
int i, level = 1;
|
||||
size_t n = posn;
|
||||
ossl_uintmax_t n = posn;
|
||||
void **p;
|
||||
|
||||
if (sa == NULL)
|
||||
|
||||
+495
@@ -0,0 +1,495 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/trace.h>
|
||||
#include "internal/bio.h"
|
||||
#include "internal/nelem.h"
|
||||
#include "internal/cryptlib_int.h"
|
||||
|
||||
#include "e_os.h" /* strcasecmp for Windows */
|
||||
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
|
||||
static CRYPTO_RWLOCK *trace_lock = NULL;
|
||||
|
||||
static const BIO *current_channel = NULL;
|
||||
|
||||
/*-
|
||||
* INTERNAL TRACE CHANNEL IMPLEMENTATION
|
||||
*
|
||||
* For our own flexibility, all trace categories are associated with a
|
||||
* BIO sink object, also called the trace channel. Instead of a BIO object,
|
||||
* the application can also provide a callback function, in which case an
|
||||
* internal trace channel is attached, which simply calls the registered
|
||||
* callback function.
|
||||
*/
|
||||
static int trace_write(BIO *b, const char *buf,
|
||||
size_t num, size_t *written);
|
||||
static int trace_puts(BIO *b, const char *str);
|
||||
static long trace_ctrl(BIO *channel, int cmd, long argl, void *argp);
|
||||
static int trace_free(BIO *b);
|
||||
|
||||
static const BIO_METHOD trace_method = {
|
||||
BIO_TYPE_SOURCE_SINK,
|
||||
"trace",
|
||||
trace_write,
|
||||
NULL, /* old write */
|
||||
NULL, /* read_ex */
|
||||
NULL, /* read */
|
||||
trace_puts,
|
||||
NULL, /* gets */
|
||||
trace_ctrl, /* ctrl */
|
||||
NULL, /* create */
|
||||
trace_free, /* free */
|
||||
NULL, /* callback_ctrl */
|
||||
};
|
||||
|
||||
struct trace_data_st {
|
||||
OSSL_trace_cb callback;
|
||||
int category;
|
||||
void *data;
|
||||
};
|
||||
|
||||
static int trace_write(BIO *channel,
|
||||
const char *buf, size_t num, size_t *written)
|
||||
{
|
||||
struct trace_data_st *ctx = BIO_get_data(channel);
|
||||
size_t cnt = ctx->callback(buf, num, ctx->category, OSSL_TRACE_CTRL_DURING,
|
||||
ctx->data);
|
||||
|
||||
*written = cnt;
|
||||
return cnt != 0;
|
||||
}
|
||||
|
||||
static int trace_puts(BIO *channel, const char *str)
|
||||
{
|
||||
size_t written;
|
||||
|
||||
if (trace_write(channel, str, strlen(str), &written))
|
||||
return (int)written;
|
||||
|
||||
return EOF;
|
||||
}
|
||||
|
||||
static long trace_ctrl(BIO *channel, int cmd, long argl, void *argp)
|
||||
{
|
||||
struct trace_data_st *ctx = BIO_get_data(channel);
|
||||
|
||||
switch (cmd) {
|
||||
case OSSL_TRACE_CTRL_BEGIN:
|
||||
case OSSL_TRACE_CTRL_END:
|
||||
/* We know that the callback is likely to return 0 here */
|
||||
ctx->callback("", 0, ctx->category, cmd, ctx->data);
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return -2; /* Unsupported */
|
||||
}
|
||||
|
||||
static int trace_free(BIO *channel)
|
||||
{
|
||||
if (channel == NULL)
|
||||
return 0;
|
||||
OPENSSL_free(BIO_get_data(channel));
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* TRACE
|
||||
*/
|
||||
|
||||
/* Helper struct and macro to get name string to number mapping */
|
||||
struct trace_category_st {
|
||||
const char * const name;
|
||||
const int num;
|
||||
};
|
||||
#define TRACE_CATEGORY_(name) { #name, OSSL_TRACE_CATEGORY_##name }
|
||||
|
||||
static const struct trace_category_st trace_categories[] = {
|
||||
TRACE_CATEGORY_(ANY),
|
||||
TRACE_CATEGORY_(TRACE),
|
||||
TRACE_CATEGORY_(INIT),
|
||||
TRACE_CATEGORY_(TLS),
|
||||
TRACE_CATEGORY_(TLS_CIPHER),
|
||||
TRACE_CATEGORY_(ENGINE_CONF),
|
||||
TRACE_CATEGORY_(ENGINE_TABLE),
|
||||
TRACE_CATEGORY_(ENGINE_REF_COUNT),
|
||||
TRACE_CATEGORY_(PKCS5V2),
|
||||
TRACE_CATEGORY_(PKCS12_KEYGEN),
|
||||
TRACE_CATEGORY_(PKCS12_DECRYPT),
|
||||
TRACE_CATEGORY_(X509V3_POLICY),
|
||||
TRACE_CATEGORY_(BN_CTX),
|
||||
};
|
||||
|
||||
const char *OSSL_trace_get_category_name(int num)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < OSSL_NELEM(trace_categories); i++)
|
||||
if (trace_categories[i].num == num)
|
||||
return trace_categories[i].name;
|
||||
return NULL; /* not found */
|
||||
}
|
||||
|
||||
int OSSL_trace_get_category_num(const char *name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < OSSL_NELEM(trace_categories); i++)
|
||||
if (strcasecmp(name, trace_categories[i].name) == 0)
|
||||
return trace_categories[i].num;
|
||||
return -1; /* not found */
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
|
||||
/* We use one trace channel for each trace category */
|
||||
static struct {
|
||||
enum { t_channel, t_callback } type;
|
||||
BIO *bio;
|
||||
char *prefix;
|
||||
char *suffix;
|
||||
} trace_channels[OSSL_TRACE_CATEGORY_NUM] = {
|
||||
{ 0, NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
static int trace_attach_cb(int category, int type, const void *data)
|
||||
{
|
||||
switch (type) {
|
||||
case 0: /* Channel */
|
||||
OSSL_TRACE2(TRACE, "Attach channel %p to category '%s'\n",
|
||||
data, trace_categories[category].name);
|
||||
break;
|
||||
case 1: /* Prefix */
|
||||
OSSL_TRACE2(TRACE, "Attach prefix \"%s\" to category '%s'\n",
|
||||
(const char *)data, trace_categories[category].name);
|
||||
break;
|
||||
case 2: /* Suffix */
|
||||
OSSL_TRACE2(TRACE, "Attach suffix \"%s\" to category '%s'\n",
|
||||
(const char *)data, trace_categories[category].name);
|
||||
break;
|
||||
default: /* No clue */
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int trace_detach_cb(int category, int type, const void *data)
|
||||
{
|
||||
switch (type) {
|
||||
case 0: /* Channel */
|
||||
OSSL_TRACE2(TRACE, "Detach channel %p from category '%s'\n",
|
||||
data, trace_categories[category].name);
|
||||
break;
|
||||
case 1: /* Prefix */
|
||||
OSSL_TRACE2(TRACE, "Detach prefix \"%s\" from category '%s'\n",
|
||||
(const char *)data, trace_categories[category].name);
|
||||
break;
|
||||
case 2: /* Suffix */
|
||||
OSSL_TRACE2(TRACE, "Detach suffix \"%s\" from category '%s'\n",
|
||||
(const char *)data, trace_categories[category].name);
|
||||
break;
|
||||
default: /* No clue */
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int set_trace_data(int category, BIO **channel,
|
||||
const char **prefix, const char **suffix,
|
||||
int (*attach_cb)(int, int, const void *),
|
||||
int (*detach_cb)(int, int, const void *))
|
||||
{
|
||||
BIO *curr_channel = trace_channels[category].bio;
|
||||
char *curr_prefix = trace_channels[category].prefix;
|
||||
char *curr_suffix = trace_channels[category].suffix;
|
||||
|
||||
/* Make sure to run the detach callback first on all data */
|
||||
if (prefix != NULL && curr_prefix != NULL) {
|
||||
detach_cb(category, 1, curr_prefix);
|
||||
}
|
||||
|
||||
if (suffix != NULL && curr_suffix != NULL) {
|
||||
detach_cb(category, 2, curr_suffix);
|
||||
}
|
||||
|
||||
if (channel != NULL && curr_channel != NULL) {
|
||||
detach_cb(category, 0, curr_channel);
|
||||
}
|
||||
|
||||
/* After detach callbacks are done, clear data where appropriate */
|
||||
if (prefix != NULL && curr_prefix != NULL) {
|
||||
OPENSSL_free(curr_prefix);
|
||||
trace_channels[category].prefix = NULL;
|
||||
}
|
||||
|
||||
if (suffix != NULL && curr_suffix != NULL) {
|
||||
OPENSSL_free(curr_suffix);
|
||||
trace_channels[category].suffix = NULL;
|
||||
}
|
||||
|
||||
if (channel != NULL && curr_channel != NULL) {
|
||||
BIO_free(curr_channel);
|
||||
trace_channels[category].bio = NULL;
|
||||
}
|
||||
|
||||
/* Before running callbacks are done, set new data where appropriate */
|
||||
if (channel != NULL && *channel != NULL) {
|
||||
trace_channels[category].bio = *channel;
|
||||
}
|
||||
|
||||
if (prefix != NULL && *prefix != NULL) {
|
||||
if ((curr_prefix = OPENSSL_strdup(*prefix)) == NULL)
|
||||
return 0;
|
||||
trace_channels[category].prefix = curr_prefix;
|
||||
}
|
||||
|
||||
if (suffix != NULL && *suffix != NULL) {
|
||||
if ((curr_suffix = OPENSSL_strdup(*suffix)) == NULL)
|
||||
return 0;
|
||||
trace_channels[category].suffix = curr_suffix;
|
||||
}
|
||||
|
||||
/* Finally, run the attach callback on the new data */
|
||||
if (channel != NULL && *channel != NULL) {
|
||||
attach_cb(category, 0, *channel);
|
||||
}
|
||||
|
||||
if (prefix != NULL && *prefix != NULL) {
|
||||
attach_cb(category, 1, *prefix);
|
||||
}
|
||||
|
||||
if (suffix != NULL && *suffix != NULL) {
|
||||
attach_cb(category, 2, *suffix);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int ossl_trace_init(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
trace_lock = CRYPTO_THREAD_lock_new();
|
||||
if (trace_lock != NULL)
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ossl_trace_cleanup(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
int category;
|
||||
BIO *channel = NULL;
|
||||
const char *prefix = NULL;
|
||||
const char *suffix = NULL;
|
||||
|
||||
for (category = 0; category < OSSL_TRACE_CATEGORY_NUM; category++) {
|
||||
/* We force the TRACE category to be treated last */
|
||||
if (category == OSSL_TRACE_CATEGORY_TRACE)
|
||||
continue;
|
||||
set_trace_data(category, &channel, &prefix, &suffix,
|
||||
trace_attach_cb, trace_detach_cb);
|
||||
}
|
||||
set_trace_data(OSSL_TRACE_CATEGORY_TRACE, &channel, &prefix, &suffix,
|
||||
trace_attach_cb, trace_detach_cb);
|
||||
CRYPTO_THREAD_lock_free(trace_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
int OSSL_trace_set_channel(int category, BIO *channel)
|
||||
{
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
if (category < 0 || category >= OSSL_TRACE_CATEGORY_NUM
|
||||
|| !set_trace_data(category, &channel, NULL, NULL,
|
||||
trace_attach_cb, trace_detach_cb))
|
||||
goto err;
|
||||
|
||||
trace_channels[category].type = t_channel;
|
||||
return 1;
|
||||
|
||||
err:
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
static int trace_attach_w_callback_cb(int category, int type, const void *data)
|
||||
{
|
||||
switch (type) {
|
||||
case 0: /* Channel */
|
||||
OSSL_TRACE2(TRACE,
|
||||
"Attach channel %p to category '%s' (with callback)\n",
|
||||
data, trace_categories[category].name);
|
||||
break;
|
||||
case 1: /* Prefix */
|
||||
OSSL_TRACE2(TRACE, "Attach prefix \"%s\" to category '%s'\n",
|
||||
(const char *)data, trace_categories[category].name);
|
||||
break;
|
||||
case 2: /* Suffix */
|
||||
OSSL_TRACE2(TRACE, "Attach suffix \"%s\" to category '%s'\n",
|
||||
(const char *)data, trace_categories[category].name);
|
||||
break;
|
||||
default: /* No clue */
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int OSSL_trace_set_callback(int category, OSSL_trace_cb callback, void *data)
|
||||
{
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
BIO *channel = NULL;
|
||||
struct trace_data_st *trace_data = NULL;
|
||||
|
||||
if (category < 0 || category >= OSSL_TRACE_CATEGORY_NUM)
|
||||
goto err;
|
||||
|
||||
if (callback != NULL) {
|
||||
if ((channel = BIO_new(&trace_method)) == NULL
|
||||
|| (trace_data =
|
||||
OPENSSL_zalloc(sizeof(struct trace_data_st))) == NULL)
|
||||
goto err;
|
||||
|
||||
trace_data->callback = callback;
|
||||
trace_data->category = category;
|
||||
trace_data->data = data;
|
||||
|
||||
BIO_set_data(channel, trace_data);
|
||||
}
|
||||
|
||||
if (!set_trace_data(category, &channel, NULL, NULL,
|
||||
trace_attach_w_callback_cb, trace_detach_cb))
|
||||
goto err;
|
||||
|
||||
trace_channels[category].type = t_callback;
|
||||
return 1;
|
||||
|
||||
err:
|
||||
BIO_free(channel);
|
||||
OPENSSL_free(trace_data);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OSSL_trace_set_prefix(int category, const char *prefix)
|
||||
{
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
if (category >= 0 || category < OSSL_TRACE_CATEGORY_NUM)
|
||||
return set_trace_data(category, NULL, &prefix, NULL,
|
||||
trace_attach_cb, trace_detach_cb);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OSSL_trace_set_suffix(int category, const char *suffix)
|
||||
{
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
if (category >= 0 || category < OSSL_TRACE_CATEGORY_NUM)
|
||||
return set_trace_data(category, NULL, NULL, &suffix,
|
||||
trace_attach_cb, trace_detach_cb);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
static int ossl_trace_get_category(int category)
|
||||
{
|
||||
if (category < 0 || category >= OSSL_TRACE_CATEGORY_NUM)
|
||||
return -1;
|
||||
if (trace_channels[category].bio != NULL)
|
||||
return category;
|
||||
return OSSL_TRACE_CATEGORY_ANY;
|
||||
}
|
||||
#endif
|
||||
|
||||
int OSSL_trace_enabled(int category)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
category = ossl_trace_get_category(category);
|
||||
ret = trace_channels[category].bio != NULL;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
BIO *OSSL_trace_begin(int category)
|
||||
{
|
||||
BIO *channel = NULL;
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
char *prefix = NULL;
|
||||
|
||||
category = ossl_trace_get_category(category);
|
||||
channel = trace_channels[category].bio;
|
||||
prefix = trace_channels[category].prefix;
|
||||
|
||||
if (channel != NULL) {
|
||||
CRYPTO_THREAD_write_lock(trace_lock);
|
||||
current_channel = channel;
|
||||
switch (trace_channels[category].type) {
|
||||
case t_channel:
|
||||
if (prefix != NULL) {
|
||||
(void)BIO_puts(channel, prefix);
|
||||
(void)BIO_puts(channel, "\n");
|
||||
}
|
||||
break;
|
||||
case t_callback:
|
||||
(void)BIO_ctrl(channel, OSSL_TRACE_CTRL_BEGIN,
|
||||
prefix == NULL ? 0 : strlen(prefix), prefix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return channel;
|
||||
}
|
||||
|
||||
void OSSL_trace_end(int category, BIO * channel)
|
||||
{
|
||||
#ifndef OPENSSL_NO_TRACE
|
||||
char *suffix = NULL;
|
||||
|
||||
category = ossl_trace_get_category(category);
|
||||
suffix = trace_channels[category].suffix;
|
||||
if (channel != NULL
|
||||
&& ossl_assert(channel == current_channel)) {
|
||||
(void)BIO_flush(channel);
|
||||
switch (trace_channels[category].type) {
|
||||
case t_channel:
|
||||
if (suffix != NULL) {
|
||||
(void)BIO_puts(channel, suffix);
|
||||
(void)BIO_puts(channel, "\n");
|
||||
}
|
||||
break;
|
||||
case t_callback:
|
||||
(void)BIO_ctrl(channel, OSSL_TRACE_CTRL_END,
|
||||
suffix == NULL ? 0 : strlen(suffix), suffix);
|
||||
break;
|
||||
}
|
||||
current_channel = NULL;
|
||||
CRYPTO_THREAD_unlock(trace_lock);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+22
-22
@@ -17,7 +17,7 @@ ASN1_SEQUENCE(TS_MSG_IMPRINT) = {
|
||||
ASN1_SIMPLE(TS_MSG_IMPRINT, hashed_msg, ASN1_OCTET_STRING)
|
||||
} static_ASN1_SEQUENCE_END(TS_MSG_IMPRINT)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(TS_MSG_IMPRINT)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(TS_MSG_IMPRINT)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(TS_MSG_IMPRINT)
|
||||
TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bp, TS_MSG_IMPRINT **a)
|
||||
{
|
||||
@@ -25,9 +25,9 @@ TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bp, TS_MSG_IMPRINT **a)
|
||||
d2i_TS_MSG_IMPRINT, bp, a);
|
||||
}
|
||||
|
||||
int i2d_TS_MSG_IMPRINT_bio(BIO *bp, TS_MSG_IMPRINT *a)
|
||||
int i2d_TS_MSG_IMPRINT_bio(BIO *bp, const TS_MSG_IMPRINT *a)
|
||||
{
|
||||
return ASN1_i2d_bio_of_const(TS_MSG_IMPRINT, i2d_TS_MSG_IMPRINT, bp, a);
|
||||
return ASN1_i2d_bio_of(TS_MSG_IMPRINT, i2d_TS_MSG_IMPRINT, bp, a);
|
||||
}
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a)
|
||||
@@ -36,9 +36,9 @@ TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a)
|
||||
d2i_TS_MSG_IMPRINT, fp, a);
|
||||
}
|
||||
|
||||
int i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a)
|
||||
int i2d_TS_MSG_IMPRINT_fp(FILE *fp, const TS_MSG_IMPRINT *a)
|
||||
{
|
||||
return ASN1_i2d_fp_of_const(TS_MSG_IMPRINT, i2d_TS_MSG_IMPRINT, fp, a);
|
||||
return ASN1_i2d_fp_of(TS_MSG_IMPRINT, i2d_TS_MSG_IMPRINT, fp, a);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -51,16 +51,16 @@ ASN1_SEQUENCE(TS_REQ) = {
|
||||
ASN1_IMP_SEQUENCE_OF_OPT(TS_REQ, extensions, X509_EXTENSION, 0)
|
||||
} static_ASN1_SEQUENCE_END(TS_REQ)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(TS_REQ)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(TS_REQ)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(TS_REQ)
|
||||
TS_REQ *d2i_TS_REQ_bio(BIO *bp, TS_REQ **a)
|
||||
{
|
||||
return ASN1_d2i_bio_of(TS_REQ, TS_REQ_new, d2i_TS_REQ, bp, a);
|
||||
}
|
||||
|
||||
int i2d_TS_REQ_bio(BIO *bp, TS_REQ *a)
|
||||
int i2d_TS_REQ_bio(BIO *bp, const TS_REQ *a)
|
||||
{
|
||||
return ASN1_i2d_bio_of_const(TS_REQ, i2d_TS_REQ, bp, a);
|
||||
return ASN1_i2d_bio_of(TS_REQ, i2d_TS_REQ, bp, a);
|
||||
}
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a)
|
||||
@@ -68,9 +68,9 @@ TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a)
|
||||
return ASN1_d2i_fp_of(TS_REQ, TS_REQ_new, d2i_TS_REQ, fp, a);
|
||||
}
|
||||
|
||||
int i2d_TS_REQ_fp(FILE *fp, TS_REQ *a)
|
||||
int i2d_TS_REQ_fp(FILE *fp, const TS_REQ *a)
|
||||
{
|
||||
return ASN1_i2d_fp_of_const(TS_REQ, i2d_TS_REQ, fp, a);
|
||||
return ASN1_i2d_fp_of(TS_REQ, i2d_TS_REQ, fp, a);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -80,7 +80,7 @@ ASN1_SEQUENCE(TS_ACCURACY) = {
|
||||
ASN1_IMP_OPT(TS_ACCURACY, micros, ASN1_INTEGER, 1)
|
||||
} static_ASN1_SEQUENCE_END(TS_ACCURACY)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(TS_ACCURACY)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(TS_ACCURACY)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(TS_ACCURACY)
|
||||
|
||||
ASN1_SEQUENCE(TS_TST_INFO) = {
|
||||
@@ -96,7 +96,7 @@ ASN1_SEQUENCE(TS_TST_INFO) = {
|
||||
ASN1_IMP_SEQUENCE_OF_OPT(TS_TST_INFO, extensions, X509_EXTENSION, 1)
|
||||
} static_ASN1_SEQUENCE_END(TS_TST_INFO)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(TS_TST_INFO)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(TS_TST_INFO)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(TS_TST_INFO)
|
||||
TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bp, TS_TST_INFO **a)
|
||||
{
|
||||
@@ -104,9 +104,9 @@ TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bp, TS_TST_INFO **a)
|
||||
a);
|
||||
}
|
||||
|
||||
int i2d_TS_TST_INFO_bio(BIO *bp, TS_TST_INFO *a)
|
||||
int i2d_TS_TST_INFO_bio(BIO *bp, const TS_TST_INFO *a)
|
||||
{
|
||||
return ASN1_i2d_bio_of_const(TS_TST_INFO, i2d_TS_TST_INFO, bp, a);
|
||||
return ASN1_i2d_bio_of(TS_TST_INFO, i2d_TS_TST_INFO, bp, a);
|
||||
}
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a)
|
||||
@@ -115,9 +115,9 @@ TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a)
|
||||
a);
|
||||
}
|
||||
|
||||
int i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a)
|
||||
int i2d_TS_TST_INFO_fp(FILE *fp, const TS_TST_INFO *a)
|
||||
{
|
||||
return ASN1_i2d_fp_of_const(TS_TST_INFO, i2d_TS_TST_INFO, fp, a);
|
||||
return ASN1_i2d_fp_of(TS_TST_INFO, i2d_TS_TST_INFO, fp, a);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -127,7 +127,7 @@ ASN1_SEQUENCE(TS_STATUS_INFO) = {
|
||||
ASN1_OPT(TS_STATUS_INFO, failure_info, ASN1_BIT_STRING)
|
||||
} static_ASN1_SEQUENCE_END(TS_STATUS_INFO)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(TS_STATUS_INFO)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(TS_STATUS_INFO)
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(TS_STATUS_INFO)
|
||||
|
||||
static int ts_resp_set_tst_info(TS_RESP *a)
|
||||
@@ -176,7 +176,7 @@ ASN1_SEQUENCE_cb(TS_RESP, ts_resp_cb) = {
|
||||
ASN1_OPT(TS_RESP, token, PKCS7),
|
||||
} static_ASN1_SEQUENCE_END_cb(TS_RESP, TS_RESP)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS_const(TS_RESP)
|
||||
IMPLEMENT_ASN1_FUNCTIONS(TS_RESP)
|
||||
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(TS_RESP)
|
||||
|
||||
@@ -185,9 +185,9 @@ TS_RESP *d2i_TS_RESP_bio(BIO *bp, TS_RESP **a)
|
||||
return ASN1_d2i_bio_of(TS_RESP, TS_RESP_new, d2i_TS_RESP, bp, a);
|
||||
}
|
||||
|
||||
int i2d_TS_RESP_bio(BIO *bp, TS_RESP *a)
|
||||
int i2d_TS_RESP_bio(BIO *bp, const TS_RESP *a)
|
||||
{
|
||||
return ASN1_i2d_bio_of_const(TS_RESP, i2d_TS_RESP, bp, a);
|
||||
return ASN1_i2d_bio_of(TS_RESP, i2d_TS_RESP, bp, a);
|
||||
}
|
||||
#ifndef OPENSSL_NO_STDIO
|
||||
TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a)
|
||||
@@ -195,9 +195,9 @@ TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a)
|
||||
return ASN1_d2i_fp_of(TS_RESP, TS_RESP_new, d2i_TS_RESP, fp, a);
|
||||
}
|
||||
|
||||
int i2d_TS_RESP_fp(FILE *fp, TS_RESP *a)
|
||||
int i2d_TS_RESP_fp(FILE *fp, const TS_RESP *a)
|
||||
{
|
||||
return ASN1_i2d_fp_of_const(TS_RESP, i2d_TS_RESP, fp, a);
|
||||
return ASN1_i2d_fp_of(TS_RESP, i2d_TS_RESP, fp, a);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+34
-34
@@ -112,7 +112,7 @@ X509 *d2i_X509_fp(FILE *fp, X509 **x509)
|
||||
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509), fp, x509);
|
||||
}
|
||||
|
||||
int i2d_X509_fp(FILE *fp, X509 *x509)
|
||||
int i2d_X509_fp(FILE *fp, const X509 *x509)
|
||||
{
|
||||
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509), fp, x509);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ X509 *d2i_X509_bio(BIO *bp, X509 **x509)
|
||||
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509), bp, x509);
|
||||
}
|
||||
|
||||
int i2d_X509_bio(BIO *bp, X509 *x509)
|
||||
int i2d_X509_bio(BIO *bp, const X509 *x509)
|
||||
{
|
||||
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509), bp, x509);
|
||||
}
|
||||
@@ -134,7 +134,7 @@ X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl)
|
||||
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509_CRL), fp, crl);
|
||||
}
|
||||
|
||||
int i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl)
|
||||
int i2d_X509_CRL_fp(FILE *fp, const X509_CRL *crl)
|
||||
{
|
||||
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509_CRL), fp, crl);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl)
|
||||
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509_CRL), bp, crl);
|
||||
}
|
||||
|
||||
int i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl)
|
||||
int i2d_X509_CRL_bio(BIO *bp, const X509_CRL *crl)
|
||||
{
|
||||
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509_CRL), bp, crl);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7)
|
||||
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(PKCS7), fp, p7);
|
||||
}
|
||||
|
||||
int i2d_PKCS7_fp(FILE *fp, PKCS7 *p7)
|
||||
int i2d_PKCS7_fp(FILE *fp, const PKCS7 *p7)
|
||||
{
|
||||
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(PKCS7), fp, p7);
|
||||
}
|
||||
@@ -167,7 +167,7 @@ PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7)
|
||||
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(PKCS7), bp, p7);
|
||||
}
|
||||
|
||||
int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7)
|
||||
int i2d_PKCS7_bio(BIO *bp, const PKCS7 *p7)
|
||||
{
|
||||
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(PKCS7), bp, p7);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req)
|
||||
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(X509_REQ), fp, req);
|
||||
}
|
||||
|
||||
int i2d_X509_REQ_fp(FILE *fp, X509_REQ *req)
|
||||
int i2d_X509_REQ_fp(FILE *fp, const X509_REQ *req)
|
||||
{
|
||||
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(X509_REQ), fp, req);
|
||||
}
|
||||
@@ -189,7 +189,7 @@ X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req)
|
||||
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509_REQ), bp, req);
|
||||
}
|
||||
|
||||
int i2d_X509_REQ_bio(BIO *bp, X509_REQ *req)
|
||||
int i2d_X509_REQ_bio(BIO *bp, const X509_REQ *req)
|
||||
{
|
||||
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(X509_REQ), bp, req);
|
||||
}
|
||||
@@ -202,7 +202,7 @@ RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa)
|
||||
return ASN1_item_d2i_fp(ASN1_ITEM_rptr(RSAPrivateKey), fp, rsa);
|
||||
}
|
||||
|
||||
int i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa)
|
||||
int i2d_RSAPrivateKey_fp(FILE *fp, const RSA *rsa)
|
||||
{
|
||||
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(RSAPrivateKey), fp, rsa);
|
||||
}
|
||||
@@ -219,12 +219,12 @@ RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa)
|
||||
(void **)rsa);
|
||||
}
|
||||
|
||||
int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa)
|
||||
int i2d_RSAPublicKey_fp(FILE *fp, const RSA *rsa)
|
||||
{
|
||||
return ASN1_item_i2d_fp(ASN1_ITEM_rptr(RSAPublicKey), fp, rsa);
|
||||
}
|
||||
|
||||
int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa)
|
||||
int i2d_RSA_PUBKEY_fp(FILE *fp, const RSA *rsa)
|
||||
{
|
||||
return ASN1_i2d_fp((I2D_OF(void))i2d_RSA_PUBKEY, fp, rsa);
|
||||
}
|
||||
@@ -235,7 +235,7 @@ RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa)
|
||||
return ASN1_item_d2i_bio(ASN1_ITEM_rptr(RSAPrivateKey), bp, rsa);
|
||||
}
|
||||
|
||||
int i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa)
|
||||
int i2d_RSAPrivateKey_bio(BIO *bp, const RSA *rsa)
|
||||
{
|
||||
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(RSAPrivateKey), bp, rsa);
|
||||
}
|
||||
@@ -250,12 +250,12 @@ RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa)
|
||||
return ASN1_d2i_bio_of(RSA, RSA_new, d2i_RSA_PUBKEY, bp, rsa);
|
||||
}
|
||||
|
||||
int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa)
|
||||
int i2d_RSAPublicKey_bio(BIO *bp, const RSA *rsa)
|
||||
{
|
||||
return ASN1_item_i2d_bio(ASN1_ITEM_rptr(RSAPublicKey), bp, rsa);
|
||||
}
|
||||
|
||||
int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa)
|
||||
int i2d_RSA_PUBKEY_bio(BIO *bp, const RSA *rsa)
|
||||
{
|
||||
return ASN1_i2d_bio_of(RSA, i2d_RSA_PUBKEY, bp, rsa);
|
||||
}
|
||||
@@ -268,9 +268,9 @@ DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa)
|
||||
return ASN1_d2i_fp_of(DSA, DSA_new, d2i_DSAPrivateKey, fp, dsa);
|
||||
}
|
||||
|
||||
int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa)
|
||||
int i2d_DSAPrivateKey_fp(FILE *fp, const DSA *dsa)
|
||||
{
|
||||
return ASN1_i2d_fp_of_const(DSA, i2d_DSAPrivateKey, fp, dsa);
|
||||
return ASN1_i2d_fp_of(DSA, i2d_DSAPrivateKey, fp, dsa);
|
||||
}
|
||||
|
||||
DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa)
|
||||
@@ -278,7 +278,7 @@ DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa)
|
||||
return ASN1_d2i_fp_of(DSA, DSA_new, d2i_DSA_PUBKEY, fp, dsa);
|
||||
}
|
||||
|
||||
int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa)
|
||||
int i2d_DSA_PUBKEY_fp(FILE *fp, const DSA *dsa)
|
||||
{
|
||||
return ASN1_i2d_fp_of(DSA, i2d_DSA_PUBKEY, fp, dsa);
|
||||
}
|
||||
@@ -289,9 +289,9 @@ DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa)
|
||||
return ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSAPrivateKey, bp, dsa);
|
||||
}
|
||||
|
||||
int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa)
|
||||
int i2d_DSAPrivateKey_bio(BIO *bp, const DSA *dsa)
|
||||
{
|
||||
return ASN1_i2d_bio_of_const(DSA, i2d_DSAPrivateKey, bp, dsa);
|
||||
return ASN1_i2d_bio_of(DSA, i2d_DSAPrivateKey, bp, dsa);
|
||||
}
|
||||
|
||||
DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa)
|
||||
@@ -299,7 +299,7 @@ DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa)
|
||||
return ASN1_d2i_bio_of(DSA, DSA_new, d2i_DSA_PUBKEY, bp, dsa);
|
||||
}
|
||||
|
||||
int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa)
|
||||
int i2d_DSA_PUBKEY_bio(BIO *bp, const DSA *dsa)
|
||||
{
|
||||
return ASN1_i2d_bio_of(DSA, i2d_DSA_PUBKEY, bp, dsa);
|
||||
}
|
||||
@@ -313,7 +313,7 @@ EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey)
|
||||
return ASN1_d2i_fp_of(EC_KEY, EC_KEY_new, d2i_EC_PUBKEY, fp, eckey);
|
||||
}
|
||||
|
||||
int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey)
|
||||
int i2d_EC_PUBKEY_fp(FILE *fp, const EC_KEY *eckey)
|
||||
{
|
||||
return ASN1_i2d_fp_of(EC_KEY, i2d_EC_PUBKEY, fp, eckey);
|
||||
}
|
||||
@@ -323,7 +323,7 @@ EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey)
|
||||
return ASN1_d2i_fp_of(EC_KEY, EC_KEY_new, d2i_ECPrivateKey, fp, eckey);
|
||||
}
|
||||
|
||||
int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey)
|
||||
int i2d_ECPrivateKey_fp(FILE *fp, const EC_KEY *eckey)
|
||||
{
|
||||
return ASN1_i2d_fp_of(EC_KEY, i2d_ECPrivateKey, fp, eckey);
|
||||
}
|
||||
@@ -333,7 +333,7 @@ EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey)
|
||||
return ASN1_d2i_bio_of(EC_KEY, EC_KEY_new, d2i_EC_PUBKEY, bp, eckey);
|
||||
}
|
||||
|
||||
int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *ecdsa)
|
||||
int i2d_EC_PUBKEY_bio(BIO *bp, const EC_KEY *ecdsa)
|
||||
{
|
||||
return ASN1_i2d_bio_of(EC_KEY, i2d_EC_PUBKEY, bp, ecdsa);
|
||||
}
|
||||
@@ -343,7 +343,7 @@ EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey)
|
||||
return ASN1_d2i_bio_of(EC_KEY, EC_KEY_new, d2i_ECPrivateKey, bp, eckey);
|
||||
}
|
||||
|
||||
int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey)
|
||||
int i2d_ECPrivateKey_bio(BIO *bp, const EC_KEY *eckey)
|
||||
{
|
||||
return ASN1_i2d_bio_of(EC_KEY, i2d_ECPrivateKey, bp, eckey);
|
||||
}
|
||||
@@ -415,7 +415,7 @@ X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8)
|
||||
return ASN1_d2i_fp_of(X509_SIG, X509_SIG_new, d2i_X509_SIG, fp, p8);
|
||||
}
|
||||
|
||||
int i2d_PKCS8_fp(FILE *fp, X509_SIG *p8)
|
||||
int i2d_PKCS8_fp(FILE *fp, const X509_SIG *p8)
|
||||
{
|
||||
return ASN1_i2d_fp_of(X509_SIG, i2d_X509_SIG, fp, p8);
|
||||
}
|
||||
@@ -426,7 +426,7 @@ X509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8)
|
||||
return ASN1_d2i_bio_of(X509_SIG, X509_SIG_new, d2i_X509_SIG, bp, p8);
|
||||
}
|
||||
|
||||
int i2d_PKCS8_bio(BIO *bp, X509_SIG *p8)
|
||||
int i2d_PKCS8_bio(BIO *bp, const X509_SIG *p8)
|
||||
{
|
||||
return ASN1_i2d_bio_of(X509_SIG, i2d_X509_SIG, bp, p8);
|
||||
}
|
||||
@@ -439,13 +439,13 @@ PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
|
||||
d2i_PKCS8_PRIV_KEY_INFO, fp, p8inf);
|
||||
}
|
||||
|
||||
int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf)
|
||||
int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, const PKCS8_PRIV_KEY_INFO *p8inf)
|
||||
{
|
||||
return ASN1_i2d_fp_of(PKCS8_PRIV_KEY_INFO, i2d_PKCS8_PRIV_KEY_INFO, fp,
|
||||
p8inf);
|
||||
}
|
||||
|
||||
int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key)
|
||||
int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, const EVP_PKEY *key)
|
||||
{
|
||||
PKCS8_PRIV_KEY_INFO *p8inf;
|
||||
int ret;
|
||||
@@ -457,7 +457,7 @@ int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey)
|
||||
int i2d_PrivateKey_fp(FILE *fp, const EVP_PKEY *pkey)
|
||||
{
|
||||
return ASN1_i2d_fp_of(EVP_PKEY, i2d_PrivateKey, fp, pkey);
|
||||
}
|
||||
@@ -467,7 +467,7 @@ EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a)
|
||||
return ASN1_d2i_fp_of(EVP_PKEY, EVP_PKEY_new, d2i_AutoPrivateKey, fp, a);
|
||||
}
|
||||
|
||||
int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey)
|
||||
int i2d_PUBKEY_fp(FILE *fp, const EVP_PKEY *pkey)
|
||||
{
|
||||
return ASN1_i2d_fp_of(EVP_PKEY, i2d_PUBKEY, fp, pkey);
|
||||
}
|
||||
@@ -486,13 +486,13 @@ PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
|
||||
d2i_PKCS8_PRIV_KEY_INFO, bp, p8inf);
|
||||
}
|
||||
|
||||
int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf)
|
||||
int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, const PKCS8_PRIV_KEY_INFO *p8inf)
|
||||
{
|
||||
return ASN1_i2d_bio_of(PKCS8_PRIV_KEY_INFO, i2d_PKCS8_PRIV_KEY_INFO, bp,
|
||||
p8inf);
|
||||
}
|
||||
|
||||
int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key)
|
||||
int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, const EVP_PKEY *key)
|
||||
{
|
||||
PKCS8_PRIV_KEY_INFO *p8inf;
|
||||
int ret;
|
||||
@@ -504,7 +504,7 @@ int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey)
|
||||
int i2d_PrivateKey_bio(BIO *bp, const EVP_PKEY *pkey)
|
||||
{
|
||||
return ASN1_i2d_bio_of(EVP_PKEY, i2d_PrivateKey, bp, pkey);
|
||||
}
|
||||
@@ -514,7 +514,7 @@ EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a)
|
||||
return ASN1_d2i_bio_of(EVP_PKEY, EVP_PKEY_new, d2i_AutoPrivateKey, bp, a);
|
||||
}
|
||||
|
||||
int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey)
|
||||
int i2d_PUBKEY_bio(BIO *bp, const EVP_PKEY *pkey)
|
||||
{
|
||||
return ASN1_i2d_bio_of(EVP_PKEY, i2d_PUBKEY, bp, pkey);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user