Compare commits
173 Commits
OpenSSL_1_
...
OpenSSL_1_
Author | SHA1 | Date | |
---|---|---|---|
![]() |
43257b9f51 | ||
![]() |
10771e3421 | ||
![]() |
36f694e09a | ||
![]() |
635ca4446f | ||
![]() |
bd00b8dc65 | ||
![]() |
2194b36979 | ||
![]() |
e81a83657c | ||
![]() |
cbbb952f3a | ||
![]() |
04f670cf3d | ||
![]() |
5cee72382c | ||
![]() |
7c6a3cf237 | ||
![]() |
be3fb8d15d | ||
![]() |
fb73f12a9c | ||
![]() |
25d738c3a4 | ||
![]() |
49446ea62f | ||
![]() |
f33ab61b5f | ||
![]() |
2d63d0c84a | ||
![]() |
cfb5d6c10a | ||
![]() |
a936ba1148 | ||
![]() |
ed736ddd74 | ||
![]() |
c7c2a56a1b | ||
![]() |
129344a8fb | ||
![]() |
be6e766953 | ||
![]() |
8dc461eccf | ||
![]() |
4b4c1fcc88 | ||
![]() |
1cfd7cf3cc | ||
![]() |
2996157127 | ||
![]() |
caeed719fe | ||
![]() |
f4868c9921 | ||
![]() |
4aaf1e493c | ||
![]() |
d96c24926d | ||
![]() |
d9b277e085 | ||
![]() |
aace6dbcb3 | ||
![]() |
85cfc188c0 | ||
![]() |
6ee7de1eb3 | ||
![]() |
7b0194db42 | ||
![]() |
bfaf796241 | ||
![]() |
c02e2d6a71 | ||
![]() |
9f49067c9e | ||
![]() |
5396c1190f | ||
![]() |
cf95b2d66a | ||
![]() |
47606dda67 | ||
![]() |
c30c876176 | ||
![]() |
73bda31b4c | ||
![]() |
dc00fb9d51 | ||
![]() |
06c3e65deb | ||
![]() |
5984c7e3d5 | ||
![]() |
beef278bd7 | ||
![]() |
58191465ef | ||
![]() |
5760c8b82f | ||
![]() |
b651407268 | ||
![]() |
a760dde681 | ||
![]() |
f5e4b6b5b5 | ||
![]() |
9ca2cc78a9 | ||
![]() |
0cf552230e | ||
![]() |
0e1c318ece | ||
![]() |
8bc8450a26 | ||
![]() |
bf68456f53 | ||
![]() |
53332a75d1 | ||
![]() |
cd387d21da | ||
![]() |
0c403e80a9 | ||
![]() |
553affbef7 | ||
![]() |
1ecfb67335 | ||
![]() |
bb565cd29e | ||
![]() |
a43bcd9e96 | ||
![]() |
c8667a2e46 | ||
![]() |
5ee441162e | ||
![]() |
63ef0db60f | ||
![]() |
f74f5c8586 | ||
![]() |
a38ae11c48 | ||
![]() |
4ca0e95b92 | ||
![]() |
f9398b92de | ||
![]() |
6af16ec5ee | ||
![]() |
d04a1e0b5b | ||
![]() |
bb1ddd3d9a | ||
![]() |
6806b69084 | ||
![]() |
9809ab965b | ||
![]() |
bd34823e55 | ||
![]() |
533814c6b5 | ||
![]() |
b32474a40b | ||
![]() |
f6e725e868 | ||
![]() |
7005eda3b6 | ||
![]() |
9a6e994240 | ||
![]() |
0b3c13092c | ||
![]() |
dfa2762bba | ||
![]() |
c0b90b3237 | ||
![]() |
788a5bad17 | ||
![]() |
1872083ca1 | ||
![]() |
05e769f269 | ||
![]() |
ccecdb130c | ||
![]() |
80d09058af | ||
![]() |
3cc0c0d21c | ||
![]() |
5e47008b61 | ||
![]() |
e9f47de1f0 | ||
![]() |
6a7a4a4e19 | ||
![]() |
67a0ea702b | ||
![]() |
89e1e5c84d | ||
![]() |
7cae6eeed0 | ||
![]() |
4b12a17fe3 | ||
![]() |
2e524475cd | ||
![]() |
ac3dc3ee87 | ||
![]() |
63039a177a | ||
![]() |
ca88bd4112 | ||
![]() |
1e7b4891cb | ||
![]() |
3623e24b45 | ||
![]() |
e164582690 | ||
![]() |
4d3df37bc7 | ||
![]() |
261e64b85e | ||
![]() |
23cf88440c | ||
![]() |
bd8192604a | ||
![]() |
8f8e7cec83 | ||
![]() |
14332e4331 | ||
![]() |
60de554e4f | ||
![]() |
c57400e86c | ||
![]() |
f90fd2b017 | ||
![]() |
8d325d1d36 | ||
![]() |
03d14f5887 | ||
![]() |
6f71d7da64 | ||
![]() |
0b9e82763f | ||
![]() |
e5f261df73 | ||
![]() |
9baee0216f | ||
![]() |
5d23e1303c | ||
![]() |
f7c7aa69f7 | ||
![]() |
ce5f32cfa7 | ||
![]() |
5891c226d8 | ||
![]() |
017a15cbd2 | ||
![]() |
786370b1b0 | ||
![]() |
56e8dc542b | ||
![]() |
9ef1d283fe | ||
![]() |
5a4a949904 | ||
![]() |
ffa69c1ced | ||
![]() |
305e2b4111 | ||
![]() |
ba7aaa5622 | ||
![]() |
2ad842b86a | ||
![]() |
297a8fd4ac | ||
![]() |
5b3a5e3e90 | ||
![]() |
40e214a23b | ||
![]() |
39679d858a | ||
![]() |
0ec6898c67 | ||
![]() |
1e10aee2a7 | ||
![]() |
34a136d90f | ||
![]() |
42af669ff2 | ||
![]() |
4c75f4e5ca | ||
![]() |
1380317483 | ||
![]() |
a35f7adf5c | ||
![]() |
1ce95f1960 | ||
![]() |
51695b98f1 | ||
![]() |
82182413a4 | ||
![]() |
0ce2dbfb5b | ||
![]() |
981545e1e7 | ||
![]() |
d60de314f4 | ||
![]() |
b6ece4c1fc | ||
![]() |
bb086221dd | ||
![]() |
b4b8969df8 | ||
![]() |
010d37621d | ||
![]() |
84d4f99d31 | ||
![]() |
82180dcc0a | ||
![]() |
c2b90b398d | ||
![]() |
c2a2ff3f0a | ||
![]() |
d64b6c980c | ||
![]() |
05df9b9ae5 | ||
![]() |
3e3cc471c2 | ||
![]() |
80fb4820cb | ||
![]() |
2229fe5b94 | ||
![]() |
a46c705214 | ||
![]() |
dc7bca8bcc | ||
![]() |
f58cfe0422 | ||
![]() |
20d1c8111f | ||
![]() |
c578fe37d9 | ||
![]() |
a4ee5bbc77 | ||
![]() |
8ad9050318 | ||
![]() |
5df07a7210 | ||
![]() |
0853b2c5e4 |
30
.gitignore
vendored
30
.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
# Object files
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# editor artefacts
|
||||
*.swp
|
||||
@@ -52,6 +53,21 @@
|
||||
*.s
|
||||
!/crypto/bn/asm/pa-risc2.s
|
||||
!/crypto/bn/asm/pa-risc2W.s
|
||||
crypto/aes/asm/a_win32.asm
|
||||
crypto/bf/asm/b_win32.asm
|
||||
crypto/bn/asm/bn_win32.asm
|
||||
crypto/bn/asm/co_win32.asm
|
||||
crypto/bn/asm/mt_win32.asm
|
||||
crypto/cast/asm/c_win32.asm
|
||||
crypto/cpu_win32.asm
|
||||
crypto/des/asm/d_win32.asm
|
||||
crypto/des/asm/y_win32.asm
|
||||
crypto/md5/asm/m5_win32.asm
|
||||
crypto/rc4/asm/r4_win32.asm
|
||||
crypto/rc5/asm/r5_win32.asm
|
||||
crypto/ripemd/asm/rm_win32.asm
|
||||
crypto/sha/asm/s1_win32.asm
|
||||
crypto/sha/asm/sha512-sse2.asm
|
||||
|
||||
# Executables
|
||||
/apps/openssl
|
||||
@@ -82,3 +98,17 @@ Makefile.save
|
||||
*.bak
|
||||
tags
|
||||
TAGS
|
||||
|
||||
# Windows
|
||||
/tmp32dll
|
||||
/tmp32dll.dbg
|
||||
/out32dll
|
||||
/out32dll.dbg
|
||||
/inc32
|
||||
/MINFO
|
||||
ms/bcb.mak
|
||||
ms/libeay32.def
|
||||
ms/nt.mak
|
||||
ms/ntdll.mak
|
||||
ms/ssleay32.def
|
||||
ms/version32.rc
|
||||
|
206
CHANGES
206
CHANGES
@@ -2,11 +2,58 @@
|
||||
OpenSSL CHANGES
|
||||
_______________
|
||||
|
||||
Changes between 1.0.1i and 1.0.2 [xx XXX xxxx]
|
||||
Changes between 1.0.1k and 1.0.2 [xx XXX xxxx]
|
||||
|
||||
*) SRTP Memory Leak.
|
||||
|
||||
A flaw in the DTLS SRTP extension parsing code allows an attacker, who
|
||||
sends a carefully crafted handshake message, to cause OpenSSL to fail
|
||||
to free up to 64k of memory causing a memory leak. This could be
|
||||
exploited in a Denial Of Service attack. This issue affects OpenSSL
|
||||
1.0.1 server implementations for both SSL/TLS and DTLS regardless of
|
||||
whether SRTP is used or configured. Implementations of OpenSSL that
|
||||
have been compiled with OPENSSL_NO_SRTP defined are not affected.
|
||||
|
||||
The fix was developed by the OpenSSL team.
|
||||
(CVE-2014-3513)
|
||||
[OpenSSL team]
|
||||
|
||||
*) Session Ticket Memory Leak.
|
||||
|
||||
When an OpenSSL SSL/TLS/DTLS server receives a session ticket the
|
||||
integrity of that ticket is first verified. In the event of a session
|
||||
ticket integrity check failing, OpenSSL will fail to free memory
|
||||
causing a memory leak. By sending a large number of invalid session
|
||||
tickets an attacker could exploit this issue in a Denial Of Service
|
||||
attack.
|
||||
(CVE-2014-3567)
|
||||
[Steve Henson]
|
||||
|
||||
*) Build option no-ssl3 is incomplete.
|
||||
|
||||
When OpenSSL is configured with "no-ssl3" as a build option, servers
|
||||
could accept and complete a SSL 3.0 handshake, and clients could be
|
||||
configured to send them.
|
||||
(CVE-2014-3568)
|
||||
[Akamai and the OpenSSL team]
|
||||
|
||||
*) Add support for TLS_FALLBACK_SCSV.
|
||||
Client applications doing fallback retries should call
|
||||
SSL_set_mode(s, SSL_MODE_SEND_FALLBACK_SCSV).
|
||||
(CVE-2014-3566)
|
||||
[Adam Langley, Bodo Moeller]
|
||||
|
||||
*) Facilitate "universal" ARM builds targeting range of ARM ISAs, e.g.
|
||||
ARMv5 through ARMv8, as opposite to "locking" it to single one.
|
||||
So far those who have to target multiple plaforms would compromise
|
||||
and argue that binary targeting say ARMv5 would still execute on
|
||||
ARMv8. "Universal" build resolves this compromise by providing
|
||||
near-optimal performance even on newer platforms.
|
||||
[Andy Polyakov]
|
||||
|
||||
*) Accelerated NIST P-256 elliptic curve implementation for x86_64
|
||||
(other platforms pending).
|
||||
[Shay Gueron (Intel Corp), Andy Polyakov]
|
||||
[Shay Gueron & Vlad Krasnov (Intel Corp), Andy Polyakov]
|
||||
|
||||
*) Add support for the SignedCertificateTimestampList certificate and
|
||||
OCSP response extensions from RFC6962.
|
||||
@@ -42,7 +89,7 @@
|
||||
|
||||
*) Accelerated modular exponentiation for Intel processors, a.k.a.
|
||||
RSAZ.
|
||||
[Shay Gueron (Intel Corp)]
|
||||
[Shay Gueron & Vlad Krasnov (Intel Corp)]
|
||||
|
||||
*) Support for new and upcoming Intel processors, including AVX2,
|
||||
BMI and SHA ISA extensions. This includes additional "stitched"
|
||||
@@ -52,6 +99,11 @@
|
||||
This work was sponsored by Intel Corp.
|
||||
[Andy Polyakov]
|
||||
|
||||
*) Support for DTLS 1.2. This adds two sets of DTLS methods: DTLS_*_method()
|
||||
supports both DTLS 1.2 and 1.0 and should use whatever version the peer
|
||||
supports and DTLSv1_2_*_method() which supports DTLS 1.2 only.
|
||||
[Steve Henson]
|
||||
|
||||
*) Use algorithm specific chains in SSL_CTX_use_certificate_chain_file():
|
||||
this fixes a limiation in previous versions of OpenSSL.
|
||||
[Steve Henson]
|
||||
@@ -319,6 +371,142 @@
|
||||
X509_CINF_set_modified, X509_CINF_get_issuer, X509_CINF_get_extensions and
|
||||
X509_CINF_get_signature were reverted post internal team review.
|
||||
|
||||
Changes between 1.0.1j and 1.0.1k [xx XXX xxxx]
|
||||
|
||||
*) Abort handshake if server key exchange message is omitted for ephemeral
|
||||
ECDH ciphersuites.
|
||||
|
||||
Thanks to Karthikeyan Bhargavan of the PROSECCO team at INRIA for
|
||||
reporting this issue.
|
||||
(CVE-2014-3572)
|
||||
[Steve Henson]
|
||||
|
||||
*) Remove non-export ephemeral RSA code on client and server. This code
|
||||
violated the TLS standard by allowing the use of temporary RSA keys in
|
||||
non-export ciphersuites and could be used by a server to effectively
|
||||
downgrade the RSA key length used to a value smaller than the server
|
||||
certificate. Thanks for Karthikeyan Bhargavan of the PROSECCO team at
|
||||
INRIA or reporting this issue.
|
||||
(CVE-2015-0204)
|
||||
[Steve Henson]
|
||||
|
||||
*) Ensure that the session ID context of an SSL is updated when its
|
||||
SSL_CTX is updated via SSL_set_SSL_CTX.
|
||||
|
||||
The session ID context is typically set from the parent SSL_CTX,
|
||||
and can vary with the CTX.
|
||||
[Adam Langley]
|
||||
|
||||
*) Fix various certificate fingerprint issues.
|
||||
|
||||
By using non-DER or invalid encodings outside the signed portion of a
|
||||
certificate the fingerprint can be changed without breaking the signature.
|
||||
Although no details of the signed portion of the certificate can be changed
|
||||
this can cause problems with some applications: e.g. those using the
|
||||
certificate fingerprint for blacklists.
|
||||
|
||||
1. Reject signatures with non zero unused bits.
|
||||
|
||||
If the BIT STRING containing the signature has non zero unused bits reject
|
||||
the signature. All current signature algorithms require zero unused bits.
|
||||
|
||||
2. Check certificate algorithm consistency.
|
||||
|
||||
Check the AlgorithmIdentifier inside TBS matches the one in the
|
||||
certificate signature. NB: this will result in signature failure
|
||||
errors for some broken certificates.
|
||||
|
||||
Thanks to Konrad Kraszewski from Google for reporting this issue.
|
||||
|
||||
3. Check DSA/ECDSA signatures use DER.
|
||||
|
||||
Reencode DSA/ECDSA signatures and compare with the original received
|
||||
signature. Return an error if there is a mismatch.
|
||||
|
||||
This will reject various cases including garbage after signature
|
||||
(thanks to Antti Karjalainen and Tuomo Untinen from the Codenomicon CROSS
|
||||
program for discovering this case) and use of BER or invalid ASN.1 INTEGERs
|
||||
(negative or with leading zeroes).
|
||||
|
||||
Further analysis was conducted and fixes were developed by Stephen Henson
|
||||
of the OpenSSL core team.
|
||||
|
||||
(CVE-2014-8275)
|
||||
[Steve Henson]
|
||||
|
||||
*) Do not resume sessions on the server if the negotiated protocol
|
||||
version does not match the session's version. Resuming with a different
|
||||
version, while not strictly forbidden by the RFC, is of questionable
|
||||
sanity and breaks all known clients.
|
||||
[David Benjamin, Emilia K<>sper]
|
||||
|
||||
*) Tighten handling of the ChangeCipherSpec (CCS) message: reject
|
||||
early CCS messages during renegotiation. (Note that because
|
||||
renegotiation is encrypted, this early CCS was not exploitable.)
|
||||
[Emilia K<>sper]
|
||||
|
||||
*) Tighten client-side session ticket handling during renegotiation:
|
||||
ensure that the client only accepts a session ticket if the server sends
|
||||
the extension anew in the ServerHello. Previously, a TLS client would
|
||||
reuse the old extension state and thus accept a session ticket if one was
|
||||
announced in the initial ServerHello.
|
||||
|
||||
Similarly, ensure that the client requires a session ticket if one
|
||||
was advertised in the ServerHello. Previously, a TLS client would
|
||||
ignore a missing NewSessionTicket message.
|
||||
[Emilia K<>sper]
|
||||
|
||||
Changes between 1.0.1i and 1.0.1j [15 Oct 2014]
|
||||
|
||||
*) SRTP Memory Leak.
|
||||
|
||||
A flaw in the DTLS SRTP extension parsing code allows an attacker, who
|
||||
sends a carefully crafted handshake message, to cause OpenSSL to fail
|
||||
to free up to 64k of memory causing a memory leak. This could be
|
||||
exploited in a Denial Of Service attack. This issue affects OpenSSL
|
||||
1.0.1 server implementations for both SSL/TLS and DTLS regardless of
|
||||
whether SRTP is used or configured. Implementations of OpenSSL that
|
||||
have been compiled with OPENSSL_NO_SRTP defined are not affected.
|
||||
|
||||
The fix was developed by the OpenSSL team.
|
||||
(CVE-2014-3513)
|
||||
[OpenSSL team]
|
||||
|
||||
*) Session Ticket Memory Leak.
|
||||
|
||||
When an OpenSSL SSL/TLS/DTLS server receives a session ticket the
|
||||
integrity of that ticket is first verified. In the event of a session
|
||||
ticket integrity check failing, OpenSSL will fail to free memory
|
||||
causing a memory leak. By sending a large number of invalid session
|
||||
tickets an attacker could exploit this issue in a Denial Of Service
|
||||
attack.
|
||||
(CVE-2014-3567)
|
||||
[Steve Henson]
|
||||
|
||||
*) Build option no-ssl3 is incomplete.
|
||||
|
||||
When OpenSSL is configured with "no-ssl3" as a build option, servers
|
||||
could accept and complete a SSL 3.0 handshake, and clients could be
|
||||
configured to send them.
|
||||
(CVE-2014-3568)
|
||||
[Akamai and the OpenSSL team]
|
||||
|
||||
*) Add support for TLS_FALLBACK_SCSV.
|
||||
Client applications doing fallback retries should call
|
||||
SSL_set_mode(s, SSL_MODE_SEND_FALLBACK_SCSV).
|
||||
(CVE-2014-3566)
|
||||
[Adam Langley, Bodo Moeller]
|
||||
|
||||
*) Add additional DigestInfo checks.
|
||||
|
||||
Reencode DigestInto in DER and check against the original when
|
||||
verifying RSA signature: this will reject any improperly encoded
|
||||
DigestInfo structures.
|
||||
|
||||
Note: this is a precautionary measure and no attacks are currently known.
|
||||
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.1h and 1.0.1i [6 Aug 2014]
|
||||
|
||||
*) Fix SRP buffer overrun vulnerability. Invalid parameters passed to the
|
||||
@@ -405,6 +593,18 @@
|
||||
bogus results, with non-infinity inputs mapped to infinity too.)
|
||||
[Bodo Moeller]
|
||||
|
||||
Changes between 1.0.1i and 1.0.1j [xx XXX xxxx]
|
||||
|
||||
*) Add additional DigestInfo checks.
|
||||
|
||||
Reencode DigestInto in DER and check against the original when
|
||||
verifying RSA signature: this will reject any improperly encoded
|
||||
DigestInfo structures.
|
||||
|
||||
Note: this is a precautionary measure and no attacks are currently known.
|
||||
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.1g and 1.0.1h [5 Jun 2014]
|
||||
|
||||
*) Fix for SSL/TLS MITM flaw. An attacker using a carefully crafted
|
||||
|
40
Configure
40
Configure
@@ -105,6 +105,8 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimenta
|
||||
|
||||
my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Werror -DCRYPTO_MDEBUG_ALL -DCRYPTO_MDEBUG_ABORT -DREF_CHECK -DOPENSSL_NO_DEPRECATED";
|
||||
|
||||
my $clang_disabled_warnings = "-Wno-language-extension-token -Wno-extended-offsetof -Wno-padded -Wno-shorten-64-to-32 -Wno-format-nonliteral -Wno-missing-noreturn -Wno-unused-parameter -Wno-sign-conversion -Wno-unreachable-code -Wno-conversion -Wno-documentation -Wno-missing-variable-declarations -Wno-cast-align -Wno-incompatible-pointer-types-discards-qualifiers -Wno-missing-variable-declarations -Wno-missing-field-initializers -Wno-unused-macros -Wno-disabled-macro-expansion -Wno-conditional-uninitialized -Wno-switch-enum";
|
||||
|
||||
my $strict_warnings = 0;
|
||||
|
||||
my $x86_gcc_des="DES_PTR DES_RISC1 DES_UNROLL";
|
||||
@@ -349,8 +351,34 @@ my %table=(
|
||||
# throw in -D[BL]_ENDIAN, whichever appropriate...
|
||||
"linux-generic32","gcc:-DTERMIO -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-ppc", "gcc:-DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:${ppc32_asm}:linux32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
# It's believed that majority of ARM toolchains predefine appropriate -march.
|
||||
# If you compiler does not, do complement config command line with one!
|
||||
|
||||
#######################################################################
|
||||
# Note that -march is not among compiler options in below linux-armv4
|
||||
# target line. Not specifying one is intentional to give you choice to:
|
||||
#
|
||||
# a) rely on your compiler default by not specifying one;
|
||||
# b) specify your target platform explicitly for optimal performance,
|
||||
# e.g. -march=armv6 or -march=armv7-a;
|
||||
# c) build "universal" binary that targets *range* of platforms by
|
||||
# specifying minimum and maximum supported architecture;
|
||||
#
|
||||
# As for c) option. It actually makes no sense to specify maximum to be
|
||||
# less than ARMv7, because it's the least requirement for run-time
|
||||
# switch between platform-specific code paths. And without run-time
|
||||
# switch performance would be equivalent to one for minimum. Secondly,
|
||||
# there are some natural limitations that you'd have to accept and
|
||||
# respect. Most notably you can *not* build "universal" binary for
|
||||
# big-endian platform. This is because ARMv7 processor always picks
|
||||
# instructions in little-endian order. Another similar limitation is
|
||||
# that -mthumb can't "cross" -march=armv6t2 boundary, because that's
|
||||
# where it became Thumb-2. Well, this limitation is a bit artificial,
|
||||
# because it's not really impossible, but it's deemed too tricky to
|
||||
# support. And of course you have to be sure that your binutils are
|
||||
# actually up to the task of handling maximum target platform. With all
|
||||
# this in mind here is an example of how to configure "universal" build:
|
||||
#
|
||||
# ./Configure linux-armv4 -march=armv6 -D__ARM_MAX_ARCH__=8
|
||||
#
|
||||
"linux-armv4", "gcc:-DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-aarch64","gcc:-DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
# Configure script adds minimally required -march for assembly support,
|
||||
@@ -371,6 +399,7 @@ my %table=(
|
||||
"linux-ia64", "gcc:-DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_UNROLL DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-ia64-icc","icc:-DL_ENDIAN -DTERMIO -O2 -Wall::-D_REENTRANT::-ldl -no_cpprt:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_INT:${ia64_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
|
||||
"linux-x86_64", "gcc:-m64 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
"linux-x86_64-clang", "clang: -m64 -DL_ENDIAN -DTERMIO -O3 -Weverything $clang_disabled_warnings -Qunused-arguments::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
"linux-x86_64-icc", "icc:-DL_ENDIAN -DTERMIO -O2::-D_REENTRANT::-ldl -no_cpprt:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
"linux-x32", "gcc:-mx32 -DL_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT DES_UNROLL:${x86_64_asm}:elf:dlfcn:linux-shared:-fPIC:-mx32:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::x32",
|
||||
"linux64-s390x", "gcc:-m64 -DB_ENDIAN -DTERMIO -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${s390x_asm}:64:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64",
|
||||
@@ -822,6 +851,11 @@ PROCESS_ARGS:
|
||||
{
|
||||
$disabled{"tls1"} = "option(tls)"
|
||||
}
|
||||
elsif ($1 eq "ssl3-method")
|
||||
{
|
||||
$disabled{"ssl3-method"} = "option(ssl)";
|
||||
$disabled{"ssl3"} = "option(ssl)";
|
||||
}
|
||||
else
|
||||
{
|
||||
$disabled{$1} = "option";
|
||||
@@ -1600,7 +1634,7 @@ if ($shlib_version_number =~ /(^[0-9]*)\.([0-9\.]*)/)
|
||||
if ($strict_warnings)
|
||||
{
|
||||
my $wopt;
|
||||
die "ERROR --strict-warnings requires gcc" unless ($cc =~ /gcc$/);
|
||||
die "ERROR --strict-warnings requires gcc or clang" unless ($cc =~ /gcc$/ or $cc =~ /clang$/);
|
||||
foreach $wopt (split /\s+/, $gcc_devteam_warn)
|
||||
{
|
||||
$cflags .= " $wopt" unless ($cflags =~ /$wopt/)
|
||||
|
9
NEWS
9
NEWS
@@ -5,7 +5,7 @@
|
||||
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.1i and OpenSSL 1.0.2 [in beta]:
|
||||
Major changes between OpenSSL 1.0.1j and OpenSSL 1.0.2 [in beta]:
|
||||
|
||||
o Suite B support for TLS 1.2 and DTLS 1.2
|
||||
o Support for DTLS 1.2
|
||||
@@ -16,6 +16,13 @@
|
||||
o ALPN support.
|
||||
o CMS support for RSA-PSS, RSA-OAEP, ECDH and X9.42 DH.
|
||||
|
||||
Major changes between OpenSSL 1.0.1i and OpenSSL 1.0.1j [15 Oct 2014]
|
||||
|
||||
o Fix for CVE-2014-3513
|
||||
o Fix for CVE-2014-3567
|
||||
o Mitigation for CVE-2014-3566 (SSL protocol vulnerability)
|
||||
o Fix for CVE-2014-3568
|
||||
|
||||
Major changes between OpenSSL 1.0.1h and OpenSSL 1.0.1i [6 Aug 2014]
|
||||
|
||||
o Fix for CVE-2014-3512
|
||||
|
2
README
2
README
@@ -1,5 +1,5 @@
|
||||
|
||||
OpenSSL 1.0.2-beta3 25 Sep 2014
|
||||
OpenSSL 1.0.2-beta4-dev
|
||||
|
||||
Copyright (c) 1998-2011 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
|
34
TABLE
34
TABLE
@@ -4828,6 +4828,40 @@ $ranlib =
|
||||
$arflags =
|
||||
$multilib = 64
|
||||
|
||||
*** linux-x86_64-clang
|
||||
$cc = clang
|
||||
$cflags = -m64 -DL_ENDIAN -DTERMIO -O3 -Weverything -Wno-language-extension-token -Wno-extended-offsetof -Wno-padded -Wno-shorten-64-to-32 -Wno-format-nonliteral -Wno-missing-noreturn -Wno-unused-parameter -Wno-sign-conversion -Wno-unreachable-code -Wno-conversion -Wno-documentation -Wno-missing-variable-declarations -Wno-cast-align -Wno-incompatible-pointer-types-discards-qualifiers -Wno-missing-variable-declarations -Wno-missing-field-initializers -Wno-unused-macros -Wno-disabled-macro-expansion -Wno-conditional-uninitialized -Wno-switch-enum -Qunused-arguments
|
||||
$unistd =
|
||||
$thread_cflag = -D_REENTRANT
|
||||
$sys_id =
|
||||
$lflags = -ldl
|
||||
$bn_ops = SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL
|
||||
$cpuid_obj = x86_64cpuid.o
|
||||
$bn_obj = x86_64-gcc.o x86_64-mont.o x86_64-mont5.o x86_64-gf2m.o rsaz_exp.o rsaz-x86_64.o rsaz-avx2.o
|
||||
$ec_obj = ecp_nistz256.o ecp_nistz256-x86_64.o
|
||||
$des_obj =
|
||||
$aes_obj = aes-x86_64.o vpaes-x86_64.o bsaes-x86_64.o aesni-x86_64.o aesni-sha1-x86_64.o aesni-sha256-x86_64.o aesni-mb-x86_64.o
|
||||
$bf_obj =
|
||||
$md5_obj = md5-x86_64.o
|
||||
$sha1_obj = sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o sha1-mb-x86_64.o sha256-mb-x86_64.o
|
||||
$cast_obj =
|
||||
$rc4_obj = rc4-x86_64.o rc4-md5-x86_64.o
|
||||
$rmd160_obj =
|
||||
$rc5_obj =
|
||||
$wp_obj = wp-x86_64.o
|
||||
$cmll_obj = cmll-x86_64.o cmll_misc.o
|
||||
$modes_obj = ghash-x86_64.o aesni-gcm-x86_64.o
|
||||
$engines_obj =
|
||||
$perlasm_scheme = elf
|
||||
$dso_scheme = dlfcn
|
||||
$shared_target= linux-shared
|
||||
$shared_cflag = -fPIC
|
||||
$shared_ldflag = -m64
|
||||
$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
|
||||
$ranlib =
|
||||
$arflags =
|
||||
$multilib = 64
|
||||
|
||||
*** linux-x86_64-icc
|
||||
$cc = icc
|
||||
$cflags = -DL_ENDIAN -DTERMIO -O2
|
||||
|
@@ -709,7 +709,7 @@ bad:
|
||||
ERR_clear_error();
|
||||
#ifdef RL_DEBUG
|
||||
if (!p)
|
||||
BIO_printf(bio_err, "DEBUG: unique_subject undefined\n", p);
|
||||
BIO_printf(bio_err, "DEBUG: unique_subject undefined\n");
|
||||
#endif
|
||||
#ifdef RL_DEBUG
|
||||
BIO_printf(bio_err, "DEBUG: configured unique_subject is %d\n",
|
||||
|
@@ -276,6 +276,8 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf(bio_err,"-d to output debug info\n");
|
||||
BIO_printf(bio_err,"-hex output as hex dump\n");
|
||||
BIO_printf(bio_err,"-binary output in binary form\n");
|
||||
BIO_printf(bio_err,"-hmac arg set the HMAC key to arg\n");
|
||||
BIO_printf(bio_err,"-non-fips-allow allow use of non FIPS digest\n");
|
||||
BIO_printf(bio_err,"-sign file sign digest using private key in file\n");
|
||||
BIO_printf(bio_err,"-verify file verify a signature using public key in file\n");
|
||||
BIO_printf(bio_err,"-prverify file verify a signature using private key in file\n");
|
||||
|
98
apps/ocsp.c
98
apps/ocsp.c
@@ -604,51 +604,52 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf (bio_err, "OCSP utility\n");
|
||||
BIO_printf (bio_err, "Usage ocsp [options]\n");
|
||||
BIO_printf (bio_err, "where options are\n");
|
||||
BIO_printf (bio_err, "-out file output filename\n");
|
||||
BIO_printf (bio_err, "-issuer file issuer certificate\n");
|
||||
BIO_printf (bio_err, "-cert file certificate to check\n");
|
||||
BIO_printf (bio_err, "-serial n serial number to check\n");
|
||||
BIO_printf (bio_err, "-signer file certificate to sign OCSP request with\n");
|
||||
BIO_printf (bio_err, "-signkey file private key to sign OCSP request with\n");
|
||||
BIO_printf (bio_err, "-sign_other file additional certificates to include in signed request\n");
|
||||
BIO_printf (bio_err, "-no_certs don't include any certificates in signed request\n");
|
||||
BIO_printf (bio_err, "-req_text print text form of request\n");
|
||||
BIO_printf (bio_err, "-resp_text print text form of response\n");
|
||||
BIO_printf (bio_err, "-text print text form of request and response\n");
|
||||
BIO_printf (bio_err, "-reqout file write DER encoded OCSP request to \"file\"\n");
|
||||
BIO_printf (bio_err, "-respout file write DER encoded OCSP reponse to \"file\"\n");
|
||||
BIO_printf (bio_err, "-reqin file read DER encoded OCSP request from \"file\"\n");
|
||||
BIO_printf (bio_err, "-respin file read DER encoded OCSP reponse from \"file\"\n");
|
||||
BIO_printf (bio_err, "-nonce add OCSP nonce to request\n");
|
||||
BIO_printf (bio_err, "-no_nonce don't add OCSP nonce to request\n");
|
||||
BIO_printf (bio_err, "-url URL OCSP responder URL\n");
|
||||
BIO_printf (bio_err, "-host host:n send OCSP request to host on port n\n");
|
||||
BIO_printf (bio_err, "-path path to use in OCSP request\n");
|
||||
BIO_printf (bio_err, "-CApath dir trusted certificates directory\n");
|
||||
BIO_printf (bio_err, "-CAfile file trusted certificates file\n");
|
||||
BIO_printf (bio_err, "-VAfile file validator certificates file\n");
|
||||
BIO_printf (bio_err, "-validity_period n maximum validity discrepancy in seconds\n");
|
||||
BIO_printf (bio_err, "-status_age n maximum status age in seconds\n");
|
||||
BIO_printf (bio_err, "-noverify don't verify response at all\n");
|
||||
BIO_printf (bio_err, "-verify_other file additional certificates to search for signer\n");
|
||||
BIO_printf (bio_err, "-trust_other don't verify additional certificates\n");
|
||||
BIO_printf (bio_err, "-no_intern don't search certificates contained in response for signer\n");
|
||||
BIO_printf (bio_err, "-out file output filename\n");
|
||||
BIO_printf (bio_err, "-issuer file issuer certificate\n");
|
||||
BIO_printf (bio_err, "-cert file certificate to check\n");
|
||||
BIO_printf (bio_err, "-serial n serial number to check\n");
|
||||
BIO_printf (bio_err, "-signer file certificate to sign OCSP request with\n");
|
||||
BIO_printf (bio_err, "-signkey file private key to sign OCSP request with\n");
|
||||
BIO_printf (bio_err, "-sign_other file additional certificates to include in signed request\n");
|
||||
BIO_printf (bio_err, "-no_certs don't include any certificates in signed request\n");
|
||||
BIO_printf (bio_err, "-req_text print text form of request\n");
|
||||
BIO_printf (bio_err, "-resp_text print text form of response\n");
|
||||
BIO_printf (bio_err, "-text print text form of request and response\n");
|
||||
BIO_printf (bio_err, "-reqout file write DER encoded OCSP request to \"file\"\n");
|
||||
BIO_printf (bio_err, "-respout file write DER encoded OCSP reponse to \"file\"\n");
|
||||
BIO_printf (bio_err, "-reqin file read DER encoded OCSP request from \"file\"\n");
|
||||
BIO_printf (bio_err, "-respin file read DER encoded OCSP reponse from \"file\"\n");
|
||||
BIO_printf (bio_err, "-nonce add OCSP nonce to request\n");
|
||||
BIO_printf (bio_err, "-no_nonce don't add OCSP nonce to request\n");
|
||||
BIO_printf (bio_err, "-url URL OCSP responder URL\n");
|
||||
BIO_printf (bio_err, "-host host:n send OCSP request to host on port n\n");
|
||||
BIO_printf (bio_err, "-path path to use in OCSP request\n");
|
||||
BIO_printf (bio_err, "-CApath dir trusted certificates directory\n");
|
||||
BIO_printf (bio_err, "-CAfile file trusted certificates file\n");
|
||||
BIO_printf (bio_err, "-VAfile file validator certificates file\n");
|
||||
BIO_printf (bio_err, "-validity_period n maximum validity discrepancy in seconds\n");
|
||||
BIO_printf (bio_err, "-status_age n maximum status age in seconds\n");
|
||||
BIO_printf (bio_err, "-noverify don't verify response at all\n");
|
||||
BIO_printf (bio_err, "-verify_other file additional certificates to search for signer\n");
|
||||
BIO_printf (bio_err, "-trust_other don't verify additional certificates\n");
|
||||
BIO_printf (bio_err, "-no_intern don't search certificates contained in response for signer\n");
|
||||
BIO_printf (bio_err, "-no_signature_verify don't check signature on response\n");
|
||||
BIO_printf (bio_err, "-no_cert_verify don't check signing certificate\n");
|
||||
BIO_printf (bio_err, "-no_chain don't chain verify response\n");
|
||||
BIO_printf (bio_err, "-no_cert_checks don't do additional checks on signing certificate\n");
|
||||
BIO_printf (bio_err, "-port num port to run responder on\n");
|
||||
BIO_printf (bio_err, "-index file certificate status index file\n");
|
||||
BIO_printf (bio_err, "-CA file CA certificate\n");
|
||||
BIO_printf (bio_err, "-rsigner file responder certificate to sign responses with\n");
|
||||
BIO_printf (bio_err, "-rkey file responder key to sign responses with\n");
|
||||
BIO_printf (bio_err, "-rother file other certificates to include in response\n");
|
||||
BIO_printf (bio_err, "-resp_no_certs don't include any certificates in response\n");
|
||||
BIO_printf (bio_err, "-nmin n number of minutes before next update\n");
|
||||
BIO_printf (bio_err, "-ndays n number of days before next update\n");
|
||||
BIO_printf (bio_err, "-resp_key_id identify reponse by signing certificate key ID\n");
|
||||
BIO_printf (bio_err, "-nrequest n number of requests to accept (default unlimited)\n");
|
||||
BIO_printf (bio_err, "-<dgst alg> use specified digest in the request\n");
|
||||
BIO_printf (bio_err, "-no_cert_verify don't check signing certificate\n");
|
||||
BIO_printf (bio_err, "-no_chain don't chain verify response\n");
|
||||
BIO_printf (bio_err, "-no_cert_checks don't do additional checks on signing certificate\n");
|
||||
BIO_printf (bio_err, "-port num port to run responder on\n");
|
||||
BIO_printf (bio_err, "-index file certificate status index file\n");
|
||||
BIO_printf (bio_err, "-CA file CA certificate\n");
|
||||
BIO_printf (bio_err, "-rsigner file responder certificate to sign responses with\n");
|
||||
BIO_printf (bio_err, "-rkey file responder key to sign responses with\n");
|
||||
BIO_printf (bio_err, "-rother file other certificates to include in response\n");
|
||||
BIO_printf (bio_err, "-resp_no_certs don't include any certificates in response\n");
|
||||
BIO_printf (bio_err, "-nmin n number of minutes before next update\n");
|
||||
BIO_printf (bio_err, "-ndays n number of days before next update\n");
|
||||
BIO_printf (bio_err, "-resp_key_id identify reponse by signing certificate key ID\n");
|
||||
BIO_printf (bio_err, "-nrequest n number of requests to accept (default unlimited)\n");
|
||||
BIO_printf (bio_err, "-<dgst alg> use specified digest in the request\n");
|
||||
BIO_printf (bio_err, "-timeout n timeout connection to OCSP responder after n seconds\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -1447,16 +1448,7 @@ OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
|
||||
if (use_ssl == 1)
|
||||
{
|
||||
BIO *sbio;
|
||||
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
|
||||
ctx = SSL_CTX_new(SSLv23_client_method());
|
||||
#elif !defined(OPENSSL_NO_SSL3)
|
||||
ctx = SSL_CTX_new(SSLv3_client_method());
|
||||
#elif !defined(OPENSSL_NO_SSL2)
|
||||
ctx = SSL_CTX_new(SSLv2_client_method());
|
||||
#else
|
||||
BIO_printf(err, "SSL is disabled\n");
|
||||
goto end;
|
||||
#endif
|
||||
if (ctx == NULL)
|
||||
{
|
||||
BIO_printf(err, "Error creating SSL context.\n");
|
||||
|
@@ -435,9 +435,7 @@ end:
|
||||
if (prog != NULL) lh_FUNCTION_free(prog);
|
||||
if (arg.data != NULL) OPENSSL_free(arg.data);
|
||||
|
||||
apps_shutdown();
|
||||
|
||||
CRYPTO_mem_leaks(bio_err);
|
||||
if (bio_err != NULL)
|
||||
{
|
||||
BIO_free(bio_err);
|
||||
@@ -450,6 +448,9 @@ end:
|
||||
OPENSSL_free(Argv);
|
||||
}
|
||||
#endif
|
||||
apps_shutdown();
|
||||
CRYPTO_mem_leaks(bio_err);
|
||||
|
||||
OPENSSL_EXIT(ret);
|
||||
}
|
||||
|
||||
|
23
apps/s_cb.c
23
apps/s_cb.c
@@ -1250,7 +1250,7 @@ struct chain_flags chain_flags_list[] =
|
||||
};
|
||||
|
||||
|
||||
static void print_chain_flags(BIO *out, int flags)
|
||||
static void print_chain_flags(BIO *out, SSL *s, int flags)
|
||||
{
|
||||
struct chain_flags *ctmp = chain_flags_list;
|
||||
while(ctmp->name)
|
||||
@@ -1259,6 +1259,11 @@ static void print_chain_flags(BIO *out, int flags)
|
||||
flags & ctmp->flag ? "OK" : "NOT OK");
|
||||
ctmp++;
|
||||
}
|
||||
BIO_printf(out, "\tSuite B: ");
|
||||
if (SSL_set_cert_flags(s, 0) & SSL_CERT_FLAG_SUITEB_128_LOS)
|
||||
BIO_puts(out, flags & CERT_PKEY_SUITEB ? "OK\n" : "NOT OK\n");
|
||||
else
|
||||
BIO_printf(out, "not tested\n");
|
||||
}
|
||||
|
||||
/* Very basic selection callback: just use any certificate chain
|
||||
@@ -1301,7 +1306,7 @@ static int set_cert_cb(SSL *ssl, void *arg)
|
||||
XN_FLAG_ONELINE);
|
||||
BIO_puts(bio_err, "\n");
|
||||
|
||||
print_chain_flags(bio_err, rv);
|
||||
print_chain_flags(bio_err, ssl, rv);
|
||||
if (rv & CERT_PKEY_VALID)
|
||||
{
|
||||
SSL_use_certificate(ssl, exc->cert);
|
||||
@@ -1402,9 +1407,15 @@ int load_excert(SSL_EXCERT **pexc, BIO *err)
|
||||
if (!exc->cert)
|
||||
return 0;
|
||||
if (exc->keyfile)
|
||||
exc->keyfile = exc->certfile;
|
||||
exc->key = load_key(err, exc->certfile, exc->certform, 0,
|
||||
NULL, NULL, "Server Certificate");
|
||||
{
|
||||
exc->key = load_key(err, exc->keyfile, exc->keyform,
|
||||
0, NULL, NULL, "Server Key");
|
||||
}
|
||||
else
|
||||
{
|
||||
exc->key = load_key(err, exc->certfile, exc->certform,
|
||||
0, NULL, NULL, "Server Key");
|
||||
}
|
||||
if (!exc->key)
|
||||
return 0;
|
||||
if (exc->chainfile)
|
||||
@@ -1413,7 +1424,7 @@ int load_excert(SSL_EXCERT **pexc, BIO *err)
|
||||
exc->chainfile, FORMAT_PEM,
|
||||
NULL, NULL,
|
||||
"Server Chain");
|
||||
if (!exc->chainfile)
|
||||
if (!exc->chain)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -291,9 +291,9 @@ static void sc_usage(void)
|
||||
BIO_printf(bio_err," -host host - use -connect instead\n");
|
||||
BIO_printf(bio_err," -port port - use -connect instead\n");
|
||||
BIO_printf(bio_err," -connect host:port - who to connect to (default is %s:%s)\n",SSL_HOST_NAME,PORT_STR);
|
||||
BIO_printf(bio_err," -checkhost host - check peer certificate matches \"host\"\n");
|
||||
BIO_printf(bio_err," -checkemail email - check peer certificate matches \"email\"\n");
|
||||
BIO_printf(bio_err," -checkip ipaddr - check peer certificate matches \"ipaddr\"\n");
|
||||
BIO_printf(bio_err," -verify_host host - check peer certificate matches \"host\"\n");
|
||||
BIO_printf(bio_err," -verify_email email - check peer certificate matches \"email\"\n");
|
||||
BIO_printf(bio_err," -verify_ip ipaddr - check peer certificate matches \"ipaddr\"\n");
|
||||
|
||||
BIO_printf(bio_err," -verify arg - turn on peer certificate verification\n");
|
||||
BIO_printf(bio_err," -verify_return_error - return verification errors\n");
|
||||
@@ -335,14 +335,17 @@ static void sc_usage(void)
|
||||
BIO_printf(bio_err," -srppass arg - password for 'user'\n");
|
||||
BIO_printf(bio_err," -srp_lateuser - SRP username into second ClientHello message\n");
|
||||
BIO_printf(bio_err," -srp_moregroups - Tolerate other than the known g N values.\n");
|
||||
BIO_printf(bio_err," -srp_strength int - minimal mength in bits for N (default %d).\n",SRP_MINIMAL_N);
|
||||
BIO_printf(bio_err," -srp_strength int - minimal length in bits for N (default %d).\n",SRP_MINIMAL_N);
|
||||
#endif
|
||||
BIO_printf(bio_err," -ssl2 - just use SSLv2\n");
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
BIO_printf(bio_err," -ssl3 - just use SSLv3\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -tls1_2 - just use TLSv1.2\n");
|
||||
BIO_printf(bio_err," -tls1_1 - just use TLSv1.1\n");
|
||||
BIO_printf(bio_err," -tls1 - just use TLSv1\n");
|
||||
BIO_printf(bio_err," -dtls1 - just use DTLSv1\n");
|
||||
BIO_printf(bio_err," -fallback_scsv - send TLS_FALLBACK_SCSV\n");
|
||||
BIO_printf(bio_err," -mtu - set the link layer MTU\n");
|
||||
BIO_printf(bio_err," -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");
|
||||
@@ -372,7 +375,9 @@ static void sc_usage(void)
|
||||
# endif
|
||||
BIO_printf(bio_err," -alpn arg - enable ALPN extension, considering named protocols supported (comma-separated list)\n");
|
||||
BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n");
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -keymatexport label - Export keying material using label\n");
|
||||
BIO_printf(bio_err," -keymatexportlen len - Export len bytes of keying material (default 20)\n");
|
||||
}
|
||||
@@ -512,7 +517,9 @@ static char * MS_CALLBACK ssl_give_srp_client_pwd_cb(SSL *s, void *arg)
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
char *srtp_profiles = NULL;
|
||||
#endif
|
||||
|
||||
# ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
/* This the context that we pass to next_proto_cb */
|
||||
@@ -649,6 +656,7 @@ int MAIN(int argc, char **argv)
|
||||
char *sess_out = NULL;
|
||||
struct sockaddr peer;
|
||||
int peerlen = sizeof(peer);
|
||||
int fallback_scsv = 0;
|
||||
int enable_timeouts = 0 ;
|
||||
long socket_mtu = 0;
|
||||
#ifndef OPENSSL_NO_JPAKE
|
||||
@@ -897,7 +905,7 @@ static char *jpake_secret = NULL;
|
||||
else if (strcmp(*argv,"-ssl2") == 0)
|
||||
meth=SSLv2_client_method();
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
else if (strcmp(*argv,"-ssl3") == 0)
|
||||
meth=SSLv3_client_method();
|
||||
#endif
|
||||
@@ -933,6 +941,10 @@ static char *jpake_secret = NULL;
|
||||
socket_mtu = atol(*(++argv));
|
||||
}
|
||||
#endif
|
||||
else if (strcmp(*argv,"-fallback_scsv") == 0)
|
||||
{
|
||||
fallback_scsv = 1;
|
||||
}
|
||||
else if (strcmp(*argv,"-keyform") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
@@ -1079,11 +1091,13 @@ static char *jpake_secret = NULL;
|
||||
jpake_secret = *++argv;
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
else if (strcmp(*argv,"-use_srtp") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
srtp_profiles = *(++argv);
|
||||
}
|
||||
#endif
|
||||
else if (strcmp(*argv,"-keymatexport") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
@@ -1305,6 +1319,8 @@ bad:
|
||||
BIO_printf(bio_c_out, "PSK key given or JPAKE in use, setting client callback\n");
|
||||
SSL_CTX_set_psk_client_callback(ctx, psk_client_cb);
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
if (srtp_profiles != NULL)
|
||||
SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles);
|
||||
#endif
|
||||
@@ -1415,6 +1431,10 @@ bad:
|
||||
SSL_set_session(con, sess);
|
||||
SSL_SESSION_free(sess);
|
||||
}
|
||||
|
||||
if (fallback_scsv)
|
||||
SSL_set_mode(con, SSL_MODE_SEND_FALLBACK_SCSV);
|
||||
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
if (servername != NULL)
|
||||
{
|
||||
@@ -1489,10 +1509,22 @@ re_start:
|
||||
BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout);
|
||||
}
|
||||
|
||||
if (socket_mtu > 28)
|
||||
if (socket_mtu)
|
||||
{
|
||||
if(socket_mtu < DTLS_get_link_min_mtu(con))
|
||||
{
|
||||
BIO_printf(bio_err,"MTU too small. Must be at least %ld\n",
|
||||
DTLS_get_link_min_mtu(con));
|
||||
BIO_free(sbio);
|
||||
goto shut;
|
||||
}
|
||||
SSL_set_options(con, SSL_OP_NO_QUERY_MTU);
|
||||
SSL_set_mtu(con, socket_mtu - 28);
|
||||
if(!DTLS_set_link_mtu(con, socket_mtu))
|
||||
{
|
||||
BIO_printf(bio_err, "Failed to set MTU\n");
|
||||
BIO_free(sbio);
|
||||
goto shut;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* want to do MTU discovery */
|
||||
@@ -2308,6 +2340,7 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
{
|
||||
SRTP_PROTECTION_PROFILE *srtp_profile=SSL_get_selected_srtp_profile(s);
|
||||
|
||||
@@ -2315,6 +2348,7 @@ static void print_stuff(BIO *bio, SSL *s, int full)
|
||||
BIO_printf(bio,"SRTP Extension negotiated, profile=%s\n",
|
||||
srtp_profile->name);
|
||||
}
|
||||
#endif
|
||||
|
||||
SSL_SESSION_print(bio,SSL_get_session(s));
|
||||
if (keymatexportlabel != NULL)
|
||||
|
@@ -473,9 +473,9 @@ static void sv_usage(void)
|
||||
BIO_printf(bio_err,"usage: s_server [args ...]\n");
|
||||
BIO_printf(bio_err,"\n");
|
||||
BIO_printf(bio_err," -accept arg - port to accept on (default is %d)\n",PORT);
|
||||
BIO_printf(bio_err," -checkhost host - check peer certificate matches \"host\"\n");
|
||||
BIO_printf(bio_err," -checkemail email - check peer certificate matches \"email\"\n");
|
||||
BIO_printf(bio_err," -checkip ipaddr - check peer certificate matches \"ipaddr\"\n");
|
||||
BIO_printf(bio_err," -verify_host host - check peer certificate matches \"host\"\n");
|
||||
BIO_printf(bio_err," -verify_email email - check peer certificate matches \"email\"\n");
|
||||
BIO_printf(bio_err," -verify_ip ipaddr - check peer certificate matches \"ipaddr\"\n");
|
||||
BIO_printf(bio_err," -context arg - set session ID context\n");
|
||||
BIO_printf(bio_err," -verify arg - turn on peer certificate verification\n");
|
||||
BIO_printf(bio_err," -Verify arg - turn on peer certificate verification, must have a cert.\n");
|
||||
@@ -537,7 +537,9 @@ static void sv_usage(void)
|
||||
BIO_printf(bio_err," -srpuserseed string - A seed string for a default user salt.\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -ssl2 - Just talk SSLv2\n");
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
BIO_printf(bio_err," -ssl3 - Just talk SSLv3\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -tls1_2 - Just talk TLSv1.2\n");
|
||||
BIO_printf(bio_err," -tls1_1 - Just talk TLSv1.1\n");
|
||||
BIO_printf(bio_err," -tls1 - Just talk TLSv1\n");
|
||||
@@ -581,7 +583,9 @@ static void sv_usage(void)
|
||||
# ifndef OPENSSL_NO_NEXTPROTONEG
|
||||
BIO_printf(bio_err," -nextprotoneg arg - set the advertised protocols for the NPN extension (comma-separated list)\n");
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_SRTP
|
||||
BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n");
|
||||
# endif
|
||||
BIO_printf(bio_err," -alpn arg - set the advertised protocols for the ALPN extension (comma-separated list)\n");
|
||||
#endif
|
||||
BIO_printf(bio_err," -keymatexport label - Export keying material using label\n");
|
||||
@@ -995,7 +999,9 @@ static char *jpake_secret = NULL;
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
static srpsrvparm srp_callback_parm;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
static char *srtp_profiles = NULL;
|
||||
#endif
|
||||
|
||||
int MAIN(int argc, char *argv[])
|
||||
{
|
||||
@@ -1398,9 +1404,12 @@ int MAIN(int argc, char *argv[])
|
||||
{ www=3; }
|
||||
#ifndef OPENSSL_NO_SSL2
|
||||
else if (strcmp(*argv,"-ssl2") == 0)
|
||||
{ meth=SSLv2_server_method(); }
|
||||
{
|
||||
no_ecdhe=1;
|
||||
meth=SSLv2_server_method();
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
else if (strcmp(*argv,"-ssl3") == 0)
|
||||
{ meth=SSLv3_server_method(); }
|
||||
#endif
|
||||
@@ -1493,11 +1502,13 @@ int MAIN(int argc, char *argv[])
|
||||
jpake_secret = *(++argv);
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
else if (strcmp(*argv,"-use_srtp") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
srtp_profiles = *(++argv);
|
||||
}
|
||||
#endif
|
||||
else if (strcmp(*argv,"-keymatexport") == 0)
|
||||
{
|
||||
if (--argc < 1) goto bad;
|
||||
@@ -1775,8 +1786,10 @@ bad:
|
||||
else
|
||||
SSL_CTX_sess_set_cache_size(ctx,128);
|
||||
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
if (srtp_profiles != NULL)
|
||||
SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (cipher == NULL) cipher=getenv("SSL_CIPHER");
|
||||
@@ -2248,10 +2261,24 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
BIO_ctrl(sbio, BIO_CTRL_DGRAM_SET_SEND_TIMEOUT, 0, &timeout);
|
||||
}
|
||||
|
||||
if (socket_mtu > 28)
|
||||
if (socket_mtu)
|
||||
{
|
||||
if(socket_mtu < DTLS_get_link_min_mtu(con))
|
||||
{
|
||||
BIO_printf(bio_err,"MTU too small. Must be at least %ld\n",
|
||||
DTLS_get_link_min_mtu(con));
|
||||
ret = -1;
|
||||
BIO_free(sbio);
|
||||
goto err;
|
||||
}
|
||||
SSL_set_options(con, SSL_OP_NO_QUERY_MTU);
|
||||
SSL_set_mtu(con, socket_mtu - 28);
|
||||
if(!DTLS_set_link_mtu(con, socket_mtu))
|
||||
{
|
||||
BIO_printf(bio_err, "Failed to set MTU\n");
|
||||
ret = -1;
|
||||
BIO_free(sbio);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* want to do MTU discovery */
|
||||
@@ -2694,6 +2721,7 @@ static int init_ssl_connection(SSL *con)
|
||||
BIO_printf(bio_s_out, "\n");
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRTP
|
||||
{
|
||||
SRTP_PROTECTION_PROFILE *srtp_profile
|
||||
= SSL_get_selected_srtp_profile(con);
|
||||
@@ -2702,6 +2730,7 @@ static int init_ssl_connection(SSL *con)
|
||||
BIO_printf(bio_s_out,"SRTP Extension negotiated, profile=%s\n",
|
||||
srtp_profile->name);
|
||||
}
|
||||
#endif
|
||||
if (SSL_cache_hit(con)) BIO_printf(bio_s_out,"Reused session-id\n");
|
||||
if (SSL_ctrl(con,SSL_CTRL_GET_FLAGS,0,NULL) &
|
||||
TLS1_FLAGS_TLS_PADDING_BUG)
|
||||
|
@@ -349,13 +349,7 @@ int MAIN(int argc, char **argv)
|
||||
if (bio_err == NULL)
|
||||
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
|
||||
|
||||
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
|
||||
s_time_meth=SSLv23_client_method();
|
||||
#elif !defined(OPENSSL_NO_SSL3)
|
||||
s_time_meth=SSLv3_client_method();
|
||||
#elif !defined(OPENSSL_NO_SSL2)
|
||||
s_time_meth=SSLv2_client_method();
|
||||
#endif
|
||||
|
||||
/* parse the command line arguments */
|
||||
if( parseArgs( argc, argv ) < 0 )
|
||||
|
23
apps/speed.c
23
apps/speed.c
@@ -225,7 +225,7 @@
|
||||
|
||||
#undef BUFSIZE
|
||||
#define BUFSIZE ((long)1024*8+1)
|
||||
int run=0;
|
||||
static volatile int run=0;
|
||||
|
||||
static int mr=0;
|
||||
static int usertime=1;
|
||||
@@ -2747,27 +2747,6 @@ static int do_multi(int multi)
|
||||
k=atoi(sstrsep(&p,sep));
|
||||
sstrsep(&p,sep);
|
||||
|
||||
d=atof(sstrsep(&p,sep));
|
||||
if(n)
|
||||
rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
|
||||
else
|
||||
rsa_results[k][0]=d;
|
||||
|
||||
d=atof(sstrsep(&p,sep));
|
||||
if(n)
|
||||
rsa_results[k][1]=1/(1/rsa_results[k][1]+1/d);
|
||||
else
|
||||
rsa_results[k][1]=d;
|
||||
}
|
||||
else if(!strncmp(buf,"+F2:",4))
|
||||
{
|
||||
int k;
|
||||
double d;
|
||||
|
||||
p=buf+4;
|
||||
k=atoi(sstrsep(&p,sep));
|
||||
sstrsep(&p,sep);
|
||||
|
||||
d=atof(sstrsep(&p,sep));
|
||||
if(n)
|
||||
rsa_results[k][0]=1/(1/rsa_results[k][0]+1/d);
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#if defined(LP_SYS_WINCE) && !defined(FindFirstFile)
|
||||
# define FindFirstFile FindFirstFileW
|
||||
#endif
|
||||
#if defined(LP_SYS_WINCE) && !defined(FindFirstFile)
|
||||
#if defined(LP_SYS_WINCE) && !defined(FindNextFile)
|
||||
# define FindNextFile FindNextFileW
|
||||
#endif
|
||||
|
||||
|
@@ -55,12 +55,7 @@ top:
|
||||
all: shared
|
||||
|
||||
buildinf.h: ../Makefile
|
||||
( echo "#ifndef MK1MF_BUILD"; \
|
||||
echo ' /* auto-generated by crypto/Makefile for crypto/cversion.c */'; \
|
||||
echo ' #define CFLAGS "$(CC) $(CFLAG)"'; \
|
||||
echo ' #define PLATFORM "$(PLATFORM)"'; \
|
||||
echo " #define DATE \"`LC_ALL=C LC_TIME=C date`\""; \
|
||||
echo '#endif' ) >buildinf.h
|
||||
$(PERL) $(TOP)/util/mkbuildinf.pl "$(CC) $(CFLAGS)" "$(PLATFORM)" >buildinf.h
|
||||
|
||||
x86cpuid.s: x86cpuid.pl perlasm/x86asm.pl
|
||||
$(PERL) x86cpuid.pl $(PERLASM_SCHEME) $(CFLAGS) $(PROCESSOR) > $@
|
||||
|
@@ -79,7 +79,7 @@ $pf = ($flavour =~ /nubi/i) ? $t0 : $t2;
|
||||
#
|
||||
######################################################################
|
||||
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -P -`=~/MIPSEL/)?1:0;
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -`=~/MIPSEL/)?1:0 if ($ENV{CC});
|
||||
|
||||
for (@ARGV) { $output=$_ if (/^\w[\w\-]*\.\w+$/); }
|
||||
open STDOUT,">$output";
|
||||
|
@@ -584,6 +584,16 @@ $code.=<<___;
|
||||
.type aesni_ecb_encrypt,\@function,5
|
||||
.align 16
|
||||
aesni_ecb_encrypt:
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
lea -0x58(%rsp),%rsp
|
||||
movaps %xmm6,(%rsp)
|
||||
movaps %xmm7,0x10(%rsp)
|
||||
movaps %xmm8,0x20(%rsp)
|
||||
movaps %xmm9,0x30(%rsp)
|
||||
.Lecb_enc_body:
|
||||
___
|
||||
$code.=<<___;
|
||||
and \$-16,$len
|
||||
jz .Lecb_ret
|
||||
|
||||
@@ -862,6 +872,16 @@ $code.=<<___;
|
||||
movups $inout5,0x50($out)
|
||||
|
||||
.Lecb_ret:
|
||||
___
|
||||
$code.=<<___ if ($win64);
|
||||
movaps (%rsp),%xmm6
|
||||
movaps 0x10(%rsp),%xmm7
|
||||
movaps 0x20(%rsp),%xmm8
|
||||
movaps 0x30(%rsp),%xmm9
|
||||
lea 0x58(%rsp),%rsp
|
||||
.Lecb_enc_ret:
|
||||
___
|
||||
$code.=<<___;
|
||||
ret
|
||||
.size aesni_ecb_encrypt,.-aesni_ecb_encrypt
|
||||
___
|
||||
@@ -3225,28 +3245,9 @@ $code.=<<___;
|
||||
.extern __imp_RtlVirtualUnwind
|
||||
___
|
||||
$code.=<<___ if ($PREFIX eq "aesni");
|
||||
.type ecb_se_handler,\@abi-omnipotent
|
||||
.type ecb_ccm64_se_handler,\@abi-omnipotent
|
||||
.align 16
|
||||
ecb_se_handler:
|
||||
push %rsi
|
||||
push %rdi
|
||||
push %rbx
|
||||
push %rbp
|
||||
push %r12
|
||||
push %r13
|
||||
push %r14
|
||||
push %r15
|
||||
pushfq
|
||||
sub \$64,%rsp
|
||||
|
||||
mov 152($context),%rax # pull context->Rsp
|
||||
|
||||
jmp .Lcommon_seh_tail
|
||||
.size ecb_se_handler,.-ecb_se_handler
|
||||
|
||||
.type ccm64_se_handler,\@abi-omnipotent
|
||||
.align 16
|
||||
ccm64_se_handler:
|
||||
ecb_ccm64_se_handler:
|
||||
push %rsi
|
||||
push %rdi
|
||||
push %rbx
|
||||
@@ -3283,7 +3284,7 @@ ccm64_se_handler:
|
||||
lea 0x58(%rax),%rax # adjust stack pointer
|
||||
|
||||
jmp .Lcommon_seh_tail
|
||||
.size ccm64_se_handler,.-ccm64_se_handler
|
||||
.size ecb_ccm64_se_handler,.-ecb_ccm64_se_handler
|
||||
|
||||
.type ctr_xts_se_handler,\@abi-omnipotent
|
||||
.align 16
|
||||
@@ -3457,14 +3458,15 @@ ___
|
||||
$code.=<<___ if ($PREFIX eq "aesni");
|
||||
.LSEH_info_ecb:
|
||||
.byte 9,0,0,0
|
||||
.rva ecb_se_handler
|
||||
.rva ecb_ccm64_se_handler
|
||||
.rva .Lecb_enc_body,.Lecb_enc_ret # HandlerData[]
|
||||
.LSEH_info_ccm64_enc:
|
||||
.byte 9,0,0,0
|
||||
.rva ccm64_se_handler
|
||||
.rva ecb_ccm64_se_handler
|
||||
.rva .Lccm64_enc_body,.Lccm64_enc_ret # HandlerData[]
|
||||
.LSEH_info_ccm64_dec:
|
||||
.byte 9,0,0,0
|
||||
.rva ccm64_se_handler
|
||||
.rva ecb_ccm64_se_handler
|
||||
.rva .Lccm64_dec_body,.Lccm64_dec_ret # HandlerData[]
|
||||
.LSEH_info_ctr32:
|
||||
.byte 9,0,0,0
|
||||
|
@@ -35,11 +35,13 @@ $prefix="aes_v8";
|
||||
$code=<<___;
|
||||
#include "arm_arch.h"
|
||||
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.text
|
||||
___
|
||||
$code.=".arch armv8-a+crypto\n" if ($flavour =~ /64/);
|
||||
$code.=".fpu neon\n.code 32\n" if ($flavour !~ /64/);
|
||||
$code.=".arch armv8-a+crypto\n" if ($flavour =~ /64/);
|
||||
$code.=".arch armv7-a\n.fpu neon\n.code 32\n" if ($flavour !~ /64/);
|
||||
#^^^^^^ this is done to simplify adoption by not depending
|
||||
# on latest binutils.
|
||||
|
||||
# Assembler mnemonics are an eclectic mix of 32- and 64-bit syntax,
|
||||
# NEON is mostly 32-bit mnemonics, integer - mostly 64. Goal is to
|
||||
|
@@ -702,13 +702,17 @@ $code.=<<___;
|
||||
# define BSAES_ASM_EXTENDED_KEY
|
||||
# define XTS_CHAIN_TWEAK
|
||||
# define __ARM_ARCH__ __LINUX_ARM_ARCH__
|
||||
# define __ARM_MAX_ARCH__ __LINUX_ARM_ARCH__
|
||||
#endif
|
||||
|
||||
#ifdef __thumb__
|
||||
# define adrl adr
|
||||
#endif
|
||||
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.text
|
||||
.syntax unified @ ARMv7-capable assembler is expected to handle this
|
||||
#ifdef __thumb2__
|
||||
@@ -717,8 +721,6 @@ $code.=<<___;
|
||||
.code 32
|
||||
#endif
|
||||
|
||||
.fpu neon
|
||||
|
||||
.type _bsaes_decrypt8,%function
|
||||
.align 4
|
||||
_bsaes_decrypt8:
|
||||
|
@@ -52,6 +52,18 @@
|
||||
#include <openssl/fipssyms.h>
|
||||
#endif
|
||||
|
||||
#if !defined(__ARM_MAX_ARCH__)
|
||||
# define __ARM_MAX_ARCH__ __ARM_ARCH__
|
||||
#endif
|
||||
|
||||
#if __ARM_MAX_ARCH__<__ARM_ARCH__
|
||||
# error "__ARM_MAX_ARCH__ can't be less than __ARM_ARCH__"
|
||||
#elif __ARM_MAX_ARCH__!=__ARM_ARCH__
|
||||
# if __ARM_ARCH__<7 && __ARM_MAX_ARCH__>=7 && defined(__ARMEB__)
|
||||
# error "can't build universal big-endian binary"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !__ASSEMBLER__
|
||||
extern unsigned int OPENSSL_armcap_P;
|
||||
#endif
|
||||
|
@@ -7,8 +7,12 @@
|
||||
|
||||
#include "arm_arch.h"
|
||||
|
||||
unsigned int OPENSSL_armcap_P;
|
||||
unsigned int OPENSSL_armcap_P=0;
|
||||
|
||||
#if __ARM_MAX_ARCH__<7
|
||||
void OPENSSL_cpuid_setup(void) {}
|
||||
unsigned long OPENSSL_rdtsc(void) { return 0; }
|
||||
#else
|
||||
static sigset_t all_masked;
|
||||
|
||||
static sigjmp_buf ill_jmp;
|
||||
@@ -155,3 +159,4 @@ void OPENSSL_cpuid_setup(void)
|
||||
sigaction (SIGILL,&ill_oact,NULL);
|
||||
sigprocmask(SIG_SETMASK,&oset,NULL);
|
||||
}
|
||||
#endif
|
||||
|
@@ -3,52 +3,6 @@
|
||||
.text
|
||||
.code 32
|
||||
|
||||
.align 5
|
||||
.global _armv7_neon_probe
|
||||
.type _armv7_neon_probe,%function
|
||||
_armv7_neon_probe:
|
||||
.byte 0xf0,0x01,0x60,0xf2 @ vorr q8,q8,q8
|
||||
.byte 0x1e,0xff,0x2f,0xe1 @ bx lr
|
||||
.size _armv7_neon_probe,.-_armv7_neon_probe
|
||||
|
||||
.global _armv7_tick
|
||||
.type _armv7_tick,%function
|
||||
_armv7_tick:
|
||||
mrrc p15,1,r0,r1,c14 @ CNTVCT
|
||||
#if __ARM_ARCH__>=5
|
||||
bx lr
|
||||
#else
|
||||
.word 0xe12fff1e @ bx lr
|
||||
#endif
|
||||
.size _armv7_tick,.-_armv7_tick
|
||||
|
||||
.global _armv8_aes_probe
|
||||
.type _armv8_aes_probe,%function
|
||||
_armv8_aes_probe:
|
||||
.byte 0x00,0x03,0xb0,0xf3 @ aese.8 q0,q0
|
||||
.byte 0x1e,0xff,0x2f,0xe1 @ bx lr
|
||||
.size _armv8_aes_probe,.-_armv8_aes_probe
|
||||
|
||||
.global _armv8_sha1_probe
|
||||
.type _armv8_sha1_probe,%function
|
||||
_armv8_sha1_probe:
|
||||
.byte 0x40,0x0c,0x00,0xf2 @ sha1c.32 q0,q0,q0
|
||||
.byte 0x1e,0xff,0x2f,0xe1 @ bx lr
|
||||
.size _armv8_sha1_probe,.-_armv8_sha1_probe
|
||||
|
||||
.global _armv8_sha256_probe
|
||||
.type _armv8_sha256_probe,%function
|
||||
_armv8_sha256_probe:
|
||||
.byte 0x40,0x0c,0x00,0xf3 @ sha256h.32 q0,q0,q0
|
||||
.byte 0x1e,0xff,0x2f,0xe1 @ bx lr
|
||||
.size _armv8_sha256_probe,.-_armv8_sha256_probe
|
||||
.global _armv8_pmull_probe
|
||||
.type _armv8_pmull_probe,%function
|
||||
_armv8_pmull_probe:
|
||||
.byte 0x00,0x0e,0xa0,0xf2 @ vmull.p64 q0,d0,d0
|
||||
.byte 0x1e,0xff,0x2f,0xe1 @ bx lr
|
||||
.size _armv8_pmull_probe,.-_armv8_pmull_probe
|
||||
|
||||
.align 5
|
||||
.global OPENSSL_atomic_add
|
||||
.type OPENSSL_atomic_add,%function
|
||||
@@ -122,30 +76,81 @@ OPENSSL_cleanse:
|
||||
#endif
|
||||
.size OPENSSL_cleanse,.-OPENSSL_cleanse
|
||||
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.align 5
|
||||
.global _armv7_neon_probe
|
||||
.type _armv7_neon_probe,%function
|
||||
_armv7_neon_probe:
|
||||
vorr q0,q0,q0
|
||||
bx lr
|
||||
.size _armv7_neon_probe,.-_armv7_neon_probe
|
||||
|
||||
.global _armv7_tick
|
||||
.type _armv7_tick,%function
|
||||
_armv7_tick:
|
||||
mrrc p15,1,r0,r1,c14 @ CNTVCT
|
||||
bx lr
|
||||
.size _armv7_tick,.-_armv7_tick
|
||||
|
||||
.global _armv8_aes_probe
|
||||
.type _armv8_aes_probe,%function
|
||||
_armv8_aes_probe:
|
||||
.byte 0x00,0x03,0xb0,0xf3 @ aese.8 q0,q0
|
||||
bx lr
|
||||
.size _armv8_aes_probe,.-_armv8_aes_probe
|
||||
|
||||
.global _armv8_sha1_probe
|
||||
.type _armv8_sha1_probe,%function
|
||||
_armv8_sha1_probe:
|
||||
.byte 0x40,0x0c,0x00,0xf2 @ sha1c.32 q0,q0,q0
|
||||
bx lr
|
||||
.size _armv8_sha1_probe,.-_armv8_sha1_probe
|
||||
|
||||
.global _armv8_sha256_probe
|
||||
.type _armv8_sha256_probe,%function
|
||||
_armv8_sha256_probe:
|
||||
.byte 0x40,0x0c,0x00,0xf3 @ sha256h.32 q0,q0,q0
|
||||
bx lr
|
||||
.size _armv8_sha256_probe,.-_armv8_sha256_probe
|
||||
.global _armv8_pmull_probe
|
||||
.type _armv8_pmull_probe,%function
|
||||
_armv8_pmull_probe:
|
||||
.byte 0x00,0x0e,0xa0,0xf2 @ vmull.p64 q0,d0,d0
|
||||
bx lr
|
||||
.size _armv8_pmull_probe,.-_armv8_pmull_probe
|
||||
#endif
|
||||
|
||||
.global OPENSSL_wipe_cpu
|
||||
.type OPENSSL_wipe_cpu,%function
|
||||
OPENSSL_wipe_cpu:
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
ldr r0,.LOPENSSL_armcap
|
||||
adr r1,.LOPENSSL_armcap
|
||||
ldr r0,[r1,r0]
|
||||
#endif
|
||||
eor r2,r2,r2
|
||||
eor r3,r3,r3
|
||||
eor ip,ip,ip
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
tst r0,#1
|
||||
beq .Lwipe_done
|
||||
.byte 0x50,0x01,0x00,0xf3 @ veor q0, q0, q0
|
||||
.byte 0x52,0x21,0x02,0xf3 @ veor q1, q1, q1
|
||||
.byte 0x54,0x41,0x04,0xf3 @ veor q2, q2, q2
|
||||
.byte 0x56,0x61,0x06,0xf3 @ veor q3, q3, q3
|
||||
.byte 0xf0,0x01,0x40,0xf3 @ veor q8, q8, q8
|
||||
.byte 0xf2,0x21,0x42,0xf3 @ veor q9, q9, q9
|
||||
.byte 0xf4,0x41,0x44,0xf3 @ veor q10, q10, q10
|
||||
.byte 0xf6,0x61,0x46,0xf3 @ veor q11, q11, q11
|
||||
.byte 0xf8,0x81,0x48,0xf3 @ veor q12, q12, q12
|
||||
.byte 0xfa,0xa1,0x4a,0xf3 @ veor q13, q13, q13
|
||||
.byte 0xfc,0xc1,0x4c,0xf3 @ veor q14, q14, q14
|
||||
.byte 0xfe,0xe1,0x4e,0xf3 @ veor q14, q14, q14
|
||||
veor q0, q0, q0
|
||||
veor q1, q1, q1
|
||||
veor q2, q2, q2
|
||||
veor q3, q3, q3
|
||||
veor q8, q8, q8
|
||||
veor q9, q9, q9
|
||||
veor q10, q10, q10
|
||||
veor q11, q11, q11
|
||||
veor q12, q12, q12
|
||||
veor q13, q13, q13
|
||||
veor q14, q14, q14
|
||||
veor q15, q15, q15
|
||||
.Lwipe_done:
|
||||
#endif
|
||||
mov r0,sp
|
||||
#if __ARM_ARCH__>=5
|
||||
bx lr
|
||||
@@ -183,8 +188,10 @@ OPENSSL_instrument_bus2:
|
||||
.size OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2
|
||||
|
||||
.align 5
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.LOPENSSL_armcap:
|
||||
.word OPENSSL_armcap_P-.LOPENSSL_armcap
|
||||
#endif
|
||||
#if __ARM_ARCH__>=6
|
||||
.align 5
|
||||
#else
|
||||
|
@@ -136,11 +136,16 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
|
||||
|
||||
p= *pp;
|
||||
i= *(p++);
|
||||
if (i > 7)
|
||||
{
|
||||
i=ASN1_R_INVALID_BIT_STRING_BITS_LEFT;
|
||||
goto err;
|
||||
}
|
||||
/* We do this to preserve the settings. If we modify
|
||||
* the settings, via the _set_bit function, we will recalculate
|
||||
* on output */
|
||||
ret->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
|
||||
ret->flags|=(ASN1_STRING_FLAG_BITS_LEFT|(i&0x07)); /* set */
|
||||
ret->flags|=(ASN1_STRING_FLAG_BITS_LEFT|i); /* set */
|
||||
|
||||
if (len-- > 1) /* using one because of the bits left byte */
|
||||
{
|
||||
|
@@ -113,7 +113,7 @@ IMPLEMENT_STACK_OF(ASN1_TYPE)
|
||||
IMPLEMENT_ASN1_SET_OF(ASN1_TYPE)
|
||||
|
||||
/* Returns 0 if they are equal, != 0 otherwise. */
|
||||
int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b)
|
||||
int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
|
@@ -90,6 +90,12 @@ int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
|
||||
ASN1err(ASN1_F_ASN1_VERIFY,ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_VERIFY, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
|
||||
goto err;
|
||||
}
|
||||
|
||||
inl=i2d(data,NULL);
|
||||
buf_in=OPENSSL_malloc((unsigned int)inl);
|
||||
@@ -146,6 +152,12 @@ int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *a,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (signature->type == V_ASN1_BIT_STRING && signature->flags & 0x7)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ASN1_R_INVALID_BIT_STRING_BITS_LEFT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
EVP_MD_CTX_init(&ctx);
|
||||
|
||||
/* Convert signature OID into digest and public key OIDs */
|
||||
|
@@ -776,7 +776,7 @@ DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE)
|
||||
int ASN1_TYPE_get(ASN1_TYPE *a);
|
||||
void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
|
||||
int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value);
|
||||
int ASN1_TYPE_cmp(ASN1_TYPE *a, ASN1_TYPE *b);
|
||||
int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b);
|
||||
|
||||
ASN1_OBJECT * ASN1_OBJECT_new(void );
|
||||
void ASN1_OBJECT_free(ASN1_OBJECT *a);
|
||||
@@ -1331,6 +1331,7 @@ void ERR_load_ASN1_strings(void);
|
||||
#define ASN1_R_ILLEGAL_TIME_VALUE 184
|
||||
#define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185
|
||||
#define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128
|
||||
#define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220
|
||||
#define ASN1_R_INVALID_BMPSTRING_LENGTH 129
|
||||
#define ASN1_R_INVALID_DIGIT 130
|
||||
#define ASN1_R_INVALID_MIME_TYPE 205
|
||||
@@ -1380,6 +1381,7 @@ void ERR_load_ASN1_strings(void);
|
||||
#define ASN1_R_TIME_NOT_ASCII_FORMAT 193
|
||||
#define ASN1_R_TOO_LONG 155
|
||||
#define ASN1_R_TYPE_NOT_CONSTRUCTED 156
|
||||
#define ASN1_R_TYPE_NOT_PRIMITIVE 218
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_KEY 157
|
||||
#define ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY 158
|
||||
#define ASN1_R_UNEXPECTED_EOC 159
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* crypto/asn1/asn1_err.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2014 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
|
||||
@@ -246,6 +246,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
|
||||
{ERR_REASON(ASN1_R_ILLEGAL_TIME_VALUE) ,"illegal time value"},
|
||||
{ERR_REASON(ASN1_R_INTEGER_NOT_ASCII_FORMAT),"integer not ascii format"},
|
||||
{ERR_REASON(ASN1_R_INTEGER_TOO_LARGE_FOR_LONG),"integer too large for long"},
|
||||
{ERR_REASON(ASN1_R_INVALID_BIT_STRING_BITS_LEFT),"invalid bit string bits left"},
|
||||
{ERR_REASON(ASN1_R_INVALID_BMPSTRING_LENGTH),"invalid bmpstring length"},
|
||||
{ERR_REASON(ASN1_R_INVALID_DIGIT) ,"invalid digit"},
|
||||
{ERR_REASON(ASN1_R_INVALID_MIME_TYPE) ,"invalid mime type"},
|
||||
@@ -295,6 +296,7 @@ static ERR_STRING_DATA ASN1_str_reasons[]=
|
||||
{ERR_REASON(ASN1_R_TIME_NOT_ASCII_FORMAT),"time not ascii format"},
|
||||
{ERR_REASON(ASN1_R_TOO_LONG) ,"too long"},
|
||||
{ERR_REASON(ASN1_R_TYPE_NOT_CONSTRUCTED) ,"type not constructed"},
|
||||
{ERR_REASON(ASN1_R_TYPE_NOT_PRIMITIVE) ,"type not primitive"},
|
||||
{ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_KEY),"unable to decode rsa key"},
|
||||
{ERR_REASON(ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY),"unable to decode rsa private key"},
|
||||
{ERR_REASON(ASN1_R_UNEXPECTED_EOC) ,"unexpected eoc"},
|
||||
|
@@ -870,6 +870,14 @@ static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
|
||||
}
|
||||
else if (cst)
|
||||
{
|
||||
if (utype == V_ASN1_NULL || utype == V_ASN1_BOOLEAN
|
||||
|| utype == V_ASN1_OBJECT || utype == V_ASN1_INTEGER
|
||||
|| utype == V_ASN1_ENUMERATED)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE,
|
||||
ASN1_R_TYPE_NOT_PRIMITIVE);
|
||||
return 0;
|
||||
}
|
||||
buf.length = 0;
|
||||
buf.max = 0;
|
||||
buf.data = NULL;
|
||||
|
@@ -142,3 +142,14 @@ void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md)
|
||||
X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_MD_type(md)), param_type, NULL);
|
||||
|
||||
}
|
||||
|
||||
int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b)
|
||||
{
|
||||
int rv;
|
||||
rv = OBJ_cmp(a->algorithm, b->algorithm);
|
||||
if (rv)
|
||||
return rv;
|
||||
if (!a->parameter && !b->parameter)
|
||||
return 0;
|
||||
return ASN1_TYPE_cmp(a->parameter, b->parameter);
|
||||
}
|
||||
|
@@ -350,6 +350,8 @@ static int x509_name_canon(X509_NAME *a)
|
||||
set = entry->set;
|
||||
}
|
||||
tmpentry = X509_NAME_ENTRY_new();
|
||||
if (!tmpentry)
|
||||
goto err;
|
||||
tmpentry->object = OBJ_dup(entry->object);
|
||||
if (!asn1_string_canon(tmpentry->value, entry->value))
|
||||
goto err;
|
||||
|
@@ -176,6 +176,8 @@ extern "C" {
|
||||
* adjust socket timeouts */
|
||||
#define BIO_CTRL_DGRAM_SET_DONT_FRAG 48
|
||||
|
||||
#define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49
|
||||
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
/* SCTP stuff */
|
||||
#define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50
|
||||
@@ -608,6 +610,8 @@ int BIO_ctrl_reset_read_request(BIO *b);
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer)
|
||||
#define BIO_dgram_set_peer(b,peer) \
|
||||
(int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer)
|
||||
#define BIO_dgram_get_mtu_overhead(b) \
|
||||
(unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL)
|
||||
|
||||
/* These two aren't currently implemented */
|
||||
/* int BIO_get_ex_num(BIO *bio); */
|
||||
|
@@ -458,6 +458,36 @@ static int dgram_write(BIO *b, const char *in, int inl)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static long dgram_get_mtu_overhead(bio_dgram_data *data)
|
||||
{
|
||||
long ret;
|
||||
|
||||
switch (data->peer.sa.sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
/* Assume this is UDP - 20 bytes for IP, 8 bytes for UDP */
|
||||
ret = 28;
|
||||
break;
|
||||
#if OPENSSL_USE_IPV6
|
||||
case AF_INET6:
|
||||
#ifdef IN6_IS_ADDR_V4MAPPED
|
||||
if (IN6_IS_ADDR_V4MAPPED(&data->peer.sa_in6.sin6_addr))
|
||||
/* Assume this is UDP - 20 bytes for IP, 8 bytes for UDP */
|
||||
ret = 28;
|
||||
else
|
||||
#endif
|
||||
/* Assume this is UDP - 40 bytes for IP, 8 bytes for UDP */
|
||||
ret = 48;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* We don't know. Go with the historical default */
|
||||
ret = 28;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret=1;
|
||||
@@ -634,23 +664,24 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
#endif
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_FALLBACK_MTU:
|
||||
ret = -dgram_get_mtu_overhead(data);
|
||||
switch (data->peer.sa.sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
ret = 576 - 20 - 8;
|
||||
ret += 576;
|
||||
break;
|
||||
#if OPENSSL_USE_IPV6
|
||||
case AF_INET6:
|
||||
#ifdef IN6_IS_ADDR_V4MAPPED
|
||||
if (IN6_IS_ADDR_V4MAPPED(&data->peer.sa_in6.sin6_addr))
|
||||
ret = 576 - 20 - 8;
|
||||
ret += 576;
|
||||
else
|
||||
#endif
|
||||
ret = 1280 - 40 - 8;
|
||||
ret += 1280;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret = 576 - 20 - 8;
|
||||
ret += 576;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -895,6 +926,9 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_MTU_OVERHEAD:
|
||||
ret = dgram_get_mtu_overhead(data);
|
||||
break;
|
||||
default:
|
||||
ret=0;
|
||||
break;
|
||||
@@ -941,10 +975,18 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
|
||||
/* Activate SCTP-AUTH for DATA and FORWARD-TSN chunks */
|
||||
auth.sauth_chunk = OPENSSL_SCTP_DATA_CHUNK_TYPE;
|
||||
ret = setsockopt(fd, IPPROTO_SCTP, SCTP_AUTH_CHUNK, &auth, sizeof(struct sctp_authchunk));
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
auth.sauth_chunk = OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE;
|
||||
ret = setsockopt(fd, IPPROTO_SCTP, SCTP_AUTH_CHUNK, &auth, sizeof(struct sctp_authchunk));
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Test if activation was successful. When using accept(),
|
||||
* SCTP-AUTH has to be activated for the listening socket
|
||||
@@ -953,7 +995,13 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
|
||||
authchunks = OPENSSL_malloc(sockopt_len);
|
||||
memset(authchunks, 0, sizeof(sockopt_len));
|
||||
ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks, &sockopt_len);
|
||||
OPENSSL_assert(ret >= 0);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
OPENSSL_free(authchunks);
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
for (p = (unsigned char*) authchunks->gauth_chunks;
|
||||
p < (unsigned char*) authchunks + sockopt_len;
|
||||
@@ -975,16 +1023,28 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
|
||||
event.se_type = SCTP_AUTHENTICATION_EVENT;
|
||||
event.se_on = 1;
|
||||
ret = setsockopt(fd, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event));
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
#else
|
||||
sockopt_len = (socklen_t) sizeof(struct sctp_event_subscribe);
|
||||
ret = getsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, &sockopt_len);
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
event.sctp_authentication_event = 1;
|
||||
|
||||
ret = setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(struct sctp_event_subscribe));
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -992,7 +1052,11 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
|
||||
* larger than the max record size of 2^14 + 2048 + 13
|
||||
*/
|
||||
ret = setsockopt(fd, IPPROTO_SCTP, SCTP_PARTIAL_DELIVERY_POINT, &optval, sizeof(optval));
|
||||
OPENSSL_assert(ret >= 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
BIO_vfree(bio);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
return(bio);
|
||||
}
|
||||
@@ -1030,7 +1094,12 @@ static int dgram_sctp_free(BIO *a)
|
||||
return 0;
|
||||
|
||||
data = (bio_dgram_sctp_data *)a->ptr;
|
||||
if(data != NULL) OPENSSL_free(data);
|
||||
if(data != NULL)
|
||||
{
|
||||
if(data->saved_message.data != NULL)
|
||||
OPENSSL_free(data->saved_message.data);
|
||||
OPENSSL_free(data);
|
||||
}
|
||||
|
||||
return(1);
|
||||
}
|
||||
@@ -1082,6 +1151,13 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
msg.msg_flags = 0;
|
||||
n = recvmsg(b->num, &msg, 0);
|
||||
|
||||
if (n <= 0)
|
||||
{
|
||||
if (n < 0)
|
||||
ret = n;
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg.msg_controllen > 0)
|
||||
{
|
||||
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg))
|
||||
@@ -1121,13 +1197,6 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
}
|
||||
}
|
||||
|
||||
if (n <= 0)
|
||||
{
|
||||
if (n < 0)
|
||||
ret = n;
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg.msg_flags & MSG_NOTIFICATION)
|
||||
{
|
||||
snp = (union sctp_notification*) out;
|
||||
@@ -1147,6 +1216,7 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
dgram_sctp_write(data->saved_message.bio, data->saved_message.data,
|
||||
data->saved_message.length);
|
||||
OPENSSL_free(data->saved_message.data);
|
||||
data->saved_message.data = NULL;
|
||||
data->saved_message.length = 0;
|
||||
}
|
||||
|
||||
@@ -1157,16 +1227,28 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
event.se_type = SCTP_SENDER_DRY_EVENT;
|
||||
event.se_on = 0;
|
||||
i = setsockopt(b->num, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(struct sctp_event));
|
||||
OPENSSL_assert(i >= 0);
|
||||
if (i < 0)
|
||||
{
|
||||
ret = i;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
eventsize = sizeof(struct sctp_event_subscribe);
|
||||
i = getsockopt(b->num, IPPROTO_SCTP, SCTP_EVENTS, &event, &eventsize);
|
||||
OPENSSL_assert(i >= 0);
|
||||
if (i < 0)
|
||||
{
|
||||
ret = i;
|
||||
break;
|
||||
}
|
||||
|
||||
event.sctp_sender_dry_event = 0;
|
||||
|
||||
i = setsockopt(b->num, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(struct sctp_event_subscribe));
|
||||
OPENSSL_assert(i >= 0);
|
||||
if (i < 0)
|
||||
{
|
||||
ret = i;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1199,8 +1281,8 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
*/
|
||||
optlen = (socklen_t) sizeof(int);
|
||||
ret = getsockopt(b->num, SOL_SOCKET, SO_RCVBUF, &optval, &optlen);
|
||||
OPENSSL_assert(ret >= 0);
|
||||
OPENSSL_assert(optval >= 18445);
|
||||
if (ret >= 0)
|
||||
OPENSSL_assert(optval >= 18445);
|
||||
|
||||
/* Test if SCTP doesn't partially deliver below
|
||||
* max record size (2^14 + 2048 + 13)
|
||||
@@ -1208,8 +1290,8 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
optlen = (socklen_t) sizeof(int);
|
||||
ret = getsockopt(b->num, IPPROTO_SCTP, SCTP_PARTIAL_DELIVERY_POINT,
|
||||
&optval, &optlen);
|
||||
OPENSSL_assert(ret >= 0);
|
||||
OPENSSL_assert(optval >= 18445);
|
||||
if (ret >= 0)
|
||||
OPENSSL_assert(optval >= 18445);
|
||||
|
||||
/* Partially delivered notification??? Probably a bug.... */
|
||||
OPENSSL_assert(!(msg.msg_flags & MSG_NOTIFICATION));
|
||||
@@ -1243,15 +1325,15 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
|
||||
authchunks = OPENSSL_malloc(optlen);
|
||||
memset(authchunks, 0, sizeof(optlen));
|
||||
ii = getsockopt(b->num, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, authchunks, &optlen);
|
||||
OPENSSL_assert(ii >= 0);
|
||||
|
||||
for (p = (unsigned char*) authchunks->gauth_chunks;
|
||||
p < (unsigned char*) authchunks + optlen;
|
||||
p += sizeof(uint8_t))
|
||||
{
|
||||
if (*p == OPENSSL_SCTP_DATA_CHUNK_TYPE) auth_data = 1;
|
||||
if (*p == OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE) auth_forward = 1;
|
||||
}
|
||||
if (ii >= 0)
|
||||
for (p = (unsigned char*) authchunks->gauth_chunks;
|
||||
p < (unsigned char*) authchunks + optlen;
|
||||
p += sizeof(uint8_t))
|
||||
{
|
||||
if (*p == OPENSSL_SCTP_DATA_CHUNK_TYPE) auth_data = 1;
|
||||
if (*p == OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE) auth_forward = 1;
|
||||
}
|
||||
|
||||
OPENSSL_free(authchunks);
|
||||
|
||||
@@ -1306,9 +1388,11 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl)
|
||||
if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b))
|
||||
{
|
||||
data->saved_message.bio = b;
|
||||
data->saved_message.length = inl;
|
||||
if (data->saved_message.data)
|
||||
OPENSSL_free(data->saved_message.data);
|
||||
data->saved_message.data = OPENSSL_malloc(inl);
|
||||
memcpy(data->saved_message.data, in, inl);
|
||||
data->saved_message.length = inl;
|
||||
return inl;
|
||||
}
|
||||
|
||||
@@ -1415,6 +1499,10 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
* Returns always 1.
|
||||
*/
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_MTU_OVERHEAD:
|
||||
/* We allow transport protocol fragmentation so this is irrelevant */
|
||||
ret = 0;
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE:
|
||||
if (num > 0)
|
||||
data->in_handshake = 1;
|
||||
|
@@ -253,6 +253,7 @@ 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_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
|
||||
|
@@ -40,10 +40,6 @@ $code=<<___;
|
||||
|
||||
.text
|
||||
.code 32
|
||||
|
||||
#if __ARM_ARCH__>=7
|
||||
.fpu neon
|
||||
#endif
|
||||
___
|
||||
################
|
||||
# private interface to mul_1x1_ialu
|
||||
@@ -142,72 +138,18 @@ ___
|
||||
# BN_ULONG a1,BN_ULONG a0,
|
||||
# BN_ULONG b1,BN_ULONG b0); # r[3..0]=a1a0<61>b1b0
|
||||
{
|
||||
my ($r,$t0,$t1,$t2,$t3)=map("q$_",(0..3,8..12));
|
||||
my ($a,$b,$k48,$k32,$k16)=map("d$_",(26..31));
|
||||
|
||||
$code.=<<___;
|
||||
.global bn_GF2m_mul_2x2
|
||||
.type bn_GF2m_mul_2x2,%function
|
||||
.align 5
|
||||
bn_GF2m_mul_2x2:
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
ldr r12,.LOPENSSL_armcap
|
||||
.Lpic: ldr r12,[pc,r12]
|
||||
tst r12,#1
|
||||
beq .Lialu
|
||||
|
||||
ldr r12, [sp] @ 5th argument
|
||||
vmov.32 $a, r2, r1
|
||||
vmov.32 $b, r12, r3
|
||||
vmov.i64 $k48, #0x0000ffffffffffff
|
||||
vmov.i64 $k32, #0x00000000ffffffff
|
||||
vmov.i64 $k16, #0x000000000000ffff
|
||||
|
||||
vext.8 $t0#lo, $a, $a, #1 @ A1
|
||||
vmull.p8 $t0, $t0#lo, $b @ F = A1*B
|
||||
vext.8 $r#lo, $b, $b, #1 @ B1
|
||||
vmull.p8 $r, $a, $r#lo @ E = A*B1
|
||||
vext.8 $t1#lo, $a, $a, #2 @ A2
|
||||
vmull.p8 $t1, $t1#lo, $b @ H = A2*B
|
||||
vext.8 $t3#lo, $b, $b, #2 @ B2
|
||||
vmull.p8 $t3, $a, $t3#lo @ G = A*B2
|
||||
vext.8 $t2#lo, $a, $a, #3 @ A3
|
||||
veor $t0, $t0, $r @ L = E + F
|
||||
vmull.p8 $t2, $t2#lo, $b @ J = A3*B
|
||||
vext.8 $r#lo, $b, $b, #3 @ B3
|
||||
veor $t1, $t1, $t3 @ M = G + H
|
||||
vmull.p8 $r, $a, $r#lo @ I = A*B3
|
||||
veor $t0#lo, $t0#lo, $t0#hi @ t0 = (L) (P0 + P1) << 8
|
||||
vand $t0#hi, $t0#hi, $k48
|
||||
vext.8 $t3#lo, $b, $b, #4 @ B4
|
||||
veor $t1#lo, $t1#lo, $t1#hi @ t1 = (M) (P2 + P3) << 16
|
||||
vand $t1#hi, $t1#hi, $k32
|
||||
vmull.p8 $t3, $a, $t3#lo @ K = A*B4
|
||||
veor $t2, $t2, $r @ N = I + J
|
||||
veor $t0#lo, $t0#lo, $t0#hi
|
||||
veor $t1#lo, $t1#lo, $t1#hi
|
||||
veor $t2#lo, $t2#lo, $t2#hi @ t2 = (N) (P4 + P5) << 24
|
||||
vand $t2#hi, $t2#hi, $k16
|
||||
vext.8 $t0, $t0, $t0, #15
|
||||
veor $t3#lo, $t3#lo, $t3#hi @ t3 = (K) (P6 + P7) << 32
|
||||
vmov.i64 $t3#hi, #0
|
||||
vext.8 $t1, $t1, $t1, #14
|
||||
veor $t2#lo, $t2#lo, $t2#hi
|
||||
vmull.p8 $r, $a, $b @ D = A*B
|
||||
vext.8 $t3, $t3, $t3, #12
|
||||
vext.8 $t2, $t2, $t2, #13
|
||||
veor $t0, $t0, $t1
|
||||
veor $t2, $t2, $t3
|
||||
veor $r, $r, $t0
|
||||
veor $r, $r, $t2
|
||||
|
||||
vst1.32 {$r}, [r0]
|
||||
ret @ bx lr
|
||||
.align 4
|
||||
.Lialu:
|
||||
bne .LNEON
|
||||
#endif
|
||||
___
|
||||
}
|
||||
$ret="r10"; # reassigned 1st argument
|
||||
$code.=<<___;
|
||||
stmdb sp!,{r4-r10,lr}
|
||||
@@ -257,8 +199,72 @@ $code.=<<___;
|
||||
moveq pc,lr @ be binary compatible with V4, yet
|
||||
bx lr @ interoperable with Thumb ISA:-)
|
||||
#endif
|
||||
___
|
||||
}
|
||||
{
|
||||
my ($r,$t0,$t1,$t2,$t3)=map("q$_",(0..3,8..12));
|
||||
my ($a,$b,$k48,$k32,$k16)=map("d$_",(26..31));
|
||||
|
||||
$code.=<<___;
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.align 5
|
||||
.LNEON:
|
||||
ldr r12, [sp] @ 5th argument
|
||||
vmov.32 $a, r2, r1
|
||||
vmov.32 $b, r12, r3
|
||||
vmov.i64 $k48, #0x0000ffffffffffff
|
||||
vmov.i64 $k32, #0x00000000ffffffff
|
||||
vmov.i64 $k16, #0x000000000000ffff
|
||||
|
||||
vext.8 $t0#lo, $a, $a, #1 @ A1
|
||||
vmull.p8 $t0, $t0#lo, $b @ F = A1*B
|
||||
vext.8 $r#lo, $b, $b, #1 @ B1
|
||||
vmull.p8 $r, $a, $r#lo @ E = A*B1
|
||||
vext.8 $t1#lo, $a, $a, #2 @ A2
|
||||
vmull.p8 $t1, $t1#lo, $b @ H = A2*B
|
||||
vext.8 $t3#lo, $b, $b, #2 @ B2
|
||||
vmull.p8 $t3, $a, $t3#lo @ G = A*B2
|
||||
vext.8 $t2#lo, $a, $a, #3 @ A3
|
||||
veor $t0, $t0, $r @ L = E + F
|
||||
vmull.p8 $t2, $t2#lo, $b @ J = A3*B
|
||||
vext.8 $r#lo, $b, $b, #3 @ B3
|
||||
veor $t1, $t1, $t3 @ M = G + H
|
||||
vmull.p8 $r, $a, $r#lo @ I = A*B3
|
||||
veor $t0#lo, $t0#lo, $t0#hi @ t0 = (L) (P0 + P1) << 8
|
||||
vand $t0#hi, $t0#hi, $k48
|
||||
vext.8 $t3#lo, $b, $b, #4 @ B4
|
||||
veor $t1#lo, $t1#lo, $t1#hi @ t1 = (M) (P2 + P3) << 16
|
||||
vand $t1#hi, $t1#hi, $k32
|
||||
vmull.p8 $t3, $a, $t3#lo @ K = A*B4
|
||||
veor $t2, $t2, $r @ N = I + J
|
||||
veor $t0#lo, $t0#lo, $t0#hi
|
||||
veor $t1#lo, $t1#lo, $t1#hi
|
||||
veor $t2#lo, $t2#lo, $t2#hi @ t2 = (N) (P4 + P5) << 24
|
||||
vand $t2#hi, $t2#hi, $k16
|
||||
vext.8 $t0, $t0, $t0, #15
|
||||
veor $t3#lo, $t3#lo, $t3#hi @ t3 = (K) (P6 + P7) << 32
|
||||
vmov.i64 $t3#hi, #0
|
||||
vext.8 $t1, $t1, $t1, #14
|
||||
veor $t2#lo, $t2#lo, $t2#hi
|
||||
vmull.p8 $r, $a, $b @ D = A*B
|
||||
vext.8 $t3, $t3, $t3, #12
|
||||
vext.8 $t2, $t2, $t2, #13
|
||||
veor $t0, $t0, $t1
|
||||
veor $t2, $t2, $t3
|
||||
veor $r, $r, $t0
|
||||
veor $r, $r, $t2
|
||||
|
||||
vst1.32 {$r}, [r0]
|
||||
ret @ bx lr
|
||||
#endif
|
||||
___
|
||||
}
|
||||
$code.=<<___;
|
||||
.size bn_GF2m_mul_2x2,.-bn_GF2m_mul_2x2
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.align 5
|
||||
.LOPENSSL_armcap:
|
||||
.word OPENSSL_armcap_P-(.Lpic+8)
|
||||
@@ -266,7 +272,9 @@ $code.=<<___;
|
||||
.asciz "GF(2^m) Multiplication for ARMv4/NEON, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.align 5
|
||||
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.comm OPENSSL_armcap_P,4,4
|
||||
#endif
|
||||
___
|
||||
|
||||
foreach (split("\n",$code)) {
|
||||
|
@@ -72,7 +72,7 @@ $code=<<___;
|
||||
.text
|
||||
.code 32
|
||||
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.align 5
|
||||
.LOPENSSL_armcap:
|
||||
.word OPENSSL_armcap_P-bn_mul_mont
|
||||
@@ -85,7 +85,7 @@ $code=<<___;
|
||||
bn_mul_mont:
|
||||
ldr ip,[sp,#4] @ load num
|
||||
stmdb sp!,{r0,r2} @ sp points at argument block
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
tst ip,#7
|
||||
bne .Lialu
|
||||
adr r0,bn_mul_mont
|
||||
@@ -256,7 +256,8 @@ my ($rptr,$aptr,$bptr,$nptr,$n0,$num)=map("r$_",(0..5));
|
||||
my ($tinptr,$toutptr,$inner,$outer)=map("r$_",(6..9));
|
||||
|
||||
$code.=<<___;
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.type bn_mul8x_mont_neon,%function
|
||||
@@ -663,7 +664,7 @@ ___
|
||||
$code.=<<___;
|
||||
.asciz "Montgomery multiplication for ARMv4/NEON, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.align 2
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.comm OPENSSL_armcap_P,4,4
|
||||
#endif
|
||||
___
|
||||
|
@@ -1872,6 +1872,41 @@ ___
|
||||
|
||||
($a_4,$a_5,$a_6,$a_7)=($b_0,$b_1,$b_2,$b_3);
|
||||
|
||||
sub add_c2 () {
|
||||
my ($hi,$lo,$c0,$c1,$c2,
|
||||
$warm, # !$warm denotes first call with specific sequence of
|
||||
# $c_[XYZ] when there is no Z-carry to accumulate yet;
|
||||
$an,$bn # these two are arguments for multiplication which
|
||||
# result is used in *next* step [which is why it's
|
||||
# commented as "forward multiplication" below];
|
||||
)=@_;
|
||||
$code.=<<___;
|
||||
mflo $lo
|
||||
mfhi $hi
|
||||
$ADDU $c0,$lo
|
||||
sltu $at,$c0,$lo
|
||||
$MULTU $an,$bn # forward multiplication
|
||||
$ADDU $c0,$lo
|
||||
$ADDU $at,$hi
|
||||
sltu $lo,$c0,$lo
|
||||
$ADDU $c1,$at
|
||||
$ADDU $hi,$lo
|
||||
___
|
||||
$code.=<<___ if (!$warm);
|
||||
sltu $c2,$c1,$at
|
||||
$ADDU $c1,$hi
|
||||
sltu $hi,$c1,$hi
|
||||
$ADDU $c2,$hi
|
||||
___
|
||||
$code.=<<___ if ($warm);
|
||||
sltu $at,$c1,$at
|
||||
$ADDU $c1,$hi
|
||||
$ADDU $c2,$at
|
||||
sltu $hi,$c1,$hi
|
||||
$ADDU $c2,$hi
|
||||
___
|
||||
}
|
||||
|
||||
$code.=<<___;
|
||||
|
||||
.align 5
|
||||
@@ -1920,21 +1955,10 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $c_3,$t_2,$at
|
||||
$ST $c_2,$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_1 # mul_add_c(a[1],b[1],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_1,$a_1); # mul_add_c(a[1],b[1],c3,c1,c2);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_3,$t_1
|
||||
@@ -1945,67 +1969,19 @@ $code.=<<___;
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
$ST $c_3,2*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_3,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_2 # mul_add_c2(a[1],b[2],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_4,$a_0 # mul_add_c2(a[4],b[0],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,0,
|
||||
$a_1,$a_2); # mul_add_c2(a[1],b[2],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_4,$a_0); # mul_add_c2(a[4],b[0],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
$ST $c_1,3*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_1,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_3,$a_1 # mul_add_c2(a[3],b[1],c2,c3,c1);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_1,$at
|
||||
$MULTU $a_2,$a_2 # mul_add_c(a[2],b[2],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,0,
|
||||
$a_3,$a_1); # mul_add_c2(a[3],b[1],c2,c3,c1);
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,1,
|
||||
$a_2,$a_2); # mul_add_c(a[2],b[2],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_2,$t_1
|
||||
@@ -2016,97 +1992,23 @@ $code.=<<___;
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
$ST $c_2,4*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_4 # mul_add_c2(a[1],b[4],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_2,$at
|
||||
$MULTU $a_2,$a_3 # mul_add_c2(a[2],b[3],c3,c1,c2);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$MULTU $a_6,$a_0 # mul_add_c2(a[6],b[0],c1,c2,c3);
|
||||
$ADDU $c_2,$at
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_1,$a_4); # mul_add_c2(a[1],b[4],c3,c1,c2);
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,1,
|
||||
$a_2,$a_3); # mul_add_c2(a[2],b[3],c3,c1,c2);
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,1,
|
||||
$a_6,$a_0); # mul_add_c2(a[6],b[0],c1,c2,c3);
|
||||
$code.=<<___;
|
||||
$ST $c_3,5*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_3,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_5,$a_1 # mul_add_c2(a[5],b[1],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_4,$a_2 # mul_add_c2(a[4],b[2],c1,c2,c3);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_3,$a_3 # mul_add_c(a[3],b[3],c1,c2,c3);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,0,
|
||||
$a_5,$a_1); # mul_add_c2(a[5],b[1],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_4,$a_2); # mul_add_c2(a[4],b[2],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_3,$a_3); # mul_add_c(a[3],b[3],c1,c2,c3);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_1,$t_1
|
||||
@@ -2117,112 +2019,25 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
$ST $c_1,6*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_1,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_6 # mul_add_c2(a[1],b[6],c2,c3,c1);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_1,$at
|
||||
$MULTU $a_2,$a_5 # mul_add_c2(a[2],b[5],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_1,$at
|
||||
$MULTU $a_3,$a_4 # mul_add_c2(a[3],b[4],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_1,$at
|
||||
$MULTU $a_7,$a_1 # mul_add_c2(a[7],b[1],c3,c1,c2);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,0,
|
||||
$a_1,$a_6); # mul_add_c2(a[1],b[6],c2,c3,c1);
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,1,
|
||||
$a_2,$a_5); # mul_add_c2(a[2],b[5],c2,c3,c1);
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,1,
|
||||
$a_3,$a_4); # mul_add_c2(a[3],b[4],c2,c3,c1);
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,1,
|
||||
$a_7,$a_1); # mul_add_c2(a[7],b[1],c3,c1,c2);
|
||||
$code.=<<___;
|
||||
$ST $c_2,7*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_6,$a_2 # mul_add_c2(a[6],b[2],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_2,$at
|
||||
$MULTU $a_5,$a_3 # mul_add_c2(a[5],b[3],c3,c1,c2);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_2,$at
|
||||
$MULTU $a_4,$a_4 # mul_add_c(a[4],b[4],c3,c1,c2);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_6,$a_2); # mul_add_c2(a[6],b[2],c3,c1,c2);
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,1,
|
||||
$a_5,$a_3); # mul_add_c2(a[5],b[3],c3,c1,c2);
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,1,
|
||||
$a_4,$a_4); # mul_add_c(a[4],b[4],c3,c1,c2);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_3,$t_1
|
||||
@@ -2233,82 +2048,21 @@ $code.=<<___;
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
$ST $c_3,8*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_3,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_3,$a_6 # mul_add_c2(a[3],b[6],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_4,$a_5 # mul_add_c2(a[4],b[5],c1,c2,c3);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_7,$a_3 # mul_add_c2(a[7],b[3],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,0,
|
||||
$a_3,$a_6); # mul_add_c2(a[3],b[6],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_4,$a_5); # mul_add_c2(a[4],b[5],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_7,$a_3); # mul_add_c2(a[7],b[3],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
$ST $c_1,9*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_1,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_6,$a_4 # mul_add_c2(a[6],b[4],c2,c3,c1);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_1,$at
|
||||
$MULTU $a_5,$a_5 # mul_add_c(a[5],b[5],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,0,
|
||||
$a_6,$a_4); # mul_add_c2(a[6],b[4],c2,c3,c1);
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,1,
|
||||
$a_5,$a_5); # mul_add_c(a[5],b[5],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_2,$t_1
|
||||
@@ -2319,52 +2073,17 @@ $code.=<<___;
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
$ST $c_2,10*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_5,$a_6 # mul_add_c2(a[5],b[6],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_2,$at
|
||||
$MULTU $a_7,$a_5 # mul_add_c2(a[7],b[5],c1,c2,c3);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_5,$a_6); # mul_add_c2(a[5],b[6],c3,c1,c2);
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,1,
|
||||
$a_7,$a_5); # mul_add_c2(a[7],b[5],c1,c2,c3);
|
||||
$code.=<<___;
|
||||
$ST $c_3,11*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_3,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_6,$a_6 # mul_add_c(a[6],b[6],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,0,
|
||||
$a_6,$a_6); # mul_add_c(a[6],b[6],c1,c2,c3);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_1,$t_1
|
||||
@@ -2375,21 +2094,10 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
$ST $c_1,12*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_1,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_7,$a_7 # mul_add_c(a[7],b[7],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,0,
|
||||
$a_7,$a_7); # mul_add_c(a[7],b[7],c3,c1,c2);
|
||||
$code.=<<___;
|
||||
$ST $c_2,13*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
@@ -2457,21 +2165,10 @@ $code.=<<___;
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $c_3,$t_2,$at
|
||||
$ST $c_2,$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_1 # mul_add_c(a[1],b[1],c3,c1,c2);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_1,$a_1); # mul_add_c(a[1],b[1],c3,c1,c2);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_3,$t_1
|
||||
@@ -2482,52 +2179,17 @@ $code.=<<___;
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
$ST $c_3,2*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_3,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_1,$a_2 # mul_add_c(a2[1],b[2],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $at,$t_2,$zero
|
||||
$ADDU $c_3,$at
|
||||
$MULTU $a_3,$a_1 # mul_add_c2(a[3],b[1],c2,c3,c1);
|
||||
$SLL $t_2,1
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_1,$t_1
|
||||
sltu $at,$c_1,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_2,$t_2
|
||||
sltu $at,$c_2,$t_2
|
||||
$ADDU $c_3,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,0,
|
||||
$a_1,$a_2); # mul_add_c2(a2[1],b[2],c1,c2,c3);
|
||||
&add_c2($t_2,$t_1,$c_1,$c_2,$c_3,1,
|
||||
$a_3,$a_1); # mul_add_c2(a[3],b[1],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
$ST $c_1,3*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_1,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_2,$a_2 # mul_add_c(a[2],b[2],c2,c3,c1);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_2,$t_1
|
||||
sltu $at,$c_2,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_3,$t_2
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_2,$c_3,$c_1,0,
|
||||
$a_2,$a_2); # mul_add_c(a[2],b[2],c2,c3,c1);
|
||||
$code.=<<___;
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
$ADDU $c_2,$t_1
|
||||
@@ -2538,21 +2200,10 @@ $code.=<<___;
|
||||
sltu $at,$c_3,$t_2
|
||||
$ADDU $c_1,$at
|
||||
$ST $c_2,4*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
mfhi $t_2
|
||||
slt $c_2,$t_2,$zero
|
||||
$SLL $t_2,1
|
||||
$MULTU $a_3,$a_3 # mul_add_c(a[3],b[3],c1,c2,c3);
|
||||
slt $a2,$t_1,$zero
|
||||
$ADDU $t_2,$a2
|
||||
$SLL $t_1,1
|
||||
$ADDU $c_3,$t_1
|
||||
sltu $at,$c_3,$t_1
|
||||
$ADDU $t_2,$at
|
||||
$ADDU $c_1,$t_2
|
||||
sltu $at,$c_1,$t_2
|
||||
$ADDU $c_2,$at
|
||||
___
|
||||
&add_c2($t_2,$t_1,$c_3,$c_1,$c_2,0,
|
||||
$a_3,$a_3); # mul_add_c(a[3],b[3],c1,c2,c3);
|
||||
$code.=<<___;
|
||||
$ST $c_3,5*$BNSZ($a0)
|
||||
|
||||
mflo $t_1
|
||||
|
@@ -61,8 +61,12 @@
|
||||
#
|
||||
# rsa2048 sign/sec OpenSSL 1.0.1 scalar(*) this
|
||||
# 2.3GHz Haswell 621 765/+23% 1113/+79%
|
||||
# 2.3GHz Broadwell(**) 688 1200(***)/+74% 1120/+63%
|
||||
#
|
||||
# (*) if system doesn't support AVX2, for reference purposes;
|
||||
# (**) scaled to 2.3GHz to simplify comparison;
|
||||
# (***) scalar AD*X code is faster than AVX2 and is preferred code
|
||||
# path for Broadwell;
|
||||
|
||||
$flavour = shift;
|
||||
$output = shift;
|
||||
|
@@ -276,77 +276,76 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
|
||||
/* sqr_add_c(a,i,c0,c1,c2) -- c+=a[i]^2 for three word number c=(c2,c1,c0) */
|
||||
/* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */
|
||||
|
||||
/*
|
||||
* Keep in mind that carrying into high part of multiplication result
|
||||
* can not overflow, because it cannot be all-ones.
|
||||
*/
|
||||
#if 0
|
||||
/* original macros are kept for reference purposes */
|
||||
#define mul_add_c(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b); \
|
||||
t1 = ta * tb; \
|
||||
t2 = BN_UMULT_HIGH(ta,tb); \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
#define mul_add_c(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a), tb = (b); \
|
||||
BN_ULONG lo, hi; \
|
||||
BN_UMULT_LOHI(lo,hi,ta,tb); \
|
||||
c0 += lo; hi += (c0<lo)?1:0; \
|
||||
c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
} while(0)
|
||||
|
||||
#define mul_add_c2(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b),t0; \
|
||||
t1 = BN_UMULT_HIGH(ta,tb); \
|
||||
t0 = ta * tb; \
|
||||
t2 = t1+t1; c2 += (t2<t1)?1:0; \
|
||||
t1 = t0+t0; t2 += (t1<t0)?1:0; \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
#define mul_add_c2(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a), tb = (b); \
|
||||
BN_ULONG lo, hi, tt; \
|
||||
BN_UMULT_LOHI(lo,hi,ta,tb); \
|
||||
c0 += lo; tt = hi+((c0<lo)?1:0); \
|
||||
c1 += tt; c2 += (c1<tt)?1:0; \
|
||||
c0 += lo; hi += (c0<lo)?1:0; \
|
||||
c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
} while(0)
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a)[i]; \
|
||||
BN_ULONG lo, hi; \
|
||||
BN_UMULT_LOHI(lo,hi,ta,ta); \
|
||||
c0 += lo; hi += (c0<lo)?1:0; \
|
||||
c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
} while(0)
|
||||
#else
|
||||
#define mul_add_c(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG t1,t2; \
|
||||
asm ("mulq %3" \
|
||||
: "=a"(t1),"=d"(t2) \
|
||||
: "a"(a),"m"(b) \
|
||||
: "cc"); \
|
||||
asm ("addq %2,%0; adcq %3,%1" \
|
||||
: "+r"(c0),"+d"(t2) \
|
||||
: "a"(t1),"g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %2,%0; adcq %3,%1" \
|
||||
: "+r"(c1),"+r"(c2) \
|
||||
: "d"(t2),"g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %3,%0; adcq %4,%1; adcq %5,%2" \
|
||||
: "+r"(c0),"+r"(c1),"+r"(c2) \
|
||||
: "r"(t1),"r"(t2),"g"(0) \
|
||||
: "cc"); \
|
||||
} while (0)
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) do { \
|
||||
BN_ULONG t1,t2; \
|
||||
asm ("mulq %2" \
|
||||
: "=a"(t1),"=d"(t2) \
|
||||
: "a"(a[i]) \
|
||||
: "cc"); \
|
||||
asm ("addq %2,%0; adcq %3,%1" \
|
||||
: "+r"(c0),"+d"(t2) \
|
||||
: "a"(t1),"g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %2,%0; adcq %3,%1" \
|
||||
: "+r"(c1),"+r"(c2) \
|
||||
: "d"(t2),"g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %3,%0; adcq %4,%1; adcq %5,%2" \
|
||||
: "+r"(c0),"+r"(c1),"+r"(c2) \
|
||||
: "r"(t1),"r"(t2),"g"(0) \
|
||||
: "cc"); \
|
||||
} while (0)
|
||||
|
||||
#define mul_add_c2(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG t1,t2; \
|
||||
asm ("mulq %3" \
|
||||
: "=a"(t1),"=d"(t2) \
|
||||
: "a"(a),"m"(b) \
|
||||
: "cc"); \
|
||||
asm ("addq %0,%0; adcq %2,%1" \
|
||||
: "+d"(t2),"+r"(c2) \
|
||||
: "g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %0,%0; adcq %2,%1" \
|
||||
: "+a"(t1),"+d"(t2) \
|
||||
: "g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %2,%0; adcq %3,%1" \
|
||||
: "+r"(c0),"+d"(t2) \
|
||||
: "a"(t1),"g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %2,%0; adcq %3,%1" \
|
||||
: "+r"(c1),"+r"(c2) \
|
||||
: "d"(t2),"g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %3,%0; adcq %4,%1; adcq %5,%2" \
|
||||
: "+r"(c0),"+r"(c1),"+r"(c2) \
|
||||
: "r"(t1),"r"(t2),"g"(0) \
|
||||
: "cc"); \
|
||||
asm ("addq %3,%0; adcq %4,%1; adcq %5,%2" \
|
||||
: "+r"(c0),"+r"(c1),"+r"(c2) \
|
||||
: "r"(t1),"r"(t2),"g"(0) \
|
||||
: "cc"); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
@@ -355,7 +354,6 @@ BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n)
|
||||
|
||||
void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
{
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
@@ -459,7 +457,6 @@ void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
|
||||
void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
{
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
@@ -499,7 +496,6 @@ void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
|
||||
void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)
|
||||
{
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
@@ -575,7 +571,6 @@ void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)
|
||||
|
||||
void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a)
|
||||
{
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
|
@@ -762,7 +762,9 @@ int RAND_pseudo_bytes(unsigned char *buf,int num);
|
||||
#define bn_wcheck_size(bn, words) \
|
||||
do { \
|
||||
const BIGNUM *_bnum2 = (bn); \
|
||||
assert(words <= (_bnum2)->dmax && words >= (_bnum2)->top); \
|
||||
assert((words) <= (_bnum2)->dmax && (words) >= (_bnum2)->top); \
|
||||
/* avoid unused variable warning with NDEBUG */ \
|
||||
(void)(_bnum2); \
|
||||
} while(0)
|
||||
|
||||
#else /* !BN_DEBUG */
|
||||
|
@@ -439,116 +439,143 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
/* sqr_add_c2(a,i,c0,c1,c2) -- c+=2*a[i]*a[j] for three word number c=(c2,c1,c0) */
|
||||
|
||||
#ifdef BN_LLONG
|
||||
#define mul_add_c(a,b,c0,c1,c2) \
|
||||
t=(BN_ULLONG)a*b; \
|
||||
t1=(BN_ULONG)Lw(t); \
|
||||
t2=(BN_ULONG)Hw(t); \
|
||||
c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
/*
|
||||
* Keep in mind that additions to multiplication result can not
|
||||
* overflow, because its high half cannot be all-ones.
|
||||
*/
|
||||
#define mul_add_c(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG hi; \
|
||||
BN_ULLONG t = (BN_ULLONG)(a)*(b); \
|
||||
t += c0; /* no carry */ \
|
||||
c0 = (BN_ULONG)Lw(t); \
|
||||
hi = (BN_ULONG)Hw(t); \
|
||||
c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
} while(0)
|
||||
|
||||
#define mul_add_c2(a,b,c0,c1,c2) \
|
||||
t=(BN_ULLONG)a*b; \
|
||||
tt=(t+t)&BN_MASK; \
|
||||
if (tt < t) c2++; \
|
||||
t1=(BN_ULONG)Lw(tt); \
|
||||
t2=(BN_ULONG)Hw(tt); \
|
||||
c0=(c0+t1)&BN_MASK2; \
|
||||
if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
#define mul_add_c2(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG hi; \
|
||||
BN_ULLONG t = (BN_ULLONG)(a)*(b); \
|
||||
BN_ULLONG tt = t+c0; /* no carry */ \
|
||||
c0 = (BN_ULONG)Lw(tt); \
|
||||
hi = (BN_ULONG)Hw(tt); \
|
||||
c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
t += c0; /* no carry */ \
|
||||
c0 = (BN_ULONG)Lw(t); \
|
||||
hi = (BN_ULONG)Hw(t); \
|
||||
c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
} while(0)
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) \
|
||||
t=(BN_ULLONG)a[i]*a[i]; \
|
||||
t1=(BN_ULONG)Lw(t); \
|
||||
t2=(BN_ULONG)Hw(t); \
|
||||
c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
#define sqr_add_c(a,i,c0,c1,c2) do { \
|
||||
BN_ULONG hi; \
|
||||
BN_ULLONG t = (BN_ULLONG)a[i]*a[i]; \
|
||||
t += c0; /* no carry */ \
|
||||
c0 = (BN_ULONG)Lw(t); \
|
||||
hi = (BN_ULONG)Hw(t); \
|
||||
c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
} while(0)
|
||||
|
||||
#define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
mul_add_c2((a)[i],(a)[j],c0,c1,c2)
|
||||
|
||||
#elif defined(BN_UMULT_LOHI)
|
||||
/*
|
||||
* Keep in mind that additions to hi can not overflow, because
|
||||
* the high word of a multiplication result cannot be all-ones.
|
||||
*/
|
||||
#define mul_add_c(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a), tb = (b); \
|
||||
BN_ULONG lo, hi; \
|
||||
BN_UMULT_LOHI(lo,hi,ta,tb); \
|
||||
c0 += lo; hi += (c0<lo)?1:0; \
|
||||
c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
} while(0)
|
||||
|
||||
#define mul_add_c(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b); \
|
||||
BN_UMULT_LOHI(t1,t2,ta,tb); \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
#define mul_add_c2(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a), tb = (b); \
|
||||
BN_ULONG lo, hi, tt; \
|
||||
BN_UMULT_LOHI(lo,hi,ta,tb); \
|
||||
c0 += lo; tt = hi+((c0<lo)?1:0); \
|
||||
c1 += tt; c2 += (c1<tt)?1:0; \
|
||||
c0 += lo; hi += (c0<lo)?1:0; \
|
||||
c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
} while(0)
|
||||
|
||||
#define mul_add_c2(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b),t0; \
|
||||
BN_UMULT_LOHI(t0,t1,ta,tb); \
|
||||
t2 = t1+t1; c2 += (t2<t1)?1:0; \
|
||||
t1 = t0+t0; t2 += (t1<t0)?1:0; \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a)[i]; \
|
||||
BN_UMULT_LOHI(t1,t2,ta,ta); \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
#define sqr_add_c(a,i,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a)[i]; \
|
||||
BN_ULONG lo, hi; \
|
||||
BN_UMULT_LOHI(lo,hi,ta,ta); \
|
||||
c0 += lo; hi += (c0<lo)?1:0; \
|
||||
c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
} while(0)
|
||||
|
||||
#define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
mul_add_c2((a)[i],(a)[j],c0,c1,c2)
|
||||
|
||||
#elif defined(BN_UMULT_HIGH)
|
||||
/*
|
||||
* Keep in mind that additions to hi can not overflow, because
|
||||
* the high word of a multiplication result cannot be all-ones.
|
||||
*/
|
||||
#define mul_add_c(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a), tb = (b); \
|
||||
BN_ULONG lo = ta * tb; \
|
||||
BN_ULONG hi = BN_UMULT_HIGH(ta,tb); \
|
||||
c0 += lo; hi += (c0<lo)?1:0; \
|
||||
c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
} while(0)
|
||||
|
||||
#define mul_add_c(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b); \
|
||||
t1 = ta * tb; \
|
||||
t2 = BN_UMULT_HIGH(ta,tb); \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
#define mul_add_c2(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a), tb = (b), tt; \
|
||||
BN_ULONG lo = ta * tb; \
|
||||
BN_ULONG hi = BN_UMULT_HIGH(ta,tb); \
|
||||
c0 += lo; tt = hi + ((c0<lo)?1:0); \
|
||||
c1 += tt; c2 += (c1<tt)?1:0; \
|
||||
c0 += lo; hi += (c0<lo)?1:0; \
|
||||
c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
} while(0)
|
||||
|
||||
#define mul_add_c2(a,b,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a),tb=(b),t0; \
|
||||
t1 = BN_UMULT_HIGH(ta,tb); \
|
||||
t0 = ta * tb; \
|
||||
t2 = t1+t1; c2 += (t2<t1)?1:0; \
|
||||
t1 = t0+t0; t2 += (t1<t0)?1:0; \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) { \
|
||||
BN_ULONG ta=(a)[i]; \
|
||||
t1 = ta * ta; \
|
||||
t2 = BN_UMULT_HIGH(ta,ta); \
|
||||
c0 += t1; t2 += (c0<t1)?1:0; \
|
||||
c1 += t2; c2 += (c1<t2)?1:0; \
|
||||
}
|
||||
#define sqr_add_c(a,i,c0,c1,c2) do { \
|
||||
BN_ULONG ta = (a)[i]; \
|
||||
BN_ULONG lo = ta * ta; \
|
||||
BN_ULONG hi = BN_UMULT_HIGH(ta,ta); \
|
||||
c0 += lo; hi += (c0<lo)?1:0; \
|
||||
c1 += hi; c2 += (c1<hi)?1:0; \
|
||||
} while(0)
|
||||
|
||||
#define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
mul_add_c2((a)[i],(a)[j],c0,c1,c2)
|
||||
|
||||
#else /* !BN_LLONG */
|
||||
#define mul_add_c(a,b,c0,c1,c2) \
|
||||
t1=LBITS(a); t2=HBITS(a); \
|
||||
bl=LBITS(b); bh=HBITS(b); \
|
||||
mul64(t1,t2,bl,bh); \
|
||||
c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
/*
|
||||
* Keep in mind that additions to hi can not overflow, because
|
||||
* the high word of a multiplication result cannot be all-ones.
|
||||
*/
|
||||
#define mul_add_c(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG lo = LBITS(a), hi = HBITS(a); \
|
||||
BN_ULONG bl = LBITS(b), bh = HBITS(b); \
|
||||
mul64(lo,hi,bl,bh); \
|
||||
c0 = (c0+lo)&BN_MASK2; if (c0<lo) hi++; \
|
||||
c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
} while(0)
|
||||
|
||||
#define mul_add_c2(a,b,c0,c1,c2) \
|
||||
t1=LBITS(a); t2=HBITS(a); \
|
||||
bl=LBITS(b); bh=HBITS(b); \
|
||||
mul64(t1,t2,bl,bh); \
|
||||
if (t2 & BN_TBIT) c2++; \
|
||||
t2=(t2+t2)&BN_MASK2; \
|
||||
if (t1 & BN_TBIT) t2++; \
|
||||
t1=(t1+t1)&BN_MASK2; \
|
||||
c0=(c0+t1)&BN_MASK2; \
|
||||
if ((c0 < t1) && (((++t2)&BN_MASK2) == 0)) c2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
#define mul_add_c2(a,b,c0,c1,c2) do { \
|
||||
BN_ULONG tt; \
|
||||
BN_ULONG lo = LBITS(a), hi = HBITS(a); \
|
||||
BN_ULONG bl = LBITS(b), bh = HBITS(b); \
|
||||
mul64(lo,hi,bl,bh); \
|
||||
tt = hi; \
|
||||
c0 = (c0+lo)&BN_MASK2; if (c0<lo) tt++; \
|
||||
c1 = (c1+tt)&BN_MASK2; if (c1<tt) c2++; \
|
||||
c0 = (c0+lo)&BN_MASK2; if (c0<lo) hi++; \
|
||||
c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
} while(0)
|
||||
|
||||
#define sqr_add_c(a,i,c0,c1,c2) \
|
||||
sqr64(t1,t2,(a)[i]); \
|
||||
c0=(c0+t1)&BN_MASK2; if ((c0) < t1) t2++; \
|
||||
c1=(c1+t2)&BN_MASK2; if ((c1) < t2) c2++;
|
||||
#define sqr_add_c(a,i,c0,c1,c2) do { \
|
||||
BN_ULONG lo, hi; \
|
||||
sqr64(lo,hi,(a)[i]); \
|
||||
c0 = (c0+lo)&BN_MASK2; if (c0<lo) hi++; \
|
||||
c1 = (c1+hi)&BN_MASK2; if (c1<hi) c2++; \
|
||||
} while(0)
|
||||
|
||||
#define sqr_add_c2(a,i,j,c0,c1,c2) \
|
||||
mul_add_c2((a)[i],(a)[j],c0,c1,c2)
|
||||
@@ -556,12 +583,6 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
|
||||
|
||||
void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
{
|
||||
#ifdef BN_LLONG
|
||||
BN_ULLONG t;
|
||||
#else
|
||||
BN_ULONG bl,bh;
|
||||
#endif
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
@@ -665,12 +686,6 @@ void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
|
||||
void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
{
|
||||
#ifdef BN_LLONG
|
||||
BN_ULLONG t;
|
||||
#else
|
||||
BN_ULONG bl,bh;
|
||||
#endif
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
@@ -710,12 +725,6 @@ void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b)
|
||||
|
||||
void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)
|
||||
{
|
||||
#ifdef BN_LLONG
|
||||
BN_ULLONG t,tt;
|
||||
#else
|
||||
BN_ULONG bl,bh;
|
||||
#endif
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
@@ -791,12 +800,6 @@ void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a)
|
||||
|
||||
void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a)
|
||||
{
|
||||
#ifdef BN_LLONG
|
||||
BN_ULLONG t,tt;
|
||||
#else
|
||||
BN_ULONG bl,bh;
|
||||
#endif
|
||||
BN_ULONG t1,t2;
|
||||
BN_ULONG c1,c2,c3;
|
||||
|
||||
c1=0;
|
||||
|
@@ -158,7 +158,7 @@ static void ctxdbg(BN_CTX *ctx)
|
||||
unsigned int bnidx = 0, fpidx = 0;
|
||||
BN_POOL_ITEM *item = ctx->pool.head;
|
||||
BN_STACK *stack = &ctx->stack;
|
||||
fprintf(stderr,"(%08x): ", (unsigned int)ctx);
|
||||
fprintf(stderr,"(%16p): ", ctx);
|
||||
while(bnidx < ctx->used)
|
||||
{
|
||||
fprintf(stderr,"%03x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);
|
||||
|
@@ -189,15 +189,17 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
||||
int no_branch=0;
|
||||
|
||||
/* Invalid zero-padding would have particularly bad consequences
|
||||
* in the case of 'num', so don't just rely on bn_check_top() for this one
|
||||
* so don't just rely on bn_check_top() here
|
||||
* (bn_check_top() works only for BN_DEBUG builds) */
|
||||
if (num->top > 0 && num->d[num->top - 1] == 0)
|
||||
if ((num->top > 0 && num->d[num->top - 1] == 0) ||
|
||||
(divisor->top > 0 && divisor->d[divisor->top - 1] == 0))
|
||||
{
|
||||
BNerr(BN_F_BN_DIV,BN_R_NOT_INITIALIZED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bn_check_top(num);
|
||||
bn_check_top(divisor);
|
||||
|
||||
if ((BN_get_flags(num, BN_FLG_CONSTTIME) != 0) || (BN_get_flags(divisor, BN_FLG_CONSTTIME) != 0))
|
||||
{
|
||||
@@ -207,7 +209,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
|
||||
bn_check_top(dv);
|
||||
bn_check_top(rm);
|
||||
/* bn_check_top(num); */ /* 'num' has been checked already */
|
||||
bn_check_top(divisor);
|
||||
/* bn_check_top(divisor); */ /* 'divisor' has been checked already */
|
||||
|
||||
if (BN_is_zero(divisor))
|
||||
{
|
||||
|
@@ -107,6 +107,7 @@ int test_mod(BIO *bp,BN_CTX *ctx);
|
||||
int test_mod_mul(BIO *bp,BN_CTX *ctx);
|
||||
int test_mod_exp(BIO *bp,BN_CTX *ctx);
|
||||
int test_mod_exp_mont_consttime(BIO *bp,BN_CTX *ctx);
|
||||
int test_mod_exp_mont5(BIO *bp, BN_CTX *ctx);
|
||||
int test_exp(BIO *bp,BN_CTX *ctx);
|
||||
int test_gf2m_add(BIO *bp);
|
||||
int test_gf2m_mod(BIO *bp);
|
||||
@@ -249,6 +250,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
message(out,"BN_mod_exp_mont_consttime");
|
||||
if (!test_mod_exp_mont_consttime(out,ctx)) goto err;
|
||||
if (!test_mod_exp_mont5(out,ctx)) goto err;
|
||||
(void)BIO_flush(out);
|
||||
|
||||
message(out,"BN_exp");
|
||||
@@ -676,44 +678,98 @@ int test_mul(BIO *bp)
|
||||
|
||||
int test_sqr(BIO *bp, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM a,c,d,e;
|
||||
int i;
|
||||
BIGNUM *a,*c,*d,*e;
|
||||
int i, ret = 0;
|
||||
|
||||
BN_init(&a);
|
||||
BN_init(&c);
|
||||
BN_init(&d);
|
||||
BN_init(&e);
|
||||
a = BN_new();
|
||||
c = BN_new();
|
||||
d = BN_new();
|
||||
e = BN_new();
|
||||
if (a == NULL || c == NULL || d == NULL || e == NULL)
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (i=0; i<num0; i++)
|
||||
{
|
||||
BN_bntest_rand(&a,40+i*10,0,0);
|
||||
a.neg=rand_neg();
|
||||
BN_sqr(&c,&a,ctx);
|
||||
BN_bntest_rand(a,40+i*10,0,0);
|
||||
a->neg=rand_neg();
|
||||
BN_sqr(c,a,ctx);
|
||||
if (bp != NULL)
|
||||
{
|
||||
if (!results)
|
||||
{
|
||||
BN_print(bp,&a);
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," * ");
|
||||
BN_print(bp,&a);
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," - ");
|
||||
}
|
||||
BN_print(bp,&c);
|
||||
BN_print(bp,c);
|
||||
BIO_puts(bp,"\n");
|
||||
}
|
||||
BN_div(&d,&e,&c,&a,ctx);
|
||||
BN_sub(&d,&d,&a);
|
||||
if(!BN_is_zero(&d) || !BN_is_zero(&e))
|
||||
{
|
||||
fprintf(stderr,"Square test failed!\n");
|
||||
return 0;
|
||||
}
|
||||
BN_div(d,e,c,a,ctx);
|
||||
BN_sub(d,d,a);
|
||||
if(!BN_is_zero(d) || !BN_is_zero(e))
|
||||
{
|
||||
fprintf(stderr,"Square test failed!\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
BN_free(&a);
|
||||
BN_free(&c);
|
||||
BN_free(&d);
|
||||
BN_free(&e);
|
||||
return(1);
|
||||
|
||||
/* Regression test for a BN_sqr overflow bug. */
|
||||
BN_hex2bn(&a,
|
||||
"80000000000000008000000000000001FFFFFFFFFFFFFFFE0000000000000000");
|
||||
BN_sqr(c, a, ctx);
|
||||
if (bp != NULL)
|
||||
{
|
||||
if (!results)
|
||||
{
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," * ");
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," - ");
|
||||
}
|
||||
BN_print(bp,c);
|
||||
BIO_puts(bp,"\n");
|
||||
}
|
||||
BN_mul(d, a, a, ctx);
|
||||
if (BN_cmp(c, d))
|
||||
{
|
||||
fprintf(stderr, "Square test failed: BN_sqr and BN_mul produce "
|
||||
"different results!\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Regression test for a BN_sqr overflow bug. */
|
||||
BN_hex2bn(&a,
|
||||
"80000000000000000000000080000001FFFFFFFE000000000000000000000000");
|
||||
BN_sqr(c, a, ctx);
|
||||
if (bp != NULL)
|
||||
{
|
||||
if (!results)
|
||||
{
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," * ");
|
||||
BN_print(bp,a);
|
||||
BIO_puts(bp," - ");
|
||||
}
|
||||
BN_print(bp,c);
|
||||
BIO_puts(bp,"\n");
|
||||
}
|
||||
BN_mul(d, a, a, ctx);
|
||||
if (BN_cmp(c, d))
|
||||
{
|
||||
fprintf(stderr, "Square test failed: BN_sqr and BN_mul produce "
|
||||
"different results!\n");
|
||||
goto err;
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
if (a != NULL) BN_free(a);
|
||||
if (c != NULL) BN_free(c);
|
||||
if (d != NULL) BN_free(d);
|
||||
if (e != NULL) BN_free(e);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_mont(BIO *bp, BN_CTX *ctx)
|
||||
@@ -1012,6 +1068,80 @@ int test_mod_exp_mont_consttime(BIO *bp, BN_CTX *ctx)
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Test constant-time modular exponentiation with 1024-bit inputs,
|
||||
* which on x86_64 cause a different code branch to be taken.
|
||||
*/
|
||||
int test_mod_exp_mont5(BIO *bp, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *a,*p,*m,*d,*e;
|
||||
|
||||
BN_MONT_CTX *mont;
|
||||
|
||||
a=BN_new();
|
||||
p=BN_new();
|
||||
m=BN_new();
|
||||
d=BN_new();
|
||||
e=BN_new();
|
||||
|
||||
mont = BN_MONT_CTX_new();
|
||||
|
||||
BN_bntest_rand(m,1024,0,1); /* must be odd for montgomery */
|
||||
/* Zero exponent */
|
||||
BN_bntest_rand(a,1024,0,0);
|
||||
BN_zero(p);
|
||||
if(!BN_mod_exp_mont_consttime(d,a,p,m,ctx,NULL))
|
||||
return 0;
|
||||
if(!BN_is_one(d))
|
||||
{
|
||||
fprintf(stderr, "Modular exponentiation test failed!\n");
|
||||
return 0;
|
||||
}
|
||||
/* Zero input */
|
||||
BN_bntest_rand(p,1024,0,0);
|
||||
BN_zero(a);
|
||||
if(!BN_mod_exp_mont_consttime(d,a,p,m,ctx,NULL))
|
||||
return 0;
|
||||
if(!BN_is_zero(d))
|
||||
{
|
||||
fprintf(stderr, "Modular exponentiation test failed!\n");
|
||||
return 0;
|
||||
}
|
||||
/* Craft an input whose Montgomery representation is 1,
|
||||
* i.e., shorter than the modulus m, in order to test
|
||||
* the const time precomputation scattering/gathering.
|
||||
*/
|
||||
BN_one(a);
|
||||
BN_MONT_CTX_set(mont,m,ctx);
|
||||
if(!BN_from_montgomery(e,a,mont,ctx))
|
||||
return 0;
|
||||
if(!BN_mod_exp_mont_consttime(d,e,p,m,ctx,NULL))
|
||||
return 0;
|
||||
if(!BN_mod_exp_simple(a,e,p,m,ctx))
|
||||
return 0;
|
||||
if(BN_cmp(a,d) != 0)
|
||||
{
|
||||
fprintf(stderr,"Modular exponentiation test failed!\n");
|
||||
return 0;
|
||||
}
|
||||
/* Finally, some regular test vectors. */
|
||||
BN_bntest_rand(e,1024,0,0);
|
||||
if(!BN_mod_exp_mont_consttime(d,e,p,m,ctx,NULL))
|
||||
return 0;
|
||||
if(!BN_mod_exp_simple(a,e,p,m,ctx))
|
||||
return 0;
|
||||
if(BN_cmp(a,d) != 0)
|
||||
{
|
||||
fprintf(stderr,"Modular exponentiation test failed!\n");
|
||||
return 0;
|
||||
}
|
||||
BN_free(a);
|
||||
BN_free(p);
|
||||
BN_free(m);
|
||||
BN_free(d);
|
||||
BN_free(e);
|
||||
return(1);
|
||||
}
|
||||
|
||||
int test_exp(BIO *bp, BN_CTX *ctx)
|
||||
{
|
||||
BIGNUM *a,*b,*d,*e,*one;
|
||||
|
@@ -129,17 +129,12 @@ static inline int constant_time_select_int(unsigned int mask, int a, int b);
|
||||
|
||||
static inline unsigned int constant_time_msb(unsigned int a)
|
||||
{
|
||||
return (unsigned int)((int)(a) >> (sizeof(int) * 8 - 1));
|
||||
return 0-(a >> (sizeof(a) * 8 - 1));
|
||||
}
|
||||
|
||||
static inline unsigned int constant_time_lt(unsigned int a, unsigned int b)
|
||||
{
|
||||
unsigned int lt;
|
||||
/* Case 1: msb(a) == msb(b). a < b iff the MSB of a - b is set.*/
|
||||
lt = ~(a ^ b) & (a - b);
|
||||
/* Case 2: msb(a) != msb(b). a < b iff the MSB of b is set. */
|
||||
lt |= ~a & b;
|
||||
return constant_time_msb(lt);
|
||||
return constant_time_msb(a^((a^b)|((a-b)^b)));
|
||||
}
|
||||
|
||||
static inline unsigned char constant_time_lt_8(unsigned int a, unsigned int b)
|
||||
@@ -149,12 +144,7 @@ static inline unsigned char constant_time_lt_8(unsigned int a, unsigned int b)
|
||||
|
||||
static inline unsigned int constant_time_ge(unsigned int a, unsigned int b)
|
||||
{
|
||||
unsigned int ge;
|
||||
/* Case 1: msb(a) == msb(b). a >= b iff the MSB of a - b is not set.*/
|
||||
ge = ~((a ^ b) | (a - b));
|
||||
/* Case 2: msb(a) != msb(b). a >= b iff the MSB of a is set. */
|
||||
ge |= a & ~b;
|
||||
return constant_time_msb(ge);
|
||||
return ~constant_time_lt(a, b);
|
||||
}
|
||||
|
||||
static inline unsigned char constant_time_ge_8(unsigned int a, unsigned int b)
|
||||
@@ -204,7 +194,7 @@ static inline unsigned char constant_time_select_8(unsigned char mask,
|
||||
return (unsigned char)(constant_time_select(mask, a, b));
|
||||
}
|
||||
|
||||
inline int constant_time_select_int(unsigned int mask, int a, int b)
|
||||
static inline int constant_time_select_int(unsigned int mask, int a, int b)
|
||||
{
|
||||
return (int)(constant_time_select(mask, (unsigned)(a), (unsigned)(b)));
|
||||
}
|
||||
|
@@ -69,10 +69,11 @@ const char *SSLeay_version(int t)
|
||||
if (t == SSLEAY_BUILT_ON)
|
||||
{
|
||||
#ifdef DATE
|
||||
static char buf[sizeof(DATE)+11];
|
||||
|
||||
BIO_snprintf(buf,sizeof buf,"built on: %s",DATE);
|
||||
return(buf);
|
||||
# ifdef OPENSSL_USE_BUILD_DATE
|
||||
return(DATE);
|
||||
# else
|
||||
return("built on: reproducible build, date unspecified");
|
||||
# endif
|
||||
#else
|
||||
return("built on: date not available");
|
||||
#endif
|
||||
@@ -80,10 +81,7 @@ const char *SSLeay_version(int t)
|
||||
if (t == SSLEAY_CFLAGS)
|
||||
{
|
||||
#ifdef CFLAGS
|
||||
static char buf[sizeof(CFLAGS)+11];
|
||||
|
||||
BIO_snprintf(buf,sizeof buf,"compiler: %s",CFLAGS);
|
||||
return(buf);
|
||||
return(CFLAGS);
|
||||
#else
|
||||
return("compiler: information not available");
|
||||
#endif
|
||||
@@ -91,10 +89,7 @@ const char *SSLeay_version(int t)
|
||||
if (t == SSLEAY_PLATFORM)
|
||||
{
|
||||
#ifdef PLATFORM
|
||||
static char buf[sizeof(PLATFORM)+11];
|
||||
|
||||
BIO_snprintf(buf,sizeof buf,"platform: %s", PLATFORM);
|
||||
return(buf);
|
||||
return(PLATFORM);
|
||||
#else
|
||||
return("platform: information not available");
|
||||
#endif
|
||||
|
@@ -131,7 +131,7 @@ static int dh_sharedinfo_encode(unsigned char **pder, unsigned char **pctr,
|
||||
return 0;
|
||||
if (!skip_asn1(&p, &tlen, V_ASN1_OCTET_STRING))
|
||||
return 0;
|
||||
if (memcmp(p, ctr, 4))
|
||||
if (CRYPTO_memcmp(p, ctr, 4))
|
||||
return 0;
|
||||
*pctr = p;
|
||||
return derlen;
|
||||
|
@@ -176,13 +176,25 @@ int DSA_verify(int type, const unsigned char *dgst, int dgst_len,
|
||||
const unsigned char *sigbuf, int siglen, DSA *dsa)
|
||||
{
|
||||
DSA_SIG *s;
|
||||
const unsigned char *p = sigbuf;
|
||||
unsigned char *der = NULL;
|
||||
int derlen = -1;
|
||||
int ret=-1;
|
||||
|
||||
s = DSA_SIG_new();
|
||||
if (s == NULL) return(ret);
|
||||
if (d2i_DSA_SIG(&s,&sigbuf,siglen) == NULL) goto err;
|
||||
if (d2i_DSA_SIG(&s,&p,siglen) == NULL) goto err;
|
||||
/* Ensure signature uses DER and doesn't have trailing garbage */
|
||||
derlen = i2d_DSA_SIG(s, &der);
|
||||
if (derlen != siglen || memcmp(sigbuf, der, derlen))
|
||||
goto err;
|
||||
ret=DSA_do_verify(dgst,dgst_len,s,dsa);
|
||||
err:
|
||||
if (derlen > 0)
|
||||
{
|
||||
OPENSSL_cleanse(der, derlen);
|
||||
OPENSSL_free(der);
|
||||
}
|
||||
DSA_SIG_free(s);
|
||||
return(ret);
|
||||
}
|
||||
|
@@ -60,10 +60,8 @@
|
||||
that handle _GNU_SOURCE and other similar macros. Defining it later
|
||||
is simply too late, because those headers are protected from re-
|
||||
inclusion. */
|
||||
#ifdef __linux
|
||||
# ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE /* make sure dladdr is declared */
|
||||
# endif
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE /* make sure dladdr is declared */
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
@@ -31,15 +31,16 @@
|
||||
# Further optimization by <appro@openssl.org>:
|
||||
#
|
||||
# this/original
|
||||
# Opteron +8-33%
|
||||
# Bulldozer +10-30%
|
||||
# P4 +14-38%
|
||||
# Westmere +8-23%
|
||||
# Sandy Bridge +8-24%
|
||||
# Ivy Bridge +7-25%
|
||||
# Haswell +5-25%
|
||||
# Atom +10-32%
|
||||
# VIA Nano +37-130%
|
||||
# Opteron +12-49%
|
||||
# Bulldozer +14-45%
|
||||
# P4 +18-46%
|
||||
# Westmere +12-34%
|
||||
# Sandy Bridge +9-35%
|
||||
# Ivy Bridge +9-35%
|
||||
# Haswell +8-37%
|
||||
# Broadwell +18-58%
|
||||
# Atom +15-50%
|
||||
# VIA Nano +43-160%
|
||||
#
|
||||
# Ranges denote minimum and maximum improvement coefficients depending
|
||||
# on benchmark.
|
||||
@@ -549,28 +550,20 @@ __ecp_nistz256_mul_montq:
|
||||
# and add the result to the acc.
|
||||
# Due to the special form of p256 we do some optimizations
|
||||
#
|
||||
# acc[0] x p256[0] = acc[0] x 2^64 - acc[0]
|
||||
# then we add acc[0] and get acc[0] x 2^64
|
||||
|
||||
mulq $poly1
|
||||
xor $t0, $t0
|
||||
add $acc0, $acc1 # +=acc[0]*2^64
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc1
|
||||
mov $acc0, %rax
|
||||
|
||||
# acc[0] x p256[2] = 0
|
||||
adc %rdx, $acc2
|
||||
adc \$0, $t0
|
||||
# acc[0] x p256[0..1] = acc[0] x 2^96 - acc[0]
|
||||
# then we add acc[0] and get acc[0] x 2^96
|
||||
|
||||
mov $acc0, $t1
|
||||
shl \$32, $acc0
|
||||
mulq $poly3
|
||||
xor $acc0, $acc0
|
||||
add $t0, $acc3
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc3
|
||||
shr \$32, $t1
|
||||
add $acc0, $acc1 # +=acc[0]<<96
|
||||
adc $t1, $acc2
|
||||
adc %rax, $acc3
|
||||
mov 8*1($b_ptr), %rax
|
||||
adc %rdx, $acc4
|
||||
adc \$0, $acc5
|
||||
xor $acc0, $acc0
|
||||
|
||||
########################################################################
|
||||
# Multiply by b[1]
|
||||
@@ -607,23 +600,17 @@ __ecp_nistz256_mul_montq:
|
||||
|
||||
########################################################################
|
||||
# Second reduction step
|
||||
mulq $poly1
|
||||
xor $t0, $t0
|
||||
add $acc1, $acc2
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc2
|
||||
mov $acc1, %rax
|
||||
adc %rdx, $acc3
|
||||
adc \$0, $t0
|
||||
|
||||
mov $acc1, $t1
|
||||
shl \$32, $acc1
|
||||
mulq $poly3
|
||||
xor $acc1, $acc1
|
||||
add $t0, $acc4
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc4
|
||||
shr \$32, $t1
|
||||
add $acc1, $acc2
|
||||
adc $t1, $acc3
|
||||
adc %rax, $acc4
|
||||
mov 8*2($b_ptr), %rax
|
||||
adc %rdx, $acc5
|
||||
adc \$0, $acc0
|
||||
xor $acc1, $acc1
|
||||
|
||||
########################################################################
|
||||
# Multiply by b[2]
|
||||
@@ -660,23 +647,17 @@ __ecp_nistz256_mul_montq:
|
||||
|
||||
########################################################################
|
||||
# Third reduction step
|
||||
mulq $poly1
|
||||
xor $t0, $t0
|
||||
add $acc2, $acc3
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc3
|
||||
mov $acc2, %rax
|
||||
adc %rdx, $acc4
|
||||
adc \$0, $t0
|
||||
|
||||
mov $acc2, $t1
|
||||
shl \$32, $acc2
|
||||
mulq $poly3
|
||||
xor $acc2, $acc2
|
||||
add $t0, $acc5
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc5
|
||||
shr \$32, $t1
|
||||
add $acc2, $acc3
|
||||
adc $t1, $acc4
|
||||
adc %rax, $acc5
|
||||
mov 8*3($b_ptr), %rax
|
||||
adc %rdx, $acc0
|
||||
adc \$0, $acc1
|
||||
xor $acc2, $acc2
|
||||
|
||||
########################################################################
|
||||
# Multiply by b[3]
|
||||
@@ -713,20 +694,14 @@ __ecp_nistz256_mul_montq:
|
||||
|
||||
########################################################################
|
||||
# Final reduction step
|
||||
mulq $poly1
|
||||
#xor $t0, $t0
|
||||
add $acc3, $acc4
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc4
|
||||
mov $acc3, %rax
|
||||
adc %rdx, $acc5
|
||||
#adc \$0, $t0 # doesn't overflow
|
||||
|
||||
mov $acc3, $t1
|
||||
shl \$32, $acc3
|
||||
mulq $poly3
|
||||
#add $t0, $acc0
|
||||
#adc \$0, %rdx
|
||||
shr \$32, $t1
|
||||
add $acc3, $acc4
|
||||
adc $t1, $acc5
|
||||
mov $acc4, $t0
|
||||
add %rax, $acc0
|
||||
adc %rax, $acc0
|
||||
adc %rdx, $acc1
|
||||
mov $acc5, $t1
|
||||
adc \$0, $acc2
|
||||
@@ -739,14 +714,14 @@ __ecp_nistz256_mul_montq:
|
||||
sbb \$0, $acc0 # .Lpoly[2]
|
||||
mov $acc1, $t3
|
||||
sbb $poly3, $acc1 # .Lpoly[3]
|
||||
neg $acc2
|
||||
sbb \$0, $acc2
|
||||
|
||||
cmovnc $t0, $acc4
|
||||
cmovnc $t1, $acc5
|
||||
cmovc $t0, $acc4
|
||||
cmovc $t1, $acc5
|
||||
mov $acc4, 8*0($r_ptr)
|
||||
cmovnc $t2, $acc0
|
||||
cmovc $t2, $acc0
|
||||
mov $acc5, 8*1($r_ptr)
|
||||
cmovnc $t3, $acc1
|
||||
cmovc $t3, $acc1
|
||||
mov $acc0, 8*2($r_ptr)
|
||||
mov $acc1, 8*3($r_ptr)
|
||||
|
||||
@@ -896,89 +871,62 @@ __ecp_nistz256_sqr_montq:
|
||||
##########################################
|
||||
# Now the reduction
|
||||
# First iteration
|
||||
mulq $a_ptr
|
||||
#xor $t0, $t0
|
||||
add $acc0, $acc1
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc1
|
||||
mov $acc0, %rax
|
||||
adc %rdx, $acc2 # doesn't overflow
|
||||
#adc \$0, $t0
|
||||
|
||||
mov $acc0, $t0
|
||||
shl \$32, $acc0
|
||||
mulq $t1
|
||||
xor $acc0, $acc0
|
||||
#add $t0, $acc3
|
||||
#adc \$0, %rdx
|
||||
add %rax, $acc3
|
||||
shr \$32, $t0
|
||||
add $acc0, $acc1 # +=acc[0]<<96
|
||||
adc $t0, $acc2
|
||||
adc %rax, $acc3
|
||||
mov $acc1, %rax
|
||||
adc %rdx, $acc4
|
||||
adc \$0, $acc0
|
||||
adc \$0, %rdx
|
||||
|
||||
##########################################
|
||||
# Second iteration
|
||||
mulq $a_ptr
|
||||
#xor $t0, $t0
|
||||
add $acc1, $acc2
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc2
|
||||
mov $acc1, %rax
|
||||
adc %rdx, $acc3 # doesn't overflow
|
||||
#adc \$0, $t0
|
||||
|
||||
mov $acc1, $t0
|
||||
shl \$32, $acc1
|
||||
mov %rdx, $acc0
|
||||
mulq $t1
|
||||
xor $acc1, $acc1
|
||||
#add $t0, $acc4
|
||||
#adc \$0, %rdx
|
||||
add %rax, $acc4
|
||||
shr \$32, $t0
|
||||
add $acc1, $acc2
|
||||
adc $t0, $acc3
|
||||
adc %rax, $acc0
|
||||
mov $acc2, %rax
|
||||
adc %rdx, $acc0
|
||||
adc \$0, $acc1
|
||||
adc \$0, %rdx
|
||||
|
||||
##########################################
|
||||
# Third iteration
|
||||
mulq $a_ptr
|
||||
#xor $t0, $t0
|
||||
add $acc2, $acc3
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc3
|
||||
mov $acc2, %rax
|
||||
adc %rdx, $acc4 # doesn't overflow
|
||||
#adc \$0, $t0
|
||||
|
||||
mov $acc2, $t0
|
||||
shl \$32, $acc2
|
||||
mov %rdx, $acc1
|
||||
mulq $t1
|
||||
xor $acc2, $acc2
|
||||
#add $t0, $acc0
|
||||
#adc \$0, %rdx
|
||||
add %rax, $acc0
|
||||
shr \$32, $t0
|
||||
add $acc2, $acc3
|
||||
adc $t0, $acc0
|
||||
adc %rax, $acc1
|
||||
mov $acc3, %rax
|
||||
adc %rdx, $acc1
|
||||
adc \$0, $acc2
|
||||
adc \$0, %rdx
|
||||
|
||||
###########################################
|
||||
# Last iteration
|
||||
mulq $a_ptr
|
||||
#xor $t0, $t0
|
||||
add $acc3, $acc4
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc4
|
||||
mov $acc3, %rax
|
||||
adc %rdx, $acc0 # doesn't overflow
|
||||
#adc \$0, $t0
|
||||
|
||||
mov $acc3, $t0
|
||||
shl \$32, $acc3
|
||||
mov %rdx, $acc2
|
||||
mulq $t1
|
||||
shr \$32, $t0
|
||||
add $acc3, $acc0
|
||||
adc $t0, $acc1
|
||||
adc %rax, $acc2
|
||||
adc \$0, %rdx
|
||||
xor $acc3, $acc3
|
||||
#add $t0, $acc1
|
||||
#adc \$0, %rdx
|
||||
add %rax, $acc1
|
||||
adc %rdx, $acc2
|
||||
adc \$0, $acc3
|
||||
|
||||
############################################
|
||||
# Add the rest of the acc
|
||||
add $acc0, $acc5
|
||||
add $acc0, $acc4
|
||||
adc $acc1, $acc5
|
||||
mov $acc4, $acc0
|
||||
adc $acc1, $acc6
|
||||
adc $acc2, $acc7
|
||||
adc $acc2, $acc6
|
||||
adc %rdx, $acc7
|
||||
mov $acc5, $acc1
|
||||
adc \$0, $acc3
|
||||
|
||||
@@ -988,14 +936,14 @@ __ecp_nistz256_sqr_montq:
|
||||
sbb \$0, $acc6 # .Lpoly[2]
|
||||
mov $acc7, $t0
|
||||
sbb $t1, $acc7 # .Lpoly[3]
|
||||
neg $acc3
|
||||
sbb \$0, $acc3
|
||||
|
||||
cmovnc $acc0, $acc4
|
||||
cmovnc $acc1, $acc5
|
||||
cmovc $acc0, $acc4
|
||||
cmovc $acc1, $acc5
|
||||
mov $acc4, 8*0($r_ptr)
|
||||
cmovnc $acc2, $acc6
|
||||
cmovc $acc2, $acc6
|
||||
mov $acc5, 8*1($r_ptr)
|
||||
cmovnc $t0, $acc7
|
||||
cmovc $t0, $acc7
|
||||
mov $acc6, 8*2($r_ptr)
|
||||
mov $acc7, 8*3($r_ptr)
|
||||
|
||||
@@ -1027,18 +975,15 @@ __ecp_nistz256_mul_montx:
|
||||
|
||||
########################################################################
|
||||
# First reduction step
|
||||
xor $acc0, $acc0 # $acc0=0,cf=0,of=0
|
||||
adox $t1, $acc1
|
||||
adox $t0, $acc2
|
||||
add $t1, $acc1
|
||||
adc $t0, $acc2
|
||||
|
||||
mulx $poly3, $t0, $t1
|
||||
mov 8*1($b_ptr), %rdx
|
||||
adox $t0, $acc3
|
||||
adcx $t1, $acc4
|
||||
|
||||
adox $acc0, $acc4
|
||||
adcx $acc0, $acc5 # cf=0
|
||||
adox $acc0, $acc5 # of=0
|
||||
adc $t0, $acc3
|
||||
adc $t1, $acc4
|
||||
adc \$0, $acc5
|
||||
xor $acc0, $acc0 # $acc0=0,cf=0,of=0
|
||||
|
||||
########################################################################
|
||||
# Multiply by b[1]
|
||||
@@ -1067,18 +1012,15 @@ __ecp_nistz256_mul_montx:
|
||||
|
||||
########################################################################
|
||||
# Second reduction step
|
||||
xor $acc1 ,$acc1 # $acc1=0,cf=0,of=0
|
||||
adox $t0, $acc2
|
||||
adox $t1, $acc3
|
||||
add $t0, $acc2
|
||||
adc $t1, $acc3
|
||||
|
||||
mulx $poly3, $t0, $t1
|
||||
mov 8*2($b_ptr), %rdx
|
||||
adox $t0, $acc4
|
||||
adcx $t1, $acc5
|
||||
|
||||
adox $acc1, $acc5
|
||||
adcx $acc1, $acc0 # cf=0
|
||||
adox $acc1, $acc0 # of=0
|
||||
adc $t0, $acc4
|
||||
adc $t1, $acc5
|
||||
adc \$0, $acc0
|
||||
xor $acc1 ,$acc1 # $acc1=0,cf=0,of=0
|
||||
|
||||
########################################################################
|
||||
# Multiply by b[2]
|
||||
@@ -1107,18 +1049,15 @@ __ecp_nistz256_mul_montx:
|
||||
|
||||
########################################################################
|
||||
# Third reduction step
|
||||
xor $acc2, $acc2 # $acc2=0,cf=0,of=0
|
||||
adox $t0, $acc3
|
||||
adox $t1, $acc4
|
||||
add $t0, $acc3
|
||||
adc $t1, $acc4
|
||||
|
||||
mulx $poly3, $t0, $t1
|
||||
mov 8*3($b_ptr), %rdx
|
||||
adox $t0, $acc5
|
||||
adcx $t1, $acc0
|
||||
|
||||
adox $acc2, $acc0
|
||||
adcx $acc2, $acc1 # cf=0
|
||||
adox $acc2, $acc1 # of=0
|
||||
adc $t0, $acc5
|
||||
adc $t1, $acc0
|
||||
adc \$0, $acc1
|
||||
xor $acc2, $acc2 # $acc2=0,cf=0,of=0
|
||||
|
||||
########################################################################
|
||||
# Multiply by b[3]
|
||||
@@ -1147,38 +1086,34 @@ __ecp_nistz256_mul_montx:
|
||||
|
||||
########################################################################
|
||||
# Fourth reduction step
|
||||
xor $acc3, $acc3 # $acc3=0,cf=0,of=0
|
||||
adox $t0, $acc4
|
||||
adox $t1, $acc5
|
||||
add $t0, $acc4
|
||||
adc $t1, $acc5
|
||||
|
||||
mulx $poly3, $t0, $t1
|
||||
mov $acc4, $t2
|
||||
mov .Lpoly+8*1(%rip), $poly1
|
||||
adcx $t0, $acc0
|
||||
adox $t1, $acc1
|
||||
adc $t0, $acc0
|
||||
mov $acc5, $t3
|
||||
|
||||
adcx $acc3, $acc1
|
||||
adox $acc3, $acc2
|
||||
adc $t1, $acc1
|
||||
adc \$0, $acc2
|
||||
mov $acc0, $t0
|
||||
|
||||
########################################################################
|
||||
# Branch-less conditional subtraction of P
|
||||
xor %eax, %eax
|
||||
mov $acc0, $t0
|
||||
sbb \$-1, $acc4 # .Lpoly[0]
|
||||
sbb $poly1, $acc5 # .Lpoly[1]
|
||||
sbb \$0, $acc0 # .Lpoly[2]
|
||||
mov $acc1, $t1
|
||||
sbb $poly3, $acc1 # .Lpoly[3]
|
||||
sbb \$0, $acc2
|
||||
|
||||
bt \$0,$acc2
|
||||
cmovnc $t2, $acc4
|
||||
cmovnc $t3, $acc5
|
||||
cmovc $t2, $acc4
|
||||
cmovc $t3, $acc5
|
||||
mov $acc4, 8*0($r_ptr)
|
||||
cmovnc $t0, $acc0
|
||||
cmovc $t0, $acc0
|
||||
mov $acc5, 8*1($r_ptr)
|
||||
cmovnc $t1, $acc1
|
||||
cmovc $t1, $acc1
|
||||
mov $acc0, 8*2($r_ptr)
|
||||
mov $acc1, 8*3($r_ptr)
|
||||
|
||||
@@ -1246,52 +1181,44 @@ __ecp_nistz256_sqr_montx:
|
||||
mov .Lpoly+8*3(%rip), $t1
|
||||
|
||||
# reduction step 1
|
||||
xor $acc0, $acc0
|
||||
adcx $t0, $acc1
|
||||
adcx $t4, $acc2
|
||||
add $t0, $acc1
|
||||
adc $t4, $acc2
|
||||
|
||||
mulx $t1, $t0, $t4
|
||||
mulx $t1, $t0, $acc0
|
||||
mov $acc1, %rdx
|
||||
adcx $t0, $acc3
|
||||
adc $t0, $acc3
|
||||
shlx $a_ptr, $acc1, $t0
|
||||
adox $t4, $acc0
|
||||
shrx $a_ptr, $acc1, $t4
|
||||
adc \$0, $acc0
|
||||
shrx $a_ptr, $acc1, $t4
|
||||
|
||||
# reduction step 2
|
||||
xor $acc1, $acc1
|
||||
adcx $t0, $acc2
|
||||
adcx $t4, $acc3
|
||||
add $t0, $acc2
|
||||
adc $t4, $acc3
|
||||
|
||||
mulx $t1, $t0, $t4
|
||||
mulx $t1, $t0, $acc1
|
||||
mov $acc2, %rdx
|
||||
adcx $t0, $acc0
|
||||
adc $t0, $acc0
|
||||
shlx $a_ptr, $acc2, $t0
|
||||
adox $t4, $acc1
|
||||
shrx $a_ptr, $acc2, $t4
|
||||
adc \$0, $acc1
|
||||
shrx $a_ptr, $acc2, $t4
|
||||
|
||||
# reduction step 3
|
||||
xor $acc2, $acc2
|
||||
adcx $t0, $acc3
|
||||
adcx $t4, $acc0
|
||||
add $t0, $acc3
|
||||
adc $t4, $acc0
|
||||
|
||||
mulx $t1, $t0, $t4
|
||||
mulx $t1, $t0, $acc2
|
||||
mov $acc3, %rdx
|
||||
adcx $t0, $acc1
|
||||
adc $t0, $acc1
|
||||
shlx $a_ptr, $acc3, $t0
|
||||
adox $t4, $acc2
|
||||
shrx $a_ptr, $acc3, $t4
|
||||
adc \$0, $acc2
|
||||
shrx $a_ptr, $acc3, $t4
|
||||
|
||||
# reduction step 4
|
||||
xor $acc3, $acc3
|
||||
adcx $t0, $acc0
|
||||
adcx $t4, $acc1
|
||||
add $t0, $acc0
|
||||
adc $t4, $acc1
|
||||
|
||||
mulx $t1, $t0, $t4
|
||||
adcx $t0, $acc2
|
||||
adox $t4, $acc3
|
||||
mulx $t1, $t0, $acc3
|
||||
adc $t0, $acc2
|
||||
adc \$0, $acc3
|
||||
|
||||
xor $t3, $t3 # cf=0
|
||||
@@ -1311,14 +1238,14 @@ __ecp_nistz256_sqr_montx:
|
||||
sbb \$0, $acc6 # .Lpoly[2]
|
||||
mov $acc7, $acc3
|
||||
sbb $t1, $acc7 # .Lpoly[3]
|
||||
sbb \$0, $t3
|
||||
|
||||
bt \$0,$t3
|
||||
cmovnc $acc0, $acc4
|
||||
cmovnc $acc1, $acc5
|
||||
cmovc $acc0, $acc4
|
||||
cmovc $acc1, $acc5
|
||||
mov $acc4, 8*0($r_ptr)
|
||||
cmovnc $acc2, $acc6
|
||||
cmovc $acc2, $acc6
|
||||
mov $acc5, 8*1($r_ptr)
|
||||
cmovnc $acc3, $acc7
|
||||
cmovc $acc3, $acc7
|
||||
mov $acc6, 8*2($r_ptr)
|
||||
mov $acc7, 8*3($r_ptr)
|
||||
|
||||
@@ -1329,8 +1256,8 @@ ___
|
||||
}
|
||||
{
|
||||
my ($r_ptr,$in_ptr)=("%rdi","%rsi");
|
||||
my ($acc0,$acc1,$acc2,$acc3,$acc4)=map("%r$_",(8..12));
|
||||
my ($t0,$t1)=("%rcx","%rsi");
|
||||
my ($acc0,$acc1,$acc2,$acc3)=map("%r$_",(8..11));
|
||||
my ($t0,$t1,$t2)=("%rcx","%r12","%r13");
|
||||
|
||||
$code.=<<___;
|
||||
################################################################################
|
||||
@@ -1347,109 +1274,83 @@ ecp_nistz256_from_mont:
|
||||
push %r13
|
||||
|
||||
mov 8*0($in_ptr), %rax
|
||||
mov .Lpoly+8*3(%rip), $t2
|
||||
mov 8*1($in_ptr), $acc1
|
||||
mov 8*2($in_ptr), $acc2
|
||||
mov 8*3($in_ptr), $acc3
|
||||
lea .Lpoly(%rip), $in_ptr
|
||||
xor $acc4, $acc4
|
||||
mov %rax, $acc0
|
||||
mov .Lpoly+8*1(%rip), $t1
|
||||
|
||||
#########################################
|
||||
# First iteration
|
||||
mulq 1*8($in_ptr)
|
||||
xor $t0, $t0
|
||||
mov %rax, $t0
|
||||
shl \$32, $acc0
|
||||
mulq $t2
|
||||
shr \$32, $t0
|
||||
add $acc0, $acc1
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc1
|
||||
mov $acc0, %rax
|
||||
adc %rdx, $acc2
|
||||
adc \$0, $t0
|
||||
|
||||
mulq 3*8($in_ptr)
|
||||
xor $acc0, $acc0
|
||||
add $t0, $acc3
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc3
|
||||
adc $t0, $acc2
|
||||
adc %rax, $acc3
|
||||
mov $acc1, %rax
|
||||
adc %rdx, $acc4
|
||||
adc \$0, $acc0
|
||||
adc \$0, %rdx
|
||||
|
||||
#########################################
|
||||
# Second iteration
|
||||
mulq 1*8($in_ptr)
|
||||
xor $t0, $t0
|
||||
mov $acc1, $t0
|
||||
shl \$32, $acc1
|
||||
mov %rdx, $acc0
|
||||
mulq $t2
|
||||
shr \$32, $t0
|
||||
add $acc1, $acc2
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc2
|
||||
mov $acc1, %rax
|
||||
adc %rdx, $acc3
|
||||
adc \$0, $t0
|
||||
|
||||
mulq 3*8($in_ptr)
|
||||
xor $acc1, $acc1
|
||||
add $t0, $acc4
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc4
|
||||
adc $t0, $acc3
|
||||
adc %rax, $acc0
|
||||
mov $acc2, %rax
|
||||
adc %rdx, $acc0
|
||||
adc \$0, $acc1
|
||||
adc \$0, %rdx
|
||||
|
||||
##########################################
|
||||
# Third iteration
|
||||
mulq 1*8($in_ptr)
|
||||
xor $t0, $t0
|
||||
mov $acc2, $t0
|
||||
shl \$32, $acc2
|
||||
mov %rdx, $acc1
|
||||
mulq $t2
|
||||
shr \$32, $t0
|
||||
add $acc2, $acc3
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc3
|
||||
mov $acc2, %rax
|
||||
adc %rdx, $acc4
|
||||
adc \$0, $t0
|
||||
|
||||
mulq 3*8($in_ptr)
|
||||
xor $acc2, $acc2
|
||||
add $t0, $acc0
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc0
|
||||
adc $t0, $acc0
|
||||
adc %rax, $acc1
|
||||
mov $acc3, %rax
|
||||
adc %rdx, $acc1
|
||||
adc \$0, $acc2
|
||||
adc \$0, %rdx
|
||||
|
||||
###########################################
|
||||
# Last iteration
|
||||
mulq 1*8($in_ptr)
|
||||
xor $t0, $t0
|
||||
add $acc3, $acc4
|
||||
mov $acc3, $t0
|
||||
shl \$32, $acc3
|
||||
mov %rdx, $acc2
|
||||
mulq $t2
|
||||
shr \$32, $t0
|
||||
add $acc3, $acc0
|
||||
adc $t0, $acc1
|
||||
mov $acc0, $t0
|
||||
adc %rax, $acc2
|
||||
mov $acc1, $in_ptr
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc4
|
||||
mov $acc3, %rax
|
||||
adc %rdx, $acc0
|
||||
adc \$0, $t0
|
||||
|
||||
mulq 3*8($in_ptr)
|
||||
add $t0, $acc1
|
||||
adc \$0, %rdx
|
||||
add %rax, $acc1
|
||||
adc %rdx, $acc2
|
||||
sbb $acc3, $acc3
|
||||
###########################################
|
||||
# Branch-less conditional subtraction
|
||||
sub \$-1, $acc0
|
||||
mov $acc2, %rax
|
||||
sbb $t1, $acc1
|
||||
sbb \$0, $acc2
|
||||
mov %rdx, $acc3
|
||||
sbb $t2, %rdx
|
||||
sbb $t2, $t2
|
||||
|
||||
mov 0*8($in_ptr), %rax
|
||||
mov 1*8($in_ptr), %rdx
|
||||
mov 2*8($in_ptr), $t0
|
||||
mov 3*8($in_ptr), $t1
|
||||
|
||||
and $acc3, %rax
|
||||
and $acc3, %rdx
|
||||
and $acc3, $t0
|
||||
and $acc3, $t1
|
||||
|
||||
sub %rax, $acc4
|
||||
sbb %rdx, $acc0
|
||||
mov $acc4, 8*0($r_ptr)
|
||||
sbb $t0, $acc1
|
||||
mov $acc0, 8*1($r_ptr)
|
||||
sbb $t1, $acc2
|
||||
mov $acc1, 8*2($r_ptr)
|
||||
mov $acc2, 8*3($r_ptr)
|
||||
cmovnz $t0, $acc0
|
||||
cmovnz $in_ptr, $acc1
|
||||
mov $acc0, 8*0($r_ptr)
|
||||
cmovnz %rax, $acc2
|
||||
mov $acc1, 8*1($r_ptr)
|
||||
cmovz %rdx, $acc3
|
||||
mov $acc2, 8*2($r_ptr)
|
||||
mov $acc3, 8*3($r_ptr)
|
||||
|
||||
pop %r13
|
||||
pop %r12
|
||||
|
@@ -68,7 +68,7 @@
|
||||
|
||||
#include "ec_lcl.h"
|
||||
|
||||
static const char EC_version[] = "EC" OPENSSL_VERSION_PTEXT;
|
||||
const char EC_version[] = "EC" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
|
||||
/* functions for EC_GROUP objects */
|
||||
|
@@ -445,15 +445,16 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
|
||||
wNAF_len = OPENSSL_malloc(totalnum * sizeof wNAF_len[0]);
|
||||
wNAF = OPENSSL_malloc((totalnum + 1) * sizeof wNAF[0]); /* includes space for pivot */
|
||||
val_sub = OPENSSL_malloc(totalnum * sizeof val_sub[0]);
|
||||
|
||||
|
||||
/* Ensure wNAF is initialised in case we end up going to err */
|
||||
if (wNAF) wNAF[0] = NULL; /* preliminary pivot */
|
||||
|
||||
if (!wsize || !wNAF_len || !wNAF || !val_sub)
|
||||
{
|
||||
ECerr(EC_F_EC_WNAF_MUL, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
wNAF[0] = NULL; /* preliminary pivot */
|
||||
|
||||
/* num_val will be the total number of temporarily precomputed points */
|
||||
num_val = 0;
|
||||
|
||||
|
@@ -213,6 +213,7 @@ static int pkey_ec_verify(EVP_PKEY_CTX *ctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_ECDH
|
||||
static int pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)
|
||||
{
|
||||
int ret;
|
||||
@@ -244,8 +245,8 @@ static int pkey_ec_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen)
|
||||
outlen = *keylen;
|
||||
|
||||
ret = ECDH_compute_key(key, outlen, pubkey, eckey, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret <= 0)
|
||||
return 0;
|
||||
*keylen = ret;
|
||||
return 1;
|
||||
}
|
||||
@@ -288,6 +289,7 @@ static int pkey_ec_kdf_derive(EVP_PKEY_CTX *ctx,
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
{
|
||||
@@ -316,6 +318,7 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
EC_GROUP_set_asn1_flag(dctx->gen_group, p1);
|
||||
return 1;
|
||||
|
||||
#ifndef OPENSSL_NO_ECDH
|
||||
case EVP_PKEY_CTRL_EC_ECDH_COFACTOR:
|
||||
if (p1 == -2)
|
||||
{
|
||||
@@ -357,6 +360,7 @@ static int pkey_ec_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
|
||||
dctx->co_key = NULL;
|
||||
}
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
case EVP_PKEY_CTRL_EC_KDF_TYPE:
|
||||
if (p1 == -2)
|
||||
@@ -556,7 +560,11 @@ const EVP_PKEY_METHOD ec_pkey_meth =
|
||||
0,0,
|
||||
|
||||
0,
|
||||
#ifndef OPENSSL_NO_ECDH
|
||||
pkey_ec_kdf_derive,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
|
||||
pkey_ec_ctrl,
|
||||
pkey_ec_ctrl_str
|
||||
|
@@ -113,7 +113,6 @@ typedef u64 smallfelem[NLIMBS];
|
||||
|
||||
/* This is the value of the prime as four 64-bit words, little-endian. */
|
||||
static const u64 kPrime[4] = { 0xfffffffffffffffful, 0xffffffff, 0, 0xffffffff00000001ul };
|
||||
static const limb bottom32bits = 0xffffffff;
|
||||
static const u64 bottom63bits = 0x7ffffffffffffffful;
|
||||
|
||||
/* bin32_to_felem takes a little-endian byte array and converts it into felem
|
||||
|
@@ -1366,7 +1366,7 @@ static const struct nistp_test_params nistp_tests_params[] =
|
||||
},
|
||||
};
|
||||
|
||||
void nistp_single_test(const struct nistp_test_params *test)
|
||||
static void nistp_single_test(const struct nistp_test_params *test)
|
||||
{
|
||||
BN_CTX *ctx;
|
||||
BIGNUM *p, *a, *b, *x, *y, *n, *m, *order;
|
||||
@@ -1469,7 +1469,7 @@ void nistp_single_test(const struct nistp_test_params *test)
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
|
||||
void nistp_tests()
|
||||
static void nistp_tests()
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
|
@@ -57,6 +57,7 @@
|
||||
*/
|
||||
|
||||
#include "ecs_locl.h"
|
||||
#include <string.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
@@ -84,13 +85,25 @@ int ECDSA_verify(int type, const unsigned char *dgst, int dgst_len,
|
||||
const unsigned char *sigbuf, int sig_len, EC_KEY *eckey)
|
||||
{
|
||||
ECDSA_SIG *s;
|
||||
const unsigned char *p = sigbuf;
|
||||
unsigned char *der = NULL;
|
||||
int derlen = -1;
|
||||
int ret=-1;
|
||||
|
||||
s = ECDSA_SIG_new();
|
||||
if (s == NULL) return(ret);
|
||||
if (d2i_ECDSA_SIG(&s, &sigbuf, sig_len) == NULL) goto err;
|
||||
if (d2i_ECDSA_SIG(&s, &p, sig_len) == NULL) goto err;
|
||||
/* Ensure signature uses DER and doesn't have trailing garbage */
|
||||
derlen = i2d_ECDSA_SIG(s, &der);
|
||||
if (derlen != sig_len || memcmp(sigbuf, der, derlen))
|
||||
goto err;
|
||||
ret=ECDSA_do_verify(dgst, dgst_len, s, eckey);
|
||||
err:
|
||||
if (derlen > 0)
|
||||
{
|
||||
OPENSSL_cleanse(der, derlen);
|
||||
OPENSSL_free(der);
|
||||
}
|
||||
ECDSA_SIG_free(s);
|
||||
return(ret);
|
||||
}
|
||||
|
@@ -114,9 +114,6 @@ static const ENGINE_CMD_DEFN dynamic_cmd_defns[] = {
|
||||
ENGINE_CMD_FLAG_NO_INPUT},
|
||||
{0, NULL, NULL, 0}
|
||||
};
|
||||
static const ENGINE_CMD_DEFN dynamic_cmd_defns_empty[] = {
|
||||
{0, NULL, NULL, 0}
|
||||
};
|
||||
|
||||
/* Loading code stores state inside the ENGINE structure via the "ex_data"
|
||||
* element. We load all our state into a single structure and use that as a
|
||||
|
@@ -72,6 +72,7 @@ R SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060
|
||||
R SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070
|
||||
R SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071
|
||||
R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
|
||||
R SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086
|
||||
R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
|
||||
R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
|
||||
R SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110
|
||||
|
@@ -406,7 +406,7 @@ evp_enc.o: ../../include/openssl/pkcs7.h ../../include/openssl/rand.h
|
||||
evp_enc.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h
|
||||
evp_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
|
||||
evp_enc.o: ../../include/openssl/x509.h ../../include/openssl/x509_vfy.h
|
||||
evp_enc.o: ../constant_time_locl.h ../cryptlib.h evp_enc.c evp_locl.h
|
||||
evp_enc.o: ../cryptlib.h evp_enc.c evp_locl.h
|
||||
evp_err.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h
|
||||
evp_err.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
|
||||
evp_err.o: ../../include/openssl/err.h ../../include/openssl/evp.h
|
||||
|
@@ -911,7 +911,7 @@ const EVP_CIPHER *EVP_aes_##keylen##_##mode(void) \
|
||||
|
||||
#if defined(OPENSSL_CPUID_OBJ) && (defined(__arm__) || defined(__arm) || defined(__aarch64__))
|
||||
#include "arm_arch.h"
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
# if defined(BSAES_ASM)
|
||||
# define BSAES_CAPABLE (OPENSSL_armcap_P & ARMV7_NEON)
|
||||
# endif
|
||||
|
@@ -148,12 +148,11 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
#ifdef KSSL_DEBUG
|
||||
{
|
||||
int i;
|
||||
char *cp;
|
||||
printf("des_ede_cbc_cipher(ctx=%lx, buflen=%d)\n", ctx, ctx->buf_len);
|
||||
printf("\t iv= ");
|
||||
fprintf(stderr,"des_ede_cbc_cipher(ctx=%p, buflen=%d)\n", ctx, ctx->buf_len);
|
||||
fprintf(stderr,"\t iv= ");
|
||||
for(i=0;i<8;i++)
|
||||
printf("%02X",ctx->iv[i]);
|
||||
printf("\n");
|
||||
fprintf(stderr,"%02X",ctx->iv[i]);
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
#endif /* KSSL_DEBUG */
|
||||
if (dat->stream.cbc)
|
||||
@@ -307,11 +306,14 @@ static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
#ifdef KSSL_DEBUG
|
||||
{
|
||||
int i;
|
||||
printf("des_ede3_init_key(ctx=%lx)\n", ctx);
|
||||
printf("\tKEY= ");
|
||||
for(i=0;i<24;i++) printf("%02X",key[i]); printf("\n");
|
||||
printf("\t IV= ");
|
||||
for(i=0;i<8;i++) printf("%02X",iv[i]); printf("\n");
|
||||
fprintf(stderr,"des_ede3_init_key(ctx=%p)\n", ctx);
|
||||
fprintf(stderr,"\tKEY= ");
|
||||
for(i=0;i<24;i++) fprintf(stderr,"%02X",key[i]); fprintf(stderr,"\n");
|
||||
if (iv)
|
||||
{
|
||||
fprintf(stderr,"\t IV= ");
|
||||
for(i=0;i<8;i++) fprintf(stderr,"%02X",iv[i]); fprintf(stderr,"\n");
|
||||
}
|
||||
}
|
||||
#endif /* KSSL_DEBUG */
|
||||
|
||||
|
@@ -67,7 +67,6 @@
|
||||
#ifdef OPENSSL_FIPS
|
||||
#include <openssl/fips.h>
|
||||
#endif
|
||||
#include "constant_time_locl.h"
|
||||
#include "evp_locl.h"
|
||||
|
||||
#ifdef OPENSSL_FIPS
|
||||
@@ -517,21 +516,21 @@ int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
|
||||
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
{
|
||||
unsigned int i, b;
|
||||
unsigned char pad, padding_good;
|
||||
int i,n;
|
||||
unsigned int b;
|
||||
*outl=0;
|
||||
|
||||
if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER)
|
||||
{
|
||||
int ret = M_do_cipher(ctx, out, NULL, 0);
|
||||
if (ret < 0)
|
||||
i = M_do_cipher(ctx, out, NULL, 0);
|
||||
if (i < 0)
|
||||
return 0;
|
||||
else
|
||||
*outl = ret;
|
||||
*outl = i;
|
||||
return 1;
|
||||
}
|
||||
|
||||
b=(unsigned int)(ctx->cipher->block_size);
|
||||
b=ctx->cipher->block_size;
|
||||
if (ctx->flags & EVP_CIPH_NO_PADDING)
|
||||
{
|
||||
if(ctx->buf_len)
|
||||
@@ -550,34 +549,33 @@ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
|
||||
return(0);
|
||||
}
|
||||
OPENSSL_assert(b <= sizeof ctx->final);
|
||||
pad=ctx->final[b-1];
|
||||
|
||||
padding_good = (unsigned char)(~constant_time_is_zero_8(pad));
|
||||
padding_good &= constant_time_ge_8(b, pad);
|
||||
|
||||
for (i = 1; i < b; ++i)
|
||||
{
|
||||
unsigned char is_pad_index = constant_time_lt_8(i, pad);
|
||||
unsigned char pad_byte_good = constant_time_eq_8(ctx->final[b-i-1], pad);
|
||||
padding_good &= constant_time_select_8(is_pad_index, pad_byte_good, 0xff);
|
||||
}
|
||||
|
||||
/*
|
||||
* At least 1 byte is always padding, so we always write b - 1
|
||||
* bytes to avoid a timing leak. The caller is required to have |b|
|
||||
* bytes space in |out| by the API contract.
|
||||
* The following assumes that the ciphertext has been authenticated.
|
||||
* Otherwise it provides a padding oracle.
|
||||
*/
|
||||
for (i = 0; i < b - 1; ++i)
|
||||
out[i] = ctx->final[i] & padding_good;
|
||||
/* Safe cast: for a good padding, EVP_MAX_IV_LENGTH >= b >= pad */
|
||||
*outl = padding_good & ((unsigned char)(b - pad));
|
||||
return padding_good & 1;
|
||||
n=ctx->final[b-1];
|
||||
if (n == 0 || n > (int)b)
|
||||
{
|
||||
EVPerr(EVP_F_EVP_DECRYPTFINAL_EX,EVP_R_BAD_DECRYPT);
|
||||
return(0);
|
||||
}
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
if (ctx->final[--b] != n)
|
||||
{
|
||||
EVPerr(EVP_F_EVP_DECRYPTFINAL_EX,EVP_R_BAD_DECRYPT);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
n=ctx->cipher->block_size-n;
|
||||
for (i=0; i<n; i++)
|
||||
out[i]=ctx->final[i];
|
||||
*outl=n;
|
||||
}
|
||||
else
|
||||
{
|
||||
*outl = 0;
|
||||
return 1;
|
||||
}
|
||||
*outl=0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx)
|
||||
|
@@ -245,8 +245,7 @@
|
||||
#define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++)))<<24), \
|
||||
l|=(((unsigned long)(*((c)++)))<<16), \
|
||||
l|=(((unsigned long)(*((c)++)))<< 8), \
|
||||
l|=(((unsigned long)(*((c)++))) ), \
|
||||
l)
|
||||
l|=(((unsigned long)(*((c)++))) ) )
|
||||
#endif
|
||||
#ifndef HOST_l2c
|
||||
#define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \
|
||||
@@ -282,8 +281,7 @@
|
||||
#define HOST_c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \
|
||||
l|=(((unsigned long)(*((c)++)))<< 8), \
|
||||
l|=(((unsigned long)(*((c)++)))<<16), \
|
||||
l|=(((unsigned long)(*((c)++)))<<24), \
|
||||
l)
|
||||
l|=(((unsigned long)(*((c)++)))<<24) )
|
||||
#endif
|
||||
#ifndef HOST_l2c
|
||||
#define HOST_l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
|
||||
|
12
crypto/mem.c
12
crypto/mem.c
@@ -255,10 +255,12 @@ void *CRYPTO_malloc_locked(int num, const char *file, int line)
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
allow_customize = 0;
|
||||
if(allow_customize)
|
||||
allow_customize = 0;
|
||||
if (malloc_debug_func != NULL)
|
||||
{
|
||||
allow_customize_debug = 0;
|
||||
if(allow_customize_debug)
|
||||
allow_customize_debug = 0;
|
||||
malloc_debug_func(NULL, num, file, line, 0);
|
||||
}
|
||||
ret = malloc_locked_ex_func(num,file,line);
|
||||
@@ -299,10 +301,12 @@ void *CRYPTO_malloc(int num, const char *file, int line)
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
allow_customize = 0;
|
||||
if(allow_customize)
|
||||
allow_customize = 0;
|
||||
if (malloc_debug_func != NULL)
|
||||
{
|
||||
allow_customize_debug = 0;
|
||||
if(allow_customize_debug)
|
||||
allow_customize_debug = 0;
|
||||
malloc_debug_func(NULL, num, file, line, 0);
|
||||
}
|
||||
ret = malloc_ex_func(num,file,line);
|
||||
|
@@ -22,7 +22,10 @@
|
||||
# [1] and [2], with MOVBE twist suggested by Ilya Albrekht and Max
|
||||
# Locktyukhin of Intel Corp. who verified that it reduces shuffles
|
||||
# pressure with notable relative improvement, achieving 1.0 cycle per
|
||||
# byte processed with 128-bit key on Haswell processor.
|
||||
# byte processed with 128-bit key on Haswell processor, and 0.74 -
|
||||
# on Broadwell. [Mentioned results are raw profiled measurements for
|
||||
# favourable packet size, one divisible by 96. Applications using the
|
||||
# EVP interface will observe a few percent worse performance.]
|
||||
#
|
||||
# [1] http://rt.openssl.org/Ticket/Display.html?id=2900&user=guest&pass=guest
|
||||
# [2] http://www.intel.com/content/dam/www/public/us/en/documents/software-support/enabling-high-performance-gcm.pdf
|
||||
|
@@ -365,7 +365,8 @@ ___
|
||||
}
|
||||
|
||||
$code.=<<___;
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.global gcm_init_neon
|
||||
|
@@ -63,6 +63,7 @@
|
||||
# Sandy Bridge 1.80(+8%)
|
||||
# Ivy Bridge 1.80(+7%)
|
||||
# Haswell 0.55(+93%) (if system doesn't support AVX)
|
||||
# Broadwell 0.45(+110%)(if system doesn't support AVX)
|
||||
# Bulldozer 1.49(+27%)
|
||||
# Silvermont 2.88(+13%)
|
||||
|
||||
@@ -73,7 +74,8 @@
|
||||
# CPUs such as Sandy and Ivy Bridge can execute it, the code performs
|
||||
# sub-optimally in comparison to above mentioned version. But thanks
|
||||
# to Ilya Albrekht and Max Locktyukhin of Intel Corp. we knew that
|
||||
# it performs in 0.41 cycles per byte on Haswell processor.
|
||||
# it performs in 0.41 cycles per byte on Haswell processor, and in
|
||||
# 0.29 on Broadwell.
|
||||
#
|
||||
# [1] http://rt.openssl.org/Ticket/Display.html?id=2900&user=guest&pass=guest
|
||||
|
||||
|
@@ -675,7 +675,7 @@ void gcm_ghash_4bit_x86(u64 Xi[2],const u128 Htable[16],const u8 *inp,size_t len
|
||||
# endif
|
||||
# elif defined(__arm__) || defined(__arm) || defined(__aarch64__)
|
||||
# include "arm_arch.h"
|
||||
# if __ARM_ARCH__>=7
|
||||
# if __ARM_MAX_ARCH__>=7
|
||||
# define GHASH_ASM_ARM
|
||||
# define GCM_FUNCREF_4BIT
|
||||
# define PMULL_CAPABLE (OPENSSL_armcap_P & ARMV8_PMULL)
|
||||
|
@@ -53,9 +53,6 @@ static const nid_triple sigoid_srt[] =
|
||||
|
||||
static const nid_triple * const sigoid_srt_xref[] =
|
||||
{
|
||||
&sigoid_srt[29],
|
||||
&sigoid_srt[17],
|
||||
&sigoid_srt[18],
|
||||
&sigoid_srt[0],
|
||||
&sigoid_srt[1],
|
||||
&sigoid_srt[7],
|
||||
|
@@ -91,7 +91,10 @@ EOF
|
||||
|
||||
foreach (@srt2)
|
||||
{
|
||||
my $x = $xref_tbl{$_}[2];
|
||||
my ($p1, $p2, $x) = @{$xref_tbl{$_}};
|
||||
# If digest or signature algorithm is "undef" then the algorithm
|
||||
# needs special handling and is excluded from the cross reference table.
|
||||
next if $p1 eq "undef" || $p2 eq "undef";
|
||||
print "\t\&sigoid_srt\[$x\],\n";
|
||||
}
|
||||
|
||||
|
@@ -29,11 +29,11 @@ extern "C" {
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
#define OPENSSL_VERSION_NUMBER 0x10002003L
|
||||
#define OPENSSL_VERSION_NUMBER 0x10002004L
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2-beta3-fips 25 Sep 2014"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2-beta4-fips-dev xx XXX xxxx"
|
||||
#else
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2-beta3 25 Sep 2014"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2-beta4-dev xx XXX xxxx"
|
||||
#endif
|
||||
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
|
||||
|
||||
|
@@ -233,10 +233,6 @@ DECLARE_PKCS12_STACK_OF(PKCS7)
|
||||
(OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)
|
||||
#define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data)
|
||||
#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)
|
||||
#define PKCS7_type_is_encrypted(a) \
|
||||
(OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)
|
||||
|
||||
#define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)
|
||||
|
||||
#define PKCS7_set_detached(p,v) \
|
||||
PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)
|
||||
|
@@ -196,12 +196,6 @@ int RAND_poll(void)
|
||||
DWORD w;
|
||||
int good = 0;
|
||||
|
||||
/* Determine the OS version we are on so we can turn off things
|
||||
* that do not work properly.
|
||||
*/
|
||||
OSVERSIONINFO osverinfo ;
|
||||
osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ;
|
||||
GetVersionEx( &osverinfo ) ;
|
||||
|
||||
#if defined(OPENSSL_SYS_WINCE)
|
||||
# if defined(_WIN32_WCE) && _WIN32_WCE>=300
|
||||
@@ -281,56 +275,6 @@ int RAND_poll(void)
|
||||
* at random times on Windows 2000. Reported by Jeffrey Altman.
|
||||
* Only use it on NT.
|
||||
*/
|
||||
/* Wolfgang Marczy <WMarczy@topcall.co.at> reports that
|
||||
* the RegQueryValueEx call below can hang on NT4.0 (SP6).
|
||||
* So we don't use this at all for now. */
|
||||
#if 0
|
||||
if ( osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
|
||||
osverinfo.dwMajorVersion < 5)
|
||||
{
|
||||
/* Read Performance Statistics from NT/2000 registry
|
||||
* The size of the performance data can vary from call
|
||||
* to call so we must guess the size of the buffer to use
|
||||
* and increase its size if we get an ERROR_MORE_DATA
|
||||
* return instead of ERROR_SUCCESS.
|
||||
*/
|
||||
LONG rc=ERROR_MORE_DATA;
|
||||
char * buf=NULL;
|
||||
DWORD bufsz=0;
|
||||
DWORD length;
|
||||
|
||||
while (rc == ERROR_MORE_DATA)
|
||||
{
|
||||
buf = realloc(buf,bufsz+8192);
|
||||
if (!buf)
|
||||
break;
|
||||
bufsz += 8192;
|
||||
|
||||
length = bufsz;
|
||||
rc = RegQueryValueEx(HKEY_PERFORMANCE_DATA, TEXT("Global"),
|
||||
NULL, NULL, buf, &length);
|
||||
}
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
/* For entropy count assume only least significant
|
||||
* byte of each DWORD is random.
|
||||
*/
|
||||
RAND_add(&length, sizeof(length), 0);
|
||||
RAND_add(buf, length, length / 4.0);
|
||||
|
||||
/* Close the Registry Key to allow Windows to cleanup/close
|
||||
* the open handle
|
||||
* Note: The 'HKEY_PERFORMANCE_DATA' key is implicitly opened
|
||||
* when the RegQueryValueEx above is done. However, if
|
||||
* it is not explicitly closed, it can cause disk
|
||||
* partition manipulation problems.
|
||||
*/
|
||||
RegCloseKey(HKEY_PERFORMANCE_DATA);
|
||||
}
|
||||
if (buf)
|
||||
free(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (advapi)
|
||||
{
|
||||
@@ -383,7 +327,7 @@ int RAND_poll(void)
|
||||
if (advapi)
|
||||
FreeLibrary(advapi);
|
||||
|
||||
if ((osverinfo.dwPlatformId != VER_PLATFORM_WIN32_NT ||
|
||||
if ((!check_winnt() ||
|
||||
!OPENSSL_isservice()) &&
|
||||
(user = LoadLibrary(TEXT("USER32.DLL"))))
|
||||
{
|
||||
@@ -407,8 +351,7 @@ int RAND_poll(void)
|
||||
* on NT4 even though it exists in SP3 (or SP6) and
|
||||
* higher.
|
||||
*/
|
||||
if ( osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&
|
||||
osverinfo.dwMajorVersion < 5)
|
||||
if (check_winnt() && !check_win_minplat(5))
|
||||
cursor = 0;
|
||||
}
|
||||
if (cursor)
|
||||
|
@@ -151,6 +151,25 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check DigestInfo structure does not contain extraneous data by reencoding
|
||||
* using DER and checking encoding against original.
|
||||
*/
|
||||
static int rsa_check_digestinfo(X509_SIG *sig, const unsigned char *dinfo, int dinfolen)
|
||||
{
|
||||
unsigned char *der = NULL;
|
||||
int derlen;
|
||||
int ret = 0;
|
||||
derlen = i2d_X509_SIG(sig, &der);
|
||||
if (derlen <= 0)
|
||||
return 0;
|
||||
if (derlen == dinfolen && !memcmp(dinfo, der, derlen))
|
||||
ret = 1;
|
||||
OPENSSL_cleanse(der, derlen);
|
||||
OPENSSL_free(der);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int int_rsa_verify(int dtype, const unsigned char *m,
|
||||
unsigned int m_len,
|
||||
unsigned char *rm, size_t *prm_len,
|
||||
@@ -228,7 +247,7 @@ int int_rsa_verify(int dtype, const unsigned char *m,
|
||||
if (sig == NULL) goto err;
|
||||
|
||||
/* Excess data can be used to create forgeries */
|
||||
if(p != s+i)
|
||||
if(p != s+i || !rsa_check_digestinfo(sig, s, i))
|
||||
{
|
||||
RSAerr(RSA_F_INT_RSA_VERIFY,RSA_R_BAD_SIGNATURE);
|
||||
goto err;
|
||||
|
@@ -174,7 +174,7 @@ $code=<<___;
|
||||
|
||||
.align 5
|
||||
sha1_block_data_order:
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
sub r3,pc,#8 @ sha1_block_data_order
|
||||
ldr r12,.LOPENSSL_armcap
|
||||
ldr r12,[r3,r12] @ OPENSSL_armcap_P
|
||||
@@ -264,8 +264,10 @@ $code.=<<___;
|
||||
.LK_20_39: .word 0x6ed9eba1
|
||||
.LK_40_59: .word 0x8f1bbcdc
|
||||
.LK_60_79: .word 0xca62c1d6
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.LOPENSSL_armcap:
|
||||
.word OPENSSL_armcap_P-sha1_block_data_order
|
||||
#endif
|
||||
.asciz "SHA1 block transform for ARMv4/NEON/ARMv8, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.align 5
|
||||
___
|
||||
@@ -476,7 +478,8 @@ sub Xloop()
|
||||
}
|
||||
|
||||
$code.=<<___;
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.type sha1_block_data_order_neon,%function
|
||||
@@ -563,7 +566,7 @@ my @Kxx=map("q$_",(8..11));
|
||||
my ($W0,$W1,$ABCD_SAVE)=map("q$_",(12..14));
|
||||
|
||||
$code.=<<___;
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.type sha1_block_data_order_armv8,%function
|
||||
.align 5
|
||||
sha1_block_data_order_armv8:
|
||||
@@ -637,7 +640,9 @@ $code.=<<___;
|
||||
___
|
||||
}}}
|
||||
$code.=<<___;
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.comm OPENSSL_armcap_P,4,4
|
||||
#endif
|
||||
___
|
||||
|
||||
{ my %opcode = (
|
||||
|
@@ -68,7 +68,7 @@ if ($flavour =~ /64|n32/i) {
|
||||
#
|
||||
######################################################################
|
||||
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -P -`=~/MIPSEL/)?1:0;
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -`=~/MIPSEL/)?1:0 if ($ENV{CC});
|
||||
|
||||
for (@ARGV) { $output=$_ if (/^\w[\w\-]*\.\w+$/); }
|
||||
open STDOUT,">$output";
|
||||
|
@@ -177,8 +177,10 @@ K256:
|
||||
.word 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
|
||||
.size K256,.-K256
|
||||
.word 0 @ terminator
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.LOPENSSL_armcap:
|
||||
.word OPENSSL_armcap_P-sha256_block_data_order
|
||||
#endif
|
||||
.align 5
|
||||
|
||||
.global sha256_block_data_order
|
||||
@@ -186,7 +188,7 @@ K256:
|
||||
sha256_block_data_order:
|
||||
sub r3,pc,#8 @ sha256_block_data_order
|
||||
add $len,$inp,$len,lsl#6 @ len to point at the end of inp
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
ldr r12,.LOPENSSL_armcap
|
||||
ldr r12,[r3,r12] @ OPENSSL_armcap_P
|
||||
tst r12,#ARMV8_SHA256
|
||||
@@ -423,7 +425,8 @@ sub body_00_15 () {
|
||||
}
|
||||
|
||||
$code.=<<___;
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.type sha256_block_data_order_neon,%function
|
||||
@@ -545,7 +548,7 @@ my ($W0,$W1,$ABCD_SAVE,$EFGH_SAVE)=map("q$_",(12..15));
|
||||
my $Ktbl="r3";
|
||||
|
||||
$code.=<<___;
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.type sha256_block_data_order_armv8,%function
|
||||
.align 5
|
||||
sha256_block_data_order_armv8:
|
||||
@@ -616,7 +619,9 @@ ___
|
||||
$code.=<<___;
|
||||
.asciz "SHA256 block transform for ARMv4/NEON/ARMv8, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.align 2
|
||||
#if __ARM_MARCH_ARCH__>=7
|
||||
.comm OPENSSL_armcap_P,4,4
|
||||
#endif
|
||||
___
|
||||
|
||||
{ my %opcode = (
|
||||
|
@@ -237,16 +237,20 @@ WORD64(0x3c9ebe0a,0x15c9bebc, 0x431d67c4,0x9c100d4c)
|
||||
WORD64(0x4cc5d4be,0xcb3e42b6, 0x597f299c,0xfc657e2a)
|
||||
WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817)
|
||||
.size K512,.-K512
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.LOPENSSL_armcap:
|
||||
.word OPENSSL_armcap_P-sha512_block_data_order
|
||||
.skip 32-4
|
||||
#else
|
||||
.skip 32
|
||||
#endif
|
||||
|
||||
.global sha512_block_data_order
|
||||
.type sha512_block_data_order,%function
|
||||
sha512_block_data_order:
|
||||
sub r3,pc,#8 @ sha512_block_data_order
|
||||
add $len,$inp,$len,lsl#7 @ len to point at the end of inp
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
ldr r12,.LOPENSSL_armcap
|
||||
ldr r12,[r3,r12] @ OPENSSL_armcap_P
|
||||
tst r12,#1
|
||||
@@ -551,7 +555,8 @@ ___
|
||||
}
|
||||
|
||||
$code.=<<___;
|
||||
#if __ARM_ARCH__>=7
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.arch armv7-a
|
||||
.fpu neon
|
||||
|
||||
.align 4
|
||||
@@ -592,7 +597,9 @@ $code.=<<___;
|
||||
.size sha512_block_data_order,.-sha512_block_data_order
|
||||
.asciz "SHA512 block transform for ARMv4/NEON, CRYPTOGAMS by <appro\@openssl.org>"
|
||||
.align 2
|
||||
#if __ARM_MAX_ARCH__>=7
|
||||
.comm OPENSSL_armcap_P,4,4
|
||||
#endif
|
||||
___
|
||||
|
||||
$code =~ s/\`([^\`]*)\`/eval $1/gem;
|
||||
|
@@ -72,7 +72,7 @@ $pf = ($flavour =~ /nubi/i) ? $t0 : $t2;
|
||||
#
|
||||
######################################################################
|
||||
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -P -`=~/MIPSEL/)?1:0;
|
||||
$big_endian=(`echo MIPSEL | $ENV{CC} -E -`=~/MIPSEL/)?1:0 if ($ENV{CC});
|
||||
|
||||
for (@ARGV) { $output=$_ if (/^\w[\w\-]*\.\w+$/); }
|
||||
open STDOUT,">$output";
|
||||
|
@@ -971,7 +971,7 @@ TS_RESP_set_genTime_with_precision(ASN1_GENERALIZEDTIME *asn1_time,
|
||||
if (precision > 0)
|
||||
{
|
||||
/* Add fraction of seconds (leave space for dot and null). */
|
||||
BIO_snprintf(p, 2 + precision, ".%ld", usec);
|
||||
BIO_snprintf(p, 2 + precision, ".%06ld", usec);
|
||||
/* We cannot use the snprintf return value,
|
||||
because it might have been truncated. */
|
||||
p += strlen(p);
|
||||
|
@@ -772,6 +772,7 @@ int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, void *pval);
|
||||
void X509_ALGOR_get0(ASN1_OBJECT **paobj, int *pptype, void **ppval,
|
||||
X509_ALGOR *algor);
|
||||
void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
|
||||
int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
|
||||
|
||||
X509_NAME *X509_NAME_dup(X509_NAME *xn);
|
||||
X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne);
|
||||
|
@@ -73,6 +73,8 @@
|
||||
|
||||
int X509_verify(X509 *a, EVP_PKEY *r)
|
||||
{
|
||||
if (X509_ALGOR_cmp(a->sig_alg, a->cert_info->signature))
|
||||
return 0;
|
||||
return(ASN1_item_verify(ASN1_ITEM_rptr(X509_CINF),a->sig_alg,
|
||||
a->signature,a->cert_info,r));
|
||||
}
|
||||
|
@@ -401,7 +401,7 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base)
|
||||
if (dns->length > base->length)
|
||||
{
|
||||
dnsptr += dns->length - base->length;
|
||||
if (dnsptr[-1] != '.')
|
||||
if (*baseptr != '.' && dnsptr[-1] != '.')
|
||||
return X509_V_ERR_PERMITTED_VIOLATION;
|
||||
}
|
||||
|
||||
|
@@ -752,7 +752,7 @@ static const unsigned char *valid_star(const unsigned char *p, size_t len,
|
||||
{
|
||||
int atstart = (state & LABEL_START);
|
||||
int atend = (i == len - 1 || p[i+i] == '.');
|
||||
/*
|
||||
/*-
|
||||
* At most one wildcard per pattern.
|
||||
* No wildcards in IDNA labels.
|
||||
* No wildcards after the first label.
|
||||
@@ -769,45 +769,26 @@ static const unsigned char *valid_star(const unsigned char *p, size_t len,
|
||||
star = &p[i];
|
||||
state &= ~LABEL_START;
|
||||
}
|
||||
else if ((state & LABEL_START) != 0)
|
||||
{
|
||||
/*
|
||||
* At the start of a label, skip any "xn--" and
|
||||
* remain in the LABEL_START state, but set the
|
||||
* IDNA label state
|
||||
*/
|
||||
if ((state & LABEL_IDNA) == 0 && len - i >= 4
|
||||
&& strncasecmp((char *)&p[i], "xn--", 4) == 0)
|
||||
{
|
||||
i += 3;
|
||||
state |= LABEL_IDNA;
|
||||
continue;
|
||||
}
|
||||
/* Labels must start with a letter or digit */
|
||||
state &= ~LABEL_START;
|
||||
if (('a' <= p[i] && p[i] <= 'z')
|
||||
|| ('A' <= p[i] && p[i] <= 'Z')
|
||||
|| ('0' <= p[i] && p[i] <= '9'))
|
||||
continue;
|
||||
return NULL;
|
||||
}
|
||||
else if (('a' <= p[i] && p[i] <= 'z')
|
||||
|| ('A' <= p[i] && p[i] <= 'Z')
|
||||
|| ('0' <= p[i] && p[i] <= '9'))
|
||||
{
|
||||
state &= LABEL_IDNA;
|
||||
continue;
|
||||
if ((state & LABEL_START) != 0
|
||||
&& len - i >= 4
|
||||
&& strncasecmp((char *)&p[i], "xn--", 4) == 0)
|
||||
state |= LABEL_IDNA;
|
||||
state &= ~(LABEL_HYPHEN|LABEL_START);
|
||||
}
|
||||
else if (p[i] == '.')
|
||||
{
|
||||
if (state & (LABEL_HYPHEN | LABEL_START))
|
||||
if ((state & (LABEL_HYPHEN | LABEL_START)) != 0)
|
||||
return NULL;
|
||||
state = LABEL_START;
|
||||
++dots;
|
||||
}
|
||||
else if (p[i] == '-')
|
||||
{
|
||||
if (state & LABEL_HYPHEN)
|
||||
if ((state & LABEL_HYPHEN) != 0)
|
||||
return NULL;
|
||||
state |= LABEL_HYPHEN;
|
||||
}
|
||||
|
@@ -3,22 +3,22 @@
|
||||
|
||||
1. Introduction
|
||||
|
||||
How you handle certificates depend a great deal on what your role is.
|
||||
How you handle certificates depends a great deal on what your role is.
|
||||
Your role can be one or several of:
|
||||
|
||||
- User of some client software
|
||||
- User of some server software
|
||||
- User of some client application
|
||||
- User of some server application
|
||||
- Certificate authority
|
||||
|
||||
This file is for users who wish to get a certificate of their own.
|
||||
Certificate authorities should read ca.txt.
|
||||
Certificate authorities should read https://www.openssl.org/docs/apps/ca.html.
|
||||
|
||||
In all the cases shown below, the standard configuration file, as
|
||||
compiled into openssl, will be used. You may find it in /etc/,
|
||||
/usr/local/ssl/ or somewhere else. The name is openssl.cnf, and
|
||||
is better described in another HOWTO <config.txt?>. If you want to
|
||||
use a different configuration file, use the argument '-config {file}'
|
||||
with the command shown below.
|
||||
/usr/local/ssl/ or somewhere else. By default the file is named
|
||||
openssl.cnf and is described at https://www.openssl.org/docs/apps/config.html.
|
||||
You can specify a different configuration file using the
|
||||
'-config {file}' argument with the commands shown below.
|
||||
|
||||
|
||||
2. Relationship with keys
|
||||
@@ -29,24 +29,26 @@ somewhere. With OpenSSL, public keys are easily derived from private
|
||||
keys, so before you create a certificate or a certificate request, you
|
||||
need to create a private key.
|
||||
|
||||
Private keys are generated with 'openssl genrsa' if you want a RSA
|
||||
private key, or 'openssl gendsa' if you want a DSA private key.
|
||||
Further information on how to create private keys can be found in
|
||||
another HOWTO <keys.txt?>. The rest of this text assumes you have
|
||||
a private key in the file privkey.pem.
|
||||
Private keys are generated with 'openssl genrsa -out privkey.pem' if
|
||||
you want a RSA private key, or if you want a DSA private key:
|
||||
'openssl dsaparam -out dsaparam.pem 2048; openssl gendsa -out privkey.pem dsaparam.pem'.
|
||||
|
||||
The private keys created by these commands are not passphrase protected;
|
||||
it might or might not be the desirable thing. Further information on how to
|
||||
create private keys can be found at https://www.openssl.org/docs/HOWTO/keys.txt.
|
||||
The rest of this text assumes you have a private key in the file privkey.pem.
|
||||
|
||||
|
||||
3. Creating a certificate request
|
||||
|
||||
To create a certificate, you need to start with a certificate
|
||||
request (or, as some certificate authorities like to put
|
||||
it, "certificate signing request", since that's exactly what they do,
|
||||
they sign it and give you the result back, thus making it authentic
|
||||
according to their policies). A certificate request can then be sent
|
||||
to a certificate authority to get it signed into a certificate, or if
|
||||
you have your own certificate authority, you may sign it yourself, or
|
||||
if you need a self-signed certificate (because you just want a test
|
||||
certificate or because you are setting up your own CA).
|
||||
To create a certificate, you need to start with a certificate request
|
||||
(or, as some certificate authorities like to put it, "certificate
|
||||
signing request", since that's exactly what they do, they sign it and
|
||||
give you the result back, thus making it authentic according to their
|
||||
policies). A certificate request is sent to a certificate authority
|
||||
to get it signed into a certificate. You can also sign the certificate
|
||||
yourself if you have your own certificate authority or create a
|
||||
self-signed certificate (typically for testing purpose).
|
||||
|
||||
The certificate request is created like this:
|
||||
|
||||
@@ -55,12 +57,14 @@ The certificate request is created like this:
|
||||
Now, cert.csr can be sent to the certificate authority, if they can
|
||||
handle files in PEM format. If not, use the extra argument '-outform'
|
||||
followed by the keyword for the format to use (see another HOWTO
|
||||
<formats.txt?>). In some cases, that isn't sufficient and you will
|
||||
have to be more creative.
|
||||
<formats.txt?>). In some cases, -outform does not let you output the
|
||||
certificate request in the right format and you will have to use one
|
||||
of the various other commands that are exposed by openssl (or get
|
||||
creative and use a combination of tools).
|
||||
|
||||
When the certificate authority has then done the checks the need to
|
||||
do (and probably gotten payment from you), they will hand over your
|
||||
new certificate to you.
|
||||
The certificate authority performs various checks (according to their
|
||||
policies) and usually waits for payment from you. Once that is
|
||||
complete, they send you your new certificate.
|
||||
|
||||
Section 5 will tell you more on how to handle the certificate you
|
||||
received.
|
||||
@@ -68,11 +72,12 @@ received.
|
||||
|
||||
4. Creating a self-signed test certificate
|
||||
|
||||
If you don't want to deal with another certificate authority, or just
|
||||
want to create a test certificate for yourself. This is similar to
|
||||
creating a certificate request, but creates a certificate instead of
|
||||
a certificate request. This is NOT the recommended way to create a
|
||||
CA certificate, see ca.txt.
|
||||
You can create a self-signed certificate if you don't want to deal
|
||||
with a certificate authority, or if you just want to create a test
|
||||
certificate for yourself. This is similar to creating a certificate
|
||||
request, but creates a certificate instead of a certificate request.
|
||||
This is NOT the recommended way to create a CA certificate, see
|
||||
https://www.openssl.org/docs/apps/ca.html.
|
||||
|
||||
openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
|
||||
|
||||
@@ -93,13 +98,13 @@ certificate and your key to various formats, most often also putting
|
||||
them together into one file. The ways to do this is described in
|
||||
another HOWTO <formats.txt?>, I will just mention the simplest case.
|
||||
In the case of a raw DER thing in PEM format, and assuming that's all
|
||||
right for yor applications, simply concatenating the certificate and
|
||||
right for your applications, simply concatenating the certificate and
|
||||
the key into a new file and using that one should be enough. With
|
||||
some applications, you don't even have to do that.
|
||||
|
||||
|
||||
By now, you have your cetificate and your private key and can start
|
||||
using the software that depend on it.
|
||||
By now, you have your certificate and your private key and can start
|
||||
using applications that depend on it.
|
||||
|
||||
--
|
||||
Richard Levitte
|
||||
|
@@ -1,74 +1,69 @@
|
||||
<DRAFT!>
|
||||
HOWTO proxy certificates
|
||||
|
||||
0. WARNING
|
||||
|
||||
NONE OF THE CODE PRESENTED HERE HAVE BEEN CHECKED! They are just an
|
||||
example to show you how things can be done. There may be typos or
|
||||
type conflicts, and you will have to resolve them.
|
||||
NONE OF THE CODE PRESENTED HERE HAS BEEN CHECKED! The code is just examples to
|
||||
show you how things could be done. There might be typos or type conflicts, and
|
||||
you will have to resolve them.
|
||||
|
||||
1. Introduction
|
||||
|
||||
Proxy certificates are defined in RFC 3820. They are really usual
|
||||
certificates with the mandatory extension proxyCertInfo.
|
||||
Proxy certificates are defined in RFC 3820. They are really usual certificates
|
||||
with the mandatory extension proxyCertInfo.
|
||||
|
||||
Proxy certificates are issued by an End Entity (typically a user),
|
||||
either directly with the EE certificate as issuing certificate, or by
|
||||
extension through an already issued proxy certificate.. They are used
|
||||
to extend rights to some other entity (a computer process, typically,
|
||||
or sometimes to the user itself), so it can perform operations in the
|
||||
name of the owner of the EE certificate.
|
||||
Proxy certificates are issued by an End Entity (typically a user), either
|
||||
directly with the EE certificate as issuing certificate, or by extension through
|
||||
an already issued proxy certificate. Proxy certificates are used to extend
|
||||
rights to some other entity (a computer process, typically, or sometimes to the
|
||||
user itself). This allows the entity to perform operations on behalf of the
|
||||
owner of the EE certificate.
|
||||
|
||||
See http://www.ietf.org/rfc/rfc3820.txt for more information.
|
||||
|
||||
|
||||
2. A warning about proxy certificates
|
||||
|
||||
Noone seems to have tested proxy certificates with security in mind.
|
||||
Basically, to this date, it seems that proxy certificates have only
|
||||
been used in a world that's highly aware of them. What would happen
|
||||
if an unsuspecting application is to validate a chain of certificates
|
||||
that contains proxy certificates? It would usually consider the leaf
|
||||
to be the certificate to check for authorisation data, and since proxy
|
||||
certificates are controlled by the EE certificate owner alone, it's
|
||||
would be normal to consider what the EE certificate owner could do
|
||||
with them.
|
||||
No one seems to have tested proxy certificates with security in mind. To this
|
||||
date, it seems that proxy certificates have only been used in a context highly
|
||||
aware of them.
|
||||
|
||||
subjectAltName and issuerAltName are forbidden in proxy certificates,
|
||||
and this is enforced in OpenSSL. The subject must be the same as the
|
||||
issuer, with one commonName added on.
|
||||
Existing applications might misbehave when trying to validate a chain of
|
||||
certificates which use a proxy certificate. They might incorrectly consider the
|
||||
leaf to be the certificate to check for authorisation data, which is controlled
|
||||
by the EE certificate owner.
|
||||
|
||||
Possible threats are, as far as has been imagined so far:
|
||||
subjectAltName and issuerAltName are forbidden in proxy certificates, and this
|
||||
is enforced in OpenSSL. The subject must be the same as the issuer, with one
|
||||
commonName added on.
|
||||
|
||||
Possible threats we can think of at this time include:
|
||||
|
||||
- impersonation through commonName (think server certificates).
|
||||
- use of additional extensions, possibly non-standard ones used in
|
||||
certain environments, that would grant extra or different
|
||||
authorisation rights.
|
||||
- use of additional extensions, possibly non-standard ones used in certain
|
||||
environments, that would grant extra or different authorisation rights.
|
||||
|
||||
For this reason, OpenSSL requires that the use of proxy certificates
|
||||
be explicitely allowed. Currently, this can be done using the
|
||||
following methods:
|
||||
For these reasons, OpenSSL requires that the use of proxy certificates be
|
||||
explicitly allowed. Currently, this can be done using the following methods:
|
||||
|
||||
- if the application calls X509_verify_cert() itself, it can do the
|
||||
following prior to that call (ctx is the pointer passed in the call
|
||||
to X509_verify_cert()):
|
||||
- if the application directly calls X509_verify_cert(), it can first call:
|
||||
|
||||
X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS);
|
||||
X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_ALLOW_PROXY_CERTS);
|
||||
|
||||
- in all other cases, proxy certificate validation can be enabled
|
||||
before starting the application by setting the envirnoment variable
|
||||
OPENSSL_ALLOW_PROXY_CERTS with some non-empty value.
|
||||
Where ctx is the pointer which then gets passed to X509_verify_cert().
|
||||
|
||||
There are thoughts to allow proxy certificates with a line in the
|
||||
default openssl.cnf, but that's still in the future.
|
||||
- proxy certificate validation can be enabled before starting the application
|
||||
by setting the environment variable OPENSSL_ALLOW_PROXY_CERTS.
|
||||
|
||||
In the future, it might be possible to enable proxy certificates by editing
|
||||
openssl.cnf.
|
||||
|
||||
|
||||
3. How to create proxy cerificates
|
||||
3. How to create proxy certificates
|
||||
|
||||
It's quite easy to create proxy certificates, by taking advantage of
|
||||
the lack of checks of the 'openssl x509' application (*ahem*). But
|
||||
first, you need to create a configuration section that contains a
|
||||
definition of the proxyCertInfo extension, a little like this:
|
||||
Creating proxy certificates is quite easy, by taking advantage of a lack of
|
||||
checks in the 'openssl x509' application (*ahem*). You must first create a
|
||||
configuration section that contains a definition of the proxyCertInfo extension,
|
||||
for example:
|
||||
|
||||
[ v3_proxy ]
|
||||
# A proxy certificate MUST NEVER be a CA certificate.
|
||||
@@ -77,10 +72,10 @@ definition of the proxyCertInfo extension, a little like this:
|
||||
# Usual authority key ID
|
||||
authorityKeyIdentifier=keyid,issuer:always
|
||||
|
||||
# Now, for the extension that marks this certificate as a proxy one
|
||||
# The extension which marks this certificate as a proxy
|
||||
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:1,policy:text:AB
|
||||
|
||||
It's also possible to give the proxy extension in a separate section:
|
||||
It's also possible to specify the proxy extension in a separate section:
|
||||
|
||||
proxyCertInfo=critical,@proxy_ext
|
||||
|
||||
@@ -89,96 +84,85 @@ It's also possible to give the proxy extension in a separate section:
|
||||
pathlen=0
|
||||
policy=text:BC
|
||||
|
||||
The policy value has a specific syntax, {syntag}:{string}, where the
|
||||
syntag determines what will be done with the string. The recognised
|
||||
syntags are as follows:
|
||||
The policy value has a specific syntax, {syntag}:{string}, where the syntag
|
||||
determines what will be done with the string. The following syntags are
|
||||
recognised:
|
||||
|
||||
text indicates that the string is simply the bytes, not
|
||||
encoded in any kind of way:
|
||||
text indicates that the string is simply bytes, without any encoding:
|
||||
|
||||
policy=text:r<EFBFBD>ksm<EFBFBD>rg<EFBFBD>s
|
||||
policy=text:räksmörgås
|
||||
|
||||
Previous versions of this design had a specific tag
|
||||
for UTF-8 text. However, since the bytes are copied
|
||||
as-is anyway, there's no need for it. Instead, use
|
||||
the text: tag, like this:
|
||||
Previous versions of this design had a specific tag for UTF-8 text.
|
||||
However, since the bytes are copied as-is anyway, there is no need for
|
||||
such a specific tag.
|
||||
|
||||
policy=text:räksmörgås
|
||||
hex indicates the string is encoded in hex, with colons between each byte
|
||||
(every second hex digit):
|
||||
|
||||
hex indicates the string is encoded in hex, with colons
|
||||
between each byte (every second hex digit):
|
||||
policy=hex:72:E4:6B:73:6D:F6:72:67:E5:73
|
||||
|
||||
policy=hex:72:E4:6B:73:6D:F6:72:67:E5:73
|
||||
Previous versions of this design had a tag to insert a complete DER
|
||||
blob. However, the only legal use for this would be to surround the
|
||||
bytes that would go with the hex: tag with whatever is needed to
|
||||
construct a correct OCTET STRING. The DER tag therefore felt
|
||||
superfluous, and was removed.
|
||||
|
||||
Previous versions of this design had a tag to insert a
|
||||
complete DER blob. However, the only legal use for
|
||||
this would be to surround the bytes that would go with
|
||||
the hex: tag with what's needed to construct a correct
|
||||
OCTET STRING. Since hex: does that, the DER tag felt
|
||||
superfluous, and was therefore removed.
|
||||
|
||||
file indicates that the text of the policy should really be
|
||||
taken from a file. The string is then really a file
|
||||
name. This is useful for policies that are large
|
||||
(more than a few of lines) XML documents, for example.
|
||||
file indicates that the text of the policy should really be taken from a
|
||||
file. The string is then really a file name. This is useful for
|
||||
policies that are large (more than a few lines, e.g. XML documents).
|
||||
|
||||
The 'policy' setting can be split up in multiple lines like this:
|
||||
|
||||
0.policy=This is
|
||||
1.polisy= a multi-
|
||||
1.policy= a multi-
|
||||
2.policy=line policy.
|
||||
|
||||
NOTE: the proxy policy value is the part that determines the rights
|
||||
granted to the process using the proxy certificate. The value is
|
||||
completely dependent on the application reading and interpretting it!
|
||||
NOTE: the proxy policy value is the part which determines the rights granted to
|
||||
the process using the proxy certificate. The value is completely dependent on
|
||||
the application reading and interpreting it!
|
||||
|
||||
Now that you have created an extension section for your proxy
|
||||
certificate, you can now easily create a proxy certificate like this:
|
||||
Now that you have created an extension section for your proxy certificate, you
|
||||
can easily create a proxy certificate by doing:
|
||||
|
||||
openssl req -new -config openssl.cnf \
|
||||
-out proxy.req -keyout proxy.key
|
||||
openssl x509 -req -CAcreateserial -in proxy.req -days 7 \
|
||||
-out proxy.crt -CA user.crt -CAkey user.key \
|
||||
-extfile openssl.cnf -extensions v3_proxy
|
||||
openssl req -new -config openssl.cnf -out proxy.req -keyout proxy.key
|
||||
openssl x509 -req -CAcreateserial -in proxy.req -days 7 -out proxy.crt \
|
||||
-CA user.crt -CAkey user.key -extfile openssl.cnf -extensions v3_proxy
|
||||
|
||||
It's just as easy to create a proxy certificate using another proxy
|
||||
certificate as issuer (note that I'm using a different configuration
|
||||
section for it):
|
||||
You can also create a proxy certificate using another proxy certificate as
|
||||
issuer (note: I'm using a different configuration section for it):
|
||||
|
||||
openssl req -new -config openssl.cnf \
|
||||
-out proxy2.req -keyout proxy2.key
|
||||
openssl x509 -req -CAcreateserial -in proxy2.req -days 7 \
|
||||
-out proxy2.crt -CA proxy.crt -CAkey proxy.key \
|
||||
-extfile openssl.cnf -extensions v3_proxy2
|
||||
openssl req -new -config openssl.cnf -out proxy2.req -keyout proxy2.key
|
||||
openssl x509 -req -CAcreateserial -in proxy2.req -days 7 -out proxy2.crt \
|
||||
-CA proxy.crt -CAkey proxy.key -extfile openssl.cnf -extensions v3_proxy2
|
||||
|
||||
|
||||
4. How to have your application interpret the policy?
|
||||
|
||||
The basic way to interpret proxy policies is to prepare some default
|
||||
rights, then do a check of the proxy certificate against the a chain
|
||||
of proxy certificates, user certificate and CA certificates, and see
|
||||
what rights came out by the end. Sounds easy, huh? It almost is.
|
||||
The basic way to interpret proxy policies is to start with some default rights,
|
||||
then compute the resulting rights by checking the proxy certificate against
|
||||
the chain of proxy certificates, user certificate and CA certificates. You then
|
||||
use the final computed rights. Sounds easy, huh? It almost is.
|
||||
|
||||
The slightly complicated part is how to pass data between your
|
||||
The slightly complicated part is figuring out how to pass data between your
|
||||
application and the certificate validation procedure.
|
||||
|
||||
You need the following ingredients:
|
||||
|
||||
- a callback routing that will be called for every certificate that's
|
||||
validated. It will be called several times for each certificates,
|
||||
so you must be attentive to when it's a good time to do the proxy
|
||||
policy interpretation and check, as well as to fill in the defaults
|
||||
when the EE certificate is checked.
|
||||
- a callback function that will be called for every certificate being
|
||||
validated. The callback be called several times for each certificate,
|
||||
so you must be careful to do the proxy policy interpretation at the right
|
||||
time. You also need to fill in the defaults when the EE certificate is
|
||||
checked.
|
||||
|
||||
- a structure of data that's shared between your application code and
|
||||
the callback.
|
||||
- a data structure that is shared between your application code and the
|
||||
callback.
|
||||
|
||||
- a wrapper function that sets it all up.
|
||||
|
||||
- an ex_data index function that creates an index into the generic
|
||||
ex_data store that's attached to an X509 validation context.
|
||||
- an ex_data index function that creates an index into the generic ex_data
|
||||
store that is attached to an X509 validation context.
|
||||
|
||||
This is some cookbook code for you to fill in:
|
||||
Here is some skeleton code you can fill in:
|
||||
|
||||
/* In this example, I will use a view of granted rights as a bit
|
||||
array, one bit for each possible right. */
|
||||
@@ -210,7 +194,7 @@ This is some cookbook code for you to fill in:
|
||||
static int verify_callback(int ok, X509_STORE_CTX *ctx)
|
||||
{
|
||||
if (ok == 1) /* It's REALLY important you keep the proxy policy
|
||||
check within this secion. It's important to know
|
||||
check within this section. It's important to know
|
||||
that when ok is 1, the certificates are checked
|
||||
from top to bottom. You get the CA root first,
|
||||
followed by the possible chain of intermediate
|
||||
@@ -221,7 +205,7 @@ This is some cookbook code for you to fill in:
|
||||
|
||||
if (xs->ex_flags & EXFLAG_PROXY)
|
||||
{
|
||||
YOUR_RIGHTS *rights =
|
||||
YOUR_RIGHTS *rights =
|
||||
(YOUR_RIGHTS *)X509_STORE_CTX_get_ex_data(ctx,
|
||||
get_proxy_auth_ex_data_idx());
|
||||
PROXY_CERT_INFO_EXTENSION *pci =
|
||||
@@ -250,12 +234,12 @@ This is some cookbook code for you to fill in:
|
||||
bit array and fill it with the rights granted by
|
||||
the current proxy certificate, then use it as a
|
||||
mask on the accumulated rights bit array, and
|
||||
voil<EFBFBD>, you now have a new accumulated rights bit
|
||||
voilà, you now have a new accumulated rights bit
|
||||
array. */
|
||||
{
|
||||
int i;
|
||||
YOUR_RIGHTS tmp_rights;
|
||||
memset(tmp_rights.rights, 0, sizeof(tmp_rights.rights));
|
||||
memset(tmp_rights.rights, 0, sizeof(tmp_rights.rights));
|
||||
|
||||
/* process_rights() is supposed to be a procedure
|
||||
that takes a string and it's length, interprets
|
||||
@@ -276,7 +260,7 @@ This is some cookbook code for you to fill in:
|
||||
{
|
||||
/* We have a EE certificate, let's use it to set default!
|
||||
*/
|
||||
YOUR_RIGHTS *rights =
|
||||
YOUR_RIGHTS *rights =
|
||||
(YOUR_RIGHTS *)X509_STORE_CTX_get_ex_data(ctx,
|
||||
get_proxy_auth_ex_data_idx());
|
||||
|
||||
|
@@ -177,12 +177,12 @@ cipher suites using RSA key exchange.
|
||||
cipher suites using DH key agreement and DH certificates signed by CAs with RSA
|
||||
and DSS keys or either respectively.
|
||||
|
||||
=item B<kEDH>
|
||||
=item B<kDHE>, B<kEDH>
|
||||
|
||||
cipher suites using ephemeral DH key agreement, including anonymous cipher
|
||||
suites.
|
||||
|
||||
=item B<EDH>
|
||||
=item B<DHE>, B<EDH>
|
||||
|
||||
cipher suites using authenticated ephemeral DH key agreement.
|
||||
|
||||
@@ -200,12 +200,12 @@ cipher suites using DH, including anonymous DH, ephemeral DH and fixed DH.
|
||||
cipher suites using fixed ECDH key agreement signed by CAs with RSA and ECDSA
|
||||
keys or either respectively.
|
||||
|
||||
=item B<kEECDH>
|
||||
=item B<kECDHE>, B<kEECDH>
|
||||
|
||||
cipher suites using ephemeral ECDH key agreement, including anonymous
|
||||
cipher suites.
|
||||
|
||||
=item B<EECDHE>
|
||||
=item B<ECDHE>, B<EECDH>
|
||||
|
||||
cipher suites using authenticated ephemeral ECDH key agreement.
|
||||
|
||||
|
@@ -13,6 +13,8 @@ B<openssl> B<dgst>
|
||||
[B<-hex>]
|
||||
[B<-binary>]
|
||||
[B<-r>]
|
||||
[B<-hmac arg>]
|
||||
[B<-non-fips-allow>]
|
||||
[B<-out filename>]
|
||||
[B<-sign filename>]
|
||||
[B<-keyform arg>]
|
||||
@@ -62,6 +64,15 @@ output the digest or signature in binary form.
|
||||
|
||||
output the digest in the "coreutils" format used by programs like B<sha1sum>.
|
||||
|
||||
=item B<-hmac arg>
|
||||
|
||||
set the HMAC key to "arg".
|
||||
|
||||
=item B<-non-fips-allow>
|
||||
|
||||
Allow use of non FIPS digest when in FIPS mode. This has no effect when not in
|
||||
FIPS mode.
|
||||
|
||||
=item B<-out filename>
|
||||
|
||||
filename to output to, or standard output by default.
|
||||
|
@@ -133,6 +133,10 @@ if the B<host> option is present then the OCSP request is sent to the host
|
||||
B<hostname> on port B<port>. B<path> specifies the HTTP path name to use
|
||||
or "/" by default.
|
||||
|
||||
=item B<-timeout seconds>
|
||||
|
||||
connection timeout to the OCSP responder in seconds
|
||||
|
||||
=item B<-CAfile file>, B<-CApath pathname>
|
||||
|
||||
file or pathname containing trusted CA certificates. These are used to verify
|
||||
|
@@ -37,6 +37,9 @@ B<openssl> B<s_client>
|
||||
[B<-no_ssl2>]
|
||||
[B<-no_ssl3>]
|
||||
[B<-no_tls1>]
|
||||
[B<-no_tls1_1>]
|
||||
[B<-no_tls1_2>]
|
||||
[B<-fallback_scsv>]
|
||||
[B<-bugs>]
|
||||
[B<-cipher cipherlist>]
|
||||
[B<-serverpref>]
|
||||
@@ -197,16 +200,19 @@ Use the PSK key B<key> when using a PSK cipher suite. The key is
|
||||
given as a hexadecimal number without leading 0x, for example -psk
|
||||
1a2b3c4d.
|
||||
|
||||
=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>
|
||||
=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>, B<-no_tls1_1>, B<-no_tls1_2>
|
||||
|
||||
these options disable the use of certain SSL or TLS protocols. By default
|
||||
the initial handshake uses a method which should be compatible with all
|
||||
servers and permit them to use SSL v3, SSL v2 or TLS as appropriate.
|
||||
|
||||
Unfortunately there are a lot of ancient and broken servers in use which
|
||||
Unfortunately there are still ancient and broken servers in use which
|
||||
cannot handle this technique and will fail to connect. Some servers only
|
||||
work if TLS is turned off with the B<-no_tls> option others will only
|
||||
support SSL v2 and may need the B<-ssl2> option.
|
||||
work if TLS is turned off.
|
||||
|
||||
=item B<-fallback_scsv>
|
||||
|
||||
Send TLS_FALLBACK_SCSV in the ClientHello.
|
||||
|
||||
=item B<-bugs>
|
||||
|
||||
|
@@ -108,7 +108,7 @@ SSL BIOs are exceptional in that if the underlying transport
|
||||
is non blocking they can still request a retry in exceptional
|
||||
circumstances. Specifically this will happen if a session
|
||||
renegotiation takes place during a BIO_read() operation, one
|
||||
case where this happens is when SGC or step up occurs.
|
||||
case where this happens is when step up occurs.
|
||||
|
||||
In OpenSSL 0.9.6 and later the SSL flag SSL_AUTO_RETRY can be
|
||||
set to disable this behaviour. That is when this flag is set
|
||||
|
@@ -55,7 +55,10 @@ the IV.
|
||||
|
||||
=head1 RETURN VALUES
|
||||
|
||||
EVP_BytesToKey() returns the size of the derived key in bytes, or 0 on error.
|
||||
If B<data> is NULL, then EVP_BytesToKey() returns the number of bytes
|
||||
needed to store the derived key.
|
||||
Otherwise, EVP_BytesToKey() returns the size of the derived key in bytes,
|
||||
or 0 on error.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
|
@@ -125,7 +125,7 @@ writes the encrypted version to B<out>. This function can be called
|
||||
multiple times to encrypt successive blocks of data. The amount
|
||||
of data written depends on the block alignment of the encrypted data:
|
||||
as a result the amount of data written may be anything from zero bytes
|
||||
to (inl + cipher_block_size - 1) so B<outl> should contain sufficient
|
||||
to (inl + cipher_block_size - 1) so B<out> should contain sufficient
|
||||
room. The actual number of bytes written is placed in B<outl>.
|
||||
|
||||
If padding is enabled (the default) then EVP_EncryptFinal_ex() encrypts
|
||||
|
@@ -43,19 +43,23 @@ indicates the operation is not supported by the public key algorithm.
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
Encrypt data using OAEP (for RSA keys):
|
||||
Encrypt data using OAEP (for RSA keys). See also L<PEM_read_PUBKEY(3)|pem(3)> or
|
||||
L<d2i_X509(3)|d2i_X509(3)> for means to load a public key. You may also simply
|
||||
set 'eng = NULL;' to start with the default OpenSSL RSA implementation:
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/engine.h>
|
||||
|
||||
EVP_PKEY_CTX *ctx;
|
||||
ENGINE *eng;
|
||||
unsigned char *out, *in;
|
||||
size_t outlen, inlen;
|
||||
EVP_PKEY *key;
|
||||
/* NB: assumes key in, inlen are already set up
|
||||
/* NB: assumes eng, key, in, inlen are already set up,
|
||||
* and that key is an RSA public key
|
||||
*/
|
||||
ctx = EVP_PKEY_CTX_new(key);
|
||||
ctx = EVP_PKEY_CTX_new(key,eng);
|
||||
if (!ctx)
|
||||
/* Error occurred */
|
||||
if (EVP_PKEY_encrypt_init(ctx) <= 0)
|
||||
@@ -79,6 +83,8 @@ Encrypt data using OAEP (for RSA keys):
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<d2i_X509(3)|d2i_X509(3)>,
|
||||
L<engine(3)|engine(3)>,
|
||||
L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
|
||||
L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
|
||||
L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
|
||||
|
@@ -17,7 +17,7 @@ OPENSSL_VERSION_NUMBER, SSLeay, SSLeay_version - get OpenSSL version number
|
||||
|
||||
OPENSSL_VERSION_NUMBER is a numeric release version identifier:
|
||||
|
||||
MMNNFFPPS: major minor fix patch status
|
||||
MNNFFPPS: major minor fix patch status
|
||||
|
||||
The status nibble has one of the values 0 for development, 1 to e for betas
|
||||
1 to 14, and f for release.
|
||||
|
@@ -81,14 +81,14 @@ Create an B<X509_NAME> structure:
|
||||
nm = X509_NAME_new();
|
||||
if (nm == NULL)
|
||||
/* Some error */
|
||||
if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
|
||||
"C", "UK", -1, -1, 0))
|
||||
if (!X509_NAME_add_entry_by_txt(nm, "C", MBSTRING_ASC,
|
||||
"UK", -1, -1, 0))
|
||||
/* Error */
|
||||
if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
|
||||
"O", "Disorganized Organization", -1, -1, 0))
|
||||
if (!X509_NAME_add_entry_by_txt(nm, "O", MBSTRING_ASC,
|
||||
"Disorganized Organization", -1, -1, 0))
|
||||
/* Error */
|
||||
if (!X509_NAME_add_entry_by_txt(nm, MBSTRING_ASC,
|
||||
"CN", "Joe Bloggs", -1, -1, 0))
|
||||
if (!X509_NAME_add_entry_by_txt(nm, "CN", MBSTRING_ASC,
|
||||
"Joe Bloggs", -1, -1, 0))
|
||||
/* Error */
|
||||
|
||||
=head1 RETURN VALUES
|
||||
|
@@ -59,6 +59,10 @@ X509_NAME_get_index_by_OBJ() should be used followed by
|
||||
X509_NAME_get_entry() on any matching indices and then the
|
||||
various B<X509_NAME_ENTRY> utility functions on the result.
|
||||
|
||||
The list of all relevant B<NID_*> and B<OBJ_* codes> can be found in
|
||||
the source code header files E<lt>openssl/obj_mac.hE<gt> and/or
|
||||
E<lt>openssl/objects.hE<gt>.
|
||||
|
||||
=head1 EXAMPLES
|
||||
|
||||
Process all entries:
|
||||
|
@@ -109,6 +109,16 @@ If SSL_CIPHER_description() cannot handle a built-in cipher, the according
|
||||
description of the cipher property is B<unknown>. This case should not
|
||||
occur.
|
||||
|
||||
The standard terminology for ephemeral Diffie-Hellman schemes is DHE
|
||||
(finite field) or ECDHE (elliptic curve). This version of OpenSSL
|
||||
idiosyncratically reports these schemes as EDH and EECDH, even though
|
||||
it also accepts the standard terminology.
|
||||
|
||||
It is recommended to use the standard terminology (DHE and ECDHE)
|
||||
during configuration (e.g. via SSL_CTX_set_cipher_list) for clarity of
|
||||
configuration. OpenSSL versions after 1.0.2 will report the standard
|
||||
terms via SSL_CIPHER_get_name and SSL_CIPHER_description.
|
||||
|
||||
=head1 RETURN VALUES
|
||||
|
||||
See DESCRIPTION
|
||||
@@ -116,6 +126,7 @@ See DESCRIPTION
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<ssl(3)|ssl(3)>, L<SSL_get_current_cipher(3)|SSL_get_current_cipher(3)>,
|
||||
L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>, L<ciphers(1)|ciphers(1)>
|
||||
L<SSL_get_ciphers(3)|SSL_get_ciphers(3)>, L<ciphers(1)|ciphers(1)>,
|
||||
L<SSL_CTX_set_cipher_list(3)|SSL_CTX_set_cipher_list(3)>
|
||||
|
||||
=cut
|
||||
|
@@ -45,11 +45,12 @@ B<curves> array is in the form of a set of curve NIDs in preference
|
||||
order. It can return zero if the client did not send a supported curves
|
||||
extension.
|
||||
|
||||
SSL_get1_shared_curve() returns shared curve B<n> for B<ssl>. If B<n> is
|
||||
-1 then the total number of shared curves is returned, which may be
|
||||
zero. Other than for diagnostic purposes, most applications will only
|
||||
be interested in the first shared curve so B<n> is normally set to zero.
|
||||
If the value B<n> is out of range zero is returned.
|
||||
SSL_get_shared_curve() returns shared curve B<n> for a server-side
|
||||
SSL B<ssl>. If B<n> is -1 then the total number of shared curves is
|
||||
returned, which may be zero. Other than for diagnostic purposes,
|
||||
most applications will only be interested in the first shared curve
|
||||
so B<n> is normally set to zero. If the value B<n> is out of range,
|
||||
NID_undef is returned.
|
||||
|
||||
SSL_CTX_set_ecdh_auto() and SSL_set_ecdh_auto() set automatic curve
|
||||
selection for server B<ctx> or B<ssl> to B<onoff>. If B<onoff> is 1 then
|
||||
@@ -84,8 +85,12 @@ return 1 for success and 0 for failure.
|
||||
|
||||
SSL_get1_curves() returns the number of curves, which may be zero.
|
||||
|
||||
SSL_get1_shared_curve() returns the NID of shared curve B<n> of zero if there
|
||||
is no shared curve B<n> or the number of shared curves if B<n> is -1.
|
||||
SSL_get_shared_curve() returns the NID of shared curve B<n> or NID_undef if there
|
||||
is no shared curve B<n>; or the total number of shared curves if B<n>
|
||||
is -1.
|
||||
|
||||
When called on a client B<ssl>, SSL_get_shared_curve() has no meaning and
|
||||
returns -1.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user