apply patches to original opensource openssl-3.5.0. NOTE: This commit will NOT COMPILE. (#17)
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/17 Co-authored-by: siddhant <siddhant.singh@neominds.in> Co-committed-by: siddhant <siddhant.singh@neominds.in>
This commit is contained in:
@@ -2050,6 +2050,102 @@ my %targets = (
|
||||
perlasm_scheme => "o32",
|
||||
ranlib => "ranlibmips",
|
||||
},
|
||||
"vxworks-32" => {
|
||||
inherit_from => [ "BASE_unix" ],
|
||||
CC => "dummy",
|
||||
CFLAGS => picker(debug => "-O0 -g",
|
||||
release => "-O2"),
|
||||
cppflags => combine("\$(VSB_CONFIG_FILE_MACRO)"),
|
||||
cflags => "",
|
||||
sys_id => "VXWORKS",
|
||||
bn_ops => "RC4_CHAR",
|
||||
dso_scheme => "dlfcn",
|
||||
shared_target => "linux-shared",
|
||||
shared_ldflag => "-shared",
|
||||
shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
|
||||
thread_scheme => "vxtasks",
|
||||
},
|
||||
"vxworks-64" => {
|
||||
inherit_from => [ "vxworks-32" ],
|
||||
bn_ops => "SIXTY_FOUR_BIT_LONG",
|
||||
},
|
||||
"vxworks-x86" => {
|
||||
inherit_from => [ "vxworks-32" ],
|
||||
bn_ops => "BN_LLONG",
|
||||
asm_arch => 'vx_x86',
|
||||
perlasm_scheme => "elf",
|
||||
},
|
||||
"vxworks-x86-64" => {
|
||||
inherit_from => [ "vxworks-64" ],
|
||||
bn_ops => "SIXTY_FOUR_BIT_LONG",
|
||||
asm_arch => 'vx_x86_64',
|
||||
perlasm_scheme => "elf",
|
||||
},
|
||||
"vxworks-arm32" => {
|
||||
inherit_from => [ "vxworks-32" ],
|
||||
asm_arch => 'vx_armv4',
|
||||
perlasm_scheme => "void",
|
||||
},
|
||||
"vxworks-arm32-thumb" => {
|
||||
inherit_from => [ "vxworks-32" ],
|
||||
asm_arch => 'vx_armv4_thumb',
|
||||
perlasm_scheme => "void",
|
||||
},
|
||||
"vxworks-arm32-armv7m" => {
|
||||
inherit_from => [ "vxworks-32"],
|
||||
},
|
||||
"vxworks-arm32-armv7a" => {
|
||||
inherit_from => [ "vxworks-32" ],
|
||||
asm_arch => 'vx_armv7a',
|
||||
perlasm_scheme => "void",
|
||||
},
|
||||
"vxworks-arm64" => {
|
||||
inherit_from => [ "vxworks-64" ],
|
||||
asm_arch => 'vx_aarch64',
|
||||
perlasm_scheme => "linux64",
|
||||
},
|
||||
"vxworks-ppc32" => {
|
||||
inherit_from => [ "vxworks-32" ],
|
||||
asm_arch => 'vx_ppc32',
|
||||
perlasm_scheme => "32",
|
||||
},
|
||||
"vxworks-ppc64" => {
|
||||
inherit_from => [ "vxworks-64" ],
|
||||
asm_arch => 'vx_ppc64',
|
||||
perlasm_scheme => "64",
|
||||
},
|
||||
"vxworks-simlinux32" => {
|
||||
inherit_from => [ "vxworks-32" ],
|
||||
bn_ops => "BN_LLONG",
|
||||
asm_arch => 'vx_x86',
|
||||
perlasm_scheme => "elf",
|
||||
},
|
||||
"vxworks-simlinux64" => {
|
||||
inherit_from => [ "vxworks-64" ],
|
||||
bn_ops => "SIXTY_FOUR_BIT_LONG",
|
||||
asm_arch => 'vx_x86_64',
|
||||
perlasm_scheme => "elf",
|
||||
},
|
||||
"vxworks-simpc32" => {
|
||||
inherit_from => [ "vxworks-32" ],
|
||||
bn_ops => "BN_LLONG",
|
||||
asm_arch => 'vx_x86',
|
||||
perlasm_scheme => "elf",
|
||||
},
|
||||
"vxworks-simpc64" => {
|
||||
inherit_from => [ "vxworks-64" ],
|
||||
bn_ops => "SIXTY_FOUR_BIT_LONG",
|
||||
asm_arch => 'vx_x86_64',
|
||||
perlasm_scheme => "elf",
|
||||
},
|
||||
"vxworks-riscv32" => {
|
||||
inherit_from => [ "vxworks-32" ],
|
||||
bn_ops => "BN_LLONG",
|
||||
},
|
||||
"vxworks-riscv64" => {
|
||||
inherit_from => [ "vxworks-64" ],
|
||||
bn_ops => "SIXTY_FOUR_BIT_LONG",
|
||||
},
|
||||
|
||||
#### uClinux
|
||||
"uClinux-dist" => {
|
||||
|
||||
+39
-7
@@ -1730,7 +1730,10 @@ EOF
|
||||
if (grep /\.s$/, @srcs) {
|
||||
$recipe .= <<"EOF";
|
||||
$obj: $deps
|
||||
$cmd $cmdflags -c -o \$\@ $srcs
|
||||
$cmd $cmdflags -x assembler-with-cpp -c -o \$\@ $srcs
|
||||
ifdef _WRS_CONFIG_SBOM
|
||||
\@ vxsbomdep -o \$\@
|
||||
endif
|
||||
EOF
|
||||
} elsif (grep /\.S$/, @srcs) {
|
||||
# Originally there was multi-step rule with $(CC) -E file.S
|
||||
@@ -1740,12 +1743,18 @@ EOF
|
||||
# hardly a point to drag it along...
|
||||
$recipe .= <<"EOF";
|
||||
$obj: $deps
|
||||
$cmd $incs $defs $cmdflags -c -o \$\@ $srcs
|
||||
$cmd $incs $defs $cmdflags -x assembler-with-cpp -c -o \$\@ $srcs
|
||||
ifdef _WRS_CONFIG_SBOM
|
||||
\@ vxsbomdep -o \$\@
|
||||
endif
|
||||
EOF
|
||||
} elsif ($makedep_scheme eq 'gcc' && !grep /\.rc$/, @srcs) {
|
||||
$recipe .= <<"EOF";
|
||||
$obj: $deps
|
||||
$cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -c -o \$\@ $srcs
|
||||
ifdef _WRS_CONFIG_SBOM
|
||||
\@ vxsbomdep -o \$\@
|
||||
endif
|
||||
\@touch $dep.tmp
|
||||
\@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\
|
||||
rm -f $dep.tmp; \\
|
||||
@@ -1757,6 +1766,9 @@ EOF
|
||||
$recipe .= <<"EOF";
|
||||
$obj: $deps
|
||||
$cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
|
||||
ifdef _WRS_CONFIG_SBOM
|
||||
\@ vxsbomdep -o \$\@
|
||||
endif
|
||||
EOF
|
||||
if ($makedep_scheme eq 'makedepend') {
|
||||
$recipe .= <<"EOF";
|
||||
@@ -1878,7 +1890,7 @@ EOF
|
||||
$recipe .= <<"EOF";
|
||||
$full: $fulldeps
|
||||
\$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
|
||||
-o $full$shared_def \\
|
||||
-o $full \\
|
||||
$fullobjs \\
|
||||
$linklibs \$(LIB_EX_LIBS)
|
||||
EOF
|
||||
@@ -1937,14 +1949,35 @@ EOF
|
||||
my $deps = join(" \\\n" . ' ' x (length($dso) + 2),
|
||||
fill_lines(' ', $COLUMNS - length($dso) - 2,
|
||||
@objs, @defs, @deps));
|
||||
|
||||
return <<"EOF";
|
||||
$dso: $deps
|
||||
my $sharedefscript = index($dso, "fips");
|
||||
|
||||
my $configStr = join(", ",quotify_l(@{$config{perlargv}}));
|
||||
my $shareIndex = index($configStr, "no-shared");
|
||||
if ($shareIndex == -1){
|
||||
if ($sharedefscript == -1)
|
||||
{
|
||||
return <<"EOF";
|
||||
$dso: $deps
|
||||
\$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
|
||||
-o $dso \\
|
||||
$objs \\
|
||||
$linklibs\$(DSO_EX_LIBS)
|
||||
EOF
|
||||
}else{
|
||||
return <<"EOF";
|
||||
$dso: $deps
|
||||
\$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
|
||||
-o $dso$shared_def \\
|
||||
$objs \\
|
||||
$linklibs\$(DSO_EX_LIBS)
|
||||
EOF
|
||||
}
|
||||
}else{
|
||||
return <<"EOF";
|
||||
$dso: $deps
|
||||
|
||||
EOF
|
||||
}
|
||||
}
|
||||
sub obj2lib {
|
||||
my %args = @_;
|
||||
@@ -1961,7 +1994,6 @@ EOF
|
||||
$lib: $deps
|
||||
\$(RM) $lib
|
||||
$fill_lib
|
||||
\$(RANLIB) \$\@ || echo Never mind.
|
||||
EOF
|
||||
}
|
||||
sub obj2bin {
|
||||
|
||||
+3
@@ -917,6 +917,9 @@ EOF
|
||||
my $recipe = <<"EOF";
|
||||
$obj: $deps
|
||||
\$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
|
||||
ifdef _WRS_CONFIG_SBOM
|
||||
\@ vxsbomdep -o \$\@
|
||||
endif
|
||||
EOF
|
||||
$recipe .= <<"EOF" unless $disabled{makedepend};
|
||||
cmd /C "$makedepcmd $cflags $defs $srcs > $dep 2>&1"
|
||||
|
||||
@@ -993,10 +993,6 @@ while (@argvcopy)
|
||||
{
|
||||
$guess_opts{verbose} = 1;
|
||||
}
|
||||
elsif (/^-w$/)
|
||||
{
|
||||
$guess_opts{nowait} = 1;
|
||||
}
|
||||
elsif (/^-t$/) # From older 'config'
|
||||
{
|
||||
$dryrun = 1;
|
||||
@@ -1715,28 +1711,6 @@ if (!$disabled{makedepend}) {
|
||||
disable('unavailable', 'makedepend') unless $config{makedep_scheme};
|
||||
}
|
||||
|
||||
if (!$disabled{asm} && !$predefined_C{__MACH__} && $^O ne 'VMS' && !$predefined_C{_AIX}) {
|
||||
# probe for -Wa,--noexecstack option...
|
||||
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
|
||||
# probe would fail, but probed option always accepted...
|
||||
push @{$config{cflags}}, "-Wa,--noexecstack", "-Qunused-arguments";
|
||||
} else {
|
||||
my $cc = $config{CROSS_COMPILE}.$config{CC};
|
||||
open(PIPE, "$cc -Wa,--help -c -o null.$$.o -x assembler /dev/null 2>&1 |");
|
||||
while(<PIPE>) {
|
||||
if (m/--noexecstack/) {
|
||||
push @{$config{cflags}}, "-Wa,--noexecstack";
|
||||
last;
|
||||
}
|
||||
}
|
||||
close(PIPE);
|
||||
unlink("null.$$.o");
|
||||
}
|
||||
}
|
||||
|
||||
# Deal with bn_ops ###################################################
|
||||
|
||||
$config{bn_ll} =0;
|
||||
|
||||
@@ -11,7 +11,6 @@ ENDIF
|
||||
|
||||
# Source for the 'openssl' program
|
||||
$OPENSSLSRC=\
|
||||
openssl.c \
|
||||
asn1parse.c ca.c ciphers.c crl.c crl2pkcs7.c dgst.c \
|
||||
enc.c errstr.c \
|
||||
genpkey.c kdf.c mac.c nseq.c passwd.c pkcs7.c \
|
||||
@@ -56,19 +55,16 @@ IF[{- !$disabled{'cmp'} -}]
|
||||
ENDIF
|
||||
|
||||
IF[{- !$disabled{apps} -}]
|
||||
PROGRAMS=openssl
|
||||
SOURCE[openssl]=$INITSRC $OPENSSLSRC
|
||||
INCLUDE[openssl]=.. ../include include
|
||||
DEPEND[openssl]=libapps.a ../libssl
|
||||
SOURCE[libapps.a]=$OPENSSLSRC
|
||||
|
||||
# The nocheck attribute is picked up by progs.pl as a signal not to look
|
||||
# at that file; some systems may have locked it as the output file, and
|
||||
# therefore don't allow it to be read at the same time, making progs.pl
|
||||
# fail.
|
||||
SOURCE[openssl]{nocheck}=progs.c
|
||||
SOURCE[libapps.a]{nocheck}=progs.c
|
||||
DEPEND[${OPENSSLSRC/.c/.o} progs.o]=progs.h
|
||||
GENERATE[progs.c]=progs.pl "-C" $(APPS_OPENSSL)
|
||||
GENERATE[progs.h]=progs.pl "-H" $(APPS_OPENSSL)
|
||||
GENERATE[progs.c]=progs.pl "-C" apps/libapps.a
|
||||
GENERATE[progs.h]=progs.pl "-H" apps/libapps.a
|
||||
# progs.pl tries to read all 'openssl' sources, including progs.c, so we make
|
||||
# sure things are generated in the correct order.
|
||||
DEPEND[progs.h]=progs.c
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
# endif
|
||||
|
||||
# if !defined(NO_FORK) && !defined(OPENSSL_NO_SOCK) \
|
||||
&& !defined(OPENSSL_NO_POSIX_IO)
|
||||
&& !defined(OPENSSL_NO_POSIX_IO) \
|
||||
&& !defined(OPENSSL_SYS_VXWORKS)
|
||||
# define HTTP_DAEMON
|
||||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
|
||||
@@ -74,6 +74,7 @@ int app_RAND_load(void)
|
||||
ret = 0;
|
||||
}
|
||||
sk_OPENSSL_STRING_free(randfiles);
|
||||
randfiles = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -428,8 +428,10 @@ int app_load_modules(const CONF *config)
|
||||
{
|
||||
CONF *to_free = NULL;
|
||||
|
||||
if (config == NULL)
|
||||
config = to_free = app_load_config_quiet(default_config_file);
|
||||
#ifdef OPENSSL_SYS_VXWORKS_SUPPORT
|
||||
/*if (config == NULL)
|
||||
config = to_free = app_load_config_quiet(default_config_file);*/
|
||||
#endif
|
||||
if (config == NULL)
|
||||
return 1;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ ENDIF
|
||||
# Source for libapps
|
||||
$LIBAPPSSRC=apps.c apps_ui.c log.c opt.c fmt.c s_cb.c s_socket.c app_rand.c \
|
||||
columns.c app_params.c names.c app_provider.c app_x509.c http_server.c \
|
||||
engine.c engine_loader.c app_libctx.c apps_opt_printf.c
|
||||
engine_lib.c engine_loader.c app_libctx.c apps_opt_printf.c
|
||||
|
||||
IF[{- !$disabled{apps} -}]
|
||||
LIBS{noinst}=../libapps.a
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
#include "apps_ui.h"
|
||||
#endif
|
||||
|
||||
#define MAX_OPT_HELP_WIDTH 30
|
||||
const char OPT_HELP_STR[] = "-H";
|
||||
@@ -170,6 +173,15 @@ char *opt_init(int ac, char **av, const OPTIONS *o)
|
||||
/* Make sure prog name is set for usage output */
|
||||
(void)opt_progname(argv[0]);
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
static BOOL apps_setup = FALSE;
|
||||
if (!apps_setup)
|
||||
{
|
||||
setup_ui_method();
|
||||
apps_setup = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check all options up until the PARAM marker (if present) */
|
||||
for (; o->name != NULL && o->name != OPT_PARAM_STR; ++o) {
|
||||
#ifndef NDEBUG
|
||||
|
||||
@@ -971,6 +971,11 @@ int s_client_main(int argc, char **argv)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
if (bio_err == NULL)
|
||||
bio_err = dup_bio_err(FORMAT_TEXT);
|
||||
#endif
|
||||
|
||||
c_quiet = 0;
|
||||
c_debug = 0;
|
||||
c_showcerts = 0;
|
||||
@@ -3142,7 +3147,7 @@ int s_client_main(int argc, char **argv)
|
||||
goto shut;
|
||||
}
|
||||
}
|
||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VMS)
|
||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_VXWORKS)
|
||||
/* Assume Windows/DOS/BeOS can always write */
|
||||
else if (!ssl_pending && write_tty)
|
||||
#else
|
||||
|
||||
@@ -1114,6 +1114,11 @@ int s_server_main(int argc, char *argv[])
|
||||
use_sendfile = 0;
|
||||
use_zc_sendfile = 0;
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
if (bio_err == NULL)
|
||||
bio_err = dup_bio_err(FORMAT_TEXT);
|
||||
#endif
|
||||
|
||||
port = OPENSSL_strdup(PORT);
|
||||
cctx = SSL_CONF_CTX_new();
|
||||
vpm = X509_VERIFY_PARAM_new();
|
||||
|
||||
@@ -1901,6 +1901,9 @@ int speed_main(int argc, char **argv)
|
||||
size_t declen;
|
||||
BIGNUM *bn = NULL;
|
||||
EVP_PKEY_CTX *genctx = NULL;
|
||||
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
struct sigaction sa;
|
||||
#endif
|
||||
#ifndef NO_FORK
|
||||
int multi = 0;
|
||||
#endif
|
||||
@@ -2040,6 +2043,12 @@ int speed_main(int argc, char **argv)
|
||||
OPENSSL_assert(strcmp(sm2_choices[SM2_NUM - 1].name, "curveSM2") == 0);
|
||||
#endif
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
#endif
|
||||
|
||||
prog = opt_init(argc, argv, speed_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
@@ -2614,7 +2623,19 @@ int speed_main(int argc, char **argv)
|
||||
"instead of user CPU time.\n");
|
||||
|
||||
#if SIGALRM > 0
|
||||
# if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
memset(&sa,0x00,sizeof(sa));
|
||||
sa.sa_handler = alarmed;
|
||||
|
||||
if (sigaction(SIGALRM, &sa, (struct sigaction *) NULL) == -1)
|
||||
{
|
||||
BIO_printf(bio_err, "Register alarm signal ERROR!\r\n");
|
||||
BIO_flush(bio_err);
|
||||
return -1;
|
||||
}
|
||||
# else
|
||||
signal(SIGALRM, alarmed);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (doit[D_MD2]) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Note that some of these directories are filtered in Configure. Look for
|
||||
# %skipdir there for further explanations.
|
||||
|
||||
SUBDIRS=crypto ssl apps util tools fuzz providers doc
|
||||
SUBDIRS=crypto ssl apps util tools providers
|
||||
IF[{- !$disabled{tests} -}]
|
||||
SUBDIRS=test
|
||||
ENDIF
|
||||
IF[{- !$disabled{demos} -}]
|
||||
SUBDIRS=demos
|
||||
ENDIF
|
||||
#IF[{- !$disabled{demos} -}]
|
||||
# SUBDIRS=demos
|
||||
#ENDIF
|
||||
IF[{- !$disabled{'deprecated-3.0'} -}]
|
||||
SUBDIRS=engines
|
||||
ENDIF
|
||||
|
||||
@@ -514,7 +514,7 @@ $code.=<<___;
|
||||
.align 5
|
||||
.${prefix}_cbc_encrypt:
|
||||
${UCMP}i $len,16
|
||||
bltlr-
|
||||
bltlr_ori
|
||||
|
||||
cmpwi $enc,0 # test direction
|
||||
lis r0,0xffe0
|
||||
@@ -1274,7 +1274,7 @@ $code.=<<___;
|
||||
.align 5
|
||||
.${prefix}_ctr32_encrypt_blocks:
|
||||
${UCMP}i $len,1
|
||||
bltlr-
|
||||
bltlr_ori
|
||||
|
||||
lis r0,0xfff0
|
||||
mfspr $vrsave,256
|
||||
@@ -1940,7 +1940,7 @@ $code.=<<___;
|
||||
mr $inp,r3 # reassign
|
||||
li r3,-1
|
||||
${UCMP}i $len,16
|
||||
bltlr-
|
||||
bltlr_ori
|
||||
|
||||
lis r0,0xfff0
|
||||
mfspr r12,256 # save vrsave
|
||||
@@ -2151,7 +2151,7 @@ Lxts_enc_ret:
|
||||
mr $inp,r3 # reassign
|
||||
li r3,-1
|
||||
${UCMP}i $len,16
|
||||
bltlr-
|
||||
bltlr_ori
|
||||
|
||||
lis r0,0xfff8
|
||||
mfspr r12,256 # save vrsave
|
||||
|
||||
@@ -640,7 +640,7 @@ Ldec_done:
|
||||
.align 5
|
||||
.vpaes_cbc_encrypt:
|
||||
${UCMP}i r5,16
|
||||
bltlr-
|
||||
bltlr_ori
|
||||
|
||||
$STU $sp,-`($FRAME+2*$SIZE_T)`($sp)
|
||||
mflr r0
|
||||
|
||||
@@ -59,6 +59,27 @@ IF[{- !$disabled{asm} -}]
|
||||
$AESASM_loongarch64=aes_core.c aes_cbc.c vpaes-loongarch64.S
|
||||
$AESDEF_loongarch64=VPAES_ASM
|
||||
|
||||
$AESASM_vx_x86=$AESASM_x86
|
||||
$AESDEF_vx_x86=$AESDEF_x86
|
||||
$AESASM_vx_x86_sse2=$AESASM_x86_sse2
|
||||
$AESDEF_vx_x86_sse2=$AESDEF_x86_sse2
|
||||
$AESASM_vx_x86_64=$AESASM_x86_64
|
||||
$AESDEF_vx_x86_64=$AESDEF_x86_64
|
||||
$AESASM_vx_armv4=$AESASM_armv4
|
||||
$AESDEF_vx_armv4=$AESDEF_armv4
|
||||
$AESASM_vx_armv4_thumb=$AESASM_armv4
|
||||
$AESDEF_vx_armv4_thumb=$AESDEF_armv4
|
||||
$AESASM_vx_armv7m=$AESASM_armv4
|
||||
$AESDEF_vx_armv7m=$AESDEF_armv4
|
||||
$AESASM_vx_armv7a=$AESASM_armv4
|
||||
$AESDEF_vx_armv7a=$AESDEF_armv4
|
||||
$AESASM_vx_aarch64=$AESASM_aarch64
|
||||
$AESDEF_vx_aarch64=$AESDEF_aarch64
|
||||
$AESASM_vx_ppc32=$AESASM_ppc32
|
||||
$AESDEF_vx_ppc32=$AESDEF_ppc32
|
||||
$AESASM_vx_ppc64=$AESASM_ppc64
|
||||
$AESDEF_vx_ppc64=$AESDEF_ppc64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$AESASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -202,6 +202,11 @@ CRYPTO_memcmp:
|
||||
ret
|
||||
.size CRYPTO_memcmp,.-CRYPTO_memcmp
|
||||
|
||||
#ifdef OPENSSL_SYS_VXWORKS_SUPPORT
|
||||
.extern OPENSSL_armcap_P
|
||||
.hidden OPENSSL_armcap_P
|
||||
#endif
|
||||
|
||||
.globl _armv8_rng_probe
|
||||
.type _armv8_rng_probe,%function
|
||||
_armv8_rng_probe:
|
||||
|
||||
@@ -47,7 +47,9 @@
|
||||
# elif defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
|
||||
# define __ARM_ARCH__ 4
|
||||
# else
|
||||
# error "unsupported ARM architecture"
|
||||
# define __ARM_ARCH__ 7
|
||||
|
||||
/*# error "unsupported ARM architecture"*/
|
||||
# endif
|
||||
# elif defined(__ARM_ARCH)
|
||||
# define __ARM_ARCH__ __ARM_ARCH
|
||||
|
||||
@@ -172,7 +172,14 @@ static size_t OPENSSL_rndr_wrapper(size_t (*func)(unsigned char *, size_t), unsi
|
||||
buffer_size = func(buf, len);
|
||||
if (buffer_size == len)
|
||||
break;
|
||||
#ifdef OPENSSL_SYS_VXWORKS
|
||||
struct timespec ts;
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = (long int) (5 % 1000) * 1000000ul;
|
||||
nanosleep(&ts, NULL);
|
||||
#else
|
||||
usleep(5000); /* 5000 microseconds (5 milliseconds) */
|
||||
#endif
|
||||
}
|
||||
return buffer_size;
|
||||
}
|
||||
@@ -194,7 +201,11 @@ static sigset_t all_masked;
|
||||
static sigjmp_buf ill_jmp;
|
||||
static void ill_handler(int sig)
|
||||
{
|
||||
#ifndef _WRS_KERNEL
|
||||
siglongjmp(ill_jmp, sig);
|
||||
#else
|
||||
longjmp(ill_jmp, sig);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -39,6 +39,7 @@ $code.=<<___;
|
||||
.type OPENSSL_atomic_add,%function
|
||||
OPENSSL_atomic_add:
|
||||
#if __ARM_ARCH__>=6
|
||||
dmb
|
||||
.Ladd: ldrex r2,[r0]
|
||||
add r3,r2,r1
|
||||
strex r2,r3,[r0]
|
||||
|
||||
@@ -87,6 +87,31 @@ IF[{- !$disabled{asm} -}]
|
||||
$BNASM_c64xplus_ec2m=c64xplus-gf2m.s
|
||||
$BNDEF_c64xplus_ec2m=OPENSSL_BN_ASM_GF2m
|
||||
|
||||
$BNASM_vx_x86=$BNASM_x86
|
||||
$BNDEF_vx_x86=$BNDEF_x86
|
||||
$BNDEF_vx_x86_sse2=$BNDEF_x86_sse2
|
||||
$BNASM_vx_x86_64=$BNASM_x86_64
|
||||
$BNDEF_vx_x86_64=$BNDEF_x86_64
|
||||
$BNDEF_vx_x86_64_sse2=$BNDEF_x86_64_sse2
|
||||
$BNASM_vx_armv4=$BNASM_armv4
|
||||
$BNDEF_vx_armv4=$BNDEF_armv4
|
||||
$BNASM_vx_armv4_ec2m=$BNASM_armv4_ec2m
|
||||
$BNDEF_vx_armv4_ec2m=$BNDEF_armv4_ec2m
|
||||
$BNASM_vx_armv4_thumb=$BNASM_armv4
|
||||
$BNDEF_vx_armv4_thumb=$BNDEF_armv4
|
||||
$BNASM_vx_armv4_thumb_ec2m=$BNASM_armv4_ec2m
|
||||
$BNDEF_vx_armv4_thumb_ec2m=$BNDEF_armv4_ec2m
|
||||
$BNASM_vx_armv7m=$BNASM_armv4
|
||||
$BNDEF_vx_armv7m=$BNDEF_armv4
|
||||
$BNASM_vx_armv7m_ec2m=$BNASM_armv4_ec2m
|
||||
$BNDEF_vx_armv7m_ec2m=$BNDEF_armv4_ec2m
|
||||
$BNASM_vx_aarch64=$BNASM_aarch64
|
||||
$BNDEF_vx_aarch64=$BNDEF_aarch64
|
||||
$BNASM_vx_ppc32=$BNASM_ppc32
|
||||
$BNDEF_vx_ppc32=$BNDEF_ppc32
|
||||
$BNASM_vx_ppc64=$BNASM_ppc64
|
||||
$BNDEF_vx_ppc64=$BNDEF_ppc64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate ones, and define the appropriate macros
|
||||
IF[$BNASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -55,6 +55,17 @@ IF[{- !$disabled{asm} && $config{processor} ne '386' -}]
|
||||
$CPUIDASM_riscv32=riscvcap.c riscv32cpuid.s
|
||||
|
||||
$CPUIDASM_loongarch64=loongarchcap.c loongarch64cpuid.s
|
||||
|
||||
$CPUIDASM_vx_x86=$CPUIDASM_x86
|
||||
$CPUIDASM_vx_x86_64=$CPUIDASM_x86_64
|
||||
$CPUIDASM_vx_armv4=$CPUIDASM_armv4
|
||||
$CPUIDASM_vx_armv4_thumb=$CPUIDASM_armv4
|
||||
$CPUIDASM_vx_armv7m=$CPUIDASM_armv4
|
||||
$CPUIDASM_vx_armv7a=$CPUIDASM_armv4
|
||||
$CPUIDASM_vx_aarch64=$CPUIDASM_aarch64
|
||||
$CPUIDASM_vx_ppc32=$CPUIDASM_ppc32
|
||||
$CPUIDASM_vx_ppc64=$CPUIDASM_ppc64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$CPUIDASM_{- $target{asm_arch} -}]
|
||||
@@ -97,7 +108,7 @@ SOURCE[../providers/libfips.a]=$CORE_COMMON
|
||||
# Central utilities
|
||||
$UTIL_COMMON=\
|
||||
cryptlib.c params.c params_from_text.c bsearch.c ex_data.c o_str.c \
|
||||
threads_pthread.c threads_win.c threads_none.c initthread.c \
|
||||
threads_vxworks.c initthread.c \
|
||||
context.c sparse_array.c asn1_dsa.c packet.c param_build.c \
|
||||
param_build_set.c der_writer.c threads_lib.c params_dup.c \
|
||||
time.c params_idx.c
|
||||
@@ -107,15 +118,17 @@ SOURCE[../libcrypto]=$UTIL_COMMON \
|
||||
comp_methods.c cversion.c info.c cpt_err.c ebcdic.c uid.c o_time.c \
|
||||
o_dir.c o_fopen.c getenv.c o_init.c init.c trace.c provider.c \
|
||||
provider_child.c punycode.c passphrase.c sleep.c deterministic_nonce.c \
|
||||
quic_vlint.c time.c defaults.c ssl_err.c
|
||||
quic_vlint.c time.c defaults.c ssl_err.c vxRandLib.c
|
||||
SOURCE[../providers/libfips.a]=$UTIL_COMMON
|
||||
|
||||
SOURCE[../libcrypto]=$UPLINKSRC
|
||||
DEFINE[../libcrypto]=$UPLINKDEF
|
||||
|
||||
IF[{- !$disabled{module} && $disabled{shared} -}]
|
||||
DEFINE[../libcrypto]=$UPLINKDEF STATIC_LEGACY
|
||||
ENDIF
|
||||
DEPEND[info.o]=buildinf.h
|
||||
DEPEND[cversion.o]=buildinf.h
|
||||
GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)"
|
||||
GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(notdir $(CC)) $(filter-out -D_VSB_CONFIG_FILE=% -D_VSB_PUBLIC_HDR_DIR=% -ffile-prefix-map% -I% -i%,$(LIB_CFLAGS) $(CPPFLAGS_Q))" "$(PLATFORM)"
|
||||
|
||||
GENERATE[uplink-x86.S]=../ms/uplink-x86.pl
|
||||
GENERATE[uplink-x86_64.s]=../ms/uplink-x86_64.pl
|
||||
|
||||
@@ -6,6 +6,9 @@ IF[{- !$disabled{asm} -}]
|
||||
$CMLLASM_x86_64=cmll-x86_64.s cmll_misc.c
|
||||
$CMLLASM_sparcv9=camellia.c cmll_misc.c cmll_cbc.c cmllt4-sparcv9.S
|
||||
|
||||
$CMLLASM_vx_x86=$CMLLASM_x86
|
||||
$CMLLASM_vx_x86_64=$CMLLASM_x86_64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one
|
||||
IF[$CMLLASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -5,6 +5,8 @@ $CASTASM=c_enc.c
|
||||
IF[{- !$disabled{asm} && $disabled{pic} -}]
|
||||
$CASTASM_x86=cast-586.S
|
||||
|
||||
$CASTASM_vx_x86=$CASTASM_x86
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one
|
||||
IF[$CASTASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -24,6 +24,15 @@ IF[{- !$disabled{asm} -}]
|
||||
|
||||
$CHACHAASM_riscv64=chacha_riscv.c chacha_enc.c chacha-riscv64-v-zbb.s chacha-riscv64-v-zbb-zvkb.s
|
||||
$CHACHADEF_riscv64=INCLUDE_C_CHACHA20
|
||||
$CHACHAASM_vx_x86=$CHACHAASM_x86
|
||||
$CHACHAASM_vx_x86_64=$CHACHAASM_x86_64
|
||||
$CHACHAASM_vx_armv4=$CHACHAASM_armv4
|
||||
$CHACHAASM_vx_armv4_thumb=$CHACHAASM_armv4
|
||||
$CHACHAASM_vx_armv7m=$CHACHAASM_armv4
|
||||
$CHACHAASM_vx_armv7a=$CHACHAASM_armv4
|
||||
$CHACHAASM_vx_aarch64=$CHACHAASM_aarch64
|
||||
$CHACHAASM_vx_ppc32=$CHACHAASM_ppc32
|
||||
$CHACHAASM_vx_ppc64=$CHACHAASM_ppc64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one
|
||||
|
||||
@@ -4,6 +4,8 @@ IF[{- !$disabled{asm} -}]
|
||||
$DESASM_sparcv9=des_enc-sparc.S fcrypt_b.c dest4-sparcv9.S
|
||||
$DESASM_sparcv8=des_enc-sparc.S fcrypt_b.c
|
||||
|
||||
$DESASM_vx_x86=$DESASM_x86
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one
|
||||
IF[$DESASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -306,6 +306,11 @@ const BIGNUM *DSA_get0_priv_key(const DSA *d)
|
||||
return d->priv_key;
|
||||
}
|
||||
|
||||
void DSA_setnull_priv_key(DSA *d)
|
||||
{
|
||||
d->priv_key = NULL;
|
||||
}
|
||||
|
||||
void DSA_get0_key(const DSA *d,
|
||||
const BIGNUM **pub_key, const BIGNUM **priv_key)
|
||||
{
|
||||
|
||||
@@ -21,20 +21,6 @@
|
||||
|
||||
#ifdef DSO_DLFCN
|
||||
|
||||
# ifdef HAVE_DLFCN_H
|
||||
# ifdef __osf__
|
||||
# define __EXTENSIONS__
|
||||
# endif
|
||||
# include <dlfcn.h>
|
||||
# define HAVE_DLINFO 1
|
||||
# if defined(__SCO_VERSION__) || defined(_SCO_ELF) || \
|
||||
(defined(__osf__) && !defined(RTLD_NEXT)) || \
|
||||
(defined(__OpenBSD__) && !defined(RTLD_SELF)) || \
|
||||
defined(__ANDROID__) || defined(__TANDEM)
|
||||
# undef HAVE_DLINFO
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Part of the hack in "dlfcn_load" ... */
|
||||
# define DSO_MAX_TRANSLATED_SIZE 256
|
||||
|
||||
@@ -66,6 +52,449 @@ DSO_METHOD *DSO_METHOD_openssl(void)
|
||||
return &dso_meth_dlfcn;
|
||||
}
|
||||
|
||||
#if defined (_WRS_KERNEL)
|
||||
|
||||
#ifdef HOST
|
||||
#ifndef WIN32
|
||||
#include <strings.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include <host.h>
|
||||
#include <vmutex.h>
|
||||
#include <sysSymTbl.h>
|
||||
|
||||
#else /* !HOST */
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <semLib.h>
|
||||
#include <memLib.h>
|
||||
#include <memPartLib.h>
|
||||
#include <private/hashLibP.h>
|
||||
#include <ffsLib.h>
|
||||
#ifdef _WRS_CONFIG_LOADER
|
||||
#include <elf.h>
|
||||
#include <elftypes.h>
|
||||
#include <private/loadRtpLibP.h> /* _func_loadRtp* */
|
||||
#include <moduleLib.h>
|
||||
#include <loadLib.h>
|
||||
#include <loadElfLib.h>
|
||||
#endif /* _WRS_CONFIG_LOADER */
|
||||
|
||||
#ifdef _WRS_KERNEL
|
||||
#include <sysSymTbl.h>
|
||||
#else /* !_WRS_KERNEL */
|
||||
#include <strings.h>
|
||||
#endif /* _WRS_KERNEL */
|
||||
#endif /* HOST */
|
||||
|
||||
#include <hashLib.h>
|
||||
#include <private/symLibP.h>
|
||||
#include <private/symbolP.h>
|
||||
#include <errnoLib.h>
|
||||
#include <symLib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ffsLib.h>
|
||||
|
||||
typedef struct symkey
|
||||
{
|
||||
char * name;
|
||||
MODULE_ID moptr;
|
||||
}SYMKEY;
|
||||
|
||||
typedef struct symFdStore
|
||||
{
|
||||
SL_NODE pSymStore;
|
||||
MODULE_ID moptr;
|
||||
int fd;
|
||||
}SYMFDSTORE;
|
||||
|
||||
LOCAL SYM_VALUE symVal;
|
||||
LOCAL UINT symLkupPgSz = 21;
|
||||
LOCAL SL_LIST symFdList;
|
||||
LOCAL BOOL isInit = FALSE;
|
||||
|
||||
LOCAL char * strMatch
|
||||
(
|
||||
char * str1, /* where to look for match */
|
||||
char * str2 /* string to find a match for */
|
||||
)
|
||||
{
|
||||
size_t str2Length = strlen (str2);
|
||||
ssize_t ntries = strlen (str1) - str2Length;
|
||||
|
||||
for (; ntries >= 0; str1++, --ntries)
|
||||
{
|
||||
if (strncmp (str1, str2, str2Length) == 0)
|
||||
return (str1);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
LOCAL BOOL symNodeEach
|
||||
(
|
||||
SL_NODE * pNode,
|
||||
_Vx_usr_arg_t ptr
|
||||
)
|
||||
{
|
||||
SYMFDSTORE * pStore = (SYMFDSTORE *)pNode;
|
||||
|
||||
if (pStore->moptr == ptr)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LOCAL BOOL symSysTbllk
|
||||
(
|
||||
char * name, /* symbol name */
|
||||
SYM_VALUE val, /* symbol value */
|
||||
SYM_TYPE type, /* symbol type */
|
||||
_Vx_usr_arg_t substrArg, /* substring to match */
|
||||
SYM_GROUP group, /* symbol's module group */
|
||||
SYMBOL * pSymbol /* symbol structure */
|
||||
)
|
||||
{
|
||||
char moduleName [NAME_MAX];
|
||||
#ifdef _WRS_CONFIG_LOADER
|
||||
MODULE_ID moduleId = (MODULE_ID) pSymbol->symRef;
|
||||
#endif
|
||||
char * nameToPrint = name;
|
||||
char quitChar;
|
||||
SYMKEY * pSymKey = (SYMKEY *) substrArg;
|
||||
|
||||
#ifdef _WRS_CONFIG_LOADER
|
||||
|
||||
if (((SYM_REF)moduleId != SYMREF_NONE) &&
|
||||
((SYM_REF)moduleId != SYMREF_SHELL) &&
|
||||
((SYM_REF)moduleId != SYMREF_KERNEL) &&
|
||||
((SYM_REF)moduleId != SYMREF_WTX) &&
|
||||
moduleIdVerify (moduleId) == OK)
|
||||
{
|
||||
}
|
||||
else
|
||||
#endif /* _WRS_CONFIG_LOADER */
|
||||
moduleName [0] = EOS;
|
||||
|
||||
if (strMatch (name, pSymKey->name) != NULL)
|
||||
{
|
||||
#ifdef _WRS_CONFIG_CPLUS_KERNEL
|
||||
char demangled [MAX_SYS_SYM_LEN + 1];
|
||||
|
||||
nameToPrint = cplusDemangle (name, demangled, sizeof (demangled));
|
||||
#endif
|
||||
if (type & SYM_LOCAL)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (pSymKey->moptr == moduleId)
|
||||
{
|
||||
symVal = val;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
LOCAL SYM_VALUE symlkup
|
||||
(
|
||||
SYMTAB_ID pSymTbl,
|
||||
SYMKEY * pSymKey
|
||||
)
|
||||
{
|
||||
BOOL isRtpSymbolTable = FALSE;
|
||||
|
||||
if (pSymKey == NULL)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pSymTbl == sysSymTbl)
|
||||
{
|
||||
symEach (pSymTbl, (SYM_EACH_RTN_FUNCPTR)symSysTbllk,
|
||||
(_Vx_usr_arg_t) pSymKey);
|
||||
}
|
||||
}
|
||||
|
||||
return symVal;
|
||||
}
|
||||
|
||||
static int dlfcn_load(DSO *dso)
|
||||
{
|
||||
void * ptr = NULL;
|
||||
char * filename = DSO_convert_filename(dso, NULL);
|
||||
int saveerrno = get_last_sys_error();
|
||||
int fd;
|
||||
SL_NODE * pSymStore = NULL;
|
||||
|
||||
if (!isInit)
|
||||
{
|
||||
(void) sllInit (&symFdList);
|
||||
isInit = TRUE;
|
||||
}
|
||||
|
||||
if (filename == NULL)
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, DSO_R_NO_FILENAME);
|
||||
return (0);
|
||||
}
|
||||
|
||||
fd = open (filename, O_RDONLY, 0);
|
||||
if (fd == ERROR)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
ptr = loadModule (fd, LOAD_GLOBAL_SYMBOLS);
|
||||
if (ptr == NULL)
|
||||
{
|
||||
ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED,
|
||||
"filename(%s):", filename);
|
||||
goto err;
|
||||
}
|
||||
|
||||
set_sys_error(saveerrno);
|
||||
if (!sk_void_push(dso->meth_data, (char *)ptr))
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, DSO_R_STACK_ERROR);
|
||||
goto err;
|
||||
}
|
||||
/* Success */
|
||||
dso->loaded_filename = filename;
|
||||
pSymStore = (SL_NODE *) malloc (sizeof (SYMFDSTORE));
|
||||
if (pSymStore == NULL)
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, DSO_R_STACK_ERROR);
|
||||
goto err;
|
||||
}
|
||||
((SYMFDSTORE *)pSymStore)->moptr = ptr;
|
||||
((SYMFDSTORE *)pSymStore)->fd = fd;
|
||||
|
||||
sllPutAtTail (&symFdList, pSymStore);
|
||||
|
||||
return 1;
|
||||
err:
|
||||
/* Cleanup! */
|
||||
OPENSSL_free(filename);
|
||||
if (ptr != NULL)
|
||||
unldByModuleId(ptr, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dlfcn_unload(DSO *dso)
|
||||
{
|
||||
void * ptr;
|
||||
SL_NODE * pStore;
|
||||
SL_NODE * pPrevNode;
|
||||
|
||||
if (dso == NULL)
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sk_void_num(dso->meth_data) < 1)
|
||||
return 1;
|
||||
|
||||
ptr = sk_void_pop(dso->meth_data);
|
||||
if (ptr == NULL)
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, DSO_R_NULL_HANDLE);
|
||||
/*
|
||||
* Should push the value back onto the stack in case of a retry.
|
||||
*/
|
||||
sk_void_push(dso->meth_data, ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* For now I'm not aware of any errors associated with dlclose() */
|
||||
unldByModuleId(ptr, 0);
|
||||
|
||||
pStore = sllEach (&symFdList,
|
||||
symNodeEach,
|
||||
(_Vx_usr_arg_t)ptr);
|
||||
if (pStore == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
pPrevNode = sllPrevious (&symFdList, pStore);
|
||||
close (((SYMFDSTORE *)pStore)->fd);
|
||||
|
||||
sllRemove (&symFdList, pStore, pPrevNode);
|
||||
free (pStore);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
|
||||
{
|
||||
SYMKEY symKey;
|
||||
void * ptr;
|
||||
SYMFDSTORE * pSymStore = NULL;
|
||||
union {
|
||||
DSO_FUNC_TYPE sym;
|
||||
void *dlret;
|
||||
} u;
|
||||
|
||||
if ((dso == NULL) || (symname == NULL))
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sk_void_num(dso->meth_data) < 1)
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, DSO_R_STACK_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
|
||||
if (ptr == NULL)
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, DSO_R_NULL_HANDLE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pSymStore = (SYMFDSTORE *) sllEach (&symFdList,
|
||||
symNodeEach,
|
||||
(_Vx_usr_arg_t)ptr);
|
||||
|
||||
symKey.name = symname;
|
||||
symKey.moptr = ptr;
|
||||
u.sym = symlkup(sysSymTbl, &symKey);
|
||||
if (u.sym == NULL)
|
||||
{
|
||||
printf("symname(%s): ", symname);
|
||||
return NULL;
|
||||
}
|
||||
return u.sym;
|
||||
}
|
||||
|
||||
static char *dlfcn_merger
|
||||
(
|
||||
DSO * dso,
|
||||
const char * filespec1,
|
||||
const char * filespec2
|
||||
)
|
||||
{
|
||||
char *merged;
|
||||
|
||||
if (!filespec1 && !filespec2)
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
* If the first file specification is a rooted path, it rules. same goes
|
||||
* if the second file specification is missing.
|
||||
*/
|
||||
if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/'))
|
||||
{
|
||||
merged = OPENSSL_strdup(filespec1);
|
||||
if (merged == NULL)
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if (!filespec1)
|
||||
{
|
||||
merged = OPENSSL_strdup(filespec2);
|
||||
if (merged == NULL)
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
||||
int spec2len, len;
|
||||
|
||||
spec2len = strlen(filespec2);
|
||||
len = spec2len + strlen(filespec1);
|
||||
|
||||
if (spec2len && filespec2[spec2len - 1] == '/')
|
||||
{
|
||||
spec2len--;
|
||||
len--;
|
||||
}
|
||||
|
||||
merged = OPENSSL_malloc(len + 2);
|
||||
if (merged == NULL)
|
||||
{
|
||||
ERR_raise(ERR_LIB_DSO, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(merged, filespec2);
|
||||
merged[spec2len] = '/';
|
||||
strcpy(&merged[spec2len + 1], filespec1);
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
static char *dlfcn_name_converter(DSO *dso, const char *filename)
|
||||
{
|
||||
char *translated;
|
||||
int len, rsize, transform;
|
||||
|
||||
len = strlen(filename);
|
||||
rsize = len + 1;
|
||||
transform = (strstr(filename, "/") == NULL);
|
||||
if (transform) {
|
||||
/* We will convert this to "%s.so" or "lib%s.so" etc */
|
||||
rsize += strlen(DSO_EXTENSION); /* The length of ".so" */
|
||||
if ((DSO_flags(dso) & DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == 0)
|
||||
rsize += 3; /* The length of "lib" */
|
||||
}
|
||||
rsize += 5;
|
||||
translated = OPENSSL_malloc(rsize);
|
||||
if (translated == NULL) {
|
||||
ERR_raise(ERR_LIB_DSO, DSO_R_NAME_TRANSLATION_FAILED);
|
||||
return NULL;
|
||||
}
|
||||
if (transform) {
|
||||
sprintf(translated, "%s.out", filename);
|
||||
} else
|
||||
sprintf(translated, "%s", filename);
|
||||
return translated;
|
||||
}
|
||||
|
||||
static int dlfcn_pathbyaddr(void *addr, char *path, int sz)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void * dlfcn_globallookup(const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
# ifdef HAVE_DLFCN_H
|
||||
# ifdef __osf__
|
||||
# define __EXTENSIONS__
|
||||
# endif
|
||||
# include <dlfcn.h>
|
||||
# define HAVE_DLINFO 1
|
||||
# if defined(__SCO_VERSION__) || defined(_SCO_ELF) || \
|
||||
(defined(__osf__) && !defined(RTLD_NEXT)) || \
|
||||
(defined(__OpenBSD__) && !defined(RTLD_SELF)) || \
|
||||
defined(__ANDROID__) || defined(__TANDEM)
|
||||
# undef HAVE_DLINFO
|
||||
# endif
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Prior to using the dlopen() function, we should decide on the flag we
|
||||
* send. There's a few different ways of doing this and it's a messy
|
||||
@@ -449,3 +878,5 @@ static void *dlfcn_globallookup(const char *name)
|
||||
return ret;
|
||||
}
|
||||
#endif /* DSO_DLFCN */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -59,6 +59,24 @@ IF[{- !$disabled{asm} -}]
|
||||
|
||||
$ECASM_c64xplus=
|
||||
|
||||
$ECASM_vx_x86=$ECASM_x86
|
||||
$ECDEF_vx_x86=$ECDEF_x86
|
||||
$ECASM_vx_x86_64=$ECASM_x86_64
|
||||
$ECDEF_vx_x86_64=$ECDEF_x86_64
|
||||
$ECASM_vx_armv4=$ECASM_armv4
|
||||
$ECDEF_vx_armv4=$ECDEF_armv4
|
||||
$ECASM_vx_armv4_thumb=$ECASM_armv4
|
||||
$ECDEF_vx_armv4_thumb=$ECDEF_armv4
|
||||
$ECASM_vx_armv7m=$ECASM_armv4
|
||||
$ECDEF_vx_armv7m=$ECDEF_armv4
|
||||
$ECASM_vx_armv7a=$ECASM_armv4
|
||||
$ECDEF_vx_armv7a=$ECDEF_armv4
|
||||
$ECASM_vx_aarch64=$ECASM_aarch64
|
||||
$ECDEF_vx_aarch64=$ECDEF_aarch64
|
||||
$ECASM_vx_ppc32=$ECASM_ppc32
|
||||
$ECASM_vx_ppc64=$ECASM_ppc64
|
||||
$ECDEF_vx_ppc64=$ECDEF_ppc64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$ECASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -459,7 +459,11 @@ ENGINE *ENGINE_by_id(const char *id)
|
||||
*/
|
||||
if (strcmp(id, "dynamic")) {
|
||||
if ((load_dir = ossl_safe_getenv("OPENSSL_ENGINES")) == NULL)
|
||||
{
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
load_dir = ossl_get_enginesdir();
|
||||
#endif
|
||||
}
|
||||
iterator = ENGINE_by_id("dynamic");
|
||||
if (!iterator || !ENGINE_ctrl_cmd_string(iterator, "ID", id, 0) ||
|
||||
!ENGINE_ctrl_cmd_string(iterator, "DIR_LOAD", "2", 0) ||
|
||||
|
||||
+8
@@ -40,6 +40,14 @@
|
||||
struct translation_ctx_st; /* Forwarding */
|
||||
struct translation_st; /* Forwarding */
|
||||
|
||||
/* VxWorks defines NONE, too. Please find the defination
|
||||
* in source/os/core/kernel/h/vxWorksCommon.h
|
||||
*/
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
#ifdef NONE
|
||||
#undef NONE
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* The fixup_args functions are called with the following parameters:
|
||||
*
|
||||
|
||||
@@ -457,6 +457,18 @@ unsigned long EVP_CIPHER_get_flags(const EVP_CIPHER *cipher)
|
||||
return cipher == NULL ? 0 : cipher->flags;
|
||||
}
|
||||
|
||||
/*OPENSSL_SYS_VXWORKS_SUPPORT*/
|
||||
void *EVP_CIPHER_get_app_data(const EVP_CIPHER *cipher)
|
||||
{
|
||||
return cipher->app_data;
|
||||
}
|
||||
|
||||
/*OPENSSL_SYS_VXWORKS_SUPPORT*/
|
||||
void EVP_CIPHER_set_app_data(EVP_CIPHER *cipher, void *data)
|
||||
{
|
||||
cipher->app_data = data;
|
||||
}
|
||||
|
||||
void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx)
|
||||
{
|
||||
return ctx->app_data;
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef HEADER_EVP_LOCAL_H
|
||||
# define HEADER_EVP_LOCAL_H
|
||||
|
||||
#include <openssl/core_dispatch.h>
|
||||
#include "internal/refcount.h"
|
||||
|
||||
@@ -414,3 +417,5 @@ int evp_names_do_all(OSSL_PROVIDER *prov, int number,
|
||||
void (*fn)(const char *name, void *data),
|
||||
void *data);
|
||||
int evp_cipher_cache_constants(EVP_CIPHER *cipher);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1038,6 +1038,18 @@ int EVP_PKEY_get_id(const EVP_PKEY *pkey)
|
||||
return pkey->type;
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
ENGINE * EVP_PKEY_engine(const EVP_PKEY *pkey)
|
||||
{
|
||||
return pkey->engine;
|
||||
}
|
||||
|
||||
void EVP_PKEY_set_engine(EVP_PKEY *pkey, ENGINE *e)
|
||||
{
|
||||
pkey->engine = e;
|
||||
}
|
||||
#endif
|
||||
|
||||
int EVP_PKEY_get_base_id(const EVP_PKEY *pkey)
|
||||
{
|
||||
return EVP_PKEY_type(pkey->type);
|
||||
|
||||
@@ -220,8 +220,11 @@ const char *OPENSSL_info(int t)
|
||||
switch (t) {
|
||||
case OPENSSL_INFO_CONFIG_DIR:
|
||||
return ossl_get_openssldir();
|
||||
case OPENSSL_INFO_ENGINES_DIR:
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
case OPENSSL_INFO_ENGINES_DIR:
|
||||
return ossl_get_enginesdir();
|
||||
#endif
|
||||
case OPENSSL_INFO_MODULES_DIR:
|
||||
return ossl_get_modulesdir();
|
||||
case OPENSSL_INFO_DSO_EXTENSION:
|
||||
|
||||
@@ -35,6 +35,12 @@
|
||||
#include <openssl/ssl.h> /* for OPENSSL_INIT_(NO_)?LOAD_SSL_STRINGS */
|
||||
#include "crypto/ctype.h"
|
||||
#include "sslerr.h"
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
#include <stdio.h>
|
||||
#include <semLib.h>
|
||||
#include <openssl/provider.h>
|
||||
#include "ipcrypto_config.h"
|
||||
#endif
|
||||
|
||||
static int stopped = 0;
|
||||
static uint64_t optsdone = 0;
|
||||
@@ -109,8 +115,10 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_register_atexit)
|
||||
if (_onexit(win32atexit) == NULL)
|
||||
return 0;
|
||||
# else
|
||||
# if !defined(_WRS_KERNEL)
|
||||
if (atexit(OPENSSL_cleanup) != 0)
|
||||
return 0;
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
@@ -762,3 +770,117 @@ int OPENSSL_atexit(void (*handler)(void))
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
|
||||
BIO *bio_out = NULL;
|
||||
BIO *bio_err = NULL;
|
||||
char *default_config_file = IPCRYPTO_DEFAULT_CONFIG_FILE;
|
||||
|
||||
#define SEM_ID_NULL NULL
|
||||
|
||||
RAND_METHOD* vxRandLibMeth(void);
|
||||
|
||||
extern int OPENSSL_thread_started();
|
||||
|
||||
static STATUS openSSLTaskDeleteHook (TASK_ID taskId)
|
||||
{
|
||||
/*
|
||||
* Ensure OPENSSL_thread_stop is called for tasking using OpenSSL which
|
||||
* relies on TSS API.
|
||||
* OPENSSL_thread_stop might access TSS API for the first time and register
|
||||
* thrdDeleteHook if current task is not using OpenSSL. It is not a designed
|
||||
* behavior to register one task delete hook while running another one.
|
||||
*/
|
||||
|
||||
if (OPENSSL_thread_started ())
|
||||
{
|
||||
OPENSSL_thread_stop ();
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* crypto_init_internal - initialize openssl algorithms and setup callback function
|
||||
*/
|
||||
|
||||
int ipcrypto_init_internal(SEM_ID semId)
|
||||
{
|
||||
static int init = 0;
|
||||
OSSL_PROVIDER *legacy;
|
||||
OSSL_PROVIDER *deflt;
|
||||
|
||||
if(init == 0)
|
||||
{
|
||||
init = 1;
|
||||
|
||||
#ifndef _WRS_CONFIG_OPENSSL_FIPSMODULE
|
||||
RAND_set_rand_method(vxRandLibMeth());
|
||||
#endif
|
||||
|
||||
OpenSSL_add_all_algorithms();
|
||||
|
||||
/* Init things so we will get meaningful error messages rather than numbers. */
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
ENGINE_load_builtin_engines();
|
||||
#endif
|
||||
|
||||
legacy = OSSL_PROVIDER_load(NULL, "legacy");
|
||||
if (legacy == NULL) {
|
||||
printf("Failed to load Legacy provider\n");
|
||||
}
|
||||
deflt = OSSL_PROVIDER_load(NULL, "default");
|
||||
if (deflt == NULL) {
|
||||
printf("Failed to load Default provider\n");
|
||||
OSSL_PROVIDER_unload(legacy);
|
||||
}
|
||||
|
||||
#if defined (_WRS_KERNEL)
|
||||
/* use shareable FILEs rather than task-specific stdout/stderr */
|
||||
FILE * fpout = _Files[1];
|
||||
FILE * fperr = _Files[2];
|
||||
bio_out = BIO_new_fp(fpout, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
bio_err = BIO_new_fp(fperr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
#else
|
||||
bio_out = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
#endif /* _WRS_KERNEL */
|
||||
|
||||
/*
|
||||
* Explicitly deallocates resources associated with one task when task
|
||||
* exits. VxWorks uses C11 thread-specific API tssXXX to implement
|
||||
* CRYPTO_THREAD_XXX API. But as the cleanup passed to tss_create is
|
||||
* invoked only for C11 thread not for normal task or pthread, that
|
||||
* would cause memory leak without OPENSSL_thread_stop being called.
|
||||
* This step has to be placed at the end to make sure this hook is
|
||||
* added after TSS hook thrdDeleteHookInit and hence called earlier.
|
||||
*/
|
||||
|
||||
if (taskDeleteHookAdd ((FUNCPTR) openSSLTaskDeleteHook) != OK) {
|
||||
printf ("ipcrypto_init_internal() failed to add delete hook");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (semId)
|
||||
(void)semGive(semId);
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifndef _WRS_KERNEL
|
||||
/*******************************************************************************
|
||||
*
|
||||
* crypto_init - it must run after pthreadLibInit and pthreadRwLocksInit
|
||||
*/
|
||||
|
||||
_WRS_CONSTRUCTOR(ipcrypto_init, 70)
|
||||
{
|
||||
(void)ipcrypto_init_internal(SEM_ID_NULL);
|
||||
}
|
||||
|
||||
#endif /*_WRS_KERNEL*/
|
||||
#endif /*OPENSSL_SYS_VXWORKS*/
|
||||
|
||||
@@ -141,6 +141,8 @@ static union {
|
||||
CRYPTO_THREAD_LOCAL value;
|
||||
} destructor_key = { -1 };
|
||||
|
||||
static __thread int openssl_thread_started = 0;
|
||||
|
||||
/*
|
||||
* The thread event handler list is a thread specific linked list
|
||||
* of callback functions which are invoked in list order by the
|
||||
@@ -417,9 +419,22 @@ int ossl_init_thread_start(const void *index, void *arg,
|
||||
hand->next = *hands;
|
||||
*hands = hand;
|
||||
|
||||
#ifndef FIPS_MODULE
|
||||
openssl_thread_started = 1;
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int OPENSSL_thread_started()
|
||||
{
|
||||
#ifndef FIPS_MODULE
|
||||
return openssl_thread_started;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODULE
|
||||
static int init_thread_deregister(void *index, int all)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,9 @@ IF[{- !$disabled{asm} -}]
|
||||
$MD5ASM_loongarch64=md5-loongarch64.S
|
||||
$MD5ASM_sparcv9=md5-sparcv9.S
|
||||
|
||||
$MD5ASM_vx_x86=$MD5ASM_x86
|
||||
$MD5ASM_vx_x86_64=$MD5ASM_x86_64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$MD5ASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -42,10 +42,13 @@ VirtualLock(
|
||||
# endif
|
||||
# include <stdlib.h>
|
||||
# include <assert.h>
|
||||
# if defined(OPENSSL_SYS_UNIX)
|
||||
# if defined(OPENSSL_SYS_UNIX) || defined(OPENSSL_SYS_VXWORKS)
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
# include <sys/types.h>
|
||||
# if defined(OPENSSL_SYS_VXWORKS)
|
||||
# include <sys/mman.h>
|
||||
# endif
|
||||
# if defined(OPENSSL_SYS_UNIX)
|
||||
# include <sys/mman.h>
|
||||
# if defined(__FreeBSD__)
|
||||
@@ -63,8 +66,10 @@ VirtualLock(
|
||||
# endif
|
||||
# include <sys/param.h>
|
||||
# endif
|
||||
# if !defined(OPENSSL_SYS_VXWORKS)
|
||||
# include <sys/stat.h>
|
||||
# include <fcntl.h>
|
||||
# endif
|
||||
#endif
|
||||
#ifndef HAVE_MADVISE
|
||||
# if defined(MADV_DONTDUMP)
|
||||
|
||||
@@ -46,6 +46,23 @@ IF[{- !$disabled{asm} -}]
|
||||
$MODESASM_riscv64=ghash-riscv64.s ghash-riscv64-zvkb-zvbc.s ghash-riscv64-zvkg.s aes-gcm-riscv64-zvkb-zvkg-zvkned.s
|
||||
$MODESDEF_riscv64=GHASH_ASM
|
||||
|
||||
$MODESASM_vx_x86=$MODESASM_x86
|
||||
$MODESDEF_vx_x86=$MODESDEF_x86
|
||||
$MODESASM_vx_x86_64=$MODESASM_x86_64
|
||||
$MODESDEF_vx_x86_64=$MODESDEF_x86_64
|
||||
$MODESASM_vx_armv4=$MODESASM_armv4
|
||||
$MODESDEF_vx_armv4=$MODESDEF_armv4
|
||||
$MODESASM_vx_armv4_thumb=$MODESASM_armv4
|
||||
$MODESDEF_vx_armv4_thumb=$MODESDEF_armv4
|
||||
$MODESASM_vx_armv7a=$MODESASM_armv4
|
||||
$MODESDEF_vx_armv7a=$MODESDEF_armv4
|
||||
$MODESASM_vx_aarch64=$MODESASM_aarch64
|
||||
$MODESDEF_vx_aarch64=$MODESDEF_aarch64
|
||||
$MODESASM_vx_ppc32=$MODESASM_ppc32
|
||||
$MODESDEF_vx_ppc32=$MODESDEF_ppc32
|
||||
$MODESASM_vx_ppc64=$MODESASM_ppc64
|
||||
$MODESDEF_vx_ppc64=$MODESDEF_ppc64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$MODESASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -228,6 +228,9 @@ my $bltlr = sub {
|
||||
" .long ".sprintf "0x%x",19<<26|$bo<<21|16<<1 :
|
||||
" bclr $bo,0";
|
||||
};
|
||||
my $bltlr_ori = sub {
|
||||
" bltlr";
|
||||
};
|
||||
my $bnelr = sub {
|
||||
my $f = shift;
|
||||
my $bo = $f=~/\-/ ? 4+2 : 4; # optional "not to be taken" hint
|
||||
@@ -242,6 +245,9 @@ my $beqlr = sub {
|
||||
" .long ".sprintf "0x%X",19<<26|$bo<<21|2<<16|16<<1 :
|
||||
" bclr $bo,2";
|
||||
};
|
||||
my $beqlr_ori = sub {
|
||||
" beqlr";
|
||||
};
|
||||
# GNU assembler can't handle extrdi rA,rS,16,48, or when sum of last two
|
||||
# arguments is 64, with "operand out of range" error.
|
||||
my $extrdi = sub {
|
||||
|
||||
@@ -21,6 +21,13 @@ IF[{- !$disabled{asm} -}]
|
||||
|
||||
$POLY1305ASM_c64xplus=poly1305-c64xplus.s
|
||||
|
||||
$POLY1305ASM_vx_x86=$POLY1305ASM_x86
|
||||
$POLY1305ASM_vx_x86_64=$POLY1305ASM_x86_64
|
||||
$POLY1305ASM_vx_armv4=$POLY1305ASM_armv4
|
||||
$POLY1305ASM_vx_aarch64=$POLY1305ASM_aarch64
|
||||
$POLY1305ASM_vx_ppc32=$POLY1305ASM_ppc32
|
||||
$POLY1305ASM_vx_ppc64=$POLY1305ASM_ppc64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$POLY1305ASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -37,7 +37,11 @@ static sigset_t all_masked;
|
||||
static sigjmp_buf ill_jmp;
|
||||
static void ill_handler(int sig)
|
||||
{
|
||||
#ifdef OPENSSL_SYS_VXWORKS_SUPPORT
|
||||
longjmp(ill_jmp, sig);
|
||||
#else
|
||||
siglongjmp(ill_jmp, sig);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OPENSSL_fpu_probe(void);
|
||||
@@ -287,8 +291,10 @@ void OPENSSL_cpuid_setup(void)
|
||||
if (uname(&uts) == 0 && strcmp(uts.machine, "ppc64") == 0)
|
||||
# endif
|
||||
if (sigsetjmp(ill_jmp, 1) == 0) {
|
||||
# if defined (OPENSSL_SYS_VXWORKS_SUPPORT) && defined (_WRS_CONFIG_LP64)
|
||||
OPENSSL_ppc64_probe();
|
||||
OPENSSL_ppccap_P |= PPC_FPU64;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
@@ -297,6 +303,7 @@ void OPENSSL_cpuid_setup(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_SYS_VXWORKS_SUPPORT
|
||||
if (sigsetjmp(ill_jmp, 1) == 0) {
|
||||
OPENSSL_altivec_probe();
|
||||
OPENSSL_ppccap_P |= PPC_ALTIVEC;
|
||||
@@ -319,6 +326,7 @@ void OPENSSL_cpuid_setup(void)
|
||||
OPENSSL_rdtsc_mfspr268();
|
||||
OPENSSL_ppccap_P |= PPC_MFSPR268;
|
||||
}
|
||||
#endif
|
||||
|
||||
sigaction(SIGILL, &ill_oact, NULL);
|
||||
sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
|
||||
@@ -164,7 +164,7 @@ Ladd: lwarx r5,0,r3
|
||||
li r0,0
|
||||
bge Lot
|
||||
$CMPLI r4,0
|
||||
beqlr-
|
||||
beqlr_ori
|
||||
Little: mtctr r4
|
||||
stb r0,0(r3)
|
||||
addi r3,r3,1
|
||||
|
||||
@@ -411,7 +411,7 @@ OSSL_PROVIDER *ossl_provider_find(OSSL_LIB_CTX *libctx, const char *name,
|
||||
* Make sure any providers are loaded from config before we try to find
|
||||
* them.
|
||||
*/
|
||||
if (!noconfig) {
|
||||
if ((!noconfig) && (strncmp (name, "fips", sizeof ("fips")) == 0)) {
|
||||
if (ossl_lib_ctx_is_default(libctx))
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL);
|
||||
}
|
||||
|
||||
@@ -212,6 +212,7 @@ void RAND_keep_random_devices_open(int keep)
|
||||
ossl_rand_pool_keep_random_devices_open(keep);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* RAND_poll() reseeds the default RNG using random input
|
||||
*
|
||||
@@ -258,6 +259,7 @@ int RAND_poll(void)
|
||||
RAND_seed(salt, sizeof(salt));
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
static int rand_set_rand_method_internal(const RAND_METHOD *meth,
|
||||
@@ -309,10 +311,14 @@ const RAND_METHOD *RAND_get_rand_method(void)
|
||||
default_RAND_meth = tmp_meth;
|
||||
} else {
|
||||
ENGINE_finish(e);
|
||||
#if !defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
default_RAND_meth = &ossl_rand_meth;
|
||||
#endif
|
||||
}
|
||||
# else
|
||||
#if !defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
default_RAND_meth = &ossl_rand_meth;
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
tmp_meth = default_RAND_meth;
|
||||
@@ -1147,3 +1153,28 @@ int ossl_rand_check_random_provider_on_unload(OSSL_LIB_CTX *ctx,
|
||||
}
|
||||
|
||||
#endif /* !FIPS_MODULE */
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)&&!defined(FIPS_MODULE)
|
||||
#include <vxWorks.h>
|
||||
#include <randomNumGen.h>
|
||||
|
||||
int RAND_poll(void)
|
||||
{
|
||||
char uninitialized_buf[32];
|
||||
char tmp[32];
|
||||
int i;
|
||||
|
||||
(void)RAND_add(uninitialized_buf, 32, 20);
|
||||
|
||||
for (i=0;i<10;i++)
|
||||
{
|
||||
if (randPseudoBytes(tmp, sizeof(tmp)) == OK)
|
||||
(void)RAND_add(tmp, sizeof(tmp), sizeof(tmp));
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ IF[{- !$disabled{asm} -}]
|
||||
$RC4ASM_parisc20_64=$RC4ASM_parisc11
|
||||
$RC4ASM_c64xplus=rc4-c64xplus.s
|
||||
|
||||
$RC4ASM_vx_x86=$RC4ASM_x86
|
||||
$RC4ASM_vx_x86_64=$RC4ASM_x86_64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$RC4ASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -4,6 +4,8 @@ $RC5ASM=rc5_enc.c
|
||||
IF[{- !$disabled{asm} -}]
|
||||
$RC5ASM_x86=rc5-586.S
|
||||
|
||||
$RC5ASM_vx_x86=$RC5ASM_x86
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$RC5ASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -4,6 +4,8 @@ $RMD160ASM=
|
||||
IF[{- !$disabled{asm} -}]
|
||||
$RMD160ASM_x86=rmd-586.S
|
||||
|
||||
$RMD160ASM_vx_x86=$RMD160ASM_x86
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$RMD160ASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -480,6 +480,51 @@ int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RSA_setnull_factors(RSA *r, int p, int q)
|
||||
{
|
||||
if (p) {
|
||||
r->p = NULL;
|
||||
}
|
||||
|
||||
if (q){
|
||||
r->q = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RSA_setnull_key(RSA *r, int n, int e, int d)
|
||||
{
|
||||
if (n){
|
||||
r->n = NULL;
|
||||
}
|
||||
|
||||
if (e){
|
||||
r->e = NULL;
|
||||
}
|
||||
|
||||
if (d){
|
||||
r->d = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RSA_setnull_crt_params(RSA *r, int dmp1, int dmq1, int iqmp)
|
||||
{
|
||||
|
||||
if (dmp1) {
|
||||
r->dmp1 = NULL;
|
||||
}
|
||||
|
||||
if (dmq1) {
|
||||
r->dmq1 = NULL;
|
||||
}
|
||||
|
||||
if (iqmp) {
|
||||
r->iqmp = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifndef FIPS_MODULE
|
||||
/*
|
||||
* Is it better to export RSA_PRIME_INFO structure
|
||||
|
||||
@@ -194,6 +194,18 @@ int ossl_rsa_sp800_56b_validate_strength(int nbits, int strength)
|
||||
*/
|
||||
static int rsa_validate_rng_strength(EVP_RAND_CTX *rng, int nbits)
|
||||
{
|
||||
/*
|
||||
* VxWorks doesn't implement DRBG and use its own RAND_METHOD to server
|
||||
* following APIs:
|
||||
* RAND_bytes
|
||||
* RAND_priv_bytes
|
||||
* RAND_bytes_ex
|
||||
* RAND_priv_bytes_ex
|
||||
*/
|
||||
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
if (rng == NULL)
|
||||
return 0;
|
||||
#ifdef FIPS_MODULE
|
||||
|
||||
@@ -48,6 +48,24 @@ IF[{- !$disabled{asm} -}]
|
||||
|
||||
$SHA1ASM_riscv64=sha_riscv.c sha256-riscv64-zvkb-zvknha_or_zvknhb.S sha512-riscv64-zvkb-zvknhb.S
|
||||
$SHA1DEF_riscv64=SHA256_ASM INCLUDE_C_SHA256 SHA512_ASM INCLUDE_C_SHA512
|
||||
$SHA1ASM_vx_x86=$SHA1ASM_x86
|
||||
$SHA1DEF_vx_x86=$SHA1DEF_x86
|
||||
$SHA1ASM_vx_x86_64=$SHA1ASM_x86_64
|
||||
$SHA1DEF_vx_x86_64=$SHA1DEF_x86_64
|
||||
$SHA1ASM_vx_armv4=$SHA1ASM_armv4
|
||||
$SHA1DEF_vx_armv4=$SHA1DEF_armv4
|
||||
$SHA1ASM_vx_armv4_thumb=$SHA1ASM_armv4
|
||||
$SHA1DEF_vx_armv4_thumb=$SHA1DEF_armv4
|
||||
$SHA1ASM_vx_armv7m=$SHA1ASM_armv4
|
||||
$SHA1DEF_vx_armv7m=$SHA1DEF_armv4
|
||||
$SHA1ASM_vx_armv7a=$SHA1ASM_armv4
|
||||
$SHA1DEF_vx_armv7a=$SHA1DEF_armv4
|
||||
$SHA1ASM_vx_aarch64=$SHA1ASM_aarch64
|
||||
$SHA1DEF_vx_aarch64=$SHA1DEF_aarch64
|
||||
$SHA1ASM_vx_ppc32=$SHA1ASM_ppc32
|
||||
$SHA1DEF_vx_ppc32=$SHA1DEF_ppc32
|
||||
$SHA1ASM_vx_ppc64=$SHA1ASM_ppc64
|
||||
$SHA1DEF_vx_ppc64=$SHA1DEF_ppc64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
@@ -69,6 +87,15 @@ IF[{- !$disabled{asm} -}]
|
||||
|
||||
$KECCAK1600ASM_ppc64=keccak1600-ppc64.s
|
||||
|
||||
$KECCAK1600ASM_vx_x86=$KECCAK1600ASM_x86
|
||||
$KECCAK1600ASM_vx_x86_64=$KECCAK1600ASM_x86_64
|
||||
$KECCAK1600ASM_vx_armv4=$KECCAK1600ASM_armv4
|
||||
$KECCAK1600ASM_vx_armv4_thumb=$KECCAK1600ASM_armv4
|
||||
$KECCAK1600ASM_vx_armv7m=$KECCAK1600ASM_armv4
|
||||
$KECCAK1600ASM_vx_armv7a=$KECCAK1600ASM_armv4
|
||||
$KECCAK1600ASM_vx_aarch64=$KECCAK1600ASM_aarch64
|
||||
$KECCAK1600ASM_vx_ppc64=$KECCAK1600ASM_ppc64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$KECCAK1600ASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright 2016-2022 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
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2022 Wind River Systems, Inc. */
|
||||
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <private/semLibP.h>
|
||||
#include <openssl/crypto.h>
|
||||
|
||||
#if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && defined(OPENSSL_SYS_VXWORKS)
|
||||
|
||||
# define SEM_MAX_READERS 0x20
|
||||
# define SEM_CREATE(options) semRWCreate((int) options, (int) SEM_MAX_READERS)
|
||||
# define SEM_R_TAKE(sem, timeout) semRTake((SEM_ID) sem, (_Vx_ticks_t) timeout)
|
||||
# define SEM_W_TAKE(sem, timeout) semWTake((SEM_ID) sem, (_Vx_ticks_t) timeout)
|
||||
# define SEM_DELETE(sem) semDelete((SEM_ID) sem)
|
||||
|
||||
# if defined(_WRS_KERNEL)
|
||||
# define SEM_GIVE(sem) semRWGive((SEM_ID) sem)
|
||||
# else
|
||||
# define SEM_GIVE(sem) semGive((SEM_ID) sem)
|
||||
# endif
|
||||
|
||||
CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
|
||||
{
|
||||
CRYPTO_RWLOCK *lock;
|
||||
|
||||
lock = SEM_CREATE (SEM_Q_PRIORITY);
|
||||
|
||||
if (SEM_ID_NULL == lock) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return lock;
|
||||
}
|
||||
|
||||
int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
|
||||
{
|
||||
if(SEM_R_TAKE(lock, WAIT_FOREVER) != OK)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
|
||||
{
|
||||
if(SEM_W_TAKE(lock, WAIT_FOREVER) != OK)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)
|
||||
{
|
||||
if(SEM_GIVE(lock) != OK)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
|
||||
{
|
||||
if (lock == NULL)
|
||||
return;
|
||||
|
||||
SEM_DELETE(lock);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
|
||||
{
|
||||
call_once(once, init);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))
|
||||
{
|
||||
if (tss_create(key, cleanup) != thrd_success)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
|
||||
{
|
||||
return tss_get(*key);
|
||||
}
|
||||
|
||||
int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
|
||||
{
|
||||
if (tss_set(*key, val) != thrd_success)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)
|
||||
{
|
||||
tss_delete(*key);
|
||||
return 1;
|
||||
}
|
||||
|
||||
CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void)
|
||||
{
|
||||
return taskIdSelf ();
|
||||
}
|
||||
|
||||
int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b)
|
||||
{
|
||||
return (a == b);
|
||||
}
|
||||
|
||||
int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
|
||||
{
|
||||
*ret = vxAtomic32Add(val, amount) + amount;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if (_VX_CPU_FAMILY == _VX_PPC) && defined (_WRS_CONFIG_ILP32)
|
||||
int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret,
|
||||
CRYPTO_RWLOCK *lock)
|
||||
{
|
||||
*val |= op;
|
||||
*ret = *val;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock)
|
||||
{
|
||||
*ret = *val;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret,
|
||||
CRYPTO_RWLOCK *lock)
|
||||
{
|
||||
*ret = (uint64_t)vxAtomic64Or((atomic64_t *)val, (atomic64Val_t)op) | op;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock)
|
||||
{
|
||||
*ret = (uint64_t)vxAtomic64Or((atomic64_t *)val, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int openssl_init_fork_handlers(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int openssl_get_fork_id(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,10 +5,16 @@ IF[{- !$disabled{asm} -}]
|
||||
IF[{- $config{processor} ne "386" -}]
|
||||
$WPASM_x86=wp_block.c wp-mmx.S
|
||||
$WPDEF_x86=WHIRLPOOL_ASM
|
||||
|
||||
$WPASM_vx_x86=$WPASM_x86
|
||||
$WPDEF_vx_x86=$WPDEF_x86
|
||||
ENDIF
|
||||
$WPASM_x86_64=wp-x86_64.s
|
||||
$WPDEF_x86_64=WHIRLPOOL_ASM
|
||||
|
||||
$WPASM_vx_x86_64=$WPASM_x86_64
|
||||
$WPDEF_vx_x86_64=$WPDEF_x86_64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$WPASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -4,6 +4,9 @@ IF[{- !$disabled{"engine"} -}]
|
||||
$PADLOCKASM_x86=e_padlock-x86.S
|
||||
$PADLOCKASM_x86_64=e_padlock-x86_64.s
|
||||
|
||||
$PADLOCKASM_vx_x86=$PADLOCKASM_x86
|
||||
$PADLOCKASM_vx_x86_64=$PADLOCKASM_x86_64
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$PADLOCKASM_{- $target{asm_arch} -}]
|
||||
|
||||
@@ -163,11 +163,7 @@ FILE *__iob_func(void);
|
||||
|
||||
# else /* The non-microsoft world */
|
||||
|
||||
# if defined(OPENSSL_SYS_VXWORKS)
|
||||
# include <time.h>
|
||||
# else
|
||||
# include <sys/time.h>
|
||||
# endif
|
||||
#include <sys/time.h>
|
||||
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
# define VMS 1
|
||||
@@ -222,7 +218,9 @@ FILE *__iob_func(void);
|
||||
# endif
|
||||
|
||||
# define LIST_SEPARATOR_CHAR ':'
|
||||
# if !defined(OPENSSL_SYS_VXWORKS)
|
||||
# define EXIT(n) exit(n)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# endif
|
||||
@@ -253,9 +251,31 @@ FILE *__iob_func(void);
|
||||
# include <vxWorks.h>
|
||||
# include <sockLib.h>
|
||||
# include <taskLib.h>
|
||||
# include <vsbConfig.h>
|
||||
# include <sys/un.h>
|
||||
# include <sys/types.h>
|
||||
|
||||
|
||||
# define TTY_STRUCT int
|
||||
# define sleep(a) taskDelay((a) * sysClkRateGet())
|
||||
# define EXIT(n) return(n)
|
||||
|
||||
# undef DEVRANDOM
|
||||
# define MFUNC
|
||||
# define OPENSSL_NO_HW_4758_CCA
|
||||
# define OPENSSL_NO_HW_AEP
|
||||
# define OPENSSL_NO_HW_ATALLA
|
||||
# define OPENSSL_NO_HW_CSWIFT
|
||||
# define OPENSSL_NO_HW_NCIPHER
|
||||
# define OPENSSL_NO_HW_NURON
|
||||
# define OPENSSL_NO_HW_SUREWARE
|
||||
# define OPENSSL_NO_HW_UBSEC
|
||||
# define OPENSSL_NO_PADLOCKENG
|
||||
# define OPENSSL_NO_GOST
|
||||
# define NO_SYS_UN_H
|
||||
# define NO_SYS_PARAM_H
|
||||
# define OPENSSL_NO_IDEA
|
||||
# define OPENSSL_NO_MDC2
|
||||
|
||||
/*
|
||||
* NOTE: these are implemented by helpers in database app! if the database is
|
||||
|
||||
@@ -32,6 +32,25 @@
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined(OPENSSL_SYS_VXWORKS) && defined(_WRS_CONFIG_ARM_ARMV7M) && !defined(_WRS_CONFIG_SUPPORTS_LDREX_STREX)
|
||||
|
||||
typedef atomic32_t CRYPTO_REF_COUNT;
|
||||
|
||||
static inline int CRYPTO_UP_REF(_Atomic int *val, int *ret, void *lock)
|
||||
{
|
||||
vxAtomicInc(val);
|
||||
*ret = *val;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock)
|
||||
{
|
||||
vxAtomicDec(val);
|
||||
*ret = *val;
|
||||
return 1;
|
||||
}
|
||||
# else
|
||||
|
||||
typedef struct {
|
||||
_Atomic int val;
|
||||
} CRYPTO_REF_COUNT;
|
||||
@@ -73,6 +92,7 @@ static inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret)
|
||||
*ret = atomic_load_explicit(&refcnt->val, memory_order_acquire);
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ typedef size_t socklen_t; /* Currently appears to be missing on VMS */
|
||||
# define readsocket(s,b,n) recv((s),(b),(n),0)
|
||||
# define writesocket(s,b,n) send((s),(b),(n),0)
|
||||
# elif defined(OPENSSL_SYS_VXWORKS)
|
||||
# define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
|
||||
# define ioctlsocket(a,b,c) ioctl((a),(b),(_Vx_ioctl_arg_t)(c))
|
||||
# define closesocket(s) close(s)
|
||||
# define readsocket(s,b,n) read((s),(b),(n))
|
||||
# define writesocket(s,b,n) write((s),(char *)(b),(n))
|
||||
|
||||
+25
-7
@@ -57,13 +57,24 @@
|
||||
|
||||
# if defined(ATOMIC_POINTER_LOCK_FREE) \
|
||||
&& ATOMIC_POINTER_LOCK_FREE >= 2
|
||||
# define TSAN_QUALIFIER _Atomic
|
||||
# define tsan_load(ptr) atomic_load_explicit((ptr), memory_order_relaxed)
|
||||
# define tsan_store(ptr, val) atomic_store_explicit((ptr), (val), memory_order_relaxed)
|
||||
# define tsan_add(ptr, n) atomic_fetch_add_explicit((ptr), (n), memory_order_relaxed)
|
||||
# define tsan_ld_acq(ptr) atomic_load_explicit((ptr), memory_order_acquire)
|
||||
# define tsan_st_rel(ptr, val) atomic_store_explicit((ptr), (val), memory_order_release)
|
||||
# endif
|
||||
|
||||
# define TSAN_QUALIFIER _Atomic
|
||||
|
||||
# if defined(OPENSSL_SYS_VXWORKS) && defined(_WRS_CONFIG_ARM_ARMV7M) && !defined(_WRS_CONFIG_SUPPORTS_LDREX_STREX)
|
||||
# define tsan_load(ptr) vxAtomicGet((ptr))
|
||||
# define tsan_store(ptr, val) vxAtomicStore((ptr), (val))
|
||||
# define tsan_add(ptr,n ) vxAtomicAdd((ptr), (n))
|
||||
# define tsan_ld_acq(ptr) vxAtomicGet((ptr))
|
||||
# define tsan_st_rel(ptr, val) vxAtomicStore((ptr), (val))
|
||||
# else
|
||||
# define tsan_load(ptr) atomic_load_explicit((ptr), memory_order_relaxed)
|
||||
# define tsan_store(ptr, val) atomic_store_explicit((ptr), (val), memory_order_relaxed)
|
||||
# define tsan_add(ptr, n) atomic_fetch_add_explicit((ptr), (n), memory_order_relaxed)
|
||||
# define tsan_ld_acq(ptr) atomic_load_explicit((ptr), memory_order_acquire)
|
||||
# define tsan_st_rel(ptr, val) atomic_store_explicit((ptr), (val), memory_order_release)
|
||||
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED)
|
||||
|
||||
@@ -147,7 +158,14 @@
|
||||
|
||||
# endif
|
||||
|
||||
# if defined(OPENSSL_SYS_VXWORKS) && defined(_WRS_CONFIG_ARM_ARMV7M) && !defined(_WRS_CONFIG_SUPPORTS_LDREX_STREX)
|
||||
#define tsan_counter(ptr) vxAtomicAdd((ptr), 1)
|
||||
#define tsan_decr(ptr) vxAtomicAdd((ptr), -1)
|
||||
#else
|
||||
# define tsan_counter(ptr) tsan_add((ptr), 1)
|
||||
# define tsan_decr(ptr) tsan_add((ptr), -1)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -53,6 +53,16 @@ use OpenSSL::stackhash qw(generate_stack_macros);
|
||||
# include <openssl/opensslv.h>
|
||||
# endif
|
||||
|
||||
# if defined(OPENSSL_SYS_VXWORKS) && defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG)
|
||||
#include <taskLib.h>
|
||||
/* threads.h cannot be included from C++ files, so define these types */
|
||||
typedef int once_flag;
|
||||
typedef unsigned int tss_t;
|
||||
# ifndef __cplusplus
|
||||
#include <threads.h>
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -504,6 +514,11 @@ typedef DWORD CRYPTO_THREAD_ID;
|
||||
typedef LONG CRYPTO_ONCE;
|
||||
# define CRYPTO_ONCE_STATIC_INIT 0
|
||||
# endif
|
||||
# elif defined(OPENSSL_SYS_VXWORKS)
|
||||
typedef once_flag CRYPTO_ONCE;
|
||||
typedef tss_t CRYPTO_THREAD_LOCAL;
|
||||
typedef TASK_ID CRYPTO_THREAD_ID;
|
||||
# define CRYPTO_ONCE_STATIC_INIT ONCE_FLAG_INIT
|
||||
# else
|
||||
# if defined(__TANDEM) && defined(_SPT_MODEL_)
|
||||
# define SPT_THREAD_SIGNAL 1
|
||||
|
||||
@@ -215,6 +215,9 @@ OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_q(const DSA *d);
|
||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_g(const DSA *d);
|
||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_pub_key(const DSA *d);
|
||||
OSSL_DEPRECATEDIN_3_0 const BIGNUM *DSA_get0_priv_key(const DSA *d);
|
||||
|
||||
OSSL_DEPRECATEDIN_3_0 void DSA_setnull_priv_key(DSA *d);
|
||||
|
||||
OSSL_DEPRECATEDIN_3_0 void DSA_clear_flags(DSA *d, int flags);
|
||||
OSSL_DEPRECATEDIN_3_0 int DSA_test_flags(const DSA *d, int flags);
|
||||
OSSL_DEPRECATEDIN_3_0 void DSA_set_flags(DSA *d, int flags);
|
||||
|
||||
@@ -153,6 +153,12 @@ extern "C" {
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* -------------------------------- VxWorks ----------------------------------- */
|
||||
# if defined(OPENSSL_SYS_VXWORKS)
|
||||
# undef OPENSSL_SYS_UNIX
|
||||
# undef ENGINESDIR
|
||||
# endif
|
||||
|
||||
/**
|
||||
* That's it for OS-specific stuff
|
||||
*****************************************************************************/
|
||||
|
||||
@@ -628,6 +628,10 @@ int EVP_CIPHER_get_mode(const EVP_CIPHER *cipher);
|
||||
# define EVP_CIPHER_mode EVP_CIPHER_get_mode
|
||||
int EVP_CIPHER_get_type(const EVP_CIPHER *cipher);
|
||||
# define EVP_CIPHER_type EVP_CIPHER_get_type
|
||||
/*OPENSSL_SYS_VXWORKS_SUPPORT*/
|
||||
void *EVP_CIPHER_get_app_data(const EVP_CIPHER *cipher);
|
||||
void EVP_CIPHER_set_app_data(EVP_CIPHER *cipher, void *data);
|
||||
/*OPENSSL_SYS_VXWORKS_SUPPORT end*/
|
||||
EVP_CIPHER *EVP_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
|
||||
const char *properties);
|
||||
int EVP_CIPHER_can_pipeline(const EVP_CIPHER *cipher, int enc);
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
# pragma once
|
||||
|
||||
# include <openssl/configuration.h>
|
||||
|
||||
#undef OPENSSL_NO_DEPRECATED
|
||||
#define OPENSSL_SUPPRESS_DEPRECATED
|
||||
# include <openssl/macros.h>
|
||||
|
||||
#endif /* OPENSSL_OPENSSLCONF_H */
|
||||
|
||||
@@ -254,6 +254,9 @@ OSSL_DEPRECATEDIN_3_0 int RSA_test_flags(const RSA *r, int flags);
|
||||
OSSL_DEPRECATEDIN_3_0 void RSA_set_flags(RSA *r, int flags);
|
||||
OSSL_DEPRECATEDIN_3_0 int RSA_get_version(RSA *r);
|
||||
OSSL_DEPRECATEDIN_3_0 ENGINE *RSA_get0_engine(const RSA *r);
|
||||
OSSL_DEPRECATEDIN_3_0 void RSA_setnull_factors(RSA *r, int p, int q);
|
||||
OSSL_DEPRECATEDIN_3_0 void RSA_setnull_key(RSA *r, int n, int e, int d);
|
||||
OSSL_DEPRECATEDIN_3_0 void RSA_setnull_crt_params(RSA *r, int dmp1, int dmq1, int iqmp);
|
||||
# endif /* !OPENSSL_NO_DEPRECATED_3_0 */
|
||||
|
||||
# define EVP_RSA_gen(bits) \
|
||||
|
||||
@@ -114,11 +114,13 @@ IF[{- !$disabled{fips} -}]
|
||||
SOURCE[$FIPSGOAL]=fips.ld
|
||||
GENERATE[fips.ld]=../util/providers.num
|
||||
ENDIF
|
||||
|
||||
DEPEND[|build_modules_nodep|]=fipsmodule.cnf
|
||||
|
||||
IF[{- !$disabled{shared} -}]
|
||||
DEPEND[|build_modules_nodep|]=fipsmodule.cnf
|
||||
GENERATE[fipsmodule.cnf]=../util/mk-fipsmodule-cnf.pl \
|
||||
-module $(FIPSMODULE) -section_name fips_sect -key $(FIPSKEY)
|
||||
-module $(FIPSMODULE) -section_name fips_sect -key $(FIPSKEY)
|
||||
DEPEND[fipsmodule.cnf]=$FIPSGOAL
|
||||
ENDIF
|
||||
|
||||
# Add VERSIONINFO resource for windows
|
||||
IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-|BC-)/ -}]
|
||||
@@ -161,6 +163,11 @@ IF[{- !$disabled{legacy} -}]
|
||||
ENDIF
|
||||
|
||||
SOURCE[$LIBLEGACY]=prov_running.c
|
||||
IF[{- $disabled{shared} -}]
|
||||
DEFINE[$LEGACYGOAL]=STATIC_LEGACY
|
||||
SOURCE[liblegacy.a]=legacyprov.c
|
||||
DEFINE[liblegacy.a]=STATIC_LEGACY
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
# Common things that are valid no matter what form the Legacy provider
|
||||
|
||||
@@ -160,7 +160,11 @@ void __TERM__cleanup(void) {
|
||||
# define DEP_INITIAL_STATE FIPS_STATE_SELFTEST
|
||||
#endif
|
||||
|
||||
#if defined (_WRS_KERNEL)
|
||||
static TSAN_QUALIFIER int FIPS_state = FIPS_STATE_SELFTEST;
|
||||
#else
|
||||
static TSAN_QUALIFIER int FIPS_state = DEP_INITIAL_STATE;
|
||||
#endif
|
||||
|
||||
#if defined(DEP_INIT_ATTRIBUTE)
|
||||
DEP_INIT_ATTRIBUTE void init(void)
|
||||
|
||||
+2
-1
@@ -425,7 +425,8 @@ static int mac_gen_set_params(void *genctx, const OSSL_PARAM params[])
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
gctx->priv_key = OPENSSL_secure_malloc(p->data_size);
|
||||
/* allocate at least one byte to distinguish empty key from no key set */
|
||||
gctx->priv_key = OPENSSL_secure_malloc(p->data_size > 0 ? p->data_size : 1);
|
||||
if (gctx->priv_key == NULL)
|
||||
return 0;
|
||||
memcpy(gctx->priv_key, p->data, p->data_size);
|
||||
|
||||
+7
-6
@@ -30,7 +30,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(RAND_SEED_VXRANDLIB)
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
# include <randomNumGen.h>
|
||||
#endif
|
||||
|
||||
@@ -100,7 +100,7 @@ int ossl_pool_add_nonce_data(RAND_POOL *pool)
|
||||
|
||||
size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
|
||||
{
|
||||
#if defined(RAND_SEED_VXRANDLIB)
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
/* vxRandLib based entropy method */
|
||||
size_t bytes_needed;
|
||||
|
||||
@@ -112,13 +112,14 @@ size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
|
||||
|
||||
buffer = ossl_rand_pool_add_begin(pool, bytes_needed);
|
||||
while ((result != OK) && (retryCount < 10)) {
|
||||
RANDOM_NUM_GEN_STATUS status = randStatus();
|
||||
int status = randSecure();
|
||||
|
||||
if ((status == RANDOM_NUM_GEN_ENOUGH_ENTROPY)
|
||||
|| (status == RANDOM_NUM_GEN_MAX_ENTROPY)) {
|
||||
result = randBytes(buffer, bytes_needed);
|
||||
if (status == 1) {
|
||||
result = randUBytes(buffer, bytes_needed);
|
||||
if (result == OK)
|
||||
{
|
||||
ossl_rand_pool_add_end(pool, bytes_needed, 8 * bytes_needed);
|
||||
}
|
||||
/*
|
||||
* no else here: randStatus said ok, if randBytes failed
|
||||
* it will result in another loop or no entropy
|
||||
|
||||
@@ -466,6 +466,7 @@ int setup_tests(void)
|
||||
}
|
||||
# endif
|
||||
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_PRINT:
|
||||
@@ -477,6 +478,7 @@ int setup_tests(void)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ADD_ALL_TESTS(test_bf_ecb_raw, 2);
|
||||
ADD_ALL_TESTS(test_bf_ecb, NUM_TESTS);
|
||||
|
||||
@@ -3357,6 +3357,7 @@ const OPTIONS *test_get_options(void)
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
OPTION_CHOICE o;
|
||||
int n, stochastic = 0;
|
||||
|
||||
@@ -3373,6 +3374,8 @@ int setup_tests(void)
|
||||
}
|
||||
}
|
||||
n = test_get_argument_count();
|
||||
#endif
|
||||
int n = 0, stochastic = 0;
|
||||
|
||||
if (!TEST_ptr(ctx = BN_CTX_new()))
|
||||
return 0;
|
||||
|
||||
@@ -216,10 +216,12 @@ end:
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
if (!test_skip_common_options()) {
|
||||
TEST_error("Error parsing test options\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
ADD_ALL_TESTS(test_client_hello, TOTAL_NUM_TESTS);
|
||||
return 1;
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "testutil.h"
|
||||
|
||||
#ifndef OPENSSL_NO_CMAC
|
||||
|
||||
static const char xtskey[32] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
|
||||
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
@@ -338,12 +340,15 @@ static char *pt(unsigned char *md, unsigned int len)
|
||||
OSSL_HEX_CHARS_PER_BYTE + 1, "%02x", md[i]);
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_CMAC
|
||||
ADD_TEST(test_cmac_bad);
|
||||
ADD_TEST(test_cmac_run);
|
||||
ADD_TEST(test_cmac_copy);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -709,6 +709,7 @@ const OPTIONS *test_get_options(void)
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
OPTION_CHOICE o;
|
||||
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
@@ -730,6 +731,7 @@ int setup_tests(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ADD_TEST(test_x448);
|
||||
ADD_TEST(test_ed448);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
# include "internal/nelem.h"
|
||||
# include "ecdsatest.h"
|
||||
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
static fake_random_generate_cb fbytes;
|
||||
|
||||
static const char *numbers[2];
|
||||
@@ -156,6 +157,167 @@ static int x9_62_tests(int n)
|
||||
BN_clear_free(rp);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
/* functions to change the RAND_METHOD */
|
||||
static int fbytes(unsigned char *buf, int num);
|
||||
|
||||
static RAND_METHOD fake_rand;
|
||||
static const RAND_METHOD *old_rand;
|
||||
static int use_fake = 0;
|
||||
static const char *numbers[2];
|
||||
static size_t crv_len = 0;
|
||||
static EC_builtin_curve *curves = NULL;
|
||||
|
||||
static int change_rand(void)
|
||||
{
|
||||
/* save old rand method */
|
||||
if (!TEST_ptr(old_rand = RAND_get_rand_method()))
|
||||
return 0;
|
||||
|
||||
fake_rand = *old_rand;
|
||||
/* use own random function */
|
||||
fake_rand.bytes = fbytes;
|
||||
/* set new RAND_METHOD */
|
||||
if (!TEST_true(RAND_set_rand_method(&fake_rand)))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int restore_rand(void)
|
||||
{
|
||||
if (!TEST_true(RAND_set_rand_method(old_rand)))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int fbytes(unsigned char *buf, int num)
|
||||
{
|
||||
int ret = 0;
|
||||
static int fbytes_counter = 0;
|
||||
BIGNUM *tmp = NULL;
|
||||
|
||||
if (use_fake == 0)
|
||||
return old_rand->bytes(buf, num);
|
||||
|
||||
use_fake = 0;
|
||||
|
||||
if (!TEST_ptr(tmp = BN_new())
|
||||
|| !TEST_int_lt(fbytes_counter, OSSL_NELEM(numbers))
|
||||
|| !TEST_true(BN_hex2bn(&tmp, numbers[fbytes_counter]))
|
||||
/* tmp might need leading zeros so pad it out */
|
||||
|| !TEST_int_le(BN_num_bytes(tmp), num)
|
||||
|| !TEST_true(BN_bn2binpad(tmp, buf, num)))
|
||||
goto err;
|
||||
|
||||
fbytes_counter = (fbytes_counter + 1) % OSSL_NELEM(numbers);
|
||||
ret = 1;
|
||||
err:
|
||||
BN_free(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*-
|
||||
* This function hijacks the RNG to feed it the chosen ECDSA key and nonce.
|
||||
* The ECDSA KATs are from:
|
||||
* - the X9.62 draft (4)
|
||||
* - NIST CAVP (720)
|
||||
*
|
||||
* It uses the low-level ECDSA_sign_setup instead of EVP to control the RNG.
|
||||
* NB: This is not how applications should use ECDSA; this is only for testing.
|
||||
*
|
||||
* Tests the library can successfully:
|
||||
* - generate public keys that matches those KATs
|
||||
* - create ECDSA signatures that match those KATs
|
||||
* - accept those signatures as valid
|
||||
*/
|
||||
static int x9_62_tests(int n)
|
||||
{
|
||||
int nid, md_nid, ret = 0;
|
||||
const char *r_in = NULL, *s_in = NULL, *tbs = NULL;
|
||||
unsigned char *pbuf = NULL, *qbuf = NULL, *message = NULL;
|
||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
||||
unsigned int dgst_len = 0;
|
||||
long q_len, msg_len = 0;
|
||||
size_t p_len;
|
||||
EVP_MD_CTX *mctx = NULL;
|
||||
EC_KEY *key = NULL;
|
||||
ECDSA_SIG *signature = NULL;
|
||||
BIGNUM *r = NULL, *s = NULL;
|
||||
BIGNUM *kinv = NULL, *rp = NULL;
|
||||
const BIGNUM *sig_r = NULL, *sig_s = NULL;
|
||||
|
||||
nid = ecdsa_cavs_kats[n].nid;
|
||||
md_nid = ecdsa_cavs_kats[n].md_nid;
|
||||
r_in = ecdsa_cavs_kats[n].r;
|
||||
s_in = ecdsa_cavs_kats[n].s;
|
||||
tbs = ecdsa_cavs_kats[n].msg;
|
||||
numbers[0] = ecdsa_cavs_kats[n].d;
|
||||
numbers[1] = ecdsa_cavs_kats[n].k;
|
||||
|
||||
TEST_info("ECDSA KATs for curve %s", OBJ_nid2sn(nid));
|
||||
|
||||
if (!TEST_ptr(mctx = EVP_MD_CTX_new())
|
||||
/* get the message digest */
|
||||
|| !TEST_ptr(message = OPENSSL_hexstr2buf(tbs, &msg_len))
|
||||
|| !TEST_true(EVP_DigestInit_ex(mctx, EVP_get_digestbynid(md_nid), NULL))
|
||||
|| !TEST_true(EVP_DigestUpdate(mctx, message, msg_len))
|
||||
|| !TEST_true(EVP_DigestFinal_ex(mctx, digest, &dgst_len))
|
||||
/* create the key */
|
||||
|| !TEST_ptr(key = EC_KEY_new_by_curve_name(nid))
|
||||
/* load KAT variables */
|
||||
|| !TEST_ptr(r = BN_new())
|
||||
|| !TEST_ptr(s = BN_new())
|
||||
|| !TEST_true(BN_hex2bn(&r, r_in))
|
||||
|| !TEST_true(BN_hex2bn(&s, s_in))
|
||||
/* swap the RNG source */
|
||||
|| !TEST_true(change_rand()))
|
||||
goto err;
|
||||
|
||||
/* public key must match KAT */
|
||||
use_fake = 1;
|
||||
if (!TEST_true(EC_KEY_generate_key(key))
|
||||
|| !TEST_true(p_len = EC_KEY_key2buf(key, POINT_CONVERSION_UNCOMPRESSED,
|
||||
&pbuf, NULL))
|
||||
|| !TEST_ptr(qbuf = OPENSSL_hexstr2buf(ecdsa_cavs_kats[n].Q, &q_len))
|
||||
|| !TEST_int_eq(q_len, p_len)
|
||||
|| !TEST_mem_eq(qbuf, q_len, pbuf, p_len))
|
||||
goto err;
|
||||
|
||||
/* create the signature via ECDSA_sign_setup to avoid use of ECDSA nonces */
|
||||
use_fake = 1;
|
||||
if (!TEST_true(ECDSA_sign_setup(key, NULL, &kinv, &rp))
|
||||
|| !TEST_ptr(signature = ECDSA_do_sign_ex(digest, dgst_len,
|
||||
kinv, rp, key))
|
||||
/* verify the signature */
|
||||
|| !TEST_int_eq(ECDSA_do_verify(digest, dgst_len, signature, key), 1))
|
||||
goto err;
|
||||
|
||||
/* compare the created signature with the expected signature */
|
||||
ECDSA_SIG_get0(signature, &sig_r, &sig_s);
|
||||
if (!TEST_BN_eq(sig_r, r)
|
||||
|| !TEST_BN_eq(sig_s, s))
|
||||
goto err;
|
||||
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
/* restore the RNG source */
|
||||
if (!TEST_true(restore_rand()))
|
||||
ret = 0;
|
||||
|
||||
OPENSSL_free(message);
|
||||
OPENSSL_free(pbuf);
|
||||
OPENSSL_free(qbuf);
|
||||
EC_KEY_free(key);
|
||||
ECDSA_SIG_free(signature);
|
||||
BN_free(r);
|
||||
BN_free(s);
|
||||
EVP_MD_CTX_free(mctx);
|
||||
BN_clear_free(kinv);
|
||||
BN_clear_free(rp);
|
||||
return ret;
|
||||
}
|
||||
#endif /*OPENSSL_SYS_VXWORKS*/
|
||||
|
||||
/*-
|
||||
* Positive and negative ECDSA testing through EVP interface:
|
||||
@@ -393,15 +555,19 @@ int setup_tests(void)
|
||||
#ifdef OPENSSL_NO_EC
|
||||
TEST_note("Elliptic curves are disabled.");
|
||||
#else
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
fake_rand = fake_rand_start(NULL);
|
||||
if (fake_rand == NULL)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
/* get a list of all internal curves */
|
||||
crv_len = EC_get_builtin_curves(NULL, 0);
|
||||
if (!TEST_ptr(curves = OPENSSL_malloc(sizeof(*curves) * crv_len))
|
||||
|| !TEST_true(EC_get_builtin_curves(curves, crv_len))) {
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
fake_rand_finish(fake_rand);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
ADD_ALL_TESTS(test_builtin_as_ec, crv_len);
|
||||
@@ -417,7 +583,9 @@ int setup_tests(void)
|
||||
void cleanup_tests(void)
|
||||
{
|
||||
#ifndef OPENSSL_NO_EC
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
fake_rand_finish(fake_rand);
|
||||
#endif
|
||||
OPENSSL_free(curves);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -346,6 +346,7 @@ static int test_redirect(void)
|
||||
goto err;
|
||||
|
||||
to_return = 1;
|
||||
called_encrypt = 0;
|
||||
|
||||
err:
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
@@ -446,6 +447,7 @@ int setup_tests(void)
|
||||
#ifdef OPENSSL_NO_ENGINE
|
||||
TEST_note("No ENGINE support");
|
||||
#else
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
int n;
|
||||
|
||||
if (!test_skip_common_options()) {
|
||||
@@ -456,10 +458,13 @@ int setup_tests(void)
|
||||
n = test_get_argument_count();
|
||||
if (n == 0)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
ADD_TEST(test_engines);
|
||||
ADD_TEST(test_redirect);
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
ADD_TEST(test_x509_dup_w_engine);
|
||||
#endif
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -5360,6 +5360,8 @@ static int run_file_tests(int i)
|
||||
|
||||
free_key_list(public_keys);
|
||||
free_key_list(private_keys);
|
||||
public_keys = NULL;
|
||||
private_keys = NULL;
|
||||
BIO_free(t->s.key);
|
||||
c = t->s.errors;
|
||||
OPENSSL_free(t);
|
||||
@@ -5391,6 +5393,7 @@ int setup_tests(void)
|
||||
char *config_file = NULL;
|
||||
char *provider_name = NULL;
|
||||
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
OPTION_CHOICE o;
|
||||
|
||||
extended_tests = getenv("EVP_TEST_EXTENDED") != NULL;
|
||||
@@ -5419,6 +5422,7 @@ int setup_tests(void)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Load the provider via configuration into the created library context.
|
||||
|
||||
@@ -341,7 +341,8 @@ timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y)
|
||||
static int test_stress(void)
|
||||
{
|
||||
LHASH_OF(int) *h = lh_int_new(&stress_hash, &int_cmp);
|
||||
const unsigned int n = 2500000;
|
||||
/* reduce memory use for run on platform with memory constrains */
|
||||
const unsigned int n = 250000;
|
||||
unsigned int i;
|
||||
int testresult = 0, *p;
|
||||
#ifdef MEASURE_HASH_PERFORMANCE
|
||||
|
||||
@@ -573,7 +573,7 @@ static int test_PACKET_get_quic_length_prefixed(void)
|
||||
|
||||
#endif
|
||||
|
||||
int setup_tests(void)
|
||||
static int setup_tests(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@@ -600,7 +600,8 @@ int setup_tests(void)
|
||||
ADD_TEST(test_PACKET_forward);
|
||||
ADD_TEST(test_PACKET_get_length_prefixed_1);
|
||||
ADD_TEST(test_PACKET_get_length_prefixed_2);
|
||||
ADD_TEST(test_PACKET_get_length_prefixed_3);
|
||||
/*This test caused compiler crash. Bring it back after complier bug is fixed */
|
||||
/*ADD_TEST(test_PACKET_get_length_prefixed_3);*/
|
||||
ADD_TEST(test_PACKET_as_length_prefixed_1);
|
||||
ADD_TEST(test_PACKET_as_length_prefixed_2);
|
||||
#ifndef OPENSSL_NO_QUIC
|
||||
@@ -609,3 +610,35 @@ int setup_tests(void)
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
int packettest(int argc, char *argv[]);
|
||||
int packettest(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
char * testfn = "packettest";
|
||||
char * argvTemp[1];
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
argc++;
|
||||
argvTemp[0] = testfn;
|
||||
argv = argvTemp;
|
||||
}
|
||||
|
||||
test_main(argc, argv);
|
||||
|
||||
if(0 == setup_tests())
|
||||
{
|
||||
ret = 1;
|
||||
}
|
||||
if(EXIT_SUCCESS != run_tests(testfn))
|
||||
{
|
||||
ret = 2;
|
||||
}
|
||||
TEST_info("%-30s %s ",testfn, (ret == EXIT_SUCCESS) ? "successfully":"failed");
|
||||
remove_all_tests();
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -893,7 +893,12 @@ static int set_protocol_version(const char *version, SSL *ssl, int setting)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
# ifdef OPENSSL_SYS_VXWORKS_SUPPORT
|
||||
int ssltest_main(int argc, char *argv[]);
|
||||
int ssltest_main(int argc, char *argv[])
|
||||
#else
|
||||
int ssltest_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
const char *CApath = NULL, *CAfile = NULL;
|
||||
int badop = 0;
|
||||
|
||||
@@ -355,10 +355,12 @@ int setup_tests(void)
|
||||
{
|
||||
char *cert, *pkey;
|
||||
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
if (!test_skip_common_options()) {
|
||||
TEST_error("Error parsing test options\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!TEST_ptr(cert = test_get_argument(0))
|
||||
|| !TEST_ptr(pkey = test_get_argument(1)))
|
||||
|
||||
@@ -258,10 +258,12 @@ int setup_tests(void)
|
||||
{
|
||||
int n;
|
||||
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
if (!test_skip_common_options()) {
|
||||
TEST_error("Error parsing test options\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!TEST_ptr(cert = test_get_argument(0))
|
||||
|| !TEST_ptr(privkey = test_get_argument(1)))
|
||||
|
||||
@@ -182,6 +182,9 @@
|
||||
* well as the additional options that need to be handled.
|
||||
* (3) case OPT_TEST_CASES: break; inside the opt_next() handling code.
|
||||
*/
|
||||
#if defined(OPENSSL_SYS_VXWORKS)
|
||||
# define OPT_TEST_DECLARE_USAGE(usage_str)
|
||||
#else
|
||||
# define OPT_TEST_DECLARE_USAGE(usage_str) \
|
||||
const OPTIONS *test_get_options(void) \
|
||||
{ \
|
||||
@@ -192,6 +195,7 @@ const OPTIONS *test_get_options(void) \
|
||||
}; \
|
||||
return options; \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Used to read non optional command line values that follow after the options.
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#include <openssl/bio.h>
|
||||
|
||||
/* These are available for any test program */
|
||||
BIO *bio_out = NULL;
|
||||
BIO *bio_err = NULL;
|
||||
extern BIO *bio_out;
|
||||
extern BIO *bio_err;
|
||||
|
||||
/* These are available for TAP output only (internally) */
|
||||
static BIO *tap_out = NULL;
|
||||
|
||||
@@ -81,6 +81,16 @@ void add_all_tests(const char *test_case_name, int(*test_fn)(int idx),
|
||||
num_test_cases += num;
|
||||
}
|
||||
|
||||
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
void remove_all_tests(const char *test_case_name, int(*test_fn)(int idx),
|
||||
int num, int subtest)
|
||||
{
|
||||
num_tests = 0;
|
||||
num_test_cases = 0;
|
||||
memset(all_tests, 0, 1024*sizeof(TEST_INFO));
|
||||
}
|
||||
#endif
|
||||
|
||||
static int gcd(int a, int b)
|
||||
{
|
||||
while (b != 0) {
|
||||
@@ -127,7 +137,11 @@ int setup_test_framework(int argc, char *argv[])
|
||||
win32_utf8argv(&argc, &argv);
|
||||
#endif
|
||||
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
if (!opt_init(argc, argv, test_get_options()))
|
||||
#else
|
||||
if (!opt_init(argc, argv, NULL))
|
||||
#endif
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -202,7 +216,9 @@ static int process_shared_options(void)
|
||||
case OPT_ERR:
|
||||
return ret;
|
||||
case OPT_TEST_HELP:
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
opt_help(test_get_options());
|
||||
#endif
|
||||
return 0;
|
||||
case OPT_TEST_LIST:
|
||||
show_list = 1;
|
||||
@@ -292,11 +308,13 @@ int run_tests(const char *test_prog_name)
|
||||
int subtest_case_count = 0;
|
||||
int permute[OSSL_NELEM(all_tests)];
|
||||
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
i = process_shared_options();
|
||||
if (i == 0)
|
||||
return EXIT_SUCCESS;
|
||||
if (i == -1)
|
||||
return EXIT_FAILURE;
|
||||
#endif
|
||||
|
||||
if (num_tests < 1) {
|
||||
test_printf_tapout("1..0 # Skipped: %s\n", test_prog_name);
|
||||
|
||||
@@ -12,7 +12,41 @@
|
||||
#include "tu_local.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
#if defined(OPENSSL_SYS_VXWORKS_SUPPORT)
|
||||
static size_t arg_count;
|
||||
static char **args;
|
||||
static unsigned char arg_used[1000];
|
||||
void test_main(int argc, char *argv[])
|
||||
{
|
||||
if (NULL == bio_out)
|
||||
{
|
||||
test_open_streams();
|
||||
}
|
||||
|
||||
arg_count = argc -1;
|
||||
args = argv;
|
||||
|
||||
/*setup_test_framework();*/
|
||||
/*check_arg_usage();*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
char *test_get_argument(size_t n)
|
||||
{
|
||||
if (n > arg_count)
|
||||
return NULL;
|
||||
|
||||
return args[n + 1];
|
||||
}
|
||||
|
||||
size_t test_get_argument_count(void)
|
||||
{
|
||||
return arg_count;
|
||||
}
|
||||
|
||||
#else
|
||||
int test_main(int argc, char *argv[])
|
||||
{
|
||||
int ret = EXIT_FAILURE;
|
||||
int setup_res;
|
||||
@@ -39,3 +73,4 @@ end:
|
||||
test_close_streams();
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -31,6 +31,7 @@ int test_skip_common_options(void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
size_t test_get_argument_count(void)
|
||||
{
|
||||
return opt_num_rest();
|
||||
@@ -46,6 +47,7 @@ char *test_get_argument(size_t n)
|
||||
used[n] = 1;
|
||||
return argv[n];
|
||||
}
|
||||
#endif
|
||||
|
||||
void opt_check_usage(void)
|
||||
{
|
||||
@@ -66,6 +68,7 @@ void opt_check_usage(void)
|
||||
test_printf_stderr("Warning arguments %d and later unchecked\n", i);
|
||||
}
|
||||
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
int opt_printf_stderr(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -76,4 +79,5 @@ int opt_printf_stderr(const char *fmt, ...)
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -579,7 +579,7 @@ static int test_thread_local(void)
|
||||
if (!TEST_ptr_null(ptr))
|
||||
return 0;
|
||||
|
||||
# if !defined(OPENSSL_SYS_WINDOWS)
|
||||
# if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_VXWORKS)
|
||||
if (!TEST_int_eq(destructor_run_count, 1))
|
||||
return 0;
|
||||
# endif
|
||||
@@ -1293,6 +1293,7 @@ const OPTIONS *test_get_options(void)
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
OPTION_CHOICE o;
|
||||
char *datadir;
|
||||
|
||||
@@ -1317,6 +1318,7 @@ int setup_tests(void)
|
||||
privkey = test_mk_file_path(datadir, "rsakey.pem");
|
||||
if (!TEST_ptr(privkey))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if (!TEST_ptr(global_lock = CRYPTO_THREAD_lock_new()))
|
||||
return 0;
|
||||
@@ -1344,6 +1346,8 @@ int setup_tests(void)
|
||||
ADD_TEST(test_multi_general_worker_default_provider);
|
||||
ADD_TEST(test_multi_general_worker_fips_provider);
|
||||
ADD_TEST(test_multi_fetch_worker);
|
||||
|
||||
#if !defined (OPENSSL_SYS_VXWORKS)
|
||||
ADD_TEST(test_multi_shared_pkey);
|
||||
#ifndef OPENSSL_NO_DEPRECATED_3_0
|
||||
ADD_TEST(test_multi_downgrade_shared_pkey);
|
||||
|
||||
@@ -29,6 +29,59 @@ static int wait_for_thread(thread_t thread)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#elif defined(OPENSSL_SYS_VXWORKS)
|
||||
|
||||
#include <taskLib.h>
|
||||
#include <sysLib.h>
|
||||
|
||||
typedef TASK_ID thread_t;
|
||||
static int thread_finished = 0;
|
||||
|
||||
static void *thread_run(void *arg)
|
||||
{
|
||||
void (*f)(void);
|
||||
|
||||
*(void **) (&f) = arg;
|
||||
|
||||
f();
|
||||
|
||||
if (thread_finished == 0)
|
||||
{
|
||||
TEST_info("thread_run - number failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
thread_finished--;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int run_thread(thread_t *t, void (*f)(void))
|
||||
{
|
||||
thread_finished++;
|
||||
|
||||
*t = taskSpawn(NULL, 100, 0, 8192, (FUNCPTR)thread_run,
|
||||
*(void **) &f, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||
|
||||
if (*t == NULL)
|
||||
{
|
||||
thread_finished--;
|
||||
}
|
||||
|
||||
return *t != NULL;
|
||||
}
|
||||
|
||||
static int wait_for_thread(thread_t thread)
|
||||
{
|
||||
while(thread_finished > 0)
|
||||
{
|
||||
taskDelay(sysClkRateGet());
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#elif defined(OPENSSL_SYS_WINDOWS)
|
||||
|
||||
typedef HANDLE thread_t;
|
||||
|
||||
@@ -488,10 +488,12 @@ OPT_TEST_DECLARE_USAGE("certfile privkeyfile\n")
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
#if !defined(OPENSSL_SYS_VXWORKS)
|
||||
if (!test_skip_common_options()) {
|
||||
TEST_error("Error parsing test options\n");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!TEST_ptr(cert = test_get_argument(0))
|
||||
|| !TEST_ptr(privkey = test_get_argument(1)))
|
||||
|
||||
Reference in New Issue
Block a user