Compare commits
114 Commits
OpenSSL_1_
...
OpenSSL_1_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
902f3f50d0 | ||
|
|
45e53cf881 | ||
|
|
08d0ff54d0 | ||
|
|
248808c840 | ||
|
|
515f3be47a | ||
|
|
25d14c6c29 | ||
|
|
08ea966c01 | ||
|
|
ef98503eee | ||
|
|
708dc2f129 | ||
|
|
bc38a7d2d3 | ||
|
|
1b1d8ae49a | ||
|
|
021fb42dd0 | ||
|
|
9dfd2be8a1 | ||
|
|
c175308407 | ||
|
|
29305f4edc | ||
|
|
7bcdf4ef78 | ||
|
|
e9cf5f0366 | ||
|
|
a3762a92d6 | ||
|
|
5361af815d | ||
|
|
578b956fe7 | ||
|
|
259b664f95 | ||
|
|
64333004a4 | ||
|
|
04f2a0b50d | ||
|
|
c436c990f6 | ||
|
|
f78baa9d71 | ||
|
|
5c57fbb8ca | ||
|
|
6c88c71b4e | ||
|
|
c575ceffdb | ||
|
|
b393a4ad38 | ||
|
|
43be582e9b | ||
|
|
866b282d1b | ||
|
|
24e6a0dba4 | ||
|
|
6533a0b8d1 | ||
|
|
b4b23d05d3 | ||
|
|
10c639a8a5 | ||
|
|
0fffd52242 | ||
|
|
52464477be | ||
|
|
64193c8218 | ||
|
|
402fb1896b | ||
|
|
a3baa17105 | ||
|
|
093d20a8cb | ||
|
|
5df0bde60e | ||
|
|
a2bab12a33 | ||
|
|
106dbca36c | ||
|
|
a38a159bfc | ||
|
|
e0fde613ac | ||
|
|
2454accb6e | ||
|
|
1e9446bf5c | ||
|
|
e94f52e0c7 | ||
|
|
83ab6e55a1 | ||
|
|
7107798ae6 | ||
|
|
2b0c11a620 | ||
|
|
da7947e8c6 | ||
|
|
22d192f106 | ||
|
|
95605f3ae1 | ||
|
|
f26a179abc | ||
|
|
75374adf8a | ||
|
|
c5b831f21d | ||
|
|
878e2c5b13 | ||
|
|
d81a160058 | ||
|
|
3665fa2543 | ||
|
|
2b80d00e3a | ||
|
|
78a140ecb3 | ||
|
|
f73c737c7a | ||
|
|
930d87c1e1 | ||
|
|
607e77300e | ||
|
|
0555901cb4 | ||
|
|
7934ce27cd | ||
|
|
4d6fe78f65 | ||
|
|
15debc128a | ||
|
|
e254d12c43 | ||
|
|
8788fb97a8 | ||
|
|
6fa6a66285 | ||
|
|
a2a29f702a | ||
|
|
8259ccb44d | ||
|
|
ad81ca9061 | ||
|
|
d65a8d0b7e | ||
|
|
75fdee0482 | ||
|
|
a4530ce039 | ||
|
|
cb19c0d15f | ||
|
|
a3d74afcae | ||
|
|
4d9c6fa01b | ||
|
|
c52c3b5e11 | ||
|
|
0ac6239955 | ||
|
|
905943af3b | ||
|
|
155a1623d0 | ||
|
|
1c7de36f62 | ||
|
|
6656ba7152 | ||
|
|
17592f323a | ||
|
|
6d97060ee0 | ||
|
|
7eb5125125 | ||
|
|
2a60fccdd9 | ||
|
|
f6cadeeeed | ||
|
|
dd045d17e7 | ||
|
|
93a17f79b9 | ||
|
|
ecadde4d4d | ||
|
|
44e4f5b04b | ||
|
|
474a53b3a3 | ||
|
|
e780ed0336 | ||
|
|
3cd33c42e3 | ||
|
|
50053969e3 | ||
|
|
01b5c1239b | ||
|
|
f4d1926f95 | ||
|
|
9501418ea2 | ||
|
|
50b255a260 | ||
|
|
5ff0cfa517 | ||
|
|
02d013e621 | ||
|
|
89cd4fb5e9 | ||
|
|
c44844d928 | ||
|
|
4e295148c3 | ||
|
|
8e18babd1b | ||
|
|
b12fd50626 | ||
|
|
e40d6bf00a | ||
|
|
8a27243c7b |
10
.travis-create-release.sh
Normal file
10
.travis-create-release.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#! /bin/sh
|
||||
|
||||
# $1 is expected to be $TRAVIS_OS_NAME
|
||||
|
||||
if [ "$1" == osx ]; then
|
||||
make -f Makefile.org \
|
||||
DISTTARVARS="NAME=_srcdist TAR_COMMAND='\$\$(TAR) \$\$(TARFLAGS) -s \"|^|\$\$(NAME)/|\" -T \$\$(TARFILE).list -cvf -' TARFLAGS='-n' TARFILE=_srcdist.tar" SHELL='sh -vx' dist
|
||||
else
|
||||
make -f Makefile.org DISTTARVARS='TARFILE=_srcdist.tar NAME=_srcdist' SHELL='sh -v' dist
|
||||
fi
|
||||
@@ -32,6 +32,9 @@ matrix:
|
||||
env: CONFIG_OPTS="-d --strict-warnings"
|
||||
|
||||
before_script:
|
||||
- sh .travis-create-release.sh $TRAVIS_OS_NAME
|
||||
- tar -xvzf _srcdist.tar.gz
|
||||
- cd _srcdist
|
||||
- if [ "$CC" == i686-w64-mingw32-gcc ]; then
|
||||
export CROSS_COMPILE=${CC%%gcc}; unset CC;
|
||||
./Configure mingw $CONFIG_OPTS;
|
||||
@@ -44,10 +47,13 @@ before_script:
|
||||
fi;
|
||||
./config $CONFIG_OPTS;
|
||||
fi
|
||||
- cd ..
|
||||
|
||||
script:
|
||||
- cd _srcdist
|
||||
- make
|
||||
- if [ -z "$CROSS_COMPILE" ]; then make test; fi
|
||||
- cd ..
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
||||
@@ -1,30 +1,2 @@
|
||||
The OpenSSL project depends on volunteer efforts and financial support from
|
||||
the end user community. That support comes in the form of donations and paid
|
||||
sponsorships, software support contracts, paid consulting services
|
||||
and commissioned software development.
|
||||
|
||||
Since all these activities support the continued development and improvement
|
||||
of OpenSSL we consider all these clients and customers as sponsors of the
|
||||
OpenSSL project.
|
||||
|
||||
We would like to identify and thank the following such sponsors for their past
|
||||
or current significant support of the OpenSSL project:
|
||||
|
||||
Major support:
|
||||
|
||||
Qualys http://www.qualys.com/
|
||||
|
||||
Very significant support:
|
||||
|
||||
OpenGear: http://www.opengear.com/
|
||||
|
||||
Significant support:
|
||||
|
||||
PSW Group: http://www.psw.net/
|
||||
Acano Ltd. http://acano.com/
|
||||
|
||||
Please note that we ask permission to identify sponsors and that some sponsors
|
||||
we consider eligible for inclusion here have requested to remain anonymous.
|
||||
|
||||
Additional sponsorship or financial support is always welcome: for more
|
||||
information please contact the OpenSSL Software Foundation.
|
||||
Please https://www.openssl.org/community/thanks.html for the current
|
||||
acknowledgements.
|
||||
|
||||
182
CHANGES
182
CHANGES
@@ -2,6 +2,186 @@
|
||||
OpenSSL CHANGES
|
||||
_______________
|
||||
|
||||
Changes between 1.0.2f and 1.0.2g [1 Mar 2016]
|
||||
|
||||
* Disable weak ciphers in SSLv3 and up in default builds of OpenSSL.
|
||||
Builds that are not configured with "enable-weak-ssl-ciphers" will not
|
||||
provide any "EXPORT" or "LOW" strength ciphers.
|
||||
[Viktor Dukhovni]
|
||||
|
||||
* Disable SSLv2 default build, default negotiation and weak ciphers. SSLv2
|
||||
is by default disabled at build-time. Builds that are not configured with
|
||||
"enable-ssl2" will not support SSLv2. Even if "enable-ssl2" is used,
|
||||
users who want to negotiate SSLv2 via the version-flexible SSLv23_method()
|
||||
will need to explicitly call either of:
|
||||
|
||||
SSL_CTX_clear_options(ctx, SSL_OP_NO_SSLv2);
|
||||
or
|
||||
SSL_clear_options(ssl, SSL_OP_NO_SSLv2);
|
||||
|
||||
as appropriate. Even if either of those is used, or the application
|
||||
explicitly uses the version-specific SSLv2_method() or its client and
|
||||
server variants, SSLv2 ciphers vulnerable to exhaustive search key
|
||||
recovery have been removed. Specifically, the SSLv2 40-bit EXPORT
|
||||
ciphers, and SSLv2 56-bit DES are no longer available.
|
||||
(CVE-2016-0800)
|
||||
[Viktor Dukhovni]
|
||||
|
||||
*) Fix a double-free in DSA code
|
||||
|
||||
A double free bug was discovered when OpenSSL parses malformed DSA private
|
||||
keys and could lead to a DoS attack or memory corruption for applications
|
||||
that receive DSA private keys from untrusted sources. This scenario is
|
||||
considered rare.
|
||||
|
||||
This issue was reported to OpenSSL by Adam Langley(Google/BoringSSL) using
|
||||
libFuzzer.
|
||||
(CVE-2016-0705)
|
||||
[Stephen Henson]
|
||||
|
||||
*) Disable SRP fake user seed to address a server memory leak.
|
||||
|
||||
Add a new method SRP_VBASE_get1_by_user that handles the seed properly.
|
||||
|
||||
SRP_VBASE_get_by_user had inconsistent memory management behaviour.
|
||||
In order to fix an unavoidable memory leak, SRP_VBASE_get_by_user
|
||||
was changed to ignore the "fake user" SRP seed, even if the seed
|
||||
is configured.
|
||||
|
||||
Users should use SRP_VBASE_get1_by_user instead. Note that in
|
||||
SRP_VBASE_get1_by_user, caller must free the returned value. Note
|
||||
also that even though configuring the SRP seed attempts to hide
|
||||
invalid usernames by continuing the handshake with fake
|
||||
credentials, this behaviour is not constant time and no strong
|
||||
guarantees are made that the handshake is indistinguishable from
|
||||
that of a valid user.
|
||||
(CVE-2016-0798)
|
||||
[Emilia Käsper]
|
||||
|
||||
*) Fix BN_hex2bn/BN_dec2bn NULL pointer deref/heap corruption
|
||||
|
||||
In the BN_hex2bn function the number of hex digits is calculated using an
|
||||
int value |i|. Later |bn_expand| is called with a value of |i * 4|. For
|
||||
large values of |i| this can result in |bn_expand| not allocating any
|
||||
memory because |i * 4| is negative. This can leave the internal BIGNUM data
|
||||
field as NULL leading to a subsequent NULL ptr deref. For very large values
|
||||
of |i|, the calculation |i * 4| could be a positive value smaller than |i|.
|
||||
In this case memory is allocated to the internal BIGNUM data field, but it
|
||||
is insufficiently sized leading to heap corruption. A similar issue exists
|
||||
in BN_dec2bn. This could have security consequences if BN_hex2bn/BN_dec2bn
|
||||
is ever called by user applications with very large untrusted hex/dec data.
|
||||
This is anticipated to be a rare occurrence.
|
||||
|
||||
All OpenSSL internal usage of these functions use data that is not expected
|
||||
to be untrusted, e.g. config file data or application command line
|
||||
arguments. If user developed applications generate config file data based
|
||||
on untrusted data then it is possible that this could also lead to security
|
||||
consequences. This is also anticipated to be rare.
|
||||
|
||||
This issue was reported to OpenSSL by Guido Vranken.
|
||||
(CVE-2016-0797)
|
||||
[Matt Caswell]
|
||||
|
||||
*) Fix memory issues in BIO_*printf functions
|
||||
|
||||
The internal |fmtstr| function used in processing a "%s" format string in
|
||||
the BIO_*printf functions could overflow while calculating the length of a
|
||||
string and cause an OOB read when printing very long strings.
|
||||
|
||||
Additionally the internal |doapr_outch| function can attempt to write to an
|
||||
OOB memory location (at an offset from the NULL pointer) in the event of a
|
||||
memory allocation failure. In 1.0.2 and below this could be caused where
|
||||
the size of a buffer to be allocated is greater than INT_MAX. E.g. this
|
||||
could be in processing a very long "%s" format string. Memory leaks can
|
||||
also occur.
|
||||
|
||||
The first issue may mask the second issue dependent on compiler behaviour.
|
||||
These problems could enable attacks where large amounts of untrusted data
|
||||
is passed to the BIO_*printf functions. If applications use these functions
|
||||
in this way then they could be vulnerable. OpenSSL itself uses these
|
||||
functions when printing out human-readable dumps of ASN.1 data. Therefore
|
||||
applications that print this data could be vulnerable if the data is from
|
||||
untrusted sources. OpenSSL command line applications could also be
|
||||
vulnerable where they print out ASN.1 data, or if untrusted data is passed
|
||||
as command line arguments.
|
||||
|
||||
Libssl is not considered directly vulnerable. Additionally certificates etc
|
||||
received via remote connections via libssl are also unlikely to be able to
|
||||
trigger these issues because of message size limits enforced within libssl.
|
||||
|
||||
This issue was reported to OpenSSL Guido Vranken.
|
||||
(CVE-2016-0799)
|
||||
[Matt Caswell]
|
||||
|
||||
*) Side channel attack on modular exponentiation
|
||||
|
||||
A side-channel attack was found which makes use of cache-bank conflicts on
|
||||
the Intel Sandy-Bridge microarchitecture which could lead to the recovery
|
||||
of RSA keys. The ability to exploit this issue is limited as it relies on
|
||||
an attacker who has control of code in a thread running on the same
|
||||
hyper-threaded core as the victim thread which is performing decryptions.
|
||||
|
||||
This issue was reported to OpenSSL by Yuval Yarom, The University of
|
||||
Adelaide and NICTA, Daniel Genkin, Technion and Tel Aviv University, and
|
||||
Nadia Heninger, University of Pennsylvania with more information at
|
||||
http://cachebleed.info.
|
||||
(CVE-2016-0702)
|
||||
[Andy Polyakov]
|
||||
|
||||
*) Change the req app to generate a 2048-bit RSA/DSA key by default,
|
||||
if no keysize is specified with default_bits. This fixes an
|
||||
omission in an earlier change that changed all RSA/DSA key generation
|
||||
apps to use 2048 bits by default.
|
||||
[Emilia Käsper]
|
||||
|
||||
Changes between 1.0.2e and 1.0.2f [28 Jan 2016]
|
||||
|
||||
*) DH small subgroups
|
||||
|
||||
Historically OpenSSL only ever generated DH parameters based on "safe"
|
||||
primes. More recently (in version 1.0.2) support was provided for
|
||||
generating X9.42 style parameter files such as those required for RFC 5114
|
||||
support. The primes used in such files may not be "safe". Where an
|
||||
application is using DH configured with parameters based on primes that are
|
||||
not "safe" then an attacker could use this fact to find a peer's private
|
||||
DH exponent. This attack requires that the attacker complete multiple
|
||||
handshakes in which the peer uses the same private DH exponent. For example
|
||||
this could be used to discover a TLS server's private DH exponent if it's
|
||||
reusing the private DH exponent or it's using a static DH ciphersuite.
|
||||
|
||||
OpenSSL provides the option SSL_OP_SINGLE_DH_USE for ephemeral DH (DHE) in
|
||||
TLS. It is not on by default. If the option is not set then the server
|
||||
reuses the same private DH exponent for the life of the server process and
|
||||
would be vulnerable to this attack. It is believed that many popular
|
||||
applications do set this option and would therefore not be at risk.
|
||||
|
||||
The fix for this issue adds an additional check where a "q" parameter is
|
||||
available (as is the case in X9.42 based parameters). This detects the
|
||||
only known attack, and is the only possible defense for static DH
|
||||
ciphersuites. This could have some performance impact.
|
||||
|
||||
Additionally the SSL_OP_SINGLE_DH_USE option has been switched on by
|
||||
default and cannot be disabled. This could have some performance impact.
|
||||
|
||||
This issue was reported to OpenSSL by Antonio Sanso (Adobe).
|
||||
(CVE-2016-0701)
|
||||
[Matt Caswell]
|
||||
|
||||
*) SSLv2 doesn't block disabled ciphers
|
||||
|
||||
A malicious client can negotiate SSLv2 ciphers that have been disabled on
|
||||
the server and complete SSLv2 handshakes even if all SSLv2 ciphers have
|
||||
been disabled, provided that the SSLv2 protocol was not also disabled via
|
||||
SSL_OP_NO_SSLv2.
|
||||
|
||||
This issue was reported to OpenSSL on 26th December 2015 by Nimrod Aviram
|
||||
and Sebastian Schinzel.
|
||||
(CVE-2015-3197)
|
||||
[Viktor Dukhovni]
|
||||
|
||||
*) Reject DH handshakes with parameters shorter than 1024 bits.
|
||||
[Kurt Roeckx]
|
||||
|
||||
Changes between 1.0.2d and 1.0.2e [3 Dec 2015]
|
||||
|
||||
*) BN_mod_exp may produce incorrect results on x86_64
|
||||
@@ -57,7 +237,7 @@
|
||||
[Emilia Käsper]
|
||||
|
||||
*) In DSA_generate_parameters_ex, if the provided seed is too short,
|
||||
return an error
|
||||
use a random seed, as already documented.
|
||||
[Rich Salz and Ismo Puustinen <ismo.puustinen@intel.com>]
|
||||
|
||||
Changes between 1.0.2c and 1.0.2d [9 Jul 2015]
|
||||
|
||||
41
Configure
41
Configure
@@ -58,6 +58,10 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimenta
|
||||
# library and will be loaded in run-time by the OpenSSL library.
|
||||
# sctp include SCTP support
|
||||
# 386 generate 80386 code
|
||||
# enable-weak-ssl-ciphers
|
||||
# Enable EXPORT and LOW SSLv3 ciphers that are disabled by
|
||||
# default. Note, weak SSLv2 ciphers are unconditionally
|
||||
# disabled.
|
||||
# no-sse2 disables IA-32 SSE2 code, above option implies no-sse2
|
||||
# no-<cipher> build without specified algorithm (rsa, idea, rc5, ...)
|
||||
# -<xxx> +<xxx> compiler options are passed through
|
||||
@@ -124,6 +128,9 @@ my $clang_disabled_warnings = "-Wno-unused-parameter -Wno-missing-field-initiali
|
||||
# -Wextended-offsetof
|
||||
my $clang_devteam_warn = "-Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof -Qunused-arguments";
|
||||
|
||||
# Warn that "make depend" should be run?
|
||||
my $warn_make_depend = 0;
|
||||
|
||||
my $strict_warnings = 0;
|
||||
|
||||
my $x86_gcc_des="DES_PTR DES_RISC1 DES_UNROLL";
|
||||
@@ -778,11 +785,13 @@ my %disabled = ( # "what" => "comment" [or special keyword "experimental
|
||||
"md2" => "default",
|
||||
"rc5" => "default",
|
||||
"rfc3779" => "default",
|
||||
"sctp" => "default",
|
||||
"sctp" => "default",
|
||||
"shared" => "default",
|
||||
"ssl-trace" => "default",
|
||||
"ssl2" => "default",
|
||||
"store" => "experimental",
|
||||
"unit-test" => "default",
|
||||
"weak-ssl-ciphers" => "default",
|
||||
"zlib" => "default",
|
||||
"zlib-dynamic" => "default"
|
||||
);
|
||||
@@ -1513,7 +1522,7 @@ if ($target =~ /\-icc$/) # Intel C compiler
|
||||
# linker only when --prefix is not /usr.
|
||||
if ($target =~ /^BSD\-/)
|
||||
{
|
||||
$shared_ldflag.=" -Wl,-rpath,\$(LIBRPATH)" if ($prefix !~ m|^/usr[/]*$|);
|
||||
$shared_ldflag.=" -Wl,-rpath,\$\$(LIBRPATH)" if ($prefix !~ m|^/usr[/]*$|);
|
||||
}
|
||||
|
||||
if ($sys_id ne "")
|
||||
@@ -2028,14 +2037,8 @@ EOF
|
||||
&dofile("apps/CA.pl",'/usr/local/bin/perl','^#!/', '#!%s');
|
||||
}
|
||||
if ($depflags ne $default_depflags && !$make_depend) {
|
||||
print <<EOF;
|
||||
|
||||
Since you've disabled or enabled at least one algorithm, you need to do
|
||||
the following before building:
|
||||
|
||||
make depend
|
||||
EOF
|
||||
}
|
||||
$warn_make_depend++;
|
||||
}
|
||||
}
|
||||
|
||||
# create the ms/version32.rc file if needed
|
||||
@@ -2114,12 +2117,18 @@ EOF
|
||||
|
||||
print <<\EOF if ($no_shared_warn);
|
||||
|
||||
You gave the option 'shared'. Normally, that would give you shared libraries.
|
||||
Unfortunately, the OpenSSL configuration doesn't include shared library support
|
||||
for this platform yet, so it will pretend you gave the option 'no-shared'. If
|
||||
you can inform the developpers (openssl-dev\@openssl.org) how to support shared
|
||||
libraries on this platform, they will at least look at it and try their best
|
||||
(but please first make sure you have tried with a current version of OpenSSL).
|
||||
You gave the option 'shared', which is not supported on this platform, so
|
||||
we will pretend you gave the option 'no-shared'. If you know how to implement
|
||||
shared libraries, please let us know (but please first make sure you have
|
||||
tried with a current version of OpenSSL).
|
||||
EOF
|
||||
|
||||
print <<EOF if ($warn_make_depend);
|
||||
|
||||
*** Because of configuration changes, you MUST do the following before
|
||||
*** building:
|
||||
|
||||
make depend
|
||||
EOF
|
||||
|
||||
exit(0);
|
||||
|
||||
8
INSTALL
8
INSTALL
@@ -164,10 +164,10 @@
|
||||
standard headers). If it is a problem with OpenSSL itself, please
|
||||
report the problem to <openssl-bugs@openssl.org> (note that your
|
||||
message will be recorded in the request tracker publicly readable
|
||||
via http://www.openssl.org/support/rt.html and will be forwarded to a
|
||||
public mailing list). Include the output of "make report" in your message.
|
||||
Please check out the request tracker. Maybe the bug was already
|
||||
reported or has already been fixed.
|
||||
at https://www.openssl.org/community/index.html#bugs and will be
|
||||
forwarded to a public mailing list). Include the output of "make
|
||||
report" in your message. Please check out the request tracker. Maybe
|
||||
the bug was already reported or has already been fixed.
|
||||
|
||||
[If you encounter assembler error messages, try the "no-asm"
|
||||
configuration option as an immediate fix.]
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -12,7 +12,7 @@
|
||||
---------------
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1998-2016 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
||||
38
Makefile.org
38
Makefile.org
@@ -180,8 +180,7 @@ SHARED_LDFLAGS=
|
||||
GENERAL= Makefile
|
||||
BASENAME= openssl
|
||||
NAME= $(BASENAME)-$(VERSION)
|
||||
TARFILE= $(NAME).tar
|
||||
WTARFILE= $(NAME)-win.tar
|
||||
TARFILE= ../$(NAME).tar
|
||||
EXHEADER= e_os2.h
|
||||
HEADER= e_os.h
|
||||
|
||||
@@ -499,38 +498,35 @@ TABLE: Configure
|
||||
# would occur. Therefore the list of files is temporarily stored into a file
|
||||
# and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
|
||||
# tar does not support the --files-from option.
|
||||
TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from ../$(TARFILE).list \
|
||||
--owner openssl:0 --group openssl:0 \
|
||||
--transform 's|^|openssl-$(VERSION)/|' \
|
||||
TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from $(TARFILE).list \
|
||||
--owner 0 --group 0 \
|
||||
--transform 's|^|$(NAME)/|' \
|
||||
-cvf -
|
||||
|
||||
../$(TARFILE).list:
|
||||
$(TARFILE).list:
|
||||
find * \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \
|
||||
\! -name '*.so' \! -name '*.so.*' \! -name 'openssl' \
|
||||
\! -name '*test' \! -name '.#*' \! -name '*~' \
|
||||
| sort > ../$(TARFILE).list
|
||||
\( \! -name '*test' -o -name bctest -o -name pod2mantest \) \
|
||||
\! -name '.#*' \! -name '*~' \! -type l \
|
||||
| sort > $(TARFILE).list
|
||||
|
||||
tar: ../$(TARFILE).list
|
||||
tar: $(TARFILE).list
|
||||
find . -type d -print | xargs chmod 755
|
||||
find . -type f -print | xargs chmod a+r
|
||||
find . -type f -perm -0100 -print | xargs chmod a+x
|
||||
$(TAR_COMMAND) | gzip --best >../$(TARFILE).gz
|
||||
rm -f ../$(TARFILE).list
|
||||
ls -l ../$(TARFILE).gz
|
||||
$(TAR_COMMAND) | gzip --best > $(TARFILE).gz
|
||||
rm -f $(TARFILE).list
|
||||
ls -l $(TARFILE).gz
|
||||
|
||||
tar-snap: ../$(TARFILE).list
|
||||
$(TAR_COMMAND) > ../$(TARFILE)
|
||||
rm -f ../$(TARFILE).list
|
||||
ls -l ../$(TARFILE)
|
||||
tar-snap: $(TARFILE).list
|
||||
$(TAR_COMMAND) > $(TARFILE)
|
||||
rm -f $(TARFILE).list
|
||||
ls -l $(TARFILE)
|
||||
|
||||
dist:
|
||||
$(PERL) Configure dist
|
||||
@$(MAKE) dist_pem_h
|
||||
@$(MAKE) SDIRS='$(SDIRS)' clean
|
||||
@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' tar
|
||||
|
||||
dist_pem_h:
|
||||
(cd crypto/pem; $(MAKE) -e $(BUILDENV) pem.h; $(MAKE) clean)
|
||||
@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
|
||||
|
||||
install: all install_docs install_sw
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@ link_o.cygwin:
|
||||
SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \
|
||||
ALLSYMSFLAGS='-Wl,--whole-archive'; \
|
||||
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base $$deffile -Wl,-s,-Bsymbolic"; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base $$deffile -Wl,-Bsymbolic"; \
|
||||
$(LINK_SO_O)
|
||||
#for mingw target if def-file is in use dll-name should match library-name
|
||||
link_a.cygwin:
|
||||
@@ -289,7 +289,7 @@ link_a.cygwin:
|
||||
SHLIB_SOVER=32; \
|
||||
extras="$(LIBNAME).def"; \
|
||||
$(PERL) util/mkdef.pl 32 $$SHLIB > $$extras; \
|
||||
base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
|
||||
base=; [ $(LIBNAME) = "crypto" -a -n "$(FIPSCANLIB)" ] && base=-Wl,--image-base,0x63000000; \
|
||||
fi; \
|
||||
dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
|
||||
$(PERL) util/mkrc.pl $$dll_name | \
|
||||
@@ -297,7 +297,7 @@ link_a.cygwin:
|
||||
extras="$$extras rc.o"; \
|
||||
ALLSYMSFLAGS='-Wl,--whole-archive'; \
|
||||
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-s,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \
|
||||
[ -f apps/$$dll_name ] && rm apps/$$dll_name; \
|
||||
[ -f test/$$dll_name ] && rm test/$$dll_name; \
|
||||
$(LINK_SO_A) || exit 1; \
|
||||
|
||||
18
NEWS
18
NEWS
@@ -5,6 +5,24 @@
|
||||
This file gives a brief overview of the major changes between each OpenSSL
|
||||
release. For more details please read the CHANGES file.
|
||||
|
||||
Major changes between OpenSSL 1.0.2f and OpenSSL 1.0.2g [1 Mar 2016]
|
||||
|
||||
o Disable weak ciphers in SSLv3 and up in default builds of OpenSSL.
|
||||
o Disable SSLv2 default build, default negotiation and weak ciphers
|
||||
(CVE-2016-0800)
|
||||
o Fix a double-free in DSA code (CVE-2016-0705)
|
||||
o Disable SRP fake user seed to address a server memory leak
|
||||
(CVE-2016-0798)
|
||||
o Fix BN_hex2bn/BN_dec2bn NULL pointer deref/heap corruption
|
||||
(CVE-2016-0797)
|
||||
o Fix memory issues in BIO_*printf functions (CVE-2016-0799)
|
||||
o Fix side channel attack on modular exponentiation (CVE-2016-0702)
|
||||
|
||||
Major changes between OpenSSL 1.0.2e and OpenSSL 1.0.2f [28 Jan 2016]
|
||||
|
||||
o DH small subgroups (CVE-2016-0701)
|
||||
o SSLv2 doesn't block disabled ciphers (CVE-2015-3197)
|
||||
|
||||
Major changes between OpenSSL 1.0.2d and OpenSSL 1.0.2e [3 Dec 2015]
|
||||
|
||||
o BN_mod_exp may produce incorrect results on x86_64 (CVE-2015-3193)
|
||||
|
||||
13
README
13
README
@@ -1,5 +1,5 @@
|
||||
|
||||
OpenSSL 1.0.2e 3 Dec 2015
|
||||
OpenSSL 1.0.2g 1 Mar 2016
|
||||
|
||||
Copyright (c) 1998-2015 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
@@ -90,11 +90,12 @@
|
||||
|
||||
In order to avoid spam, this is a moderated mailing list, and it might
|
||||
take a day for the ticket to show up. (We also scan posts to make sure
|
||||
that security disclosures aren't publically posted by mistake.) Mail to
|
||||
this address is recorded in the public RT (request tracker) database (see
|
||||
https://www.openssl.org/support/rt.html for details) and also forwarded
|
||||
the public openssl-dev mailing list. Confidential mail may be sent to
|
||||
openssl-security@openssl.org (PGP key available from the key servers).
|
||||
that security disclosures aren't publically posted by mistake.) Mail
|
||||
to this address is recorded in the public RT (request tracker) database
|
||||
(see https://www.openssl.org/community/index.html#bugs for details) and
|
||||
also forwarded the public openssl-dev mailing list. Confidential mail
|
||||
may be sent to openssl-security@openssl.org (PGP key available from the
|
||||
key servers).
|
||||
|
||||
Please do NOT use this for general assistance or support queries.
|
||||
Just because something doesn't work the way you expect does not mean it
|
||||
|
||||
@@ -2442,7 +2442,11 @@ int bio_to_mem(unsigned char **out, int maxlen, BIO *in)
|
||||
else
|
||||
len = 1024;
|
||||
len = BIO_read(in, tbuf, len);
|
||||
if (len <= 0)
|
||||
if (len < 0) {
|
||||
BIO_free(mem);
|
||||
return -1;
|
||||
}
|
||||
if (len == 0)
|
||||
break;
|
||||
if (BIO_write(mem, tbuf, len) != len) {
|
||||
BIO_free(mem);
|
||||
@@ -2459,7 +2463,7 @@ int bio_to_mem(unsigned char **out, int maxlen, BIO *in)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value)
|
||||
int pkey_ctrl_string(EVP_PKEY_CTX *ctx, const char *value)
|
||||
{
|
||||
int rv;
|
||||
char *stmp, *vtmp = NULL;
|
||||
|
||||
@@ -321,7 +321,7 @@ int args_verify(char ***pargs, int *pargc,
|
||||
int *badarg, BIO *err, X509_VERIFY_PARAM **pm);
|
||||
void policies_print(BIO *out, X509_STORE_CTX *ctx);
|
||||
int bio_to_mem(unsigned char **out, int maxlen, BIO *in);
|
||||
int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value);
|
||||
int pkey_ctrl_string(EVP_PKEY_CTX *ctx, const char *value);
|
||||
int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx,
|
||||
const char *algname, ENGINE *e, int do_param);
|
||||
int do_X509_sign(BIO *err, X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* apps/engine.c -*- mode: C; c-file-style: "eay" -*- */
|
||||
/* apps/engine.c */
|
||||
/*
|
||||
* Written by Richard Levitte <richard@levitte.org> for the OpenSSL project
|
||||
* 2000.
|
||||
|
||||
@@ -1041,7 +1041,7 @@ static int make_ocsp_response(OCSP_RESPONSE **resp, OCSP_REQUEST *req,
|
||||
bs = OCSP_BASICRESP_new();
|
||||
thisupd = X509_gmtime_adj(NULL, 0);
|
||||
if (ndays != -1)
|
||||
nextupd = X509_gmtime_adj(NULL, nmin * 60 + ndays * 3600 * 24);
|
||||
nextupd = X509_time_adj_ex(NULL, ndays, nmin * 60, NULL);
|
||||
|
||||
/* Examine each certificate id in the request */
|
||||
for (i = 0; i < id_count; i++) {
|
||||
|
||||
@@ -79,7 +79,8 @@ const EVP_CIPHER *enc;
|
||||
# define CLCERTS 0x8
|
||||
# define CACERTS 0x10
|
||||
|
||||
int get_cert_chain(X509 *cert, X509_STORE *store, STACK_OF(X509) **chain);
|
||||
static int get_cert_chain(X509 *cert, X509_STORE *store,
|
||||
STACK_OF(X509) **chain);
|
||||
int dump_certs_keys_p12(BIO *out, PKCS12 *p12, char *pass, int passlen,
|
||||
int options, char *pempass);
|
||||
int dump_certs_pkeys_bags(BIO *out, STACK_OF(PKCS12_SAFEBAG) *bags,
|
||||
@@ -594,7 +595,7 @@ int MAIN(int argc, char **argv)
|
||||
vret = get_cert_chain(ucert, store, &chain2);
|
||||
X509_STORE_free(store);
|
||||
|
||||
if (!vret) {
|
||||
if (vret == X509_V_OK) {
|
||||
/* Exclude verified certificate */
|
||||
for (i = 1; i < sk_X509_num(chain2); i++)
|
||||
sk_X509_push(certs, sk_X509_value(chain2, i));
|
||||
@@ -602,7 +603,7 @@ int MAIN(int argc, char **argv)
|
||||
X509_free(sk_X509_value(chain2, 0));
|
||||
sk_X509_free(chain2);
|
||||
} else {
|
||||
if (vret >= 0)
|
||||
if (vret != X509_V_ERR_UNSPECIFIED)
|
||||
BIO_printf(bio_err, "Error %s getting chain.\n",
|
||||
X509_verify_cert_error_string(vret));
|
||||
else
|
||||
@@ -906,36 +907,25 @@ int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass,
|
||||
|
||||
/* Given a single certificate return a verified chain or NULL if error */
|
||||
|
||||
/* Hope this is OK .... */
|
||||
|
||||
int get_cert_chain(X509 *cert, X509_STORE *store, STACK_OF(X509) **chain)
|
||||
static int get_cert_chain(X509 *cert, X509_STORE *store,
|
||||
STACK_OF(X509) **chain)
|
||||
{
|
||||
X509_STORE_CTX store_ctx;
|
||||
STACK_OF(X509) *chn;
|
||||
STACK_OF(X509) *chn = NULL;
|
||||
int i = 0;
|
||||
|
||||
/*
|
||||
* FIXME: Should really check the return status of X509_STORE_CTX_init
|
||||
* for an error, but how that fits into the return value of this function
|
||||
* is less obvious.
|
||||
*/
|
||||
X509_STORE_CTX_init(&store_ctx, store, cert, NULL);
|
||||
if (X509_verify_cert(&store_ctx) <= 0) {
|
||||
i = X509_STORE_CTX_get_error(&store_ctx);
|
||||
if (i == 0)
|
||||
/*
|
||||
* avoid returning 0 if X509_verify_cert() did not set an
|
||||
* appropriate error value in the context
|
||||
*/
|
||||
i = -1;
|
||||
chn = NULL;
|
||||
goto err;
|
||||
} else
|
||||
if (!X509_STORE_CTX_init(&store_ctx, store, cert, NULL)) {
|
||||
*chain = NULL;
|
||||
return X509_V_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
if (X509_verify_cert(&store_ctx) > 0)
|
||||
chn = X509_STORE_CTX_get1_chain(&store_ctx);
|
||||
err:
|
||||
else if ((i = X509_STORE_CTX_get_error(&store_ctx)) == 0)
|
||||
i = X509_V_ERR_UNSPECIFIED;
|
||||
|
||||
X509_STORE_CTX_cleanup(&store_ctx);
|
||||
*chain = chn;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
120
apps/pkeyutl.c
120
apps/pkeyutl.c
@@ -73,11 +73,12 @@ static void usage(void);
|
||||
#define PROG pkeyutl_main
|
||||
|
||||
static EVP_PKEY_CTX *init_ctx(int *pkeysize,
|
||||
char *keyfile, int keyform, int key_type,
|
||||
char *passargin, int pkey_op, ENGINE *e);
|
||||
const char *keyfile, int keyform, int key_type,
|
||||
char *passargin, int pkey_op, ENGINE *e,
|
||||
int impl);
|
||||
|
||||
static int setup_peer(BIO *err, EVP_PKEY_CTX *ctx, int peerform,
|
||||
const char *file);
|
||||
const char *file, ENGINE* e);
|
||||
|
||||
static int do_keyop(EVP_PKEY_CTX *ctx, int pkey_op,
|
||||
unsigned char *out, size_t *poutlen,
|
||||
@@ -97,10 +98,13 @@ int MAIN(int argc, char **argv)
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
char *passargin = NULL;
|
||||
int keysize = -1;
|
||||
|
||||
int engine_impl = 0;
|
||||
unsigned char *buf_in = NULL, *buf_out = NULL, *sig = NULL;
|
||||
size_t buf_outlen;
|
||||
size_t buf_outlen = 0;
|
||||
int buf_inlen = 0, siglen = -1;
|
||||
const char *inkey = NULL;
|
||||
const char *peerkey = NULL;
|
||||
STACK_OF(OPENSSL_STRING) *pkeyopts = NULL;
|
||||
|
||||
int ret = 1, rv = -1;
|
||||
|
||||
@@ -134,21 +138,13 @@ int MAIN(int argc, char **argv)
|
||||
} else if (!strcmp(*argv, "-inkey")) {
|
||||
if (--argc < 1)
|
||||
badarg = 1;
|
||||
else {
|
||||
ctx = init_ctx(&keysize,
|
||||
*(++argv), keyform, key_type,
|
||||
passargin, pkey_op, e);
|
||||
if (!ctx) {
|
||||
BIO_puts(bio_err, "Error initializing context\n");
|
||||
ERR_print_errors(bio_err);
|
||||
badarg = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
inkey = *++argv;
|
||||
} else if (!strcmp(*argv, "-peerkey")) {
|
||||
if (--argc < 1)
|
||||
badarg = 1;
|
||||
else if (!setup_peer(bio_err, ctx, peerform, *(++argv)))
|
||||
badarg = 1;
|
||||
else
|
||||
peerkey = *++argv;
|
||||
} else if (!strcmp(*argv, "-passin")) {
|
||||
if (--argc < 1)
|
||||
badarg = 1;
|
||||
@@ -171,6 +167,8 @@ int MAIN(int argc, char **argv)
|
||||
badarg = 1;
|
||||
else
|
||||
e = setup_engine(bio_err, *(++argv), 0);
|
||||
} else if (!strcmp(*argv, "-engine_impl")) {
|
||||
engine_impl = 1;
|
||||
}
|
||||
#endif
|
||||
else if (!strcmp(*argv, "-pubin"))
|
||||
@@ -187,23 +185,21 @@ int MAIN(int argc, char **argv)
|
||||
pkey_op = EVP_PKEY_OP_VERIFY;
|
||||
else if (!strcmp(*argv, "-verifyrecover"))
|
||||
pkey_op = EVP_PKEY_OP_VERIFYRECOVER;
|
||||
else if (!strcmp(*argv, "-rev"))
|
||||
rev = 1;
|
||||
else if (!strcmp(*argv, "-encrypt"))
|
||||
pkey_op = EVP_PKEY_OP_ENCRYPT;
|
||||
else if (!strcmp(*argv, "-decrypt"))
|
||||
pkey_op = EVP_PKEY_OP_DECRYPT;
|
||||
else if (!strcmp(*argv, "-derive"))
|
||||
pkey_op = EVP_PKEY_OP_DERIVE;
|
||||
else if (!strcmp(*argv, "-rev"))
|
||||
rev = 1;
|
||||
else if (strcmp(*argv, "-pkeyopt") == 0) {
|
||||
if (--argc < 1)
|
||||
badarg = 1;
|
||||
else if (!ctx) {
|
||||
BIO_puts(bio_err, "-pkeyopt command before -inkey\n");
|
||||
badarg = 1;
|
||||
} else if (pkey_ctrl_string(ctx, *(++argv)) <= 0) {
|
||||
BIO_puts(bio_err, "parameter setting error\n");
|
||||
ERR_print_errors(bio_err);
|
||||
else if ((pkeyopts == NULL &&
|
||||
(pkeyopts = sk_OPENSSL_STRING_new_null()) == NULL) ||
|
||||
sk_OPENSSL_STRING_push(pkeyopts, *++argv) == 0) {
|
||||
BIO_puts(bio_err, "out of memory\n");
|
||||
goto end;
|
||||
}
|
||||
} else
|
||||
@@ -216,10 +212,37 @@ int MAIN(int argc, char **argv)
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (!ctx) {
|
||||
if (inkey == NULL ||
|
||||
(peerkey != NULL && pkey_op != EVP_PKEY_OP_DERIVE)) {
|
||||
usage();
|
||||
goto end;
|
||||
}
|
||||
ctx = init_ctx(&keysize, inkey, keyform, key_type,
|
||||
passargin, pkey_op, e, engine_impl);
|
||||
if (!ctx) {
|
||||
BIO_puts(bio_err, "Error initializing context\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
if (peerkey != NULL && !setup_peer(bio_err, ctx, peerform, peerkey, e)) {
|
||||
BIO_puts(bio_err, "Error setting up peer key\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
if (pkeyopts != NULL) {
|
||||
int num = sk_OPENSSL_STRING_num(pkeyopts);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num; ++i) {
|
||||
const char *opt = sk_OPENSSL_STRING_value(pkeyopts, i);
|
||||
|
||||
if (pkey_ctrl_string(ctx, opt) <= 0) {
|
||||
BIO_puts(bio_err, "parameter setting error\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sigfile && (pkey_op != EVP_PKEY_OP_VERIFY)) {
|
||||
BIO_puts(bio_err, "Signature file specified for non verify\n");
|
||||
@@ -269,7 +292,7 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
siglen = bio_to_mem(&sig, keysize * 10, sigbio);
|
||||
BIO_free(sigbio);
|
||||
if (siglen <= 0) {
|
||||
if (siglen < 0) {
|
||||
BIO_printf(bio_err, "Error reading signature data\n");
|
||||
goto end;
|
||||
}
|
||||
@@ -278,7 +301,7 @@ int MAIN(int argc, char **argv)
|
||||
if (in) {
|
||||
/* Read the input data */
|
||||
buf_inlen = bio_to_mem(&buf_in, keysize * 10, in);
|
||||
if (buf_inlen <= 0) {
|
||||
if (buf_inlen < 0) {
|
||||
BIO_printf(bio_err, "Error reading input Data\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -306,7 +329,7 @@ int MAIN(int argc, char **argv)
|
||||
} else {
|
||||
rv = do_keyop(ctx, pkey_op, NULL, (size_t *)&buf_outlen,
|
||||
buf_in, (size_t)buf_inlen);
|
||||
if (rv > 0) {
|
||||
if (rv > 0 && buf_outlen != 0) {
|
||||
buf_out = OPENSSL_malloc(buf_outlen);
|
||||
if (!buf_out)
|
||||
rv = -1;
|
||||
@@ -336,12 +359,14 @@ int MAIN(int argc, char **argv)
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
BIO_free(in);
|
||||
BIO_free_all(out);
|
||||
if (buf_in)
|
||||
if (buf_in != NULL)
|
||||
OPENSSL_free(buf_in);
|
||||
if (buf_out)
|
||||
if (buf_out != NULL)
|
||||
OPENSSL_free(buf_out);
|
||||
if (sig)
|
||||
if (sig != NULL)
|
||||
OPENSSL_free(sig);
|
||||
if (pkeyopts != NULL)
|
||||
sk_OPENSSL_STRING_free(pkeyopts);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -368,18 +393,21 @@ static void usage()
|
||||
BIO_printf(bio_err, "-hexdump hex dump output\n");
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err,
|
||||
"-engine e use engine e, possibly a hardware device.\n");
|
||||
"-engine e use engine e, maybe a hardware device, for loading keys.\n");
|
||||
BIO_printf(bio_err, "-engine_impl also use engine given by -engine for crypto operations\n");
|
||||
#endif
|
||||
BIO_printf(bio_err, "-passin arg pass phrase source\n");
|
||||
|
||||
}
|
||||
|
||||
static EVP_PKEY_CTX *init_ctx(int *pkeysize,
|
||||
char *keyfile, int keyform, int key_type,
|
||||
char *passargin, int pkey_op, ENGINE *e)
|
||||
const char *keyfile, int keyform, int key_type,
|
||||
char *passargin, int pkey_op, ENGINE *e,
|
||||
int engine_impl)
|
||||
{
|
||||
EVP_PKEY *pkey = NULL;
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
ENGINE *impl = NULL;
|
||||
char *passin = NULL;
|
||||
int rv = -1;
|
||||
X509 *x;
|
||||
@@ -418,9 +446,14 @@ static EVP_PKEY_CTX *init_ctx(int *pkeysize,
|
||||
|
||||
if (!pkey)
|
||||
goto end;
|
||||
|
||||
ctx = EVP_PKEY_CTX_new(pkey, e);
|
||||
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (engine_impl)
|
||||
impl = e;
|
||||
#endif
|
||||
|
||||
ctx = EVP_PKEY_CTX_new(pkey, impl);
|
||||
|
||||
EVP_PKEY_free(pkey);
|
||||
|
||||
if (!ctx)
|
||||
@@ -467,16 +500,15 @@ static EVP_PKEY_CTX *init_ctx(int *pkeysize,
|
||||
}
|
||||
|
||||
static int setup_peer(BIO *err, EVP_PKEY_CTX *ctx, int peerform,
|
||||
const char *file)
|
||||
const char *file, ENGINE* e)
|
||||
{
|
||||
EVP_PKEY *peer = NULL;
|
||||
ENGINE* engine = NULL;
|
||||
int ret;
|
||||
if (!ctx) {
|
||||
BIO_puts(err, "-peerkey command before -inkey\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
peer = load_pubkey(bio_err, file, peerform, 0, NULL, NULL, "Peer Key");
|
||||
if (peerform == FORMAT_ENGINE)
|
||||
engine = e;
|
||||
peer = load_pubkey(bio_err, file, peerform, 0, NULL, engine, "Peer Key");
|
||||
|
||||
if (!peer) {
|
||||
BIO_printf(bio_err, "Error reading peer key %s\n", file);
|
||||
|
||||
@@ -101,8 +101,8 @@
|
||||
#define STRING_MASK "string_mask"
|
||||
#define UTF8_IN "utf8"
|
||||
|
||||
#define DEFAULT_KEY_LENGTH 512
|
||||
#define MIN_KEY_LENGTH 384
|
||||
#define DEFAULT_KEY_LENGTH 2048
|
||||
#define MIN_KEY_LENGTH 512
|
||||
|
||||
#undef PROG
|
||||
#define PROG req_main
|
||||
|
||||
@@ -250,7 +250,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
if (outfile) {
|
||||
if (!(out = BIO_new_file(outfile, "wb"))) {
|
||||
BIO_printf(bio_err, "Error Reading Output File\n");
|
||||
BIO_printf(bio_err, "Error Writing Output File\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
/* Read the input data */
|
||||
rsa_inlen = BIO_read(in, rsa_in, keysize * 2);
|
||||
if (rsa_inlen <= 0) {
|
||||
if (rsa_inlen < 0) {
|
||||
BIO_printf(bio_err, "Error reading input Data\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -311,7 +311,7 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
}
|
||||
|
||||
if (rsa_outlen <= 0) {
|
||||
if (rsa_outlen < 0) {
|
||||
BIO_printf(bio_err, "RSA operation error\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
|
||||
@@ -308,7 +308,7 @@ static void sc_usage(void)
|
||||
" -connect host:port - who to connect to (default is %s:%s)\n",
|
||||
SSL_HOST_NAME, PORT_STR);
|
||||
BIO_printf(bio_err,
|
||||
" -verify_host host - check peer certificate matches \"host\"\n");
|
||||
" -verify_hostname host - check peer certificate matches \"host\"\n");
|
||||
BIO_printf(bio_err,
|
||||
" -verify_email email - check peer certificate matches \"email\"\n");
|
||||
BIO_printf(bio_err,
|
||||
@@ -390,8 +390,6 @@ static void sc_usage(void)
|
||||
" -no_tls1_2/-no_tls1_1/-no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n");
|
||||
BIO_printf(bio_err,
|
||||
" -bugs - Switch on all SSL implementation bug workarounds\n");
|
||||
BIO_printf(bio_err,
|
||||
" -serverpref - Use server's cipher preferences (only SSLv2)\n");
|
||||
BIO_printf(bio_err,
|
||||
" -cipher - preferred cipher to use, use the 'openssl ciphers'\n");
|
||||
BIO_printf(bio_err,
|
||||
|
||||
@@ -429,6 +429,8 @@ typedef struct srpsrvparm_st {
|
||||
static int MS_CALLBACK ssl_srp_server_param_cb(SSL *s, int *ad, void *arg)
|
||||
{
|
||||
srpsrvparm *p = (srpsrvparm *) arg;
|
||||
int ret = SSL3_AL_FATAL;
|
||||
|
||||
if (p->login == NULL && p->user == NULL) {
|
||||
p->login = SSL_get_srp_username(s);
|
||||
BIO_printf(bio_err, "SRP username = \"%s\"\n", p->login);
|
||||
@@ -437,21 +439,25 @@ static int MS_CALLBACK ssl_srp_server_param_cb(SSL *s, int *ad, void *arg)
|
||||
|
||||
if (p->user == NULL) {
|
||||
BIO_printf(bio_err, "User %s doesn't exist\n", p->login);
|
||||
return SSL3_AL_FATAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (SSL_set_srp_server_param
|
||||
(s, p->user->N, p->user->g, p->user->s, p->user->v,
|
||||
p->user->info) < 0) {
|
||||
*ad = SSL_AD_INTERNAL_ERROR;
|
||||
return SSL3_AL_FATAL;
|
||||
goto err;
|
||||
}
|
||||
BIO_printf(bio_err,
|
||||
"SRP parameters set: username = \"%s\" info=\"%s\" \n",
|
||||
p->login, p->user->info);
|
||||
/* need to check whether there are memory leaks */
|
||||
ret = SSL_ERROR_NONE;
|
||||
|
||||
err:
|
||||
SRP_user_pwd_free(p->user);
|
||||
p->user = NULL;
|
||||
p->login = NULL;
|
||||
return SSL_ERROR_NONE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -498,7 +504,7 @@ static void sv_usage(void)
|
||||
BIO_printf(bio_err,
|
||||
" -accept arg - port to accept on (default is %d)\n", PORT);
|
||||
BIO_printf(bio_err,
|
||||
" -verify_host host - check peer certificate matches \"host\"\n");
|
||||
" -verify_hostname host - check peer certificate matches \"host\"\n");
|
||||
BIO_printf(bio_err,
|
||||
" -verify_email email - check peer certificate matches \"email\"\n");
|
||||
BIO_printf(bio_err,
|
||||
@@ -2452,9 +2458,10 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
while (SSL_get_error(con, k) == SSL_ERROR_WANT_X509_LOOKUP) {
|
||||
BIO_printf(bio_s_out, "LOOKUP renego during write\n");
|
||||
SRP_user_pwd_free(srp_callback_parm.user);
|
||||
srp_callback_parm.user =
|
||||
SRP_VBASE_get_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
SRP_VBASE_get1_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
if (srp_callback_parm.user)
|
||||
BIO_printf(bio_s_out, "LOOKUP done %s\n",
|
||||
srp_callback_parm.user->info);
|
||||
@@ -2508,9 +2515,10 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
while (SSL_get_error(con, i) == SSL_ERROR_WANT_X509_LOOKUP) {
|
||||
BIO_printf(bio_s_out, "LOOKUP renego during read\n");
|
||||
SRP_user_pwd_free(srp_callback_parm.user);
|
||||
srp_callback_parm.user =
|
||||
SRP_VBASE_get_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
SRP_VBASE_get1_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
if (srp_callback_parm.user)
|
||||
BIO_printf(bio_s_out, "LOOKUP done %s\n",
|
||||
srp_callback_parm.user->info);
|
||||
@@ -2605,9 +2613,10 @@ static int init_ssl_connection(SSL *con)
|
||||
while (i <= 0 && SSL_get_error(con, i) == SSL_ERROR_WANT_X509_LOOKUP) {
|
||||
BIO_printf(bio_s_out, "LOOKUP during accept %s\n",
|
||||
srp_callback_parm.login);
|
||||
SRP_user_pwd_free(srp_callback_parm.user);
|
||||
srp_callback_parm.user =
|
||||
SRP_VBASE_get_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
SRP_VBASE_get1_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
if (srp_callback_parm.user)
|
||||
BIO_printf(bio_s_out, "LOOKUP done %s\n",
|
||||
srp_callback_parm.user->info);
|
||||
@@ -2849,9 +2858,10 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
&& SSL_get_error(con, i) == SSL_ERROR_WANT_X509_LOOKUP) {
|
||||
BIO_printf(bio_s_out, "LOOKUP during accept %s\n",
|
||||
srp_callback_parm.login);
|
||||
SRP_user_pwd_free(srp_callback_parm.user);
|
||||
srp_callback_parm.user =
|
||||
SRP_VBASE_get_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
SRP_VBASE_get1_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
if (srp_callback_parm.user)
|
||||
BIO_printf(bio_s_out, "LOOKUP done %s\n",
|
||||
srp_callback_parm.user->info);
|
||||
@@ -2891,9 +2901,10 @@ static int www_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
if (BIO_should_io_special(io)
|
||||
&& BIO_get_retry_reason(io) == BIO_RR_SSL_X509_LOOKUP) {
|
||||
BIO_printf(bio_s_out, "LOOKUP renego during read\n");
|
||||
SRP_user_pwd_free(srp_callback_parm.user);
|
||||
srp_callback_parm.user =
|
||||
SRP_VBASE_get_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
SRP_VBASE_get1_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
if (srp_callback_parm.user)
|
||||
BIO_printf(bio_s_out, "LOOKUP done %s\n",
|
||||
srp_callback_parm.user->info);
|
||||
@@ -3236,9 +3247,10 @@ static int rev_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
if (BIO_should_io_special(io)
|
||||
&& BIO_get_retry_reason(io) == BIO_RR_SSL_X509_LOOKUP) {
|
||||
BIO_printf(bio_s_out, "LOOKUP renego during accept\n");
|
||||
SRP_user_pwd_free(srp_callback_parm.user);
|
||||
srp_callback_parm.user =
|
||||
SRP_VBASE_get_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
SRP_VBASE_get1_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
if (srp_callback_parm.user)
|
||||
BIO_printf(bio_s_out, "LOOKUP done %s\n",
|
||||
srp_callback_parm.user->info);
|
||||
@@ -3264,9 +3276,10 @@ static int rev_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
if (BIO_should_io_special(io)
|
||||
&& BIO_get_retry_reason(io) == BIO_RR_SSL_X509_LOOKUP) {
|
||||
BIO_printf(bio_s_out, "LOOKUP renego during read\n");
|
||||
SRP_user_pwd_free(srp_callback_parm.user);
|
||||
srp_callback_parm.user =
|
||||
SRP_VBASE_get_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
SRP_VBASE_get1_by_user(srp_callback_parm.vb,
|
||||
srp_callback_parm.login);
|
||||
if (srp_callback_parm.user)
|
||||
BIO_printf(bio_s_out, "LOOKUP done %s\n",
|
||||
srp_callback_parm.user->info);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* apps/speed.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* apps/speed.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1226,12 +1226,7 @@ static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext,
|
||||
if (X509_gmtime_adj(X509_get_notBefore(x), 0) == NULL)
|
||||
goto err;
|
||||
|
||||
/* Lets just make it 12:00am GMT, Jan 1 1970 */
|
||||
/* memcpy(x->cert_info->validity->notBefore,"700101120000Z",13); */
|
||||
/* 28 days to be certified */
|
||||
|
||||
if (X509_gmtime_adj(X509_get_notAfter(x), (long)60 * 60 * 24 * days) ==
|
||||
NULL)
|
||||
if (X509_time_adj_ex(X509_get_notAfter(x), days, 0, NULL) == NULL)
|
||||
goto err;
|
||||
|
||||
if (!X509_set_pubkey(x, pkey))
|
||||
|
||||
3
config
3
config
@@ -852,7 +852,8 @@ case "$GUESSOS" in
|
||||
# *-dgux) OUT="dgux" ;;
|
||||
mips-sony-newsos4) OUT="newsos4-gcc" ;;
|
||||
*-*-cygwin_pre1.3) OUT="Cygwin-pre1.3" ;;
|
||||
*-*-cygwin) OUT="Cygwin" ;;
|
||||
i[3456]86-*-cygwin) OUT="Cygwin" ;;
|
||||
*-*-cygwin) OUT="Cygwin-${MACHINE}" ;;
|
||||
t3e-cray-unicosmk) OUT="cray-t3e" ;;
|
||||
j90-cray-unicos) OUT="cray-j90" ;;
|
||||
nsr-tandem-nsk) OUT="tandem-c89" ;;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes_cbc.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes_cbc.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes_cfb.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes_cfb.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes_core.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes_core.c */
|
||||
/**
|
||||
* rijndael-alg-fst.c
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes_ctr.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes_ctr.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes_ecb.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes_ecb.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes_ige.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes_ige.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes_misc.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes_misc.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes_ofb.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes_ofb.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/aes/aes_core.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/aes/aes_core.c */
|
||||
/**
|
||||
* rijndael-alg-fst.c
|
||||
*
|
||||
|
||||
@@ -63,7 +63,7 @@ if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$avx = ($1>=10) + ($1>=11);
|
||||
}
|
||||
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ $avx=1 if (!$avx && $win64 && ($flavour =~ /nasm/ || $ENV{ASM} =~ /nasm/) &&
|
||||
$avx=1 if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
`ml64 2>&1` =~ /Version ([0-9]+)\./ &&
|
||||
$1>=10);
|
||||
$avx=1 if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-9]\.[0-9]+)/ && $2>=3.0);
|
||||
$avx=1 if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9]\.[0-9]+)/ && $2>=3.0);
|
||||
|
||||
$shaext=1; ### set to zero if compiling for 1.0.1
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$avx = ($1>=10) + ($1>=12);
|
||||
}
|
||||
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -717,7 +717,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
long plen;
|
||||
char cst, inf, free_cont = 0;
|
||||
const unsigned char *p;
|
||||
BUF_MEM buf;
|
||||
BUF_MEM buf = { 0, NULL, 0 };
|
||||
const unsigned char *cont = NULL;
|
||||
long len;
|
||||
if (!pval) {
|
||||
@@ -793,7 +793,6 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
} else {
|
||||
len = p - cont + plen;
|
||||
p += plen;
|
||||
buf.data = NULL;
|
||||
}
|
||||
} else if (cst) {
|
||||
if (utype == V_ASN1_NULL || utype == V_ASN1_BOOLEAN
|
||||
@@ -802,9 +801,9 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_TYPE_NOT_PRIMITIVE);
|
||||
return 0;
|
||||
}
|
||||
buf.length = 0;
|
||||
buf.max = 0;
|
||||
buf.data = NULL;
|
||||
|
||||
/* Free any returned 'buf' content */
|
||||
free_cont = 1;
|
||||
/*
|
||||
* Should really check the internal tags are correct but some things
|
||||
* may get this wrong. The relevant specs say that constructed string
|
||||
@@ -812,18 +811,16 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
* So instead just check for UNIVERSAL class and ignore the tag.
|
||||
*/
|
||||
if (!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL, 0)) {
|
||||
free_cont = 1;
|
||||
goto err;
|
||||
}
|
||||
len = buf.length;
|
||||
/* Append a final null to string */
|
||||
if (!BUF_MEM_grow_clean(&buf, len + 1)) {
|
||||
ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
goto err;
|
||||
}
|
||||
buf.data[len] = 0;
|
||||
cont = (const unsigned char *)buf.data;
|
||||
free_cont = 1;
|
||||
} else {
|
||||
cont = p;
|
||||
len = plen;
|
||||
@@ -831,6 +828,7 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
}
|
||||
|
||||
/* We now have content length and type: translate into a structure */
|
||||
/* asn1_ex_c2i may reuse allocated buffer, and so sets free_cont to 0 */
|
||||
if (!asn1_ex_c2i(pval, cont, len, utype, &free_cont, it))
|
||||
goto err;
|
||||
|
||||
|
||||
@@ -125,16 +125,16 @@
|
||||
# define LLONG long
|
||||
#endif
|
||||
|
||||
static void fmtstr(char **, char **, size_t *, size_t *,
|
||||
const char *, int, int, int);
|
||||
static void fmtint(char **, char **, size_t *, size_t *,
|
||||
LLONG, int, int, int, int);
|
||||
static void fmtfp(char **, char **, size_t *, size_t *,
|
||||
LDOUBLE, int, int, int);
|
||||
static void doapr_outch(char **, char **, size_t *, size_t *, int);
|
||||
static void _dopr(char **sbuffer, char **buffer,
|
||||
size_t *maxlen, size_t *retlen, int *truncated,
|
||||
const char *format, va_list args);
|
||||
static int fmtstr(char **, char **, size_t *, size_t *,
|
||||
const char *, int, int, int);
|
||||
static int fmtint(char **, char **, size_t *, size_t *,
|
||||
LLONG, int, int, int, int);
|
||||
static int fmtfp(char **, char **, size_t *, size_t *,
|
||||
LDOUBLE, int, int, int);
|
||||
static int doapr_outch(char **, char **, size_t *, size_t *, int);
|
||||
static int _dopr(char **sbuffer, char **buffer,
|
||||
size_t *maxlen, size_t *retlen, int *truncated,
|
||||
const char *format, va_list args);
|
||||
|
||||
/* format read states */
|
||||
#define DP_S_DEFAULT 0
|
||||
@@ -165,7 +165,7 @@ static void _dopr(char **sbuffer, char **buffer,
|
||||
#define char_to_int(p) (p - '0')
|
||||
#define OSSL_MAX(p,q) ((p >= q) ? p : q)
|
||||
|
||||
static void
|
||||
static int
|
||||
_dopr(char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *maxlen,
|
||||
@@ -196,7 +196,8 @@ _dopr(char **sbuffer,
|
||||
if (ch == '%')
|
||||
state = DP_S_FLAGS;
|
||||
else
|
||||
doapr_outch(sbuffer, buffer, &currlen, maxlen, ch);
|
||||
if(!doapr_outch(sbuffer, buffer, &currlen, maxlen, ch))
|
||||
return 0;
|
||||
ch = *format++;
|
||||
break;
|
||||
case DP_S_FLAGS:
|
||||
@@ -302,8 +303,9 @@ _dopr(char **sbuffer,
|
||||
value = va_arg(args, int);
|
||||
break;
|
||||
}
|
||||
fmtint(sbuffer, buffer, &currlen, maxlen,
|
||||
value, 10, min, max, flags);
|
||||
if (!fmtint(sbuffer, buffer, &currlen, maxlen, value, 10, min,
|
||||
max, flags))
|
||||
return 0;
|
||||
break;
|
||||
case 'X':
|
||||
flags |= DP_F_UP;
|
||||
@@ -326,17 +328,19 @@ _dopr(char **sbuffer,
|
||||
value = (LLONG) va_arg(args, unsigned int);
|
||||
break;
|
||||
}
|
||||
fmtint(sbuffer, buffer, &currlen, maxlen, value,
|
||||
ch == 'o' ? 8 : (ch == 'u' ? 10 : 16),
|
||||
min, max, flags);
|
||||
if (!fmtint(sbuffer, buffer, &currlen, maxlen, value,
|
||||
ch == 'o' ? 8 : (ch == 'u' ? 10 : 16),
|
||||
min, max, flags))
|
||||
return 0;
|
||||
break;
|
||||
case 'f':
|
||||
if (cflags == DP_C_LDOUBLE)
|
||||
fvalue = va_arg(args, LDOUBLE);
|
||||
else
|
||||
fvalue = va_arg(args, double);
|
||||
fmtfp(sbuffer, buffer, &currlen, maxlen,
|
||||
fvalue, min, max, flags);
|
||||
if (!fmtfp(sbuffer, buffer, &currlen, maxlen, fvalue, min, max,
|
||||
flags))
|
||||
return 0;
|
||||
break;
|
||||
case 'E':
|
||||
flags |= DP_F_UP;
|
||||
@@ -355,8 +359,9 @@ _dopr(char **sbuffer,
|
||||
fvalue = va_arg(args, double);
|
||||
break;
|
||||
case 'c':
|
||||
doapr_outch(sbuffer, buffer, &currlen, maxlen,
|
||||
va_arg(args, int));
|
||||
if(!doapr_outch(sbuffer, buffer, &currlen, maxlen,
|
||||
va_arg(args, int)))
|
||||
return 0;
|
||||
break;
|
||||
case 's':
|
||||
strvalue = va_arg(args, char *);
|
||||
@@ -366,13 +371,15 @@ _dopr(char **sbuffer,
|
||||
else
|
||||
max = *maxlen;
|
||||
}
|
||||
fmtstr(sbuffer, buffer, &currlen, maxlen, strvalue,
|
||||
flags, min, max);
|
||||
if (!fmtstr(sbuffer, buffer, &currlen, maxlen, strvalue,
|
||||
flags, min, max))
|
||||
return 0;
|
||||
break;
|
||||
case 'p':
|
||||
value = (long)va_arg(args, void *);
|
||||
fmtint(sbuffer, buffer, &currlen, maxlen,
|
||||
value, 16, min, max, flags | DP_F_NUM);
|
||||
if (!fmtint(sbuffer, buffer, &currlen, maxlen,
|
||||
value, 16, min, max, flags | DP_F_NUM))
|
||||
return 0;
|
||||
break;
|
||||
case 'n': /* XXX */
|
||||
if (cflags == DP_C_SHORT) {
|
||||
@@ -394,7 +401,8 @@ _dopr(char **sbuffer,
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
doapr_outch(sbuffer, buffer, &currlen, maxlen, ch);
|
||||
if(!doapr_outch(sbuffer, buffer, &currlen, maxlen, ch))
|
||||
return 0;
|
||||
break;
|
||||
case 'w':
|
||||
/* not supported yet, treat as next char */
|
||||
@@ -418,46 +426,56 @@ _dopr(char **sbuffer,
|
||||
*truncated = (currlen > *maxlen - 1);
|
||||
if (*truncated)
|
||||
currlen = *maxlen - 1;
|
||||
doapr_outch(sbuffer, buffer, &currlen, maxlen, '\0');
|
||||
if(!doapr_outch(sbuffer, buffer, &currlen, maxlen, '\0'))
|
||||
return 0;
|
||||
*retlen = currlen - 1;
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
fmtstr(char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
size_t *maxlen, const char *value, int flags, int min, int max)
|
||||
{
|
||||
int padlen, strln;
|
||||
int padlen;
|
||||
size_t strln;
|
||||
int cnt = 0;
|
||||
|
||||
if (value == 0)
|
||||
value = "<NULL>";
|
||||
for (strln = 0; value[strln]; ++strln) ;
|
||||
|
||||
strln = strlen(value);
|
||||
if (strln > INT_MAX)
|
||||
strln = INT_MAX;
|
||||
|
||||
padlen = min - strln;
|
||||
if (padlen < 0)
|
||||
if (min < 0 || padlen < 0)
|
||||
padlen = 0;
|
||||
if (flags & DP_F_MINUS)
|
||||
padlen = -padlen;
|
||||
|
||||
while ((padlen > 0) && (cnt < max)) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
if(!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
|
||||
return 0;
|
||||
--padlen;
|
||||
++cnt;
|
||||
}
|
||||
while (*value && (cnt < max)) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, *value++);
|
||||
if(!doapr_outch(sbuffer, buffer, currlen, maxlen, *value++))
|
||||
return 0;
|
||||
++cnt;
|
||||
}
|
||||
while ((padlen < 0) && (cnt < max)) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
if(!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
|
||||
return 0;
|
||||
++padlen;
|
||||
++cnt;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
fmtint(char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
@@ -517,37 +535,44 @@ fmtint(char **sbuffer,
|
||||
|
||||
/* spaces */
|
||||
while (spadlen > 0) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
if(!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
|
||||
return 0;
|
||||
--spadlen;
|
||||
}
|
||||
|
||||
/* sign */
|
||||
if (signvalue)
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
|
||||
if(!doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue))
|
||||
return 0;
|
||||
|
||||
/* prefix */
|
||||
while (*prefix) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix);
|
||||
if(!doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix))
|
||||
return 0;
|
||||
prefix++;
|
||||
}
|
||||
|
||||
/* zeros */
|
||||
if (zpadlen > 0) {
|
||||
while (zpadlen > 0) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, '0');
|
||||
if(!doapr_outch(sbuffer, buffer, currlen, maxlen, '0'))
|
||||
return 0;
|
||||
--zpadlen;
|
||||
}
|
||||
}
|
||||
/* digits */
|
||||
while (place > 0)
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, convert[--place]);
|
||||
while (place > 0) {
|
||||
if (!doapr_outch(sbuffer, buffer, currlen, maxlen, convert[--place]))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* left justified spaces */
|
||||
while (spadlen < 0) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
if (!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
|
||||
return 0;
|
||||
++spadlen;
|
||||
}
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static LDOUBLE abs_val(LDOUBLE value)
|
||||
@@ -578,7 +603,7 @@ static long roundv(LDOUBLE value)
|
||||
return intpart;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
fmtfp(char **sbuffer,
|
||||
char **buffer,
|
||||
size_t *currlen,
|
||||
@@ -657,47 +682,61 @@ fmtfp(char **sbuffer,
|
||||
|
||||
if ((flags & DP_F_ZERO) && (padlen > 0)) {
|
||||
if (signvalue) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
|
||||
if (!doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue))
|
||||
return 0;
|
||||
--padlen;
|
||||
signvalue = 0;
|
||||
}
|
||||
while (padlen > 0) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, '0');
|
||||
if (!doapr_outch(sbuffer, buffer, currlen, maxlen, '0'))
|
||||
return 0;
|
||||
--padlen;
|
||||
}
|
||||
}
|
||||
while (padlen > 0) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
if (!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
|
||||
return 0;
|
||||
--padlen;
|
||||
}
|
||||
if (signvalue)
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue);
|
||||
if (signvalue && !doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue))
|
||||
return 0;
|
||||
|
||||
while (iplace > 0)
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, iconvert[--iplace]);
|
||||
while (iplace > 0) {
|
||||
if (!doapr_outch(sbuffer, buffer, currlen, maxlen, iconvert[--iplace]))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decimal point. This should probably use locale to find the correct
|
||||
* char to print out.
|
||||
*/
|
||||
if (max > 0 || (flags & DP_F_NUM)) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, '.');
|
||||
if (!doapr_outch(sbuffer, buffer, currlen, maxlen, '.'))
|
||||
return 0;
|
||||
|
||||
while (fplace > 0)
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, fconvert[--fplace]);
|
||||
while (fplace > 0) {
|
||||
if(!doapr_outch(sbuffer, buffer, currlen, maxlen,
|
||||
fconvert[--fplace]))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
while (zpadlen > 0) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, '0');
|
||||
if (!doapr_outch(sbuffer, buffer, currlen, maxlen, '0'))
|
||||
return 0;
|
||||
--zpadlen;
|
||||
}
|
||||
|
||||
while (padlen < 0) {
|
||||
doapr_outch(sbuffer, buffer, currlen, maxlen, ' ');
|
||||
if (!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
|
||||
return 0;
|
||||
++padlen;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
#define BUFFER_INC 1024
|
||||
|
||||
static int
|
||||
doapr_outch(char **sbuffer,
|
||||
char **buffer, size_t *currlen, size_t *maxlen, int c)
|
||||
{
|
||||
@@ -708,24 +747,25 @@ doapr_outch(char **sbuffer,
|
||||
assert(*currlen <= *maxlen);
|
||||
|
||||
if (buffer && *currlen == *maxlen) {
|
||||
*maxlen += 1024;
|
||||
if (*maxlen > INT_MAX - BUFFER_INC)
|
||||
return 0;
|
||||
|
||||
*maxlen += BUFFER_INC;
|
||||
if (*buffer == NULL) {
|
||||
*buffer = OPENSSL_malloc(*maxlen);
|
||||
if (!*buffer) {
|
||||
/* Panic! Can't really do anything sensible. Just return */
|
||||
return;
|
||||
}
|
||||
if (*buffer == NULL)
|
||||
return 0;
|
||||
if (*currlen > 0) {
|
||||
assert(*sbuffer != NULL);
|
||||
memcpy(*buffer, *sbuffer, *currlen);
|
||||
}
|
||||
*sbuffer = NULL;
|
||||
} else {
|
||||
*buffer = OPENSSL_realloc(*buffer, *maxlen);
|
||||
if (!*buffer) {
|
||||
/* Panic! Can't really do anything sensible. Just return */
|
||||
return;
|
||||
}
|
||||
char *tmpbuf;
|
||||
tmpbuf = OPENSSL_realloc(*buffer, *maxlen);
|
||||
if (tmpbuf == NULL)
|
||||
return 0;
|
||||
*buffer = tmpbuf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -736,7 +776,7 @@ doapr_outch(char **sbuffer,
|
||||
(*buffer)[(*currlen)++] = (char)c;
|
||||
}
|
||||
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
@@ -768,7 +808,11 @@ int BIO_vprintf(BIO *bio, const char *format, va_list args)
|
||||
|
||||
dynbuf = NULL;
|
||||
CRYPTO_push_info("doapr()");
|
||||
_dopr(&hugebufp, &dynbuf, &hugebufsize, &retlen, &ignored, format, args);
|
||||
if (!_dopr(&hugebufp, &dynbuf, &hugebufsize, &retlen, &ignored, format,
|
||||
args)) {
|
||||
OPENSSL_free(dynbuf);
|
||||
return -1;
|
||||
}
|
||||
if (dynbuf) {
|
||||
ret = BIO_write(bio, dynbuf, (int)retlen);
|
||||
OPENSSL_free(dynbuf);
|
||||
@@ -803,7 +847,8 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
|
||||
size_t retlen;
|
||||
int truncated;
|
||||
|
||||
_dopr(&buf, NULL, &n, &retlen, &truncated, format, args);
|
||||
if(!_dopr(&buf, NULL, &n, &retlen, &truncated, format, args))
|
||||
return -1;
|
||||
|
||||
if (truncated)
|
||||
/*
|
||||
|
||||
@@ -479,11 +479,11 @@ struct bio_dgram_sctp_prinfo {
|
||||
# define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
|
||||
# define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
|
||||
# define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
|
||||
# define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0)
|
||||
# define BIO_get_conn_int_port(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL)
|
||||
|
||||
# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
|
||||
|
||||
/* BIO_s_accept_socket() */
|
||||
/* BIO_s_accept() */
|
||||
# define BIO_set_accept_port(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name)
|
||||
# define BIO_get_accept_port(b) BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)
|
||||
/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */
|
||||
@@ -496,6 +496,7 @@ struct bio_dgram_sctp_prinfo {
|
||||
# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL)
|
||||
# define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL)
|
||||
|
||||
/* BIO_s_accept() and BIO_s_connect() */
|
||||
# define BIO_do_connect(b) BIO_do_handshake(b)
|
||||
# define BIO_do_accept(b) BIO_do_handshake(b)
|
||||
# define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL)
|
||||
@@ -515,12 +516,15 @@ struct bio_dgram_sctp_prinfo {
|
||||
# define BIO_get_url(b,url) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,2,(char *)(url))
|
||||
# define BIO_get_no_connect_return(b) BIO_ctrl(b,BIO_C_GET_PROXY_PARAM,5,NULL)
|
||||
|
||||
/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */
|
||||
# define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd)
|
||||
# define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c)
|
||||
|
||||
/* BIO_s_file() */
|
||||
# define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp)
|
||||
# define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp)
|
||||
|
||||
/* BIO_s_fd() and BIO_s_file() */
|
||||
# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL)
|
||||
# define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL)
|
||||
|
||||
@@ -685,7 +689,7 @@ long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi,
|
||||
long argl, long ret);
|
||||
|
||||
BIO_METHOD *BIO_s_mem(void);
|
||||
BIO *BIO_new_mem_buf(void *buf, int len);
|
||||
BIO *BIO_new_mem_buf(const void *buf, int len);
|
||||
BIO_METHOD *BIO_s_socket(void);
|
||||
BIO_METHOD *BIO_s_connect(void);
|
||||
BIO_METHOD *BIO_s_accept(void);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/bio/bss_bio.c -*- Mode: C; c-file-style: "eay" -*- */
|
||||
/* crypto/bio/bss_bio.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -419,7 +419,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
BIO *dbio;
|
||||
int *ip;
|
||||
const char **pptr;
|
||||
const char **pptr = NULL;
|
||||
long ret = 1;
|
||||
BIO_CONNECT *data;
|
||||
|
||||
@@ -442,19 +442,28 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
case BIO_C_GET_CONNECT:
|
||||
if (ptr != NULL) {
|
||||
pptr = (const char **)ptr;
|
||||
if (num == 0) {
|
||||
*pptr = data->param_hostname;
|
||||
}
|
||||
|
||||
} else if (num == 1) {
|
||||
*pptr = data->param_port;
|
||||
} else if (num == 2) {
|
||||
*pptr = (char *)&(data->ip[0]);
|
||||
} else if (num == 3) {
|
||||
*((int *)ptr) = data->port;
|
||||
if (b->init) {
|
||||
if (pptr != NULL) {
|
||||
ret = 1;
|
||||
if (num == 0) {
|
||||
*pptr = data->param_hostname;
|
||||
} else if (num == 1) {
|
||||
*pptr = data->param_port;
|
||||
} else if (num == 2) {
|
||||
*pptr = (char *)&(data->ip[0]);
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
if ((!b->init) || (ptr == NULL))
|
||||
if (num == 3) {
|
||||
ret = data->port;
|
||||
}
|
||||
} else {
|
||||
if (pptr != NULL)
|
||||
*pptr = "not initialized";
|
||||
ret = 1;
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case BIO_C_SET_CONNECT:
|
||||
|
||||
@@ -519,10 +519,8 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
switch (cmd) {
|
||||
case BIO_CTRL_RESET:
|
||||
num = 0;
|
||||
case BIO_C_FILE_SEEK:
|
||||
ret = 0;
|
||||
break;
|
||||
case BIO_C_FILE_TELL:
|
||||
case BIO_CTRL_INFO:
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
@@ -91,7 +91,8 @@ BIO_METHOD *BIO_s_mem(void)
|
||||
return (&mem_method);
|
||||
}
|
||||
|
||||
BIO *BIO_new_mem_buf(void *buf, int len)
|
||||
|
||||
BIO *BIO_new_mem_buf(const void *buf, int len)
|
||||
{
|
||||
BIO *ret;
|
||||
BUF_MEM *b;
|
||||
@@ -105,7 +106,8 @@ BIO *BIO_new_mem_buf(void *buf, int len)
|
||||
if (!(ret = BIO_new(BIO_s_mem())))
|
||||
return NULL;
|
||||
b = (BUF_MEM *)ret->ptr;
|
||||
b->data = buf;
|
||||
/* Cast away const and trust in the MEM_RDONLY flag. */
|
||||
b->data = (void *)buf;
|
||||
b->length = sz;
|
||||
b->max = sz;
|
||||
ret->flags |= BIO_FLAGS_MEM_RDONLY;
|
||||
|
||||
@@ -252,8 +252,8 @@ bn_exp.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
bn_exp.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
|
||||
bn_exp.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
|
||||
bn_exp.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
|
||||
bn_exp.o: ../../include/openssl/symhacks.h ../cryptlib.h bn_exp.c bn_lcl.h
|
||||
bn_exp.o: rsaz_exp.h
|
||||
bn_exp.o: ../../include/openssl/symhacks.h ../constant_time_locl.h
|
||||
bn_exp.o: ../cryptlib.h bn_exp.c bn_lcl.h rsaz_exp.h
|
||||
bn_exp2.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
|
||||
bn_exp2.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
|
||||
bn_exp2.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
|
||||
|
||||
@@ -443,7 +443,7 @@ $TEMP2 = $B2;
|
||||
$TEMP3 = $Y1;
|
||||
$TEMP4 = $Y2;
|
||||
$code.=<<___;
|
||||
#we need to fix indexes 32-39 to avoid overflow
|
||||
# we need to fix indices 32-39 to avoid overflow
|
||||
vmovdqu 32*8(%rsp), $ACC8 # 32*8-192($tp0),
|
||||
vmovdqu 32*9(%rsp), $ACC1 # 32*9-192($tp0)
|
||||
vmovdqu 32*10(%rsp), $ACC2 # 32*10-192($tp0)
|
||||
@@ -1592,68 +1592,128 @@ rsaz_1024_scatter5_avx2:
|
||||
.type rsaz_1024_gather5_avx2,\@abi-omnipotent
|
||||
.align 32
|
||||
rsaz_1024_gather5_avx2:
|
||||
vzeroupper
|
||||
mov %rsp,%r11
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
lea -0x88(%rsp),%rax
|
||||
vzeroupper
|
||||
.LSEH_begin_rsaz_1024_gather5:
|
||||
# I can't trust assembler to use specific encoding:-(
|
||||
.byte 0x48,0x8d,0x60,0xe0 #lea -0x20(%rax),%rsp
|
||||
.byte 0xc5,0xf8,0x29,0x70,0xe0 #vmovaps %xmm6,-0x20(%rax)
|
||||
.byte 0xc5,0xf8,0x29,0x78,0xf0 #vmovaps %xmm7,-0x10(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x40,0x00 #vmovaps %xmm8,0(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x48,0x10 #vmovaps %xmm9,0x10(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x50,0x20 #vmovaps %xmm10,0x20(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x58,0x30 #vmovaps %xmm11,0x30(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x60,0x40 #vmovaps %xmm12,0x40(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x68,0x50 #vmovaps %xmm13,0x50(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x70,0x60 #vmovaps %xmm14,0x60(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x78,0x70 #vmovaps %xmm15,0x70(%rax)
|
||||
.byte 0x48,0x8d,0x60,0xe0 # lea -0x20(%rax),%rsp
|
||||
.byte 0xc5,0xf8,0x29,0x70,0xe0 # vmovaps %xmm6,-0x20(%rax)
|
||||
.byte 0xc5,0xf8,0x29,0x78,0xf0 # vmovaps %xmm7,-0x10(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x40,0x00 # vmovaps %xmm8,0(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x48,0x10 # vmovaps %xmm9,0x10(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x50,0x20 # vmovaps %xmm10,0x20(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x58,0x30 # vmovaps %xmm11,0x30(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x60,0x40 # vmovaps %xmm12,0x40(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x68,0x50 # vmovaps %xmm13,0x50(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x70,0x60 # vmovaps %xmm14,0x60(%rax)
|
||||
.byte 0xc5,0x78,0x29,0x78,0x70 # vmovaps %xmm15,0x70(%rax)
|
||||
___
|
||||
$code.=<<___;
|
||||
lea .Lgather_table(%rip),%r11
|
||||
mov $power,%eax
|
||||
and \$3,$power
|
||||
shr \$2,%eax # cache line number
|
||||
shl \$4,$power # offset within cache line
|
||||
lea -0x100(%rsp),%rsp
|
||||
and \$-32, %rsp
|
||||
lea .Linc(%rip), %r10
|
||||
lea -128(%rsp),%rax # control u-op density
|
||||
|
||||
vmovdqu -32(%r11),%ymm7 # .Lgather_permd
|
||||
vpbroadcastb 8(%r11,%rax), %xmm8
|
||||
vpbroadcastb 7(%r11,%rax), %xmm9
|
||||
vpbroadcastb 6(%r11,%rax), %xmm10
|
||||
vpbroadcastb 5(%r11,%rax), %xmm11
|
||||
vpbroadcastb 4(%r11,%rax), %xmm12
|
||||
vpbroadcastb 3(%r11,%rax), %xmm13
|
||||
vpbroadcastb 2(%r11,%rax), %xmm14
|
||||
vpbroadcastb 1(%r11,%rax), %xmm15
|
||||
vmovd $power, %xmm4
|
||||
vmovdqa (%r10),%ymm0
|
||||
vmovdqa 32(%r10),%ymm1
|
||||
vmovdqa 64(%r10),%ymm5
|
||||
vpbroadcastd %xmm4,%ymm4
|
||||
|
||||
lea 64($inp,$power),$inp
|
||||
mov \$64,%r11 # size optimization
|
||||
mov \$9,%eax
|
||||
jmp .Loop_gather_1024
|
||||
vpaddd %ymm5, %ymm0, %ymm2
|
||||
vpcmpeqd %ymm4, %ymm0, %ymm0
|
||||
vpaddd %ymm5, %ymm1, %ymm3
|
||||
vpcmpeqd %ymm4, %ymm1, %ymm1
|
||||
vmovdqa %ymm0, 32*0+128(%rax)
|
||||
vpaddd %ymm5, %ymm2, %ymm0
|
||||
vpcmpeqd %ymm4, %ymm2, %ymm2
|
||||
vmovdqa %ymm1, 32*1+128(%rax)
|
||||
vpaddd %ymm5, %ymm3, %ymm1
|
||||
vpcmpeqd %ymm4, %ymm3, %ymm3
|
||||
vmovdqa %ymm2, 32*2+128(%rax)
|
||||
vpaddd %ymm5, %ymm0, %ymm2
|
||||
vpcmpeqd %ymm4, %ymm0, %ymm0
|
||||
vmovdqa %ymm3, 32*3+128(%rax)
|
||||
vpaddd %ymm5, %ymm1, %ymm3
|
||||
vpcmpeqd %ymm4, %ymm1, %ymm1
|
||||
vmovdqa %ymm0, 32*4+128(%rax)
|
||||
vpaddd %ymm5, %ymm2, %ymm8
|
||||
vpcmpeqd %ymm4, %ymm2, %ymm2
|
||||
vmovdqa %ymm1, 32*5+128(%rax)
|
||||
vpaddd %ymm5, %ymm3, %ymm9
|
||||
vpcmpeqd %ymm4, %ymm3, %ymm3
|
||||
vmovdqa %ymm2, 32*6+128(%rax)
|
||||
vpaddd %ymm5, %ymm8, %ymm10
|
||||
vpcmpeqd %ymm4, %ymm8, %ymm8
|
||||
vmovdqa %ymm3, 32*7+128(%rax)
|
||||
vpaddd %ymm5, %ymm9, %ymm11
|
||||
vpcmpeqd %ymm4, %ymm9, %ymm9
|
||||
vpaddd %ymm5, %ymm10, %ymm12
|
||||
vpcmpeqd %ymm4, %ymm10, %ymm10
|
||||
vpaddd %ymm5, %ymm11, %ymm13
|
||||
vpcmpeqd %ymm4, %ymm11, %ymm11
|
||||
vpaddd %ymm5, %ymm12, %ymm14
|
||||
vpcmpeqd %ymm4, %ymm12, %ymm12
|
||||
vpaddd %ymm5, %ymm13, %ymm15
|
||||
vpcmpeqd %ymm4, %ymm13, %ymm13
|
||||
vpcmpeqd %ymm4, %ymm14, %ymm14
|
||||
vpcmpeqd %ymm4, %ymm15, %ymm15
|
||||
|
||||
vmovdqa -32(%r10),%ymm7 # .Lgather_permd
|
||||
lea 128($inp), $inp
|
||||
mov \$9,$power
|
||||
|
||||
.align 32
|
||||
.Loop_gather_1024:
|
||||
vpand -64($inp), %xmm8,%xmm0
|
||||
vpand ($inp), %xmm9,%xmm1
|
||||
vpand 64($inp), %xmm10,%xmm2
|
||||
vpand ($inp,%r11,2), %xmm11,%xmm3
|
||||
vpor %xmm0,%xmm1,%xmm1
|
||||
vpand 64($inp,%r11,2), %xmm12,%xmm4
|
||||
vpor %xmm2,%xmm3,%xmm3
|
||||
vpand ($inp,%r11,4), %xmm13,%xmm5
|
||||
vpor %xmm1,%xmm3,%xmm3
|
||||
vpand 64($inp,%r11,4), %xmm14,%xmm6
|
||||
vpor %xmm4,%xmm5,%xmm5
|
||||
vpand -128($inp,%r11,8), %xmm15,%xmm2
|
||||
lea ($inp,%r11,8),$inp
|
||||
vpor %xmm3,%xmm5,%xmm5
|
||||
vpor %xmm2,%xmm6,%xmm6
|
||||
vpor %xmm5,%xmm6,%xmm6
|
||||
vpermd %ymm6,%ymm7,%ymm6
|
||||
vmovdqu %ymm6,($out)
|
||||
vmovdqa 32*0-128($inp), %ymm0
|
||||
vmovdqa 32*1-128($inp), %ymm1
|
||||
vmovdqa 32*2-128($inp), %ymm2
|
||||
vmovdqa 32*3-128($inp), %ymm3
|
||||
vpand 32*0+128(%rax), %ymm0, %ymm0
|
||||
vpand 32*1+128(%rax), %ymm1, %ymm1
|
||||
vpand 32*2+128(%rax), %ymm2, %ymm2
|
||||
vpor %ymm0, %ymm1, %ymm4
|
||||
vpand 32*3+128(%rax), %ymm3, %ymm3
|
||||
vmovdqa 32*4-128($inp), %ymm0
|
||||
vmovdqa 32*5-128($inp), %ymm1
|
||||
vpor %ymm2, %ymm3, %ymm5
|
||||
vmovdqa 32*6-128($inp), %ymm2
|
||||
vmovdqa 32*7-128($inp), %ymm3
|
||||
vpand 32*4+128(%rax), %ymm0, %ymm0
|
||||
vpand 32*5+128(%rax), %ymm1, %ymm1
|
||||
vpand 32*6+128(%rax), %ymm2, %ymm2
|
||||
vpor %ymm0, %ymm4, %ymm4
|
||||
vpand 32*7+128(%rax), %ymm3, %ymm3
|
||||
vpand 32*8-128($inp), %ymm8, %ymm0
|
||||
vpor %ymm1, %ymm5, %ymm5
|
||||
vpand 32*9-128($inp), %ymm9, %ymm1
|
||||
vpor %ymm2, %ymm4, %ymm4
|
||||
vpand 32*10-128($inp),%ymm10, %ymm2
|
||||
vpor %ymm3, %ymm5, %ymm5
|
||||
vpand 32*11-128($inp),%ymm11, %ymm3
|
||||
vpor %ymm0, %ymm4, %ymm4
|
||||
vpand 32*12-128($inp),%ymm12, %ymm0
|
||||
vpor %ymm1, %ymm5, %ymm5
|
||||
vpand 32*13-128($inp),%ymm13, %ymm1
|
||||
vpor %ymm2, %ymm4, %ymm4
|
||||
vpand 32*14-128($inp),%ymm14, %ymm2
|
||||
vpor %ymm3, %ymm5, %ymm5
|
||||
vpand 32*15-128($inp),%ymm15, %ymm3
|
||||
lea 32*16($inp), $inp
|
||||
vpor %ymm0, %ymm4, %ymm4
|
||||
vpor %ymm1, %ymm5, %ymm5
|
||||
vpor %ymm2, %ymm4, %ymm4
|
||||
vpor %ymm3, %ymm5, %ymm5
|
||||
|
||||
vpor %ymm5, %ymm4, %ymm4
|
||||
vextracti128 \$1, %ymm4, %xmm5 # upper half is cleared
|
||||
vpor %xmm4, %xmm5, %xmm5
|
||||
vpermd %ymm5,%ymm7,%ymm5
|
||||
vmovdqu %ymm5,($out)
|
||||
lea 32($out),$out
|
||||
dec %eax
|
||||
dec $power
|
||||
jnz .Loop_gather_1024
|
||||
|
||||
vpxor %ymm0,%ymm0,%ymm0
|
||||
@@ -1661,20 +1721,20 @@ $code.=<<___;
|
||||
vzeroupper
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
movaps (%rsp),%xmm6
|
||||
movaps 0x10(%rsp),%xmm7
|
||||
movaps 0x20(%rsp),%xmm8
|
||||
movaps 0x30(%rsp),%xmm9
|
||||
movaps 0x40(%rsp),%xmm10
|
||||
movaps 0x50(%rsp),%xmm11
|
||||
movaps 0x60(%rsp),%xmm12
|
||||
movaps 0x70(%rsp),%xmm13
|
||||
movaps 0x80(%rsp),%xmm14
|
||||
movaps 0x90(%rsp),%xmm15
|
||||
lea 0xa8(%rsp),%rsp
|
||||
movaps -0xa8(%r11),%xmm6
|
||||
movaps -0x98(%r11),%xmm7
|
||||
movaps -0x88(%r11),%xmm8
|
||||
movaps -0x78(%r11),%xmm9
|
||||
movaps -0x68(%r11),%xmm10
|
||||
movaps -0x58(%r11),%xmm11
|
||||
movaps -0x48(%r11),%xmm12
|
||||
movaps -0x38(%r11),%xmm13
|
||||
movaps -0x28(%r11),%xmm14
|
||||
movaps -0x18(%r11),%xmm15
|
||||
.LSEH_end_rsaz_1024_gather5:
|
||||
___
|
||||
$code.=<<___;
|
||||
lea (%r11),%rsp
|
||||
ret
|
||||
.size rsaz_1024_gather5_avx2,.-rsaz_1024_gather5_avx2
|
||||
___
|
||||
@@ -1708,8 +1768,10 @@ $code.=<<___;
|
||||
.long 0,2,4,6,7,7,7,7
|
||||
.Lgather_permd:
|
||||
.long 0,7,1,7,2,7,3,7
|
||||
.Lgather_table:
|
||||
.byte 0,0,0,0,0,0,0,0, 0xff,0,0,0,0,0,0,0
|
||||
.Linc:
|
||||
.long 0,0,0,0, 1,1,1,1
|
||||
.long 2,2,2,2, 3,3,3,3
|
||||
.long 4,4,4,4, 4,4,4,4
|
||||
.align 64
|
||||
___
|
||||
|
||||
@@ -1837,18 +1899,19 @@ rsaz_se_handler:
|
||||
.rva rsaz_se_handler
|
||||
.rva .Lmul_1024_body,.Lmul_1024_epilogue
|
||||
.LSEH_info_rsaz_1024_gather5:
|
||||
.byte 0x01,0x33,0x16,0x00
|
||||
.byte 0x36,0xf8,0x09,0x00 #vmovaps 0x90(rsp),xmm15
|
||||
.byte 0x31,0xe8,0x08,0x00 #vmovaps 0x80(rsp),xmm14
|
||||
.byte 0x2c,0xd8,0x07,0x00 #vmovaps 0x70(rsp),xmm13
|
||||
.byte 0x27,0xc8,0x06,0x00 #vmovaps 0x60(rsp),xmm12
|
||||
.byte 0x22,0xb8,0x05,0x00 #vmovaps 0x50(rsp),xmm11
|
||||
.byte 0x1d,0xa8,0x04,0x00 #vmovaps 0x40(rsp),xmm10
|
||||
.byte 0x18,0x98,0x03,0x00 #vmovaps 0x30(rsp),xmm9
|
||||
.byte 0x13,0x88,0x02,0x00 #vmovaps 0x20(rsp),xmm8
|
||||
.byte 0x0e,0x78,0x01,0x00 #vmovaps 0x10(rsp),xmm7
|
||||
.byte 0x09,0x68,0x00,0x00 #vmovaps 0x00(rsp),xmm6
|
||||
.byte 0x04,0x01,0x15,0x00 #sub rsp,0xa8
|
||||
.byte 0x01,0x36,0x17,0x0b
|
||||
.byte 0x36,0xf8,0x09,0x00 # vmovaps 0x90(rsp),xmm15
|
||||
.byte 0x31,0xe8,0x08,0x00 # vmovaps 0x80(rsp),xmm14
|
||||
.byte 0x2c,0xd8,0x07,0x00 # vmovaps 0x70(rsp),xmm13
|
||||
.byte 0x27,0xc8,0x06,0x00 # vmovaps 0x60(rsp),xmm12
|
||||
.byte 0x22,0xb8,0x05,0x00 # vmovaps 0x50(rsp),xmm11
|
||||
.byte 0x1d,0xa8,0x04,0x00 # vmovaps 0x40(rsp),xmm10
|
||||
.byte 0x18,0x98,0x03,0x00 # vmovaps 0x30(rsp),xmm9
|
||||
.byte 0x13,0x88,0x02,0x00 # vmovaps 0x20(rsp),xmm8
|
||||
.byte 0x0e,0x78,0x01,0x00 # vmovaps 0x10(rsp),xmm7
|
||||
.byte 0x09,0x68,0x00,0x00 # vmovaps 0x00(rsp),xmm6
|
||||
.byte 0x04,0x01,0x15,0x00 # sub rsp,0xa8
|
||||
.byte 0x00,0xb3,0x00,0x00 # set_frame r11
|
||||
___
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ if (!$addx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$addx = ($1>=12);
|
||||
}
|
||||
|
||||
if (!$addx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-9])\.([0-9]+)/) {
|
||||
if (!$addx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9])\.([0-9]+)/) {
|
||||
my $ver = $2 + $3/100.0; # 3.1->3.01, 3.10->3.10
|
||||
$addx = ($ver>=3.03);
|
||||
}
|
||||
@@ -915,9 +915,76 @@ rsaz_512_mul_gather4:
|
||||
push %r14
|
||||
push %r15
|
||||
|
||||
mov $pwr, $pwr
|
||||
subq \$128+24, %rsp
|
||||
subq \$`128+24+($win64?0xb0:0)`, %rsp
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
movaps %xmm6,0xa0(%rsp)
|
||||
movaps %xmm7,0xb0(%rsp)
|
||||
movaps %xmm8,0xc0(%rsp)
|
||||
movaps %xmm9,0xd0(%rsp)
|
||||
movaps %xmm10,0xe0(%rsp)
|
||||
movaps %xmm11,0xf0(%rsp)
|
||||
movaps %xmm12,0x100(%rsp)
|
||||
movaps %xmm13,0x110(%rsp)
|
||||
movaps %xmm14,0x120(%rsp)
|
||||
movaps %xmm15,0x130(%rsp)
|
||||
___
|
||||
$code.=<<___;
|
||||
.Lmul_gather4_body:
|
||||
movd $pwr,%xmm8
|
||||
movdqa .Linc+16(%rip),%xmm1 # 00000002000000020000000200000002
|
||||
movdqa .Linc(%rip),%xmm0 # 00000001000000010000000000000000
|
||||
|
||||
pshufd \$0,%xmm8,%xmm8 # broadcast $power
|
||||
movdqa %xmm1,%xmm7
|
||||
movdqa %xmm1,%xmm2
|
||||
___
|
||||
########################################################################
|
||||
# calculate mask by comparing 0..15 to $power
|
||||
#
|
||||
for($i=0;$i<4;$i++) {
|
||||
$code.=<<___;
|
||||
paddd %xmm`$i`,%xmm`$i+1`
|
||||
pcmpeqd %xmm8,%xmm`$i`
|
||||
movdqa %xmm7,%xmm`$i+3`
|
||||
___
|
||||
}
|
||||
for(;$i<7;$i++) {
|
||||
$code.=<<___;
|
||||
paddd %xmm`$i`,%xmm`$i+1`
|
||||
pcmpeqd %xmm8,%xmm`$i`
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
pcmpeqd %xmm8,%xmm7
|
||||
|
||||
movdqa 16*0($bp),%xmm8
|
||||
movdqa 16*1($bp),%xmm9
|
||||
movdqa 16*2($bp),%xmm10
|
||||
movdqa 16*3($bp),%xmm11
|
||||
pand %xmm0,%xmm8
|
||||
movdqa 16*4($bp),%xmm12
|
||||
pand %xmm1,%xmm9
|
||||
movdqa 16*5($bp),%xmm13
|
||||
pand %xmm2,%xmm10
|
||||
movdqa 16*6($bp),%xmm14
|
||||
pand %xmm3,%xmm11
|
||||
movdqa 16*7($bp),%xmm15
|
||||
leaq 128($bp), %rbp
|
||||
pand %xmm4,%xmm12
|
||||
pand %xmm5,%xmm13
|
||||
pand %xmm6,%xmm14
|
||||
pand %xmm7,%xmm15
|
||||
por %xmm10,%xmm8
|
||||
por %xmm11,%xmm9
|
||||
por %xmm12,%xmm8
|
||||
por %xmm13,%xmm9
|
||||
por %xmm14,%xmm8
|
||||
por %xmm15,%xmm9
|
||||
|
||||
por %xmm9,%xmm8
|
||||
pshufd \$0x4e,%xmm8,%xmm9
|
||||
por %xmm9,%xmm8
|
||||
___
|
||||
$code.=<<___ if ($addx);
|
||||
movl \$0x80100,%r11d
|
||||
@@ -926,45 +993,38 @@ $code.=<<___ if ($addx);
|
||||
je .Lmulx_gather
|
||||
___
|
||||
$code.=<<___;
|
||||
movl 64($bp,$pwr,4), %eax
|
||||
movq $out, %xmm0 # off-load arguments
|
||||
movl ($bp,$pwr,4), %ebx
|
||||
movq $mod, %xmm1
|
||||
movq $n0, 128(%rsp)
|
||||
movq %xmm8,%rbx
|
||||
|
||||
movq $n0, 128(%rsp) # off-load arguments
|
||||
movq $out, 128+8(%rsp)
|
||||
movq $mod, 128+16(%rsp)
|
||||
|
||||
shlq \$32, %rax
|
||||
or %rax, %rbx
|
||||
movq ($ap), %rax
|
||||
movq 8($ap), %rcx
|
||||
leaq 128($bp,$pwr,4), %rbp
|
||||
mulq %rbx # 0 iteration
|
||||
movq %rax, (%rsp)
|
||||
movq %rcx, %rax
|
||||
movq %rdx, %r8
|
||||
|
||||
mulq %rbx
|
||||
movd (%rbp), %xmm4
|
||||
addq %rax, %r8
|
||||
movq 16($ap), %rax
|
||||
movq %rdx, %r9
|
||||
adcq \$0, %r9
|
||||
|
||||
mulq %rbx
|
||||
movd 64(%rbp), %xmm5
|
||||
addq %rax, %r9
|
||||
movq 24($ap), %rax
|
||||
movq %rdx, %r10
|
||||
adcq \$0, %r10
|
||||
|
||||
mulq %rbx
|
||||
pslldq \$4, %xmm5
|
||||
addq %rax, %r10
|
||||
movq 32($ap), %rax
|
||||
movq %rdx, %r11
|
||||
adcq \$0, %r11
|
||||
|
||||
mulq %rbx
|
||||
por %xmm5, %xmm4
|
||||
addq %rax, %r11
|
||||
movq 40($ap), %rax
|
||||
movq %rdx, %r12
|
||||
@@ -977,14 +1037,12 @@ $code.=<<___;
|
||||
adcq \$0, %r13
|
||||
|
||||
mulq %rbx
|
||||
leaq 128(%rbp), %rbp
|
||||
addq %rax, %r13
|
||||
movq 56($ap), %rax
|
||||
movq %rdx, %r14
|
||||
adcq \$0, %r14
|
||||
|
||||
mulq %rbx
|
||||
movq %xmm4, %rbx
|
||||
addq %rax, %r14
|
||||
movq ($ap), %rax
|
||||
movq %rdx, %r15
|
||||
@@ -996,6 +1054,35 @@ $code.=<<___;
|
||||
|
||||
.align 32
|
||||
.Loop_mul_gather:
|
||||
movdqa 16*0(%rbp),%xmm8
|
||||
movdqa 16*1(%rbp),%xmm9
|
||||
movdqa 16*2(%rbp),%xmm10
|
||||
movdqa 16*3(%rbp),%xmm11
|
||||
pand %xmm0,%xmm8
|
||||
movdqa 16*4(%rbp),%xmm12
|
||||
pand %xmm1,%xmm9
|
||||
movdqa 16*5(%rbp),%xmm13
|
||||
pand %xmm2,%xmm10
|
||||
movdqa 16*6(%rbp),%xmm14
|
||||
pand %xmm3,%xmm11
|
||||
movdqa 16*7(%rbp),%xmm15
|
||||
leaq 128(%rbp), %rbp
|
||||
pand %xmm4,%xmm12
|
||||
pand %xmm5,%xmm13
|
||||
pand %xmm6,%xmm14
|
||||
pand %xmm7,%xmm15
|
||||
por %xmm10,%xmm8
|
||||
por %xmm11,%xmm9
|
||||
por %xmm12,%xmm8
|
||||
por %xmm13,%xmm9
|
||||
por %xmm14,%xmm8
|
||||
por %xmm15,%xmm9
|
||||
|
||||
por %xmm9,%xmm8
|
||||
pshufd \$0x4e,%xmm8,%xmm9
|
||||
por %xmm9,%xmm8
|
||||
movq %xmm8,%rbx
|
||||
|
||||
mulq %rbx
|
||||
addq %rax, %r8
|
||||
movq 8($ap), %rax
|
||||
@@ -1004,7 +1091,6 @@ $code.=<<___;
|
||||
adcq \$0, %r8
|
||||
|
||||
mulq %rbx
|
||||
movd (%rbp), %xmm4
|
||||
addq %rax, %r9
|
||||
movq 16($ap), %rax
|
||||
adcq \$0, %rdx
|
||||
@@ -1013,7 +1099,6 @@ $code.=<<___;
|
||||
adcq \$0, %r9
|
||||
|
||||
mulq %rbx
|
||||
movd 64(%rbp), %xmm5
|
||||
addq %rax, %r10
|
||||
movq 24($ap), %rax
|
||||
adcq \$0, %rdx
|
||||
@@ -1022,7 +1107,6 @@ $code.=<<___;
|
||||
adcq \$0, %r10
|
||||
|
||||
mulq %rbx
|
||||
pslldq \$4, %xmm5
|
||||
addq %rax, %r11
|
||||
movq 32($ap), %rax
|
||||
adcq \$0, %rdx
|
||||
@@ -1031,7 +1115,6 @@ $code.=<<___;
|
||||
adcq \$0, %r11
|
||||
|
||||
mulq %rbx
|
||||
por %xmm5, %xmm4
|
||||
addq %rax, %r12
|
||||
movq 40($ap), %rax
|
||||
adcq \$0, %rdx
|
||||
@@ -1056,7 +1139,6 @@ $code.=<<___;
|
||||
adcq \$0, %r14
|
||||
|
||||
mulq %rbx
|
||||
movq %xmm4, %rbx
|
||||
addq %rax, %r15
|
||||
movq ($ap), %rax
|
||||
adcq \$0, %rdx
|
||||
@@ -1064,7 +1146,6 @@ $code.=<<___;
|
||||
movq %rdx, %r15
|
||||
adcq \$0, %r15
|
||||
|
||||
leaq 128(%rbp), %rbp
|
||||
leaq 8(%rdi), %rdi
|
||||
|
||||
decl %ecx
|
||||
@@ -1079,8 +1160,8 @@ $code.=<<___;
|
||||
movq %r14, 48(%rdi)
|
||||
movq %r15, 56(%rdi)
|
||||
|
||||
movq %xmm0, $out
|
||||
movq %xmm1, %rbp
|
||||
movq 128+8(%rsp), $out
|
||||
movq 128+16(%rsp), %rbp
|
||||
|
||||
movq (%rsp), %r8
|
||||
movq 8(%rsp), %r9
|
||||
@@ -1098,45 +1179,37 @@ $code.=<<___ if ($addx);
|
||||
|
||||
.align 32
|
||||
.Lmulx_gather:
|
||||
mov 64($bp,$pwr,4), %eax
|
||||
movq $out, %xmm0 # off-load arguments
|
||||
lea 128($bp,$pwr,4), %rbp
|
||||
mov ($bp,$pwr,4), %edx
|
||||
movq $mod, %xmm1
|
||||
mov $n0, 128(%rsp)
|
||||
movq %xmm8,%rdx
|
||||
|
||||
mov $n0, 128(%rsp) # off-load arguments
|
||||
mov $out, 128+8(%rsp)
|
||||
mov $mod, 128+16(%rsp)
|
||||
|
||||
shl \$32, %rax
|
||||
or %rax, %rdx
|
||||
mulx ($ap), %rbx, %r8 # 0 iteration
|
||||
mov %rbx, (%rsp)
|
||||
xor %edi, %edi # cf=0, of=0
|
||||
|
||||
mulx 8($ap), %rax, %r9
|
||||
movd (%rbp), %xmm4
|
||||
|
||||
mulx 16($ap), %rbx, %r10
|
||||
movd 64(%rbp), %xmm5
|
||||
adcx %rax, %r8
|
||||
|
||||
mulx 24($ap), %rax, %r11
|
||||
pslldq \$4, %xmm5
|
||||
adcx %rbx, %r9
|
||||
|
||||
mulx 32($ap), %rbx, %r12
|
||||
por %xmm5, %xmm4
|
||||
adcx %rax, %r10
|
||||
|
||||
mulx 40($ap), %rax, %r13
|
||||
adcx %rbx, %r11
|
||||
|
||||
mulx 48($ap), %rbx, %r14
|
||||
lea 128(%rbp), %rbp
|
||||
adcx %rax, %r12
|
||||
|
||||
mulx 56($ap), %rax, %r15
|
||||
movq %xmm4, %rdx
|
||||
adcx %rbx, %r13
|
||||
adcx %rax, %r14
|
||||
.byte 0x67
|
||||
mov %r8, %rbx
|
||||
adcx %rdi, %r15 # %rdi is 0
|
||||
|
||||
@@ -1145,24 +1218,48 @@ $code.=<<___ if ($addx);
|
||||
|
||||
.align 32
|
||||
.Loop_mulx_gather:
|
||||
mulx ($ap), %rax, %r8
|
||||
movdqa 16*0(%rbp),%xmm8
|
||||
movdqa 16*1(%rbp),%xmm9
|
||||
movdqa 16*2(%rbp),%xmm10
|
||||
movdqa 16*3(%rbp),%xmm11
|
||||
pand %xmm0,%xmm8
|
||||
movdqa 16*4(%rbp),%xmm12
|
||||
pand %xmm1,%xmm9
|
||||
movdqa 16*5(%rbp),%xmm13
|
||||
pand %xmm2,%xmm10
|
||||
movdqa 16*6(%rbp),%xmm14
|
||||
pand %xmm3,%xmm11
|
||||
movdqa 16*7(%rbp),%xmm15
|
||||
leaq 128(%rbp), %rbp
|
||||
pand %xmm4,%xmm12
|
||||
pand %xmm5,%xmm13
|
||||
pand %xmm6,%xmm14
|
||||
pand %xmm7,%xmm15
|
||||
por %xmm10,%xmm8
|
||||
por %xmm11,%xmm9
|
||||
por %xmm12,%xmm8
|
||||
por %xmm13,%xmm9
|
||||
por %xmm14,%xmm8
|
||||
por %xmm15,%xmm9
|
||||
|
||||
por %xmm9,%xmm8
|
||||
pshufd \$0x4e,%xmm8,%xmm9
|
||||
por %xmm9,%xmm8
|
||||
movq %xmm8,%rdx
|
||||
|
||||
.byte 0xc4,0x62,0xfb,0xf6,0x86,0x00,0x00,0x00,0x00 # mulx ($ap), %rax, %r8
|
||||
adcx %rax, %rbx
|
||||
adox %r9, %r8
|
||||
|
||||
mulx 8($ap), %rax, %r9
|
||||
.byte 0x66,0x0f,0x6e,0xa5,0x00,0x00,0x00,0x00 # movd (%rbp), %xmm4
|
||||
adcx %rax, %r8
|
||||
adox %r10, %r9
|
||||
|
||||
mulx 16($ap), %rax, %r10
|
||||
movd 64(%rbp), %xmm5
|
||||
lea 128(%rbp), %rbp
|
||||
adcx %rax, %r9
|
||||
adox %r11, %r10
|
||||
|
||||
.byte 0xc4,0x62,0xfb,0xf6,0x9e,0x18,0x00,0x00,0x00 # mulx 24($ap), %rax, %r11
|
||||
pslldq \$4, %xmm5
|
||||
por %xmm5, %xmm4
|
||||
adcx %rax, %r10
|
||||
adox %r12, %r11
|
||||
|
||||
@@ -1176,10 +1273,10 @@ $code.=<<___ if ($addx);
|
||||
|
||||
.byte 0xc4,0x62,0xfb,0xf6,0xb6,0x30,0x00,0x00,0x00 # mulx 48($ap), %rax, %r14
|
||||
adcx %rax, %r13
|
||||
.byte 0x67
|
||||
adox %r15, %r14
|
||||
|
||||
mulx 56($ap), %rax, %r15
|
||||
movq %xmm4, %rdx
|
||||
mov %rbx, 64(%rsp,%rcx,8)
|
||||
adcx %rax, %r14
|
||||
adox %rdi, %r15
|
||||
@@ -1198,10 +1295,10 @@ $code.=<<___ if ($addx);
|
||||
mov %r14, 64+48(%rsp)
|
||||
mov %r15, 64+56(%rsp)
|
||||
|
||||
movq %xmm0, $out
|
||||
movq %xmm1, %rbp
|
||||
mov 128(%rsp), %rdx # pull arguments
|
||||
mov 128+8(%rsp), $out
|
||||
mov 128+16(%rsp), %rbp
|
||||
|
||||
mov 128(%rsp), %rdx # pull $n0
|
||||
mov (%rsp), %r8
|
||||
mov 8(%rsp), %r9
|
||||
mov 16(%rsp), %r10
|
||||
@@ -1229,6 +1326,21 @@ $code.=<<___;
|
||||
call __rsaz_512_subtract
|
||||
|
||||
leaq 128+24+48(%rsp), %rax
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
movaps 0xa0-0xc8(%rax),%xmm6
|
||||
movaps 0xb0-0xc8(%rax),%xmm7
|
||||
movaps 0xc0-0xc8(%rax),%xmm8
|
||||
movaps 0xd0-0xc8(%rax),%xmm9
|
||||
movaps 0xe0-0xc8(%rax),%xmm10
|
||||
movaps 0xf0-0xc8(%rax),%xmm11
|
||||
movaps 0x100-0xc8(%rax),%xmm12
|
||||
movaps 0x110-0xc8(%rax),%xmm13
|
||||
movaps 0x120-0xc8(%rax),%xmm14
|
||||
movaps 0x130-0xc8(%rax),%xmm15
|
||||
lea 0xb0(%rax),%rax
|
||||
___
|
||||
$code.=<<___;
|
||||
movq -48(%rax), %r15
|
||||
movq -40(%rax), %r14
|
||||
movq -32(%rax), %r13
|
||||
@@ -1258,7 +1370,7 @@ rsaz_512_mul_scatter4:
|
||||
mov $pwr, $pwr
|
||||
subq \$128+24, %rsp
|
||||
.Lmul_scatter4_body:
|
||||
leaq ($tbl,$pwr,4), $tbl
|
||||
leaq ($tbl,$pwr,8), $tbl
|
||||
movq $out, %xmm0 # off-load arguments
|
||||
movq $mod, %xmm1
|
||||
movq $tbl, %xmm2
|
||||
@@ -1329,30 +1441,14 @@ $code.=<<___;
|
||||
|
||||
call __rsaz_512_subtract
|
||||
|
||||
movl %r8d, 64*0($inp) # scatter
|
||||
shrq \$32, %r8
|
||||
movl %r9d, 64*2($inp)
|
||||
shrq \$32, %r9
|
||||
movl %r10d, 64*4($inp)
|
||||
shrq \$32, %r10
|
||||
movl %r11d, 64*6($inp)
|
||||
shrq \$32, %r11
|
||||
movl %r12d, 64*8($inp)
|
||||
shrq \$32, %r12
|
||||
movl %r13d, 64*10($inp)
|
||||
shrq \$32, %r13
|
||||
movl %r14d, 64*12($inp)
|
||||
shrq \$32, %r14
|
||||
movl %r15d, 64*14($inp)
|
||||
shrq \$32, %r15
|
||||
movl %r8d, 64*1($inp)
|
||||
movl %r9d, 64*3($inp)
|
||||
movl %r10d, 64*5($inp)
|
||||
movl %r11d, 64*7($inp)
|
||||
movl %r12d, 64*9($inp)
|
||||
movl %r13d, 64*11($inp)
|
||||
movl %r14d, 64*13($inp)
|
||||
movl %r15d, 64*15($inp)
|
||||
movq %r8, 128*0($inp) # scatter
|
||||
movq %r9, 128*1($inp)
|
||||
movq %r10, 128*2($inp)
|
||||
movq %r11, 128*3($inp)
|
||||
movq %r12, 128*4($inp)
|
||||
movq %r13, 128*5($inp)
|
||||
movq %r14, 128*6($inp)
|
||||
movq %r15, 128*7($inp)
|
||||
|
||||
leaq 128+24+48(%rsp), %rax
|
||||
movq -48(%rax), %r15
|
||||
@@ -1956,16 +2052,14 @@ $code.=<<___;
|
||||
.type rsaz_512_scatter4,\@abi-omnipotent
|
||||
.align 16
|
||||
rsaz_512_scatter4:
|
||||
leaq ($out,$power,4), $out
|
||||
leaq ($out,$power,8), $out
|
||||
movl \$8, %r9d
|
||||
jmp .Loop_scatter
|
||||
.align 16
|
||||
.Loop_scatter:
|
||||
movq ($inp), %rax
|
||||
leaq 8($inp), $inp
|
||||
movl %eax, ($out)
|
||||
shrq \$32, %rax
|
||||
movl %eax, 64($out)
|
||||
movq %rax, ($out)
|
||||
leaq 128($out), $out
|
||||
decl %r9d
|
||||
jnz .Loop_scatter
|
||||
@@ -1976,22 +2070,106 @@ rsaz_512_scatter4:
|
||||
.type rsaz_512_gather4,\@abi-omnipotent
|
||||
.align 16
|
||||
rsaz_512_gather4:
|
||||
leaq ($inp,$power,4), $inp
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
.LSEH_begin_rsaz_512_gather4:
|
||||
.byte 0x48,0x81,0xec,0xa8,0x00,0x00,0x00 # sub $0xa8,%rsp
|
||||
.byte 0x0f,0x29,0x34,0x24 # movaps %xmm6,(%rsp)
|
||||
.byte 0x0f,0x29,0x7c,0x24,0x10 # movaps %xmm7,0x10(%rsp)
|
||||
.byte 0x44,0x0f,0x29,0x44,0x24,0x20 # movaps %xmm8,0x20(%rsp)
|
||||
.byte 0x44,0x0f,0x29,0x4c,0x24,0x30 # movaps %xmm9,0x30(%rsp)
|
||||
.byte 0x44,0x0f,0x29,0x54,0x24,0x40 # movaps %xmm10,0x40(%rsp)
|
||||
.byte 0x44,0x0f,0x29,0x5c,0x24,0x50 # movaps %xmm11,0x50(%rsp)
|
||||
.byte 0x44,0x0f,0x29,0x64,0x24,0x60 # movaps %xmm12,0x60(%rsp)
|
||||
.byte 0x44,0x0f,0x29,0x6c,0x24,0x70 # movaps %xmm13,0x70(%rsp)
|
||||
.byte 0x44,0x0f,0x29,0xb4,0x24,0x80,0,0,0 # movaps %xmm14,0x80(%rsp)
|
||||
.byte 0x44,0x0f,0x29,0xbc,0x24,0x90,0,0,0 # movaps %xmm15,0x90(%rsp)
|
||||
___
|
||||
$code.=<<___;
|
||||
movd $power,%xmm8
|
||||
movdqa .Linc+16(%rip),%xmm1 # 00000002000000020000000200000002
|
||||
movdqa .Linc(%rip),%xmm0 # 00000001000000010000000000000000
|
||||
|
||||
pshufd \$0,%xmm8,%xmm8 # broadcast $power
|
||||
movdqa %xmm1,%xmm7
|
||||
movdqa %xmm1,%xmm2
|
||||
___
|
||||
########################################################################
|
||||
# calculate mask by comparing 0..15 to $power
|
||||
#
|
||||
for($i=0;$i<4;$i++) {
|
||||
$code.=<<___;
|
||||
paddd %xmm`$i`,%xmm`$i+1`
|
||||
pcmpeqd %xmm8,%xmm`$i`
|
||||
movdqa %xmm7,%xmm`$i+3`
|
||||
___
|
||||
}
|
||||
for(;$i<7;$i++) {
|
||||
$code.=<<___;
|
||||
paddd %xmm`$i`,%xmm`$i+1`
|
||||
pcmpeqd %xmm8,%xmm`$i`
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
pcmpeqd %xmm8,%xmm7
|
||||
movl \$8, %r9d
|
||||
jmp .Loop_gather
|
||||
.align 16
|
||||
.Loop_gather:
|
||||
movl ($inp), %eax
|
||||
movl 64($inp), %r8d
|
||||
movdqa 16*0($inp),%xmm8
|
||||
movdqa 16*1($inp),%xmm9
|
||||
movdqa 16*2($inp),%xmm10
|
||||
movdqa 16*3($inp),%xmm11
|
||||
pand %xmm0,%xmm8
|
||||
movdqa 16*4($inp),%xmm12
|
||||
pand %xmm1,%xmm9
|
||||
movdqa 16*5($inp),%xmm13
|
||||
pand %xmm2,%xmm10
|
||||
movdqa 16*6($inp),%xmm14
|
||||
pand %xmm3,%xmm11
|
||||
movdqa 16*7($inp),%xmm15
|
||||
leaq 128($inp), $inp
|
||||
shlq \$32, %r8
|
||||
or %r8, %rax
|
||||
movq %rax, ($out)
|
||||
pand %xmm4,%xmm12
|
||||
pand %xmm5,%xmm13
|
||||
pand %xmm6,%xmm14
|
||||
pand %xmm7,%xmm15
|
||||
por %xmm10,%xmm8
|
||||
por %xmm11,%xmm9
|
||||
por %xmm12,%xmm8
|
||||
por %xmm13,%xmm9
|
||||
por %xmm14,%xmm8
|
||||
por %xmm15,%xmm9
|
||||
|
||||
por %xmm9,%xmm8
|
||||
pshufd \$0x4e,%xmm8,%xmm9
|
||||
por %xmm9,%xmm8
|
||||
movq %xmm8,($out)
|
||||
leaq 8($out), $out
|
||||
decl %r9d
|
||||
jnz .Loop_gather
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
movaps 0x00(%rsp),%xmm6
|
||||
movaps 0x10(%rsp),%xmm7
|
||||
movaps 0x20(%rsp),%xmm8
|
||||
movaps 0x30(%rsp),%xmm9
|
||||
movaps 0x40(%rsp),%xmm10
|
||||
movaps 0x50(%rsp),%xmm11
|
||||
movaps 0x60(%rsp),%xmm12
|
||||
movaps 0x70(%rsp),%xmm13
|
||||
movaps 0x80(%rsp),%xmm14
|
||||
movaps 0x90(%rsp),%xmm15
|
||||
add \$0xa8,%rsp
|
||||
___
|
||||
$code.=<<___;
|
||||
ret
|
||||
.LSEH_end_rsaz_512_gather4:
|
||||
.size rsaz_512_gather4,.-rsaz_512_gather4
|
||||
|
||||
.align 64
|
||||
.Linc:
|
||||
.long 0,0, 1,1
|
||||
.long 2,2, 2,2
|
||||
___
|
||||
}
|
||||
|
||||
@@ -2039,6 +2217,18 @@ se_handler:
|
||||
|
||||
lea 128+24+48(%rax),%rax
|
||||
|
||||
lea .Lmul_gather4_epilogue(%rip),%rbx
|
||||
cmp %r10,%rbx
|
||||
jne .Lse_not_in_mul_gather4
|
||||
|
||||
lea 0xb0(%rax),%rax
|
||||
|
||||
lea -48-0xa8(%rax),%rsi
|
||||
lea 512($context),%rdi
|
||||
mov \$20,%ecx
|
||||
.long 0xa548f3fc # cld; rep movsq
|
||||
|
||||
.Lse_not_in_mul_gather4:
|
||||
mov -8(%rax),%rbx
|
||||
mov -16(%rax),%rbp
|
||||
mov -24(%rax),%r12
|
||||
@@ -2090,7 +2280,7 @@ se_handler:
|
||||
pop %rdi
|
||||
pop %rsi
|
||||
ret
|
||||
.size sqr_handler,.-sqr_handler
|
||||
.size se_handler,.-se_handler
|
||||
|
||||
.section .pdata
|
||||
.align 4
|
||||
@@ -2114,6 +2304,10 @@ se_handler:
|
||||
.rva .LSEH_end_rsaz_512_mul_by_one
|
||||
.rva .LSEH_info_rsaz_512_mul_by_one
|
||||
|
||||
.rva .LSEH_begin_rsaz_512_gather4
|
||||
.rva .LSEH_end_rsaz_512_gather4
|
||||
.rva .LSEH_info_rsaz_512_gather4
|
||||
|
||||
.section .xdata
|
||||
.align 8
|
||||
.LSEH_info_rsaz_512_sqr:
|
||||
@@ -2136,6 +2330,19 @@ se_handler:
|
||||
.byte 9,0,0,0
|
||||
.rva se_handler
|
||||
.rva .Lmul_by_one_body,.Lmul_by_one_epilogue # HandlerData[]
|
||||
.LSEH_info_rsaz_512_gather4:
|
||||
.byte 0x01,0x46,0x16,0x00
|
||||
.byte 0x46,0xf8,0x09,0x00 # vmovaps 0x90(rsp),xmm15
|
||||
.byte 0x3d,0xe8,0x08,0x00 # vmovaps 0x80(rsp),xmm14
|
||||
.byte 0x34,0xd8,0x07,0x00 # vmovaps 0x70(rsp),xmm13
|
||||
.byte 0x2e,0xc8,0x06,0x00 # vmovaps 0x60(rsp),xmm12
|
||||
.byte 0x28,0xb8,0x05,0x00 # vmovaps 0x50(rsp),xmm11
|
||||
.byte 0x22,0xa8,0x04,0x00 # vmovaps 0x40(rsp),xmm10
|
||||
.byte 0x1c,0x98,0x03,0x00 # vmovaps 0x30(rsp),xmm9
|
||||
.byte 0x16,0x88,0x02,0x00 # vmovaps 0x20(rsp),xmm8
|
||||
.byte 0x10,0x78,0x01,0x00 # vmovaps 0x10(rsp),xmm7
|
||||
.byte 0x0b,0x68,0x00,0x00 # vmovaps 0x00(rsp),xmm6
|
||||
.byte 0x07,0x01,0x15,0x00 # sub rsp,0xa8
|
||||
___
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ if (!$addx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$addx = ($1>=12);
|
||||
}
|
||||
|
||||
if (!$addx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-9])\.([0-9]+)/) {
|
||||
if (!$addx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9])\.([0-9]+)/) {
|
||||
my $ver = $2 + $3/100.0; # 3.1->3.01, 3.10->3.10
|
||||
$addx = ($ver>=3.03);
|
||||
}
|
||||
@@ -775,100 +775,126 @@ bn_sqr8x_mont:
|
||||
# 4096. this is done to allow memory disambiguation logic
|
||||
# do its job.
|
||||
#
|
||||
lea -64(%rsp,$num,4),%r11
|
||||
lea -64(%rsp,$num,2),%r11
|
||||
mov ($n0),$n0 # *n0
|
||||
sub $aptr,%r11
|
||||
and \$4095,%r11
|
||||
cmp %r11,%r10
|
||||
jb .Lsqr8x_sp_alt
|
||||
sub %r11,%rsp # align with $aptr
|
||||
lea -64(%rsp,$num,4),%rsp # alloca(frame+4*$num)
|
||||
lea -64(%rsp,$num,2),%rsp # alloca(frame+2*$num)
|
||||
jmp .Lsqr8x_sp_done
|
||||
|
||||
.align 32
|
||||
.Lsqr8x_sp_alt:
|
||||
lea 4096-64(,$num,4),%r10 # 4096-frame-4*$num
|
||||
lea -64(%rsp,$num,4),%rsp # alloca(frame+4*$num)
|
||||
lea 4096-64(,$num,2),%r10 # 4096-frame-2*$num
|
||||
lea -64(%rsp,$num,2),%rsp # alloca(frame+2*$num)
|
||||
sub %r10,%r11
|
||||
mov \$0,%r10
|
||||
cmovc %r10,%r11
|
||||
sub %r11,%rsp
|
||||
.Lsqr8x_sp_done:
|
||||
and \$-64,%rsp
|
||||
mov $num,%r10
|
||||
mov $num,%r10
|
||||
neg $num
|
||||
|
||||
lea 64(%rsp,$num,2),%r11 # copy of modulus
|
||||
mov $n0, 32(%rsp)
|
||||
mov %rax, 40(%rsp) # save original %rsp
|
||||
.Lsqr8x_body:
|
||||
|
||||
mov $num,$i
|
||||
movq %r11, %xmm2 # save pointer to modulus copy
|
||||
shr \$3+2,$i
|
||||
mov OPENSSL_ia32cap_P+8(%rip),%eax
|
||||
jmp .Lsqr8x_copy_n
|
||||
|
||||
.align 32
|
||||
.Lsqr8x_copy_n:
|
||||
movq 8*0($nptr),%xmm0
|
||||
movq 8*1($nptr),%xmm1
|
||||
movq 8*2($nptr),%xmm3
|
||||
movq 8*3($nptr),%xmm4
|
||||
lea 8*4($nptr),$nptr
|
||||
movdqa %xmm0,16*0(%r11)
|
||||
movdqa %xmm1,16*1(%r11)
|
||||
movdqa %xmm3,16*2(%r11)
|
||||
movdqa %xmm4,16*3(%r11)
|
||||
lea 16*4(%r11),%r11
|
||||
dec $i
|
||||
jnz .Lsqr8x_copy_n
|
||||
|
||||
movq $nptr, %xmm2 # save pointer to modulus
|
||||
pxor %xmm0,%xmm0
|
||||
movq $rptr,%xmm1 # save $rptr
|
||||
movq %r10, %xmm3 # -$num
|
||||
___
|
||||
$code.=<<___ if ($addx);
|
||||
mov OPENSSL_ia32cap_P+8(%rip),%eax
|
||||
and \$0x80100,%eax
|
||||
cmp \$0x80100,%eax
|
||||
jne .Lsqr8x_nox
|
||||
|
||||
call bn_sqrx8x_internal # see x86_64-mont5 module
|
||||
|
||||
pxor %xmm0,%xmm0
|
||||
lea 48(%rsp),%rax
|
||||
lea 64(%rsp,$num,2),%rdx
|
||||
shr \$3+2,$num
|
||||
mov 40(%rsp),%rsi # restore %rsp
|
||||
jmp .Lsqr8x_zero
|
||||
# %rax top-most carry
|
||||
# %rbp nptr
|
||||
# %rcx -8*num
|
||||
# %r8 end of tp[2*num]
|
||||
lea (%r8,%rcx),%rbx
|
||||
mov %rcx,$num
|
||||
mov %rcx,%rdx
|
||||
movq %xmm1,$rptr
|
||||
sar \$3+2,%rcx # %cf=0
|
||||
jmp .Lsqr8x_sub
|
||||
|
||||
.align 32
|
||||
.Lsqr8x_nox:
|
||||
___
|
||||
$code.=<<___;
|
||||
call bn_sqr8x_internal # see x86_64-mont5 module
|
||||
|
||||
pxor %xmm0,%xmm0
|
||||
lea 48(%rsp),%rax
|
||||
lea 64(%rsp,$num,2),%rdx
|
||||
shr \$3+2,$num
|
||||
mov 40(%rsp),%rsi # restore %rsp
|
||||
jmp .Lsqr8x_zero
|
||||
# %rax top-most carry
|
||||
# %rbp nptr
|
||||
# %r8 -8*num
|
||||
# %rdi end of tp[2*num]
|
||||
lea (%rdi,$num),%rbx
|
||||
mov $num,%rcx
|
||||
mov $num,%rdx
|
||||
movq %xmm1,$rptr
|
||||
sar \$3+2,%rcx # %cf=0
|
||||
jmp .Lsqr8x_sub
|
||||
|
||||
.align 32
|
||||
.Lsqr8x_zero:
|
||||
movdqa %xmm0,16*0(%rax) # wipe t
|
||||
movdqa %xmm0,16*1(%rax)
|
||||
movdqa %xmm0,16*2(%rax)
|
||||
movdqa %xmm0,16*3(%rax)
|
||||
lea 16*4(%rax),%rax
|
||||
movdqa %xmm0,16*0(%rdx) # wipe n
|
||||
movdqa %xmm0,16*1(%rdx)
|
||||
movdqa %xmm0,16*2(%rdx)
|
||||
movdqa %xmm0,16*3(%rdx)
|
||||
lea 16*4(%rdx),%rdx
|
||||
dec $num
|
||||
jnz .Lsqr8x_zero
|
||||
.Lsqr8x_sub:
|
||||
mov 8*0(%rbx),%r12
|
||||
mov 8*1(%rbx),%r13
|
||||
mov 8*2(%rbx),%r14
|
||||
mov 8*3(%rbx),%r15
|
||||
lea 8*4(%rbx),%rbx
|
||||
sbb 8*0(%rbp),%r12
|
||||
sbb 8*1(%rbp),%r13
|
||||
sbb 8*2(%rbp),%r14
|
||||
sbb 8*3(%rbp),%r15
|
||||
lea 8*4(%rbp),%rbp
|
||||
mov %r12,8*0($rptr)
|
||||
mov %r13,8*1($rptr)
|
||||
mov %r14,8*2($rptr)
|
||||
mov %r15,8*3($rptr)
|
||||
lea 8*4($rptr),$rptr
|
||||
inc %rcx # preserves %cf
|
||||
jnz .Lsqr8x_sub
|
||||
|
||||
sbb \$0,%rax # top-most carry
|
||||
lea (%rbx,$num),%rbx # rewind
|
||||
lea ($rptr,$num),$rptr # rewind
|
||||
|
||||
movq %rax,%xmm1
|
||||
pxor %xmm0,%xmm0
|
||||
pshufd \$0,%xmm1,%xmm1
|
||||
mov 40(%rsp),%rsi # restore %rsp
|
||||
jmp .Lsqr8x_cond_copy
|
||||
|
||||
.align 32
|
||||
.Lsqr8x_cond_copy:
|
||||
movdqa 16*0(%rbx),%xmm2
|
||||
movdqa 16*1(%rbx),%xmm3
|
||||
lea 16*2(%rbx),%rbx
|
||||
movdqu 16*0($rptr),%xmm4
|
||||
movdqu 16*1($rptr),%xmm5
|
||||
lea 16*2($rptr),$rptr
|
||||
movdqa %xmm0,-16*2(%rbx) # zero tp
|
||||
movdqa %xmm0,-16*1(%rbx)
|
||||
movdqa %xmm0,-16*2(%rbx,%rdx)
|
||||
movdqa %xmm0,-16*1(%rbx,%rdx)
|
||||
pcmpeqd %xmm1,%xmm0
|
||||
pand %xmm1,%xmm2
|
||||
pand %xmm1,%xmm3
|
||||
pand %xmm0,%xmm4
|
||||
pand %xmm0,%xmm5
|
||||
pxor %xmm0,%xmm0
|
||||
por %xmm2,%xmm4
|
||||
por %xmm3,%xmm5
|
||||
movdqu %xmm4,-16*2($rptr)
|
||||
movdqu %xmm5,-16*1($rptr)
|
||||
add \$32,$num
|
||||
jnz .Lsqr8x_cond_copy
|
||||
|
||||
mov \$1,%rax
|
||||
mov -48(%rsi),%r15
|
||||
@@ -1135,64 +1161,75 @@ $code.=<<___;
|
||||
adc $zero,%r15 # modulo-scheduled
|
||||
sub 0*8($tptr),$zero # pull top-most carry
|
||||
adc %r15,%r14
|
||||
mov -8($nptr),$mi
|
||||
sbb %r15,%r15 # top-most carry
|
||||
mov %r14,-1*8($tptr)
|
||||
|
||||
cmp 16(%rsp),$bptr
|
||||
jne .Lmulx4x_outer
|
||||
|
||||
sub %r14,$mi # compare top-most words
|
||||
sbb $mi,$mi
|
||||
or $mi,%r15
|
||||
|
||||
neg $num
|
||||
xor %rdx,%rdx
|
||||
mov 32(%rsp),$rptr # restore rp
|
||||
lea 64(%rsp),$tptr
|
||||
|
||||
pxor %xmm0,%xmm0
|
||||
mov 0*8($nptr,$num),%r8
|
||||
mov 1*8($nptr,$num),%r9
|
||||
neg %r8
|
||||
jmp .Lmulx4x_sub_entry
|
||||
sub $num,$nptr # rewind $nptr
|
||||
neg %r15
|
||||
mov $num,%rdx
|
||||
shr \$3+2,$num # %cf=0
|
||||
mov 32(%rsp),$rptr # restore rp
|
||||
jmp .Lmulx4x_sub
|
||||
|
||||
.align 32
|
||||
.Lmulx4x_sub:
|
||||
mov 0*8($nptr,$num),%r8
|
||||
mov 1*8($nptr,$num),%r9
|
||||
not %r8
|
||||
.Lmulx4x_sub_entry:
|
||||
mov 2*8($nptr,$num),%r10
|
||||
not %r9
|
||||
and %r15,%r8
|
||||
mov 3*8($nptr,$num),%r11
|
||||
not %r10
|
||||
and %r15,%r9
|
||||
not %r11
|
||||
and %r15,%r10
|
||||
and %r15,%r11
|
||||
|
||||
neg %rdx # mov %rdx,%cf
|
||||
adc 0*8($tptr),%r8
|
||||
adc 1*8($tptr),%r9
|
||||
movdqa %xmm0,($tptr)
|
||||
adc 2*8($tptr),%r10
|
||||
adc 3*8($tptr),%r11
|
||||
movdqa %xmm0,16($tptr)
|
||||
lea 4*8($tptr),$tptr
|
||||
sbb %rdx,%rdx # mov %cf,%rdx
|
||||
|
||||
mov %r8,0*8($rptr)
|
||||
mov %r9,1*8($rptr)
|
||||
mov %r10,2*8($rptr)
|
||||
mov %r11,3*8($rptr)
|
||||
lea 4*8($rptr),$rptr
|
||||
|
||||
add \$32,$num
|
||||
mov 8*0($tptr),%r11
|
||||
mov 8*1($tptr),%r12
|
||||
mov 8*2($tptr),%r13
|
||||
mov 8*3($tptr),%r14
|
||||
lea 8*4($tptr),$tptr
|
||||
sbb 8*0($nptr),%r11
|
||||
sbb 8*1($nptr),%r12
|
||||
sbb 8*2($nptr),%r13
|
||||
sbb 8*3($nptr),%r14
|
||||
lea 8*4($nptr),$nptr
|
||||
mov %r11,8*0($rptr)
|
||||
mov %r12,8*1($rptr)
|
||||
mov %r13,8*2($rptr)
|
||||
mov %r14,8*3($rptr)
|
||||
lea 8*4($rptr),$rptr
|
||||
dec $num # preserves %cf
|
||||
jnz .Lmulx4x_sub
|
||||
|
||||
sbb \$0,%r15 # top-most carry
|
||||
lea 64(%rsp),$tptr
|
||||
sub %rdx,$rptr # rewind
|
||||
|
||||
movq %r15,%xmm1
|
||||
pxor %xmm0,%xmm0
|
||||
pshufd \$0,%xmm1,%xmm1
|
||||
mov 40(%rsp),%rsi # restore %rsp
|
||||
jmp .Lmulx4x_cond_copy
|
||||
|
||||
.align 32
|
||||
.Lmulx4x_cond_copy:
|
||||
movdqa 16*0($tptr),%xmm2
|
||||
movdqa 16*1($tptr),%xmm3
|
||||
lea 16*2($tptr),$tptr
|
||||
movdqu 16*0($rptr),%xmm4
|
||||
movdqu 16*1($rptr),%xmm5
|
||||
lea 16*2($rptr),$rptr
|
||||
movdqa %xmm0,-16*2($tptr) # zero tp
|
||||
movdqa %xmm0,-16*1($tptr)
|
||||
pcmpeqd %xmm1,%xmm0
|
||||
pand %xmm1,%xmm2
|
||||
pand %xmm1,%xmm3
|
||||
pand %xmm0,%xmm4
|
||||
pand %xmm0,%xmm5
|
||||
pxor %xmm0,%xmm0
|
||||
por %xmm2,%xmm4
|
||||
por %xmm3,%xmm5
|
||||
movdqu %xmm4,-16*2($rptr)
|
||||
movdqu %xmm5,-16*1($rptr)
|
||||
sub \$32,%rdx
|
||||
jnz .Lmulx4x_cond_copy
|
||||
|
||||
mov %rdx,($tptr)
|
||||
|
||||
mov \$1,%rax
|
||||
mov -48(%rsi),%r15
|
||||
mov -40(%rsi),%r14
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -125,6 +125,7 @@
|
||||
#ifndef HEADER_BN_H
|
||||
# define HEADER_BN_H
|
||||
|
||||
# include <limits.h>
|
||||
# include <openssl/e_os2.h>
|
||||
# ifndef OPENSSL_NO_FP_API
|
||||
# include <stdio.h> /* FILE */
|
||||
@@ -721,8 +722,17 @@ const BIGNUM *BN_get0_nist_prime_521(void);
|
||||
|
||||
/* library internal functions */
|
||||
|
||||
# define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
|
||||
(a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2))
|
||||
# define bn_expand(a,bits) \
|
||||
( \
|
||||
bits > (INT_MAX - BN_BITS2 + 1) ? \
|
||||
NULL \
|
||||
: \
|
||||
(((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax) ? \
|
||||
(a) \
|
||||
: \
|
||||
bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2) \
|
||||
)
|
||||
|
||||
# define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
|
||||
BIGNUM *bn_expand2(BIGNUM *a, int words);
|
||||
# ifndef OPENSSL_NO_DEPRECATED
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
*/
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include "constant_time_locl.h"
|
||||
#include "bn_lcl.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -282,9 +283,14 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
}
|
||||
|
||||
bits = BN_num_bits(p);
|
||||
|
||||
if (bits == 0) {
|
||||
ret = BN_one(r);
|
||||
/* x**0 mod 1 is still zero. */
|
||||
if (BN_is_one(m)) {
|
||||
ret = 1;
|
||||
BN_zero(r);
|
||||
} else {
|
||||
ret = BN_one(r);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -418,7 +424,13 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
}
|
||||
bits = BN_num_bits(p);
|
||||
if (bits == 0) {
|
||||
ret = BN_one(rr);
|
||||
/* x**0 mod 1 is still zero. */
|
||||
if (BN_is_one(m)) {
|
||||
ret = 1;
|
||||
BN_zero(rr);
|
||||
} else {
|
||||
ret = BN_one(rr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -595,15 +607,17 @@ static BN_ULONG bn_get_bits(const BIGNUM *a, int bitpos)
|
||||
|
||||
static int MOD_EXP_CTIME_COPY_TO_PREBUF(const BIGNUM *b, int top,
|
||||
unsigned char *buf, int idx,
|
||||
int width)
|
||||
int window)
|
||||
{
|
||||
size_t i, j;
|
||||
int i, j;
|
||||
int width = 1 << window;
|
||||
BN_ULONG *table = (BN_ULONG *)buf;
|
||||
|
||||
if (top > b->top)
|
||||
top = b->top; /* this works because 'buf' is explicitly
|
||||
* zeroed */
|
||||
for (i = 0, j = idx; i < top * sizeof b->d[0]; i++, j += width) {
|
||||
buf[j] = ((unsigned char *)b->d)[i];
|
||||
for (i = 0, j = idx; i < top; i++, j += width) {
|
||||
table[j] = b->d[i];
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -611,15 +625,51 @@ static int MOD_EXP_CTIME_COPY_TO_PREBUF(const BIGNUM *b, int top,
|
||||
|
||||
static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top,
|
||||
unsigned char *buf, int idx,
|
||||
int width)
|
||||
int window)
|
||||
{
|
||||
size_t i, j;
|
||||
int i, j;
|
||||
int width = 1 << window;
|
||||
volatile BN_ULONG *table = (volatile BN_ULONG *)buf;
|
||||
|
||||
if (bn_wexpand(b, top) == NULL)
|
||||
return 0;
|
||||
|
||||
for (i = 0, j = idx; i < top * sizeof b->d[0]; i++, j += width) {
|
||||
((unsigned char *)b->d)[i] = buf[j];
|
||||
if (window <= 3) {
|
||||
for (i = 0; i < top; i++, table += width) {
|
||||
BN_ULONG acc = 0;
|
||||
|
||||
for (j = 0; j < width; j++) {
|
||||
acc |= table[j] &
|
||||
((BN_ULONG)0 - (constant_time_eq_int(j,idx)&1));
|
||||
}
|
||||
|
||||
b->d[i] = acc;
|
||||
}
|
||||
} else {
|
||||
int xstride = 1 << (window - 2);
|
||||
BN_ULONG y0, y1, y2, y3;
|
||||
|
||||
i = idx >> (window - 2); /* equivalent of idx / xstride */
|
||||
idx &= xstride - 1; /* equivalent of idx % xstride */
|
||||
|
||||
y0 = (BN_ULONG)0 - (constant_time_eq_int(i,0)&1);
|
||||
y1 = (BN_ULONG)0 - (constant_time_eq_int(i,1)&1);
|
||||
y2 = (BN_ULONG)0 - (constant_time_eq_int(i,2)&1);
|
||||
y3 = (BN_ULONG)0 - (constant_time_eq_int(i,3)&1);
|
||||
|
||||
for (i = 0; i < top; i++, table += width) {
|
||||
BN_ULONG acc = 0;
|
||||
|
||||
for (j = 0; j < xstride; j++) {
|
||||
acc |= ( (table[j + 0 * xstride] & y0) |
|
||||
(table[j + 1 * xstride] & y1) |
|
||||
(table[j + 2 * xstride] & y2) |
|
||||
(table[j + 3 * xstride] & y3) )
|
||||
& ((BN_ULONG)0 - (constant_time_eq_int(j,idx)&1));
|
||||
}
|
||||
|
||||
b->d[i] = acc;
|
||||
}
|
||||
}
|
||||
|
||||
b->top = top;
|
||||
@@ -639,7 +689,7 @@ static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top,
|
||||
* precomputation memory layout to limit data-dependency to a minimum to
|
||||
* protect secret exponents (cf. the hyper-threading timing attacks pointed
|
||||
* out by Colin Percival,
|
||||
* http://www.daemong-consideredperthreading-considered-harmful/)
|
||||
* http://www.daemonology.net/hyperthreading-considered-harmful/)
|
||||
*/
|
||||
int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
const BIGNUM *m, BN_CTX *ctx,
|
||||
@@ -671,7 +721,13 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
|
||||
bits = BN_num_bits(p);
|
||||
if (bits == 0) {
|
||||
ret = BN_one(rr);
|
||||
/* x**0 mod 1 is still zero. */
|
||||
if (BN_is_one(m)) {
|
||||
ret = 1;
|
||||
BN_zero(rr);
|
||||
} else {
|
||||
ret = BN_one(rr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -732,8 +788,8 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
if (window >= 5) {
|
||||
window = 5; /* ~5% improvement for RSA2048 sign, and even
|
||||
* for RSA4096 */
|
||||
if ((top & 7) == 0)
|
||||
powerbufLen += 2 * top * sizeof(m->d[0]);
|
||||
/* reserve space for mont->N.d[] copy */
|
||||
powerbufLen += top * sizeof(mont->N.d[0]);
|
||||
}
|
||||
#endif
|
||||
(void)0;
|
||||
@@ -954,7 +1010,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
const BN_ULONG *not_used, const BN_ULONG *np,
|
||||
const BN_ULONG *n0, int num);
|
||||
|
||||
BN_ULONG *np = mont->N.d, *n0 = mont->n0, *np2;
|
||||
BN_ULONG *n0 = mont->n0, *np;
|
||||
|
||||
/*
|
||||
* BN_to_montgomery can contaminate words above .top [in
|
||||
@@ -965,11 +1021,11 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
for (i = tmp.top; i < top; i++)
|
||||
tmp.d[i] = 0;
|
||||
|
||||
if (top & 7)
|
||||
np2 = np;
|
||||
else
|
||||
for (np2 = am.d + top, i = 0; i < top; i++)
|
||||
np2[2 * i] = np[i];
|
||||
/*
|
||||
* copy mont->N.d[] to improve cache locality
|
||||
*/
|
||||
for (np = am.d + top, i = 0; i < top; i++)
|
||||
np[i] = mont->N.d[i];
|
||||
|
||||
bn_scatter5(tmp.d, top, powerbuf, 0);
|
||||
bn_scatter5(am.d, am.top, powerbuf, 1);
|
||||
@@ -979,7 +1035,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
# if 0
|
||||
for (i = 3; i < 32; i++) {
|
||||
/* Calculate a^i = a^(i-1) * a */
|
||||
bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np2, n0, top, i - 1);
|
||||
bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1);
|
||||
bn_scatter5(tmp.d, top, powerbuf, i);
|
||||
}
|
||||
# else
|
||||
@@ -990,7 +1046,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
}
|
||||
for (i = 3; i < 8; i += 2) {
|
||||
int j;
|
||||
bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np2, n0, top, i - 1);
|
||||
bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1);
|
||||
bn_scatter5(tmp.d, top, powerbuf, i);
|
||||
for (j = 2 * i; j < 32; j *= 2) {
|
||||
bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top);
|
||||
@@ -998,13 +1054,13 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
}
|
||||
}
|
||||
for (; i < 16; i += 2) {
|
||||
bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np2, n0, top, i - 1);
|
||||
bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1);
|
||||
bn_scatter5(tmp.d, top, powerbuf, i);
|
||||
bn_mul_mont(tmp.d, tmp.d, tmp.d, np, n0, top);
|
||||
bn_scatter5(tmp.d, top, powerbuf, 2 * i);
|
||||
}
|
||||
for (; i < 32; i += 2) {
|
||||
bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np2, n0, top, i - 1);
|
||||
bn_mul_mont_gather5(tmp.d, am.d, powerbuf, np, n0, top, i - 1);
|
||||
bn_scatter5(tmp.d, top, powerbuf, i);
|
||||
}
|
||||
# endif
|
||||
@@ -1033,11 +1089,11 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
while (bits >= 0) {
|
||||
wvalue = bn_get_bits5(p->d, bits - 4);
|
||||
bits -= 5;
|
||||
bn_power5(tmp.d, tmp.d, powerbuf, np2, n0, top, wvalue);
|
||||
bn_power5(tmp.d, tmp.d, powerbuf, np, n0, top, wvalue);
|
||||
}
|
||||
}
|
||||
|
||||
ret = bn_from_montgomery(tmp.d, tmp.d, NULL, np2, n0, top);
|
||||
ret = bn_from_montgomery(tmp.d, tmp.d, NULL, np, n0, top);
|
||||
tmp.top = top;
|
||||
bn_correct_top(&tmp);
|
||||
if (ret) {
|
||||
@@ -1048,9 +1104,9 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, 0, numPowers))
|
||||
if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, 0, window))
|
||||
goto err;
|
||||
if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&am, top, powerbuf, 1, numPowers))
|
||||
if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&am, top, powerbuf, 1, window))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
@@ -1062,15 +1118,15 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
if (window > 1) {
|
||||
if (!BN_mod_mul_montgomery(&tmp, &am, &am, mont, ctx))
|
||||
goto err;
|
||||
if (!MOD_EXP_CTIME_COPY_TO_PREBUF
|
||||
(&tmp, top, powerbuf, 2, numPowers))
|
||||
if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, 2,
|
||||
window))
|
||||
goto err;
|
||||
for (i = 3; i < numPowers; i++) {
|
||||
/* Calculate a^i = a^(i-1) * a */
|
||||
if (!BN_mod_mul_montgomery(&tmp, &am, &tmp, mont, ctx))
|
||||
goto err;
|
||||
if (!MOD_EXP_CTIME_COPY_TO_PREBUF
|
||||
(&tmp, top, powerbuf, i, numPowers))
|
||||
if (!MOD_EXP_CTIME_COPY_TO_PREBUF(&tmp, top, powerbuf, i,
|
||||
window))
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@@ -1078,8 +1134,8 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
bits--;
|
||||
for (wvalue = 0, i = bits % window; i >= 0; i--, bits--)
|
||||
wvalue = (wvalue << 1) + BN_is_bit_set(p, bits);
|
||||
if (!MOD_EXP_CTIME_COPY_FROM_PREBUF
|
||||
(&tmp, top, powerbuf, wvalue, numPowers))
|
||||
if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&tmp, top, powerbuf, wvalue,
|
||||
window))
|
||||
goto err;
|
||||
|
||||
/*
|
||||
@@ -1099,8 +1155,8 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
|
||||
/*
|
||||
* Fetch the appropriate pre-computed value from the pre-buf
|
||||
*/
|
||||
if (!MOD_EXP_CTIME_COPY_FROM_PREBUF
|
||||
(&am, top, powerbuf, wvalue, numPowers))
|
||||
if (!MOD_EXP_CTIME_COPY_FROM_PREBUF(&am, top, powerbuf, wvalue,
|
||||
window))
|
||||
goto err;
|
||||
|
||||
/* Multiply the result into the intermediate result */
|
||||
@@ -1182,8 +1238,9 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p,
|
||||
if (BN_is_one(m)) {
|
||||
ret = 1;
|
||||
BN_zero(rr);
|
||||
} else
|
||||
} else {
|
||||
ret = BN_one(rr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
if (a == 0) {
|
||||
@@ -1297,9 +1354,14 @@ int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
}
|
||||
|
||||
bits = BN_num_bits(p);
|
||||
|
||||
if (bits == 0) {
|
||||
ret = BN_one(r);
|
||||
if (bits == 0) {
|
||||
/* x**0 mod 1 is still zero. */
|
||||
if (BN_is_one(m)) {
|
||||
ret = 1;
|
||||
BN_zero(r);
|
||||
} else {
|
||||
ret = BN_one(r);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include "bn_lcl.h"
|
||||
@@ -189,7 +190,11 @@ int BN_hex2bn(BIGNUM **bn, const char *a)
|
||||
a++;
|
||||
}
|
||||
|
||||
for (i = 0; isxdigit((unsigned char)a[i]); i++) ;
|
||||
for (i = 0; i <= (INT_MAX/4) && isxdigit((unsigned char)a[i]); i++)
|
||||
continue;
|
||||
|
||||
if (i > INT_MAX/4)
|
||||
goto err;
|
||||
|
||||
num = i + neg;
|
||||
if (bn == NULL)
|
||||
@@ -204,7 +209,7 @@ int BN_hex2bn(BIGNUM **bn, const char *a)
|
||||
BN_zero(ret);
|
||||
}
|
||||
|
||||
/* i is the number of hex digests; */
|
||||
/* i is the number of hex digits */
|
||||
if (bn_expand(ret, i * 4) == NULL)
|
||||
goto err;
|
||||
|
||||
@@ -260,7 +265,11 @@ int BN_dec2bn(BIGNUM **bn, const char *a)
|
||||
a++;
|
||||
}
|
||||
|
||||
for (i = 0; isdigit((unsigned char)a[i]); i++) ;
|
||||
for (i = 0; i <= (INT_MAX/4) && isdigit((unsigned char)a[i]); i++)
|
||||
continue;
|
||||
|
||||
if (i > INT_MAX/4)
|
||||
goto err;
|
||||
|
||||
num = i + neg;
|
||||
if (bn == NULL)
|
||||
@@ -278,7 +287,7 @@ int BN_dec2bn(BIGNUM **bn, const char *a)
|
||||
BN_zero(ret);
|
||||
}
|
||||
|
||||
/* i is the number of digests, a bit of an over expand; */
|
||||
/* i is the number of digits, a bit of an over expand */
|
||||
if (bn_expand(ret, i * 4) == NULL)
|
||||
goto err;
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ void BN_RECP_CTX_init(BN_RECP_CTX *recp)
|
||||
BN_init(&(recp->N));
|
||||
BN_init(&(recp->Nr));
|
||||
recp->num_bits = 0;
|
||||
recp->shift = 0;
|
||||
recp->flags = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,25 @@
|
||||
static const char rnd_seed[] =
|
||||
"string to make the random number generator think it has entropy";
|
||||
|
||||
/*
|
||||
* Test that r == 0 in test_exp_mod_zero(). Returns one on success,
|
||||
* returns zero and prints debug output otherwise.
|
||||
*/
|
||||
static int a_is_zero_mod_one(const char *method, const BIGNUM *r,
|
||||
const BIGNUM *a) {
|
||||
if (!BN_is_zero(r)) {
|
||||
fprintf(stderr, "%s failed:\n", method);
|
||||
fprintf(stderr, "a ** 0 mod 1 = r (should be 0)\n");
|
||||
fprintf(stderr, "a = ");
|
||||
BN_print_fp(stderr, a);
|
||||
fprintf(stderr, "\nr = ");
|
||||
BN_print_fp(stderr, r);
|
||||
fprintf(stderr, "\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* test_exp_mod_zero tests that x**0 mod 1 == 0. It returns zero on success.
|
||||
*/
|
||||
@@ -79,8 +98,9 @@ static int test_exp_mod_zero()
|
||||
{
|
||||
BIGNUM a, p, m;
|
||||
BIGNUM r;
|
||||
BN_ULONG one_word = 1;
|
||||
BN_CTX *ctx = BN_CTX_new();
|
||||
int ret = 1;
|
||||
int ret = 1, failed = 0;
|
||||
|
||||
BN_init(&m);
|
||||
BN_one(&m);
|
||||
@@ -92,21 +112,65 @@ static int test_exp_mod_zero()
|
||||
BN_zero(&p);
|
||||
|
||||
BN_init(&r);
|
||||
BN_mod_exp(&r, &a, &p, &m, ctx);
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
if (BN_is_zero(&r))
|
||||
ret = 0;
|
||||
else {
|
||||
printf("1**0 mod 1 = ");
|
||||
BN_print_fp(stdout, &r);
|
||||
printf(", should be 0\n");
|
||||
if (!BN_rand(&a, 1024, 0, 0))
|
||||
goto err;
|
||||
|
||||
if (!BN_mod_exp(&r, &a, &p, &m, ctx))
|
||||
goto err;
|
||||
|
||||
if (!a_is_zero_mod_one("BN_mod_exp", &r, &a))
|
||||
failed = 1;
|
||||
|
||||
if (!BN_mod_exp_recp(&r, &a, &p, &m, ctx))
|
||||
goto err;
|
||||
|
||||
if (!a_is_zero_mod_one("BN_mod_exp_recp", &r, &a))
|
||||
failed = 1;
|
||||
|
||||
if (!BN_mod_exp_simple(&r, &a, &p, &m, ctx))
|
||||
goto err;
|
||||
|
||||
if (!a_is_zero_mod_one("BN_mod_exp_simple", &r, &a))
|
||||
failed = 1;
|
||||
|
||||
if (!BN_mod_exp_mont(&r, &a, &p, &m, ctx, NULL))
|
||||
goto err;
|
||||
|
||||
if (!a_is_zero_mod_one("BN_mod_exp_mont", &r, &a))
|
||||
failed = 1;
|
||||
|
||||
if (!BN_mod_exp_mont_consttime(&r, &a, &p, &m, ctx, NULL)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!a_is_zero_mod_one("BN_mod_exp_mont_consttime", &r, &a))
|
||||
failed = 1;
|
||||
|
||||
/*
|
||||
* A different codepath exists for single word multiplication
|
||||
* in non-constant-time only.
|
||||
*/
|
||||
if (!BN_mod_exp_mont_word(&r, one_word, &p, &m, ctx, NULL))
|
||||
goto err;
|
||||
|
||||
if (!BN_is_zero(&r)) {
|
||||
fprintf(stderr, "BN_mod_exp_mont_word failed:\n");
|
||||
fprintf(stderr, "1 ** 0 mod 1 = r (should be 0)\n");
|
||||
fprintf(stderr, "r = ");
|
||||
BN_print_fp(stderr, &r);
|
||||
fprintf(stderr, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = failed;
|
||||
|
||||
err:
|
||||
BN_free(&r);
|
||||
BN_free(&a);
|
||||
BN_free(&p);
|
||||
BN_free(&m);
|
||||
BN_CTX_free(ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/camellia/camellia.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/camellia/camellia.c */
|
||||
/* ====================================================================
|
||||
* Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) .
|
||||
* ALL RIGHTS RESERVED.
|
||||
@@ -67,7 +67,7 @@
|
||||
|
||||
/*
|
||||
* Algorithm Specification
|
||||
* http://info.isl.llia/specicrypt/eng/camellia/specifications.html
|
||||
* http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/camellia/camellia.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/camellia/camellia.h */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/camellia/camellia_cbc.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/camellia/camellia_cbc.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/camellia/camellia_cfb.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/camellia/camellia_cfb.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/camellia/camellia_ctr.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/camellia/camellia_ctr.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/camellia/camellia_ecb.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/camellia/camellia_ecb.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/camellia/camellia_locl.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/camellia/camellia_locl.h */
|
||||
/* ====================================================================
|
||||
* Copyright 2006 NTT (Nippon Telegraph and Telephone Corporation) .
|
||||
* ALL RIGHTS RESERVED.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/camellia/camellia_misc.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/camellia/camellia_misc.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/camellia/camellia_ofb.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/camellia/camellia_ofb.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/camellia/cmll_utl.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/camellia/cmll_utl.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2011 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -160,6 +160,14 @@ int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,
|
||||
EVPerr(EVP_F_CMAC_INIT, EVP_R_DISABLED_FOR_FIPS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Switch to FIPS cipher implementation if possible */
|
||||
if (cipher != NULL) {
|
||||
const EVP_CIPHER *fcipher;
|
||||
fcipher = FIPS_get_cipherbynid(EVP_CIPHER_nid(cipher));
|
||||
if (fcipher != NULL)
|
||||
cipher = fcipher;
|
||||
}
|
||||
/*
|
||||
* Other algorithm blocking will be done in FIPS_cmac_init, via
|
||||
* FIPS_cipherinit().
|
||||
|
||||
@@ -1016,11 +1016,11 @@ void *OPENSSL_stderr(void)
|
||||
return stderr;
|
||||
}
|
||||
|
||||
int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len)
|
||||
int CRYPTO_memcmp(const volatile void *in_a, const volatile void *in_b, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
const unsigned char *a = in_a;
|
||||
const unsigned char *b = in_b;
|
||||
const volatile unsigned char *a = in_a;
|
||||
const volatile unsigned char *b = in_b;
|
||||
unsigned char x = 0;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
|
||||
@@ -628,7 +628,7 @@ void OPENSSL_init(void);
|
||||
* into a defined order as the return value when a != b is undefined, other
|
||||
* than to be non-zero.
|
||||
*/
|
||||
int CRYPTO_memcmp(const void *a, const void *b, size_t len);
|
||||
int CRYPTO_memcmp(const volatile void *a, const volatile void *b, size_t len);
|
||||
|
||||
/* BEGIN ERROR CODES */
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/des/des_old.c */
|
||||
|
||||
/*-
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/des/des_old.h */
|
||||
|
||||
/*-
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/des/des_old.c */
|
||||
|
||||
/*
|
||||
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING The
|
||||
|
||||
@@ -174,6 +174,7 @@ struct dh_st {
|
||||
/* DH_check_pub_key error codes */
|
||||
# define DH_CHECK_PUBKEY_TOO_SMALL 0x01
|
||||
# define DH_CHECK_PUBKEY_TOO_LARGE 0x02
|
||||
# define DH_CHECK_PUBKEY_INVALID 0x04
|
||||
|
||||
/*
|
||||
* primes p where (p-1)/2 is prime too are called "safe"; we define this for
|
||||
|
||||
@@ -151,23 +151,37 @@ int DH_check(const DH *dh, int *ret)
|
||||
int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret)
|
||||
{
|
||||
int ok = 0;
|
||||
BIGNUM *q = NULL;
|
||||
BIGNUM *tmp = NULL;
|
||||
BN_CTX *ctx = NULL;
|
||||
|
||||
*ret = 0;
|
||||
q = BN_new();
|
||||
if (q == NULL)
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
BN_set_word(q, 1);
|
||||
if (BN_cmp(pub_key, q) <= 0)
|
||||
BN_CTX_start(ctx);
|
||||
tmp = BN_CTX_get(ctx);
|
||||
if (tmp == NULL || !BN_set_word(tmp, 1))
|
||||
goto err;
|
||||
if (BN_cmp(pub_key, tmp) <= 0)
|
||||
*ret |= DH_CHECK_PUBKEY_TOO_SMALL;
|
||||
BN_copy(q, dh->p);
|
||||
BN_sub_word(q, 1);
|
||||
if (BN_cmp(pub_key, q) >= 0)
|
||||
if (BN_copy(tmp, dh->p) == NULL || !BN_sub_word(tmp, 1))
|
||||
goto err;
|
||||
if (BN_cmp(pub_key, tmp) >= 0)
|
||||
*ret |= DH_CHECK_PUBKEY_TOO_LARGE;
|
||||
|
||||
if (dh->q != NULL) {
|
||||
/* Check pub_key^q == 1 mod p */
|
||||
if (!BN_mod_exp(tmp, pub_key, dh->q, dh->p, ctx))
|
||||
goto err;
|
||||
if (!BN_is_one(tmp))
|
||||
*ret |= DH_CHECK_PUBKEY_INVALID;
|
||||
}
|
||||
|
||||
ok = 1;
|
||||
err:
|
||||
if (q != NULL)
|
||||
BN_free(q);
|
||||
if (ctx != NULL) {
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
return (ok);
|
||||
}
|
||||
|
||||
@@ -471,6 +471,31 @@ static const unsigned char dhtest_2048_256_Z[] = {
|
||||
0xC2, 0x6C, 0x5D, 0x7C
|
||||
};
|
||||
|
||||
static const unsigned char dhtest_rfc5114_2048_224_bad_y[] = {
|
||||
0x45, 0x32, 0x5F, 0x51, 0x07, 0xE5, 0xDF, 0x1C, 0xD6, 0x02, 0x82, 0xB3,
|
||||
0x32, 0x8F, 0xA4, 0x0F, 0x87, 0xB8, 0x41, 0xFE, 0xB9, 0x35, 0xDE, 0xAD,
|
||||
0xC6, 0x26, 0x85, 0xB4, 0xFF, 0x94, 0x8C, 0x12, 0x4C, 0xBF, 0x5B, 0x20,
|
||||
0xC4, 0x46, 0xA3, 0x26, 0xEB, 0xA4, 0x25, 0xB7, 0x68, 0x8E, 0xCC, 0x67,
|
||||
0xBA, 0xEA, 0x58, 0xD0, 0xF2, 0xE9, 0xD2, 0x24, 0x72, 0x60, 0xDA, 0x88,
|
||||
0x18, 0x9C, 0xE0, 0x31, 0x6A, 0xAD, 0x50, 0x6D, 0x94, 0x35, 0x8B, 0x83,
|
||||
0x4A, 0x6E, 0xFA, 0x48, 0x73, 0x0F, 0x83, 0x87, 0xFF, 0x6B, 0x66, 0x1F,
|
||||
0xA8, 0x82, 0xC6, 0x01, 0xE5, 0x80, 0xB5, 0xB0, 0x52, 0xD0, 0xE9, 0xD8,
|
||||
0x72, 0xF9, 0x7D, 0x5B, 0x8B, 0xA5, 0x4C, 0xA5, 0x25, 0x95, 0x74, 0xE2,
|
||||
0x7A, 0x61, 0x4E, 0xA7, 0x8F, 0x12, 0xE2, 0xD2, 0x9D, 0x8C, 0x02, 0x70,
|
||||
0x34, 0x44, 0x32, 0xC7, 0xB2, 0xF3, 0xB9, 0xFE, 0x17, 0x2B, 0xD6, 0x1F,
|
||||
0x8B, 0x7E, 0x4A, 0xFA, 0xA3, 0xB5, 0x3E, 0x7A, 0x81, 0x9A, 0x33, 0x66,
|
||||
0x62, 0xA4, 0x50, 0x18, 0x3E, 0xA2, 0x5F, 0x00, 0x07, 0xD8, 0x9B, 0x22,
|
||||
0xE4, 0xEC, 0x84, 0xD5, 0xEB, 0x5A, 0xF3, 0x2A, 0x31, 0x23, 0xD8, 0x44,
|
||||
0x22, 0x2A, 0x8B, 0x37, 0x44, 0xCC, 0xC6, 0x87, 0x4B, 0xBE, 0x50, 0x9D,
|
||||
0x4A, 0xC4, 0x8E, 0x45, 0xCF, 0x72, 0x4D, 0xC0, 0x89, 0xB3, 0x72, 0xED,
|
||||
0x33, 0x2C, 0xBC, 0x7F, 0x16, 0x39, 0x3B, 0xEB, 0xD2, 0xDD, 0xA8, 0x01,
|
||||
0x73, 0x84, 0x62, 0xB9, 0x29, 0xD2, 0xC9, 0x51, 0x32, 0x9E, 0x7A, 0x6A,
|
||||
0xCF, 0xC1, 0x0A, 0xDB, 0x0E, 0xE0, 0x62, 0x77, 0x6F, 0x59, 0x62, 0x72,
|
||||
0x5A, 0x69, 0xA6, 0x5B, 0x70, 0xCA, 0x65, 0xC4, 0x95, 0x6F, 0x9A, 0xC2,
|
||||
0xDF, 0x72, 0x6D, 0xB1, 0x1E, 0x54, 0x7B, 0x51, 0xB4, 0xEF, 0x7F, 0x89,
|
||||
0x93, 0x74, 0x89, 0x59
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
DH *(*get_param) (void);
|
||||
const unsigned char *xA;
|
||||
@@ -503,10 +528,15 @@ static const rfc5114_td rfctd[] = {
|
||||
static int run_rfc5114_tests(void)
|
||||
{
|
||||
int i;
|
||||
DH *dhA = NULL;
|
||||
DH *dhB = NULL;
|
||||
unsigned char *Z1 = NULL;
|
||||
unsigned char *Z2 = NULL;
|
||||
const rfc5114_td *td = NULL;
|
||||
BIGNUM *bady = NULL;
|
||||
|
||||
for (i = 0; i < (int)(sizeof(rfctd) / sizeof(rfc5114_td)); i++) {
|
||||
DH *dhA, *dhB;
|
||||
unsigned char *Z1 = NULL, *Z2 = NULL;
|
||||
const rfc5114_td *td = rfctd + i;
|
||||
td = rfctd + i;
|
||||
/* Set up DH structures setting key components */
|
||||
dhA = td->get_param();
|
||||
dhB = td->get_param();
|
||||
@@ -549,14 +579,63 @@ static int run_rfc5114_tests(void)
|
||||
DH_free(dhB);
|
||||
OPENSSL_free(Z1);
|
||||
OPENSSL_free(Z2);
|
||||
|
||||
dhA = NULL;
|
||||
dhB = NULL;
|
||||
Z1 = NULL;
|
||||
Z2 = NULL;
|
||||
}
|
||||
|
||||
/* Now i == OSSL_NELEM(rfctd) */
|
||||
/* RFC5114 uses unsafe primes, so now test an invalid y value */
|
||||
dhA = DH_get_2048_224();
|
||||
if (dhA == NULL)
|
||||
goto bad_err;
|
||||
Z1 = OPENSSL_malloc(DH_size(dhA));
|
||||
if (Z1 == NULL)
|
||||
goto bad_err;
|
||||
|
||||
bady = BN_bin2bn(dhtest_rfc5114_2048_224_bad_y,
|
||||
sizeof(dhtest_rfc5114_2048_224_bad_y), NULL);
|
||||
if (bady == NULL)
|
||||
goto bad_err;
|
||||
|
||||
if (!DH_generate_key(dhA))
|
||||
goto bad_err;
|
||||
|
||||
if (DH_compute_key(Z1, bady, dhA) != -1) {
|
||||
/*
|
||||
* DH_compute_key should fail with -1. If we get here we unexpectedly
|
||||
* allowed an invalid y value
|
||||
*/
|
||||
goto err;
|
||||
}
|
||||
/* We'll have a stale error on the queue from the above test so clear it */
|
||||
ERR_clear_error();
|
||||
|
||||
printf("RFC5114 parameter test %d OK\n", i + 1);
|
||||
|
||||
BN_free(bady);
|
||||
DH_free(dhA);
|
||||
OPENSSL_free(Z1);
|
||||
|
||||
return 1;
|
||||
bad_err:
|
||||
BN_free(bady);
|
||||
DH_free(dhA);
|
||||
DH_free(dhB);
|
||||
OPENSSL_free(Z1);
|
||||
OPENSSL_free(Z2);
|
||||
|
||||
fprintf(stderr, "Initalisation error RFC5114 set %d\n", i + 1);
|
||||
ERR_print_errors_fp(stderr);
|
||||
return 0;
|
||||
err:
|
||||
BN_free(bady);
|
||||
DH_free(dhA);
|
||||
DH_free(dhB);
|
||||
OPENSSL_free(Z1);
|
||||
OPENSSL_free(Z2);
|
||||
|
||||
fprintf(stderr, "Test failed RFC5114 set %d\n", i + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -191,6 +191,8 @@ static int dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8)
|
||||
STACK_OF(ASN1_TYPE) *ndsa = NULL;
|
||||
DSA *dsa = NULL;
|
||||
|
||||
int ret = 0;
|
||||
|
||||
if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8))
|
||||
return 0;
|
||||
X509_ALGOR_get0(NULL, &ptype, &pval, palg);
|
||||
@@ -262,23 +264,21 @@ static int dsa_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8)
|
||||
}
|
||||
|
||||
EVP_PKEY_assign_DSA(pkey, dsa);
|
||||
|
||||
ret = 1;
|
||||
goto done;
|
||||
|
||||
decerr:
|
||||
DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_DECODE_ERROR);
|
||||
dsaerr:
|
||||
DSA_free(dsa);
|
||||
done:
|
||||
BN_CTX_free(ctx);
|
||||
if (ndsa)
|
||||
sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
|
||||
else
|
||||
ASN1_STRING_clear_free(privkey);
|
||||
|
||||
return 1;
|
||||
|
||||
decerr:
|
||||
DSAerr(DSA_F_DSA_PRIV_DECODE, EVP_R_DECODE_ERROR);
|
||||
dsaerr:
|
||||
BN_CTX_free(ctx);
|
||||
if (privkey)
|
||||
ASN1_STRING_clear_free(privkey);
|
||||
sk_ASN1_TYPE_pop_free(ndsa, ASN1_TYPE_free);
|
||||
DSA_free(dsa);
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
|
||||
|
||||
@@ -187,9 +187,6 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
|
||||
if (!BN_mod_mul(s, s, kinv, dsa->q, ctx))
|
||||
goto err;
|
||||
|
||||
ret = DSA_SIG_new();
|
||||
if (ret == NULL)
|
||||
goto err;
|
||||
/*
|
||||
* Redo if r or s is zero as required by FIPS 186-3: this is very
|
||||
* unlikely.
|
||||
@@ -201,11 +198,14 @@ static DSA_SIG *dsa_do_sign(const unsigned char *dgst, int dlen, DSA *dsa)
|
||||
}
|
||||
goto redo;
|
||||
}
|
||||
ret = DSA_SIG_new();
|
||||
if (ret == NULL)
|
||||
goto err;
|
||||
ret->r = r;
|
||||
ret->s = s;
|
||||
|
||||
err:
|
||||
if (!ret) {
|
||||
if (ret == NULL) {
|
||||
DSAerr(DSA_F_DSA_DO_SIGN, reason);
|
||||
BN_free(r);
|
||||
BN_free(s);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* dso.h -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* dso.h */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* dso_dl.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* dso_dl.c */
|
||||
/*
|
||||
* Written by Richard Levitte (richard@levitte.org) for the OpenSSL project
|
||||
* 2000.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* dso_dlfcn.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* dso_dlfcn.c */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* dso_lib.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* dso_lib.c */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
@@ -122,6 +122,7 @@ DSO *DSO_new_method(DSO_METHOD *meth)
|
||||
ret->meth = meth;
|
||||
ret->references = 1;
|
||||
if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
|
||||
sk_void_free(ret->meth_data);
|
||||
OPENSSL_free(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* dso_vms.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* dso_vms.c */
|
||||
/*
|
||||
* Written by Richard Levitte (richard@levitte.org) for the OpenSSL project
|
||||
* 2000.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* dso_win32.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* dso_win32.c */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2000.
|
||||
|
||||
@@ -81,7 +81,7 @@ if (!$addx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$addx = ($1>=12);
|
||||
}
|
||||
|
||||
if (!$addx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-9])\.([0-9]+)/) {
|
||||
if (!$addx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9])\.([0-9]+)/) {
|
||||
my $ver = $2 + $3/100.0; # 3.1->3.01, 3.10->3.10
|
||||
$avx = ($ver>=3.0) + ($ver>=3.01);
|
||||
$addx = ($ver>=3.03);
|
||||
@@ -2001,6 +2001,7 @@ $code.=<<___;
|
||||
push %r15
|
||||
sub \$32*5+8, %rsp
|
||||
|
||||
.Lpoint_double_shortcut$x:
|
||||
movdqu 0x00($a_ptr), %xmm0 # copy *(P256_POINT *)$a_ptr.x
|
||||
mov $a_ptr, $b_ptr # backup copy
|
||||
movdqu 0x10($a_ptr), %xmm1
|
||||
@@ -2291,6 +2292,7 @@ $code.=<<___;
|
||||
mov 0x40+8*1($b_ptr), $acc6
|
||||
mov 0x40+8*2($b_ptr), $acc7
|
||||
mov 0x40+8*3($b_ptr), $acc0
|
||||
movq $b_ptr, %xmm1
|
||||
|
||||
lea 0x40-$bias($b_ptr), $a_ptr
|
||||
lea $Z1sqr(%rsp), $r_ptr # Z1^2
|
||||
@@ -2346,7 +2348,7 @@ $code.=<<___;
|
||||
test $acc0, $acc0
|
||||
jnz .Ladd_proceed$x # (in1infty || in2infty)?
|
||||
test $acc1, $acc1
|
||||
jz .Ladd_proceed$x # is_equal(S1,S2)?
|
||||
jz .Ladd_double$x # is_equal(S1,S2)?
|
||||
|
||||
movq %xmm0, $r_ptr # restore $r_ptr
|
||||
pxor %xmm0, %xmm0
|
||||
@@ -2358,6 +2360,13 @@ $code.=<<___;
|
||||
movdqu %xmm0, 0x50($r_ptr)
|
||||
jmp .Ladd_done$x
|
||||
|
||||
.align 32
|
||||
.Ladd_double$x:
|
||||
movq %xmm1, $a_ptr # restore $a_ptr
|
||||
movq %xmm0, $r_ptr # restore $r_ptr
|
||||
add \$`32*(18-5)`, %rsp # difference in frame sizes
|
||||
jmp .Lpoint_double_shortcut$x
|
||||
|
||||
.align 32
|
||||
.Ladd_proceed$x:
|
||||
`&load_for_sqr("$R(%rsp)", "$src0")`
|
||||
|
||||
@@ -746,6 +746,7 @@ int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point,
|
||||
goto err;
|
||||
if (!BN_one(&point->Z))
|
||||
goto err;
|
||||
point->Z_is_one = 1;
|
||||
|
||||
ret = 1;
|
||||
|
||||
|
||||
@@ -387,6 +387,8 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,
|
||||
|
||||
tx = BN_CTX_get(ctx);
|
||||
ty = BN_CTX_get(ctx);
|
||||
if (ty == NULL)
|
||||
goto err;
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(key->group));
|
||||
|
||||
@@ -1657,8 +1657,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
*/
|
||||
if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) {
|
||||
memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp));
|
||||
ret = 1;
|
||||
goto err;
|
||||
goto done;
|
||||
}
|
||||
if ((!BN_to_felem(pre->g_pre_comp[0][1][0], &group->generator->X)) ||
|
||||
(!BN_to_felem(pre->g_pre_comp[0][1][1], &group->generator->Y)) ||
|
||||
@@ -1736,6 +1735,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
}
|
||||
make_points_affine(31, &(pre->g_pre_comp[0][1]), tmp_felems);
|
||||
|
||||
done:
|
||||
if (!EC_EX_DATA_set_data(&group->extra_data, pre, nistp224_pre_comp_dup,
|
||||
nistp224_pre_comp_free,
|
||||
nistp224_pre_comp_clear_free))
|
||||
|
||||
@@ -2249,8 +2249,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
*/
|
||||
if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) {
|
||||
memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp));
|
||||
ret = 1;
|
||||
goto err;
|
||||
goto done;
|
||||
}
|
||||
if ((!BN_to_felem(x_tmp, &group->generator->X)) ||
|
||||
(!BN_to_felem(y_tmp, &group->generator->Y)) ||
|
||||
@@ -2337,6 +2336,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
}
|
||||
make_points_affine(31, &(pre->g_pre_comp[0][1]), tmp_smallfelems);
|
||||
|
||||
done:
|
||||
if (!EC_EX_DATA_set_data(&group->extra_data, pre, nistp256_pre_comp_dup,
|
||||
nistp256_pre_comp_free,
|
||||
nistp256_pre_comp_clear_free))
|
||||
|
||||
@@ -2056,8 +2056,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
*/
|
||||
if (0 == EC_POINT_cmp(group, generator, group->generator, ctx)) {
|
||||
memcpy(pre->g_pre_comp, gmul, sizeof(pre->g_pre_comp));
|
||||
ret = 1;
|
||||
goto err;
|
||||
goto done;
|
||||
}
|
||||
if ((!BN_to_felem(pre->g_pre_comp[1][0], &group->generator->X)) ||
|
||||
(!BN_to_felem(pre->g_pre_comp[1][1], &group->generator->Y)) ||
|
||||
@@ -2115,6 +2114,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx)
|
||||
}
|
||||
make_points_affine(15, &(pre->g_pre_comp[1]), tmp_felems);
|
||||
|
||||
done:
|
||||
if (!EC_EX_DATA_set_data(&group->extra_data, pre, nistp521_pre_comp_dup,
|
||||
nistp521_pre_comp_free,
|
||||
nistp521_pre_comp_clear_free))
|
||||
|
||||
@@ -17,7 +17,7 @@ __attribute((aligned(4096)))
|
||||
#elif defined(_MSC_VER)
|
||||
__declspec(align(4096))
|
||||
#elif defined(__SUNPRO_C)
|
||||
# pragma align 4096(ecp_nistz256_precomputed)
|
||||
# pragma align 64(ecp_nistz256_precomputed)
|
||||
#endif
|
||||
static const BN_ULONG ecp_nistz256_precomputed[37][64 *
|
||||
sizeof(P256_POINT_AFFINE) /
|
||||
|
||||
@@ -1591,7 +1591,7 @@ struct nistp_test_params {
|
||||
int degree;
|
||||
/*
|
||||
* Qx, Qy and D are taken from
|
||||
* http://csrcdocut.gov/groups/ST/toolkit/documents/Examples/ECDSA_Prime.pdf
|
||||
* http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/ECDSA_Prime.pdf
|
||||
* Otherwise, values are standard curve parameters from FIPS 180-3
|
||||
*/
|
||||
const char *p, *a, *b, *Qx, *Qy, *Gx, *Gy, *order, *d;
|
||||
@@ -1758,9 +1758,18 @@ static void nistp_single_test(const struct nistp_test_params *test)
|
||||
if (0 != EC_POINT_cmp(NISTP, Q, Q_CHECK, ctx))
|
||||
ABORT;
|
||||
|
||||
/*
|
||||
* We have not performed precomputation so have_precompute mult should be
|
||||
* false
|
||||
*/
|
||||
if (EC_GROUP_have_precompute_mult(NISTP))
|
||||
ABORT;
|
||||
|
||||
/* now repeat all tests with precomputation */
|
||||
if (!EC_GROUP_precompute_mult(NISTP, ctx))
|
||||
ABORT;
|
||||
if (!EC_GROUP_have_precompute_mult(NISTP))
|
||||
ABORT;
|
||||
|
||||
/* fixed point multiplication */
|
||||
EC_POINT_mul(NISTP, Q, m, NULL, NULL, ctx);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/engine/eng_all.c -*- mode: C; c-file-style: "eay" -*- */
|
||||
/* crypto/engine/eng_all.c */
|
||||
/*
|
||||
* Written by Richard Levitte <richard@levitte.org> for the OpenSSL project
|
||||
* 2000.
|
||||
|
||||
@@ -243,8 +243,10 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx)
|
||||
* If we lost the race to set the context, c is non-NULL and *ctx is the
|
||||
* context of the thread that won.
|
||||
*/
|
||||
if (c)
|
||||
if (c) {
|
||||
sk_OPENSSL_STRING_free(c->dirs);
|
||||
OPENSSL_free(c);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/evp/e_camellia.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/evp/e_camellia.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -71,12 +71,13 @@ typedef struct {
|
||||
DES_key_schedule ks;
|
||||
} ks;
|
||||
union {
|
||||
void (*cbc) (const void *, void *, size_t, const void *, void *);
|
||||
void (*cbc) (const void *, void *, size_t,
|
||||
const DES_key_schedule *, unsigned char *);
|
||||
} stream;
|
||||
} EVP_DES_KEY;
|
||||
|
||||
# if defined(AES_ASM) && (defined(__sparc) || defined(__sparc__))
|
||||
/* ---------^^^ this is not a typo, just a way to detect that
|
||||
/* ----------^^^ this is not a typo, just a way to detect that
|
||||
* assembler support was in general requested... */
|
||||
# include "sparc_arch.h"
|
||||
|
||||
@@ -86,9 +87,9 @@ extern unsigned int OPENSSL_sparcv9cap_P[];
|
||||
|
||||
void des_t4_key_expand(const void *key, DES_key_schedule *ks);
|
||||
void des_t4_cbc_encrypt(const void *inp, void *out, size_t len,
|
||||
DES_key_schedule *ks, unsigned char iv[8]);
|
||||
const DES_key_schedule *ks, unsigned char iv[8]);
|
||||
void des_t4_cbc_decrypt(const void *inp, void *out, size_t len,
|
||||
DES_key_schedule *ks, unsigned char iv[8]);
|
||||
const DES_key_schedule *ks, unsigned char iv[8]);
|
||||
# endif
|
||||
|
||||
static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
@@ -130,7 +131,7 @@ static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
{
|
||||
EVP_DES_KEY *dat = (EVP_DES_KEY *) ctx->cipher_data;
|
||||
|
||||
if (dat->stream.cbc) {
|
||||
if (dat->stream.cbc != NULL) {
|
||||
(*dat->stream.cbc) (in, out, inl, &dat->ks.ks, ctx->iv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,8 @@ typedef struct {
|
||||
DES_key_schedule ks[3];
|
||||
} ks;
|
||||
union {
|
||||
void (*cbc) (const void *, void *, size_t, const void *, void *);
|
||||
void (*cbc) (const void *, void *, size_t,
|
||||
const DES_key_schedule *, unsigned char *);
|
||||
} stream;
|
||||
} DES_EDE_KEY;
|
||||
# define ks1 ks.ks[0]
|
||||
@@ -93,9 +94,9 @@ extern unsigned int OPENSSL_sparcv9cap_P[];
|
||||
|
||||
void des_t4_key_expand(const void *key, DES_key_schedule *ks);
|
||||
void des_t4_ede3_cbc_encrypt(const void *inp, void *out, size_t len,
|
||||
DES_key_schedule *ks, unsigned char iv[8]);
|
||||
const DES_key_schedule ks[3], unsigned char iv[8]);
|
||||
void des_t4_ede3_cbc_decrypt(const void *inp, void *out, size_t len,
|
||||
DES_key_schedule *ks, unsigned char iv[8]);
|
||||
const DES_key_schedule ks[3], unsigned char iv[8]);
|
||||
# endif
|
||||
|
||||
static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
@@ -162,7 +163,7 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
}
|
||||
# endif /* KSSL_DEBUG */
|
||||
if (dat->stream.cbc) {
|
||||
(*dat->stream.cbc) (in, out, inl, &dat->ks, ctx->iv);
|
||||
(*dat->stream.cbc) (in, out, inl, dat->ks.ks, ctx->iv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -395,7 +396,7 @@ static int des_ede3_unwrap(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
int rv = -1;
|
||||
if (inl < 24)
|
||||
return -1;
|
||||
if (!out)
|
||||
if (out == NULL)
|
||||
return inl - 16;
|
||||
memcpy(ctx->iv, wrap_iv, 8);
|
||||
/* Decrypt first block which will end up as icv */
|
||||
@@ -438,7 +439,7 @@ static int des_ede3_wrap(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
const unsigned char *in, size_t inl)
|
||||
{
|
||||
unsigned char sha1tmp[SHA_DIGEST_LENGTH];
|
||||
if (!out)
|
||||
if (out == NULL)
|
||||
return inl + 16;
|
||||
/* Copy input to output buffer + 8 so we have space for IV */
|
||||
memmove(out + 8, in, inl);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/evp/e_old.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/evp/e_old.c */
|
||||
/*
|
||||
* Written by Richard Levitte (richard@levitte.org) for the OpenSSL project
|
||||
* 2004.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/evp/e_seed.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/evp/e_seed.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2007 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* crypto/mem_clr.c -*- mode:C; c-file-style: "eay" -*- */
|
||||
/* crypto/mem_clr.c */
|
||||
/*
|
||||
* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL project
|
||||
* 2002.
|
||||
|
||||
@@ -43,7 +43,7 @@ die "can't locate x86_64-xlate.pl";
|
||||
|
||||
if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`
|
||||
=~ /GNU assembler version ([2-9]\.[0-9]+)/) {
|
||||
$avx = ($1>=2.19) + ($1>=2.22);
|
||||
$avx = ($1>=2.20) + ($1>=2.22);
|
||||
}
|
||||
|
||||
if (!$avx && $win64 && ($flavour =~ /nasm/ || $ENV{ASM} =~ /nasm/) &&
|
||||
@@ -56,7 +56,7 @@ if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$avx = ($1>=10) + ($1>=11);
|
||||
}
|
||||
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ $code.=<<___;
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
movaps -0xd8(%rax),%xmm6
|
||||
movaps -0xd8(%rax),%xmm7
|
||||
movaps -0xc8(%rax),%xmm7
|
||||
movaps -0xb8(%rax),%xmm8
|
||||
movaps -0xa8(%rax),%xmm9
|
||||
movaps -0x98(%rax),%xmm10
|
||||
|
||||
@@ -92,7 +92,7 @@ die "can't locate x86_64-xlate.pl";
|
||||
|
||||
if (`$ENV{CC} -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`
|
||||
=~ /GNU assembler version ([2-9]\.[0-9]+)/) {
|
||||
$avx = ($1>=2.19) + ($1>=2.22);
|
||||
$avx = ($1>=2.20) + ($1>=2.22);
|
||||
}
|
||||
|
||||
if (!$avx && $win64 && ($flavour =~ /nasm/ || $ENV{ASM} =~ /nasm/) &&
|
||||
@@ -105,7 +105,7 @@ if (!$avx && $win64 && ($flavour =~ /masm/ || $ENV{ASM} =~ /ml64/) &&
|
||||
$avx = ($1>=10) + ($1>=11);
|
||||
}
|
||||
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
if (!$avx && `$ENV{CC} -v 2>&1` =~ /((?:^clang|LLVM) version|.*based on LLVM) ([3-9]\.[0-9]+)/) {
|
||||
$avx = ($2>=3.0) + ($2>3.0);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user