Compare commits

...

240 Commits

Author SHA1 Message Date
Matt Caswell
91eaf079b7 Prepare for 1.1.0c release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-11-10 14:03:42 +00:00
Matt Caswell
b263c106de Update CHANGES and NEWS
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-11-10 13:04:05 +00:00
Matt Caswell
3ffb3406ce Fix the no-tls option
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-11-10 13:04:05 +00:00
Richard Levitte
6ca3e0f250 Fix no-cms (CVE-2016-7053)
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-11-10 13:04:05 +00:00
Andy Polyakov
59e92f2371 test/evptests.txt: add negative tests for AEAD ciphers.
This is done by taking one vector, "corrupting" last bit of the
tag value and verifying that decrypt fails.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-11-10 13:04:05 +00:00
Andy Polyakov
4e7a0fa104 test: add TLS application data corruption test.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-11-10 13:04:05 +00:00
Dr. Stephen Henson
e9fcdd2e69 add test for CVE-2016-7053
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-11-10 13:04:05 +00:00
Dr. Stephen Henson
610b66267e Don't set choice selector on parse failure.
Don't set choice selector on parse failure: this can pass unexpected
values to the choice callback. Instead free up partial structure
directly.

CVE-2016-7053

Thanks to Tyler Nighswander of ForAllSecure for reporting this issue.

Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-11-10 13:04:05 +00:00
Richard Levitte
99d97842dd chacha20/poly1305: make sure to clear the buffer at correct position
The offset to the memory to clear was incorrect, causing a heap buffer
overflow.

CVE-2016-7054

Thanks to Robert Święcki for reporting this

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit b8e4011fb26364e44230946b87ab38cc1c719aae)
2016-11-10 13:04:05 +00:00
Andy Polyakov
53c6cbf6e9 aes/asm/aesp8-ppc.pl: improve [backward] portability.
Some of stone-age assembler can't cope with r0 in address. It's actually
sensible thing to do, because r0 is shunted to 0 in address arithmetic
and by refusing r0 assembler effectively makes you understand that.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit a54aba5313)
2016-11-10 13:00:57 +00:00
Andy Polyakov
2a7dd548a6 bn/asm/x86_64-mont.pl: fix for CVE-2016-7055 (Low severity).
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 2fac86d9ab)
2016-11-10 10:35:50 +00:00
Andy Polyakov
9ebcbbba81 test/bntest.c: regression test for CVE-2016-7055.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit dca2e0ee17)
2016-11-10 10:35:50 +00:00
Richard Levitte
3f7452e45a Fix the evp_test Ctrl keyword processing
Skip the test if the value after ":" is a disabled algorithm, rather
than failing it

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit dfbdf4abb7)
2016-11-10 10:26:06 +00:00
Richard Levitte
267d4fb183 Fix no-dso (shlibloadtest)
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 586b79d888)
2016-11-10 10:14:57 +00:00
EasySec
73a5150689 When no SRP identity is found, no error was reported server side
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1859)

(cherry picked from commit 7bb37cb593)
2016-11-09 10:13:20 -05:00
Richard Levitte
df8dca7ac8 Unix Makefile: Make sure to use $(PERL) when running ./Configure
For consistency, it's better to use the perl that was specified to
Configure last time it was called.

Use case:

perl v5.8.8 was first along $PATH, perl v5.22.2 was available and
specified as: PERL=/opt/local/bin/perl ./config.  When make wanted to
reconfigure and called './Configure reconf', configuration broke down,
complaining about a perl that's too old.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1884)
(cherry picked from commit 12ccb021be)
2016-11-09 02:37:53 +01:00
FdaSilvaYY
daa67522e0 Missing BN_RECP_CTX field init.
BN_RECP_CTX_new direclty use bn_init to avoid twice memset calls

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1879)
(cherry picked from commit 318447bceb)
2016-11-08 17:48:38 -05:00
Rich Salz
1bb02559e3 Zero stack variable with DSA nonce
Thanks to Falko Strenzke for bringing this to our attention.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1882)
(cherry picked from commit e5e71f2857)
2016-11-08 17:40:17 -05:00
Richard Levitte
cafe1c7abe INSTALL: small typo
libssl, not libddl.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1871)
(cherry picked from commit b77b6127e8)
2016-11-08 12:28:32 +01:00
FdaSilvaYY
6fa4d63dbf Allow null in X509_CRL_METHOD_free
and fix documentation.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1634)
(cherry picked from commit 7cb1ecec59)
2016-11-07 15:48:31 -05:00
Andrea Grandi
28304b1239 Improve PRF documentation
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>

GH: #1834
(cherry picked from commit 27ed73a98f)
2016-11-07 21:14:20 +01:00
David Benjamin
b9ddc5fd0c Improve RSA test coverage.
MD5/SHA1 and MDC-2 have special-case logic beyond the generic DigestInfo
wrapping. Test that each of these works, including hash and length
mismatches (both input and signature). Also add VerifyRecover tests. It
appears 5824cc2981 added support for
VerifyRecover, but forgot to add the test data.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>

GH: #1474
(cherry picked from commit f320555735)
2016-11-07 21:07:06 +01:00
David Benjamin
439530bc57 Make RSA_sign.pod less confusing.
PKCS #1 v2.0 is the name of a document which specifies an algorithm
RSASSA-PKCS1-v1_5, often referred to as "PKCS #1 v1.5" after an earlier
document which specified it. This gets further confusing because the
document PKCS #1 v2.1 specifies two signature algorithms,
RSASSA-PKCS1-v1_5 and RSASSA-PSS. RSA_sign implements RSASSA-PKCS1-v1_5.

Refer to the document using the RFC number which is easier to find
anyway, and refer to the algorithm by its name.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>

GH: #1474
(cherry picked from commit aa90ca11c9)
2016-11-07 21:06:55 +01:00
David Benjamin
b71079a375 Implement RSASSA-PKCS1-v1_5 as specified.
RFC 3447, section 8.2.2, steps 3 and 4 states that verifiers must encode
the DigestInfo struct and then compare the result against the public key
operation result. This implies that one and only one encoding is legal.

OpenSSL instead parses with crypto/asn1, then checks that the encoding
round-trips, and allows some variations for the parameter. Sufficient
laxness in this area can allow signature forgeries, as described in
https://www.imperialviolet.org/2014/09/26/pkcs1.html

Although there aren't known attacks against OpenSSL's current scheme,
this change makes OpenSSL implement the algorithm as specified. This
avoids the uncertainty and, more importantly, helps grow a healthy
ecosystem. Laxness beyond the spec, particularly in implementations
which enjoy wide use, risks harm to the ecosystem for all. A signature
producer which only tests against OpenSSL may not notice bugs and
accidentally become widely deployed. Thus implementations have a
responsibility to honor the specification as tightly as is practical.

In some cases, the damage is permanent and the spec deviation and
security risk becomes a tax all implementors must forever pay, but not
here. Both BoringSSL and Go successfully implemented and deployed
RSASSA-PKCS1-v1_5 as specified since their respective beginnings, so
this change should be compatible enough to pin down in future OpenSSL
releases.

See also https://tools.ietf.org/html/draft-thomson-postel-was-wrong-00

As a bonus, by not having to deal with sign/verify differences, this
version is also somewhat clearer. It also more consistently enforces
digest lengths in the verify_recover codepath. The NID_md5_sha1 codepath
wasn't quite doing this right.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>

GH: #1474
(cherry picked from commit 608a026494)
2016-11-07 21:06:48 +01:00
Matt Caswell
929cc3fa6b Partial revert of "Fix client verify mode to check SSL_VERIFY_PEER"
This partially reverts commit c636c1c47. It also tweaks the documentation
and comments in this area. On the client side the documented interface for
SSL_CTX_set_verify()/SSL_set_verify() is that setting the flag
SSL_VERIFY_PEER causes verfication of the server certificate to take place.
Previously what was implemented was that if *any* flag was set then
verification would take place. The above commit improved the semantics to
be as per the documented interface.

However, we have had a report of at least one application where an
application was incorrectly using the interface and used *only*
SSL_VERIFY_FAIL_IF_NO_PEER_CERT on the client side. In OpenSSL prior to
the above commit this still caused verification of the server certificate
to take place. After this commit the application silently failed to verify
the server certificate.

Ideally SSL_CTX_set_verify()/SSL_set_verify() could be modified to indicate
if invalid flags were being used. However these are void functions!

The simplest short term solution is to revert to the previous behaviour
which at least means we "fail closed" rather than "fail open".

Thanks to Cory Benfield for reporting this issue.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit c8e2f98c97)
2016-11-07 16:05:11 +00:00
Matt Caswell
992b3740a1 Always ensure that init_msg is initialised for a CCS
We read it later in grow_init_buf(). If CCS is the first thing received in
a flight, then it will use the init_msg from the last flight we received. If
the init_buf has been grown in the meantime then it will point to some
arbitrary other memory location. This is likely to result in grow_init_buf()
attempting to grow to some excessively large amount which is likely to
fail. In practice this should never happen because the only time we receive
a CCS as the first thing in a flight is in an abbreviated handshake. None
of the preceding messages from the server flight would be large enough to
trigger this.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit c437757466)
2016-11-07 15:28:22 +00:00
Richard Levitte
51d8e5ea86 Windows: use default ZLIB1 unless --with-zlib-lib is set
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1772)
(cherry picked from commit 475592e241)
2016-11-06 22:55:55 +01:00
Richard Levitte
f02ec65590 Fix the LIBZ macro on VC config targets
If zlib-dynamic was given but not --with-zlib-lib, LIBZ was defined to
the empty string.  Instead, give it the default "ZLIB1".

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1772)
(cherry picked from commit 111b234c8f)
2016-11-06 22:55:48 +01:00
Richard Levitte
294f7a746e VMS: pretend to use -znodelete
VMS only unloads shared libraries at process rundown, so tell the
OpenSSL code so by pretending we linked with -znodelete.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1862)
(cherry picked from commit 1186a2b3d4)
2016-11-06 19:51:29 +01:00
Richard Levitte
5ee32f27a6 VMS build file template: assign 'arch' to local symbol table
Since the local symbol table is looked up before the global symbol
table, 'arch' assigned in the local symbol table of the DCL where MMS
is called would be seen before the 'arch' defined in descrip.mms.
Assigning it to the local symbol table in descrip.mms removes that
issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1853)
(cherry picked from commit 3ee24d4aca)
2016-11-04 20:19:06 +01:00
Rich Salz
dc691e859b Missed a mention of RT
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1849)
(cherry picked from commit 1e62cc12f3)
2016-11-04 10:44:03 -04:00
Richard Levitte
d29279371c Travis: add a strict build
Clang on Linux seems to catch things that we might miss otherwise.
Also, throw in 'no-deprecated' to make sure we test that as well.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1839)
(cherry picked from commit 7b19543841)
2016-11-04 14:13:56 +01:00
Richard Levitte
8f8e9f184b Don't assume to know the shared library extension
test/shlibloadtest.c assumes all Unix style platforms use .so as
shared library extension.  This is not the case for Mac OS X, which
uses .dylib.  Instead of this, have the test recipe find out the
extension from configuration data.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1844)
(cherry picked from commit 62dd3351a1)
2016-11-04 00:19:50 +01:00
Rich Salz
0d325d9cb9 Update CRYPTO_set_mem_debug() doc
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1842)
(cherry picked from commit 00bb5504cc)
2016-11-03 15:25:22 -04:00
Richard Levitte
2cf10e88b7 Enable memory debugging while testing
Pre 1.1.0, 'make test' would set the environment variable
OPENSSL_DEBUG_MEMORY to "on".  This got lost when translating the old
build files to the new templates.  This changes reintroduces that
variable.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1840)
(cherry picked from commit 6d4bc8a3d2)
2016-11-03 19:25:34 +01:00
Richard Levitte
b754f9a3a5 test/shlibloadtest: small fixes
- Make sure to initialise SHLIB variables
- Make sure to make local variables static

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1838)
(cherry picked from commit 3b0478fe03)
2016-11-03 16:36:02 +01:00
Richard Levitte
22173a40b2 Clang doesn't like -znodelete, make it a linker flag instead
gcc is kinder, it silently passes quite a few flags to ld, while clang
is stricter and wants them prefixed with -Wl,

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1836)
(cherry picked from commit 075e9da055)
2016-11-03 15:36:31 +01:00
Richard Levitte
f1ec9c07fe test/build.info: typo, $ missing
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1832)
(cherry picked from commit 9c89c8460a)
2016-11-03 15:35:11 +01:00
Kurt Roeckx
3a3f9ed140 conf fuzzer: also check for an empty file
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>

GH: #1828
(cherry picked from commit ea6199ea91)
2016-11-03 05:18:05 +01:00
Mike Aizatsky
a1aa038608 [fuzzers] do not fail fuzzers with empty input
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>

GH: #1788
(cherry picked from commit ba7407002d)
2016-11-03 05:17:51 +01:00
Matt Caswell
2e6b83f608 Implement GET_MODULE_HANDLE_EX_FLAG_PIN for windows
Rather than leaking a reference, just call GetModuleHandleEx and pin the
module on Windows.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 2b59d1beaa)
2016-11-02 23:38:20 +00:00
Matt Caswell
848dc96190 Link using -znodelete
Instead of deliberately leaking a reference to ourselves, use nodelete
which does this more neatly. Only for Linux at the moment.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit b6d5ba1a9f)
2016-11-02 23:38:20 +00:00
Matt Caswell
389d4655b1 Add a test to dynamically load and unload the libraries
This should demonstrate that the atexit() handling is working properly (or
at least not crashing) on process exit.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit b987d748e4)
2016-11-02 23:38:18 +00:00
Matt Caswell
4af9f7fe79 Ensure that libcrypto and libssl do not unload until the process exits
Because we use atexit() to cleanup after ourselves, this will cause a
problem if we have been dynamically loaded and then unloaded again: the
atexit() handler may no longer be there.

Most modern atexit() implementations can handle this, however there are
still difficulties if libssl gets unloaded before libcrypto, because of
the atexit() callback that libcrypto makes to libssl.

The most robust solution seems to be to ensure that libcrypto and libssl
never unload. This is done by simply deliberately leaking a dlopen()
reference to them.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 5836780f43)
2016-11-02 23:37:28 +00:00
Matt Caswell
f722f18e1a Add a DSO_dsobyaddr() function
This works the same way as DSO_pathbyaddr() but instead returns a ptr to
the DSO that contains the provided symbol.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit b39eda7ee6)
2016-11-02 23:37:26 +00:00
Matt Caswell
93558bf519 Partial revert of 3d8b2ec42 to add back DSO_pathbyaddr
Commit 3d8b2ec42 removed various unused functions. However now we need to
use one of them! This commit resurrects DSO_pathbyaddr(). We're not going to
resurrect the Windows version though because what we need to achieve can be
done a different way on Windows.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit cb6ea61c16)
2016-11-02 23:35:50 +00:00
Matt Caswell
717f4026d5 Add a CHANGES entry for the unrecognised record type change
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit ce95f3b724)
2016-11-02 23:25:48 +00:00
Matt Caswell
e4815a0bd2 Add a test for unrecognised record types
We should fail if we receive an unrecognised record type

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 1f3e70a450)
2016-11-02 23:25:48 +00:00
Matt Caswell
77cd04bd27 Fail if an unrecognised record type is received
TLS1.0 and TLS1.1 say you SHOULD ignore unrecognised record types, but
TLS 1.2 says you MUST send an unexpected message alert. We swap to the
TLS 1.2 behaviour for all protocol versions to prevent issues where no
progress is being made and the peer continually sends unrecognised record
types, using up resources processing them.

Issue reported by 郭志攀

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 436a2a0179)
2016-11-02 23:25:48 +00:00
Richard Levitte
bfca0515b6 Test recipes: remove duplicate OpenSSL::Test usage
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1815)
(cherry picked from commit 2c4a3f938c)
2016-11-02 18:14:49 +01:00
Sergey Bronnikov
0d72c6c66f Fix link to LibFuzzer
CLA: trivial
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1801)

(cherry picked from commit fe2582a224)
2016-11-02 13:11:11 -04:00
Matt Caswell
3f99bfed67 Add a read_ahead test
This test checks that read_ahead works correctly when dealing with large
records.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 7856332e8c)
2016-11-02 16:51:58 +00:00
Matt Caswell
0f6c9d73cb Fix read_ahead
The function ssl3_read_n() takes a parameter |clearold| which, if set,
causes any old data in the read buffer to be forgotten, and any unread data
to be moved to the start of the buffer. This is supposed to happen when we
first read the record header.

However, the data move was only taking place if there was not already
sufficient data in the buffer to satisfy the request. If read_ahead is set
then the record header could be in the buffer already from when we read the
preceding record. So with read_ahead we can get into a situation where even
though |clearold| is set, the data does not get moved to the start of the
read buffer when we read the record header. This means there is insufficient
room in the read buffer to consume the rest of the record body, resulting in
an internal error.

This commit moves the |clearold| processing to earlier in ssl3_read_n()
to ensure that it always takes place.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit a7faa6da31)
2016-11-02 16:51:58 +00:00
Richard Levitte
a95a0219a8 Secure our notification email.
Forks will have to define their own

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1821)
(cherry picked from commit 5e28b1c1e0)
2016-11-02 02:01:17 +01:00
Benjamin Kaduk
dd365d3685 Fix grammar-o in CONTRIBUTING
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1625)
(cherry picked from commit e4d94269a5)
2016-11-01 12:36:34 -04:00
Richard Levitte
32ee80362c HPUX: Add the forgotten $(DSTDIR) when linking DSOs
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1802)
(cherry picked from commit f46661de78)
2016-11-01 00:52:26 +01:00
Richard Levitte
936503cb0b Unix Makefile: Some sed implementation truncate long lines. Use perl instead.
Fixes #1781

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1813)
(cherry picked from commit ebca7961a6)
2016-10-31 23:18:56 +01:00
Richard Levitte
10f60797e7 Mark VC templates correctly.
VC-noCE-common and VC-WIN64-common were missing this line:

        template         => 1,

Fixes GH#1809

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1811)
(cherry picked from commit be1f481211)
2016-10-31 17:01:07 +01:00
Matt Caswell
5af2ad682e Implement length checks as a macro
Replace the various length checks in the extension code with a macro to
simplify the logic.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-28 09:40:55 +01:00
Matt Caswell
3ab5f981ed Ensure we have length checks for all extensions
The previous commit inspired a review of all the length checks for the
extension adding code. This adds more robust checks and adds checks where
some were missing previously. The real solution for this is to use WPACKET
which is currently in master - but that cannot be applied to release
branches.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-28 09:40:55 +01:00
Matt Caswell
8c9365a690 Fix length check writing status request extension
The status request extension did not correctly check its length, meaning
that writing the extension could go 2 bytes beyond the buffer size. In
practice this makes little difference because, due to logic in buffer.c the
buffer is actually over allocated by approximately 5k!

Issue reported by Guido Vranken.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-28 09:40:55 +01:00
Matt Caswell
3bceb47a27 Fix a double free in ca command line
Providing a spkac file with no default section causes a double free.

Thanks to Brian Carpenter for reporting this issue.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit 229bd12487)
2016-10-28 09:30:40 +01:00
Matt Caswell
dafa1c85b9 Add a test for BIO_read() returning 0 in SSL_read() (and also for write)
A BIO_read() 0 return indicates that a failure occurred that may be
retryable. An SSL_read() 0 return indicates a non-retryable failure. Check
that if BIO_read() returns 0, SSL_read() returns <0. Same for SSL_write().

The asyncio test filter BIO already returns 0 on a retryable failure so we
build on that.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit a34ac5b8b9)
2016-10-28 09:17:30 +01:00
Matt Caswell
122580ef71 A zero return from BIO_read()/BIO_write() could be retryable
A zero return from BIO_read()/BIO_write() could mean that an IO operation
is retryable. A zero return from SSL_read()/SSL_write() means that the
connection has been closed down (either cleanly or not). Therefore we
should not propagate a zero return value from BIO_read()/BIO_write() back
up the stack to SSL_read()/SSL_write(). This could result in a retryable
failure being treated as fatal.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 4880672a9b)
2016-10-28 09:17:30 +01:00
Richard Levitte
207a9cb352 VMS: tell the C compiler to use the ISO C94 standard
The current version of the VMS compiler provides C99 features,
strictly language wise.  Unfortunately, even the most recent standard
library isn't fully updated for that standard, so we need to use an
earlier standard that the compiler supports.

Most importantly, this affects the __STDC_VERSION__ value, which the
compiler unfortunately currently defaults to 199901L.  With this
change we won't have to give VMS special treatment when looking for
features based on that macro.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1785)
(cherry picked from commit 4f3015bb30)
2016-10-26 18:24:26 +02:00
Rich Salz
b2d0859ce1 Fix typo (reported by Matthias St. Pierre)
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 12a7715e3d)
2016-10-26 11:49:35 -04:00
Richard Levitte
2aec6095d3 Backdated note in CHANGES about shared library names
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1767)
(cherry picked from commit 78ce90cb1a)
2016-10-25 20:34:10 +02:00
Richard Levitte
ea897a0aa8 Add some notes on shared library names on different platforms
This is overdue since the addition of the unified build system

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1767)
(cherry picked from commit 4fa3f08fee)
2016-10-25 20:34:09 +02:00
Andy Polyakov
87148d30c9 x86_64 assembly pack: add Goldmont performance results.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit ace05265d2)
2016-10-24 13:02:41 +02:00
Richard Levitte
9df0b74d0f Efence is antiquated, remove all traces of using it
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1768)
(cherry picked from commit 4fab3e24d6)
2016-10-22 02:50:45 +02:00
Richard Levitte
8b13f33dbf Correct installation test in appveyor
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1759)
(cherry picked from commit 92403e77ac)
2016-10-21 13:48:34 +02:00
Claus Assmann
e8e9cf7e9d Fix grammar error in SSL_CTX_set_min_proto_version
CLA: trivial
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1762)

(cherry picked from commit 8b5fffc819)
2016-10-21 06:42:57 -04:00
Rich Salz
a3b94c9c2b GH1546: Fix old names in cryptodev code.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1584)
(cherry picked from commit a8a8a917c0)
2016-10-21 04:37:10 -04:00
David Woodhouse
8afb9742ae Disable encrypt_then_mac negotiation for DTLS.
I use the word 'negotiation' advisedly. Because that's all we were doing.
We negotiated it, set the TLS1_FLAGS_ENCRYPT_THEN_MAC flag in our data
structure, and then utterly ignored it in both dtls_process_record()
and do_dtls1_write().

Turn it off for 1.1.0; we'll fix it for 1.1.1 and by the time that's
released, hopefully 1.1.0b will be ancient history.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-10-20 09:59:41 +01:00
Richard Levitte
ec7b16ddbb apps: remove some #ifndef clutter
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1643)
(cherry picked from commit b85bf63952)
2016-10-20 08:59:54 +02:00
Richard Levitte
a55b395937 apps: instead of varying implementation, make setup_engine a function always
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1643)
(cherry picked from commit 907c6c8633)
2016-10-20 08:59:53 +02:00
Richard Levitte
233bcb95dd If an engine comes up explicitely, it must also come down explicitely
In apps/apps.c, one can set up an engine with setup_engine().
However, we freed the structural reference immediately, which means
that for engines that don't already have a structural reference
somewhere else (because it's a built in engine), we end up returning
an invalid reference.

Instead, the function release_engine() is added, and called at the end
of the routines that call setup_engine().

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1643)
(cherry picked from commit dd1abd4462)
2016-10-20 08:59:53 +02:00
Andrea Grandi
e7a5f50da0 Fix broken link to ASYNC_get_wait_ctx and rewrap the paragraph
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1745)
(cherry picked from commit 50c3fc00cc)
2016-10-19 10:42:57 -04:00
Mat
3d040392ff Do not set load_crypto_strings_inited when OPENSSL_NO_ERR is defined
Only set the load_crypto_strings_inited to 1 when err_load_crypto_strings_int was called.

This solves the following issue:
- openssl is built with no-err
- load_crypto_strings_inited is set to 1 during the OPENSSL_init_crypto call
- During the cleanup: OPENSSL_cleanup, err_free_strings_int is called because load_crypto_strings_inited == 1
- err_free_strings_int calls do_err_strings_init because it has never been called
- Now do_err_strings_init calls OPENSSL_init_crypto
- But since we are in the cleanup (stopped == 1) this results in an error:
  CRYPTOerr(CRYPTO_F_OPENSSL_INIT_CRYPTO, ERR_R_INIT_FAIL);
- which then tries to initialize everything we are trying to clean up: ERR_get_state, ossl_init_thread_start, etc
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1654)
(cherry picked from commit a1f2b0e6e0)
2016-10-19 07:03:04 -04:00
FdaSilvaYY
c347c5a3b6 Add error checking, small nit on ouput
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1632)
(cherry picked from commit 31dad404fd)
2016-10-19 06:42:43 -04:00
Andrea Grandi
be118c3d57 Add missing .pod extension to EVP_PKEY_CTX_set_tls1_prf_md
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit efba60ca7a)
2016-10-19 10:30:30 +01:00
Dr. Stephen Henson
e97afdad65 Fix embedded string handling.
Don't rely on embedded flag to free strings correctly: it wont be
set if there is a malloc failure during initialisation.

Thanks to Guido Vranken for reporting this issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1725)
(cherry picked from commit 6215f27a83)
2016-10-17 14:36:29 +01:00
choury
6a73da167f fix invalid use of incomplete type X509_STORE_CTX
CLA: trivial

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit ba6017a193)
2016-10-17 14:40:20 +02:00
Steven Fackler
969f378e36 Fix signatures of EVP_Digest{Sign,Verify}Update
These are implemented as macros delegating to `EVP_DigestUpdate`, which
takes a `size_t` as its third argument, not an `unsigned int`.

CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 8bdce8d160)
2016-10-15 23:39:01 +01:00
Matt Caswell
953ef2cbd0 Ensure we handle len == 0 in ERR_err_string_n
If len == 0 in a call to ERR_error_string_n() then we can read beyond the
end of the buffer. Really applications should not be calling this function
with len == 0, but we shouldn't be letting it through either!

Thanks to Agostino Sarubbo for reporting this issue. Agostino's blog on
this issue is available here:
https://blogs.gentoo.org/ago/2016/10/14/openssl-libcrypto-stack-based-buffer-overflow-in-err_error_string_n-err-c/

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit e5c1361580)
2016-10-15 11:32:24 +01:00
Tomas Mraz
5389388a2b Engine afalg: properly set operation type also on big endian.
Copy the whole ALG_OP_TYPE to CMSG_DATA.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 574cffd5d5)
2016-10-14 20:09:53 +01:00
Xiaoyin Liu
1ee297e52f Fix typo
I think the second "VC-WIN32" should be "VC-WIN64".
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
CLA: trivial
2016-10-14 10:02:42 +01:00
Vitezslav Cizek
bf4e64227d Configure: remove superfluous 0x
The number is taken from the OPENSSL_VERSION_NUMBER which is already
in the hex form.

CLA: trivial

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1706)

(cherry picked from commit 35a498e431)
2016-10-13 15:37:00 -04:00
Dr. Stephen Henson
91951307d6 Add memory leak detection to d2i_test
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1707)
(cherry picked from commit 4a4c4bf06d)
2016-10-13 19:27:34 +01:00
FdaSilvaYY
5c0c82c3f6 Fix copy-paste test labels
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 32804b04b8)
2016-10-13 13:42:03 +02:00
Ben Laurie
8934b0949c Remove blank line.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-13 10:08:37 +01:00
Ben Laurie
d0929aff54 Fix no-ocsp.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-13 09:52:53 +01:00
Richard Levitte
d8631ebaab Remove automatic RPATH - Add a CHANGES entry
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 38be1ea855)
2016-10-13 02:26:34 +02:00
Richard Levitte
7b7f21cd60 Remove automatic RPATH - adapt shlib_wrap.sh
Looking for something starting with '-Wl,-rpath,' isn't good enough,
as someone might give something like '-Wl,--enable-new-dtags,-rpath,/PATH'.
Looking for ',-rpath,' should be safe enough.

We could remove the preloading stuff entirely, but just in case the
user has chosen to given RPATH setting arguments at configuration,
we'd better make sure testing will still work.  Fair warning, there
are some configuration options that do not work with preloaded OpenSSL
libraries, such as the sanity checking ones.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 71d8ff1a89)
2016-10-13 02:25:46 +02:00
Richard Levitte
0de5e4f092 Remove automatic RPATH - add user rpath support
Make Configure recognise -rpath and -R to support user added rpaths
for OSF1 and Solaris.  For convenience, add a variable LIBRPATH in the
Unix Makefile, which the users can use as follows:

    ./config [options] -Wl,-rpath,\$(LIBRPATH)

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit fad599f7f1)
2016-10-13 02:25:42 +02:00
Richard Levitte
68f3b89910 Remove automatic RPATH
Before OpenSSL 1.1.0, binaries were installed in a non-standard
location by default, and runpath directories were therefore added in
those binaries, to make sure the executables would be able to find the
shared libraries they were linked with.

With OpenSSL 1.1.0 and on, binaries are installed in standard
directories by default, and the addition of runpath directories is
therefore not needed any more.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 075f7e2c60)
2016-10-13 02:24:40 +02:00
Rich Salz
e4e407fe82 RT is put out to pasture
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1702)
(cherry picked from commit 7954dced19)
2016-10-12 19:05:43 -04:00
Dr. Stephen Henson
15ef80b5b1 Fix X509_NAME decode for malloc failures.
The original X509_NAME decode free code was buggy: this
could result in double free or leaks if a malloc failure
occurred.

Simplify and fix the logic.

Thanks to Guido Vranken for reporting this issue.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1691)
(cherry picked from commit 6dcba070a9)
2016-10-11 22:18:20 +01:00
Ben Laurie
174ec019c3 Remove untrue comment.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-02 22:58:59 +01:00
Ben Laurie
941005df14 Make dependencies if Makefile is new.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-02 22:58:59 +01:00
Ben Laurie
dc2a7e42a2 Don't use des when disabled.
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-02 05:58:22 +01:00
Dr. Stephen Henson
08a78f8c44 fix memory leak
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit eb67172ae5)
2016-10-01 15:31:29 +01:00
Dr. Stephen Henson
3f39423aac SRP code tidy.
Tidy up srp_Calc_k and SRP_Calc_u by making them a special case of
srp_Calc_xy which performs SHA1(PAD(x) | PAD(y)).

This addresses an OCAP Audit issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 8f332ac962)
2016-10-01 14:13:02 +01:00
Dr. Stephen Henson
25a127bde9 Add SRP test vectors from RFC5054
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 198d805900)
2016-10-01 14:13:02 +01:00
Matt Caswell
6b02b586c3 Fix missing NULL checks in NewSessionTicket construction
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 83ae466131)
2016-09-29 16:17:54 +01:00
David Woodhouse
9cb0c3a3ca Restore '-keyform engine' support for s_client
This used to work in 1.0.2 but disappeared when the argument parsing was
revamped.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1639)

(cherry picked from commit a6972f3462)
2016-09-29 12:52:15 +02:00
Matt Caswell
61b1eb2c67 Fix an Uninit read in DTLS
If we have a handshake fragment waiting then dtls1_read_bytes() was not
correctly setting the value of recvd_type, leading to an uninit read.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 2f2d6e3e3c)
2016-09-29 10:00:52 +01:00
Matt Caswell
dd63da7032 Fix no-dtls
The new large message test in sslapitest needs OPENSSL_NO_DTLS guards

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 55386bef80)
2016-09-29 09:54:38 +01:00
Richard Levitte
a1b791225f apps/apps.c: initialize and de-initialize engine around key loading
Before loading a key from an engine, it may need to be initialized.
When done loading the key, we must de-initialize the engine.
(if the engine is already initialized somehow, only the reference
counter will be incremented then decremented)

Reviewed-by: Stephen Henson <steve@openssl.org>
(cherry picked from commit 49e476a538)
2016-09-28 21:58:50 +02:00
Matt Caswell
8061fdc8d3 Add DTLS renegotiation tests
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit f9b1b6644a)
2016-09-28 09:18:46 +01:00
Matt Caswell
f1522af442 Extend the renegotiation tests
Add the ability to test both server initiated and client initiated reneg.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit fe7dd55341)
2016-09-28 09:18:46 +01:00
Matt Caswell
d17300093c Update README.ssltest.md
Add update for testing renegotiation. Also change info on CTLOG_FILE
environment variable - which always seems to be required.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 1329b952a6)
2016-09-28 09:18:46 +01:00
Matt Caswell
cccaf5d60b Add support for testing renegotiation
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit e42c4544c8)
2016-09-28 09:18:46 +01:00
David Benjamin
a7511d72a3 Add a basic test for BN_bn2dec.
This would have caught 099e2968ed. This is
a port of the test added in
https://boringssl.googlesource.com/boringssl/+/7c040756178e14a4d181b6d93abb3827c93189c4

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1496)
(cherry picked from commit 8ff70f3326)
2016-09-27 09:41:52 -04:00
David Benjamin
35c2aca31f Add missing parameter.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 243ecf19dd)
2016-09-26 23:14:19 +01:00
David Benjamin
9e4a7023aa Switch back to assuming TLS 1.2.
The TLSProxy::Record->new call hard-codes a version, like
70-test_sslrecords.t.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit f3ea8d7708)
2016-09-26 23:14:19 +01:00
David Benjamin
f53e42e518 Address review comments.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 3058b74266)
2016-09-26 23:14:19 +01:00
David Benjamin
a905d13bbb Don't test quite so many of them.
Avoid making the CI blow up.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 5cf6d7c51f)
2016-09-26 23:14:19 +01:00
David Benjamin
384fd75ad8 Test CBC mode padding.
This is a regression test for
https://github.com/openssl/openssl/pull/1431. It tests a
maximally-padded record with each possible invalid offset.

This required fixing a bug in Message.pm where the client sending a
fatal alert followed by close_notify was still treated as success.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 8523288e6d)
2016-09-26 23:14:19 +01:00
Matt Caswell
7cac055800 Fix some mem leaks in sslapitest
A mem leak could occur on an error path. Also the mempacket BIO_METHOD
needs to be cleaned up, because of the newly added DTLS test.

Also fixed a double semi-colon in ssltestlib.c

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit fa454945cf)
2016-09-26 17:29:26 +01:00
Matt Caswell
a12778be17 Prepare for 1.1.0c-dev
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-26 10:46:58 +01:00
Matt Caswell
16c34d4f74 Prepare for 1.1.0b release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-26 10:46:03 +01:00
Matt Caswell
87cd6f9253 Updates CHANGES and NEWS for new release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-26 10:25:13 +01:00
Robert Swiecki
f8644220a0 Add to fuzz corpora for CVE-2016-6309
Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 44f206aa9d)
2016-09-26 09:05:42 +01:00
Matt Caswell
acacbfa756 Fix Use After Free for large message sizes
The buffer to receive messages is initialised to 16k. If a message is
received that is larger than that then the buffer is "realloc'd". This can
cause the location of the underlying buffer to change. Anything that is
referring to the old location will be referring to free'd data. In the
recent commit c1ef7c97 (master) and 4b390b6c (1.1.0) the point in the code
where the message buffer is grown was changed. However s->init_msg was not
updated to point at the new location.

CVE-2016-6309

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 0d698f6696)
2016-09-26 09:05:30 +01:00
Matt Caswell
df7681e468 Add a test for large messages
Ensure that we send a large message during the test suite.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 84d5549e69)
2016-09-26 09:05:17 +01:00
Matt Caswell
5fe5914d30 Prepare for 1.1.0b-dev
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-22 11:15:54 +01:00
Matt Caswell
ac2c44c628 Prepare for 1.1.0a release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-22 11:14:50 +01:00
Matt Caswell
f3e189613f Updates CHANGES and NEWS for new release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-22 09:28:07 +01:00
Dmitry Belyavsky
d3c9d6e99f Avoid KCI attack for GOST
Russian GOST ciphersuites are vulnerable to the KCI attack because they use
long-term keys to establish the connection when ssl client authorization is
on. This change brings the GOST implementation into line with the latest
specs in order to avoid the attack. It should not break backwards
compatibility.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-09-22 09:28:07 +01:00
Matt Caswell
63658103d4 Fix a hang with SSL_peek()
If while calling SSL_peek() we read an empty record then we go into an
infinite loop, continually trying to read data from the empty record and
never making any progress. This could be exploited by a malicious peer in
a Denial Of Service attack.

CVE-2016-6305

GitHub Issue #1563

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-22 09:28:07 +01:00
Matt Caswell
6d32c2ae28 Fix a mem leak in NPN handling
If a server sent multiple NPN extensions in a single ClientHello then a
mem leak can occur. This will only happen where the client has requested
NPN in the first place. It does not occur during renegotiation. Therefore
the maximum that could be leaked in a single connection with a malicious
server is 64k (the maximum size of the ServerHello extensions section). As
this is client side, only occurs if NPN has been requested and does not
occur during renegotiation this is unlikely to be exploitable.

Issue reported by Shi Lei.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-22 09:28:07 +01:00
Matt Caswell
f6a7505e64 Add some more OCSP testing
Test that the OCSP callbacks work as expected.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-22 09:28:07 +01:00
Matt Caswell
7409b0aae5 Add OCSP_RESPID_match()
Add a function for testing whether a given OCSP_RESPID matches with a
certificate.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-22 09:28:07 +01:00
Matt Caswell
1645f3f4b9 Add the ability to set OCSP_RESPID fields
OCSP_RESPID was made opaque in 1.1.0, but no accessors were provided for
setting the name/key value for the OCSP_RESPID.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-22 09:28:07 +01:00
Matt Caswell
a59ab1c4dd Fix OCSP Status Request extension unbounded memory growth
A malicious client can send an excessively large OCSP Status Request
extension. If that client continually requests renegotiation,
sending a large OCSP Status Request extension each time, then there will
be unbounded memory growth on the server. This will eventually lead to a
Denial Of Service attack through memory exhaustion. Servers with a
default configuration are vulnerable even if they do not support OCSP.
Builds using the "no-ocsp" build time option are not affected.

I have also checked other extensions to see if they suffer from a similar
problem but I could not find any other issues.

CVE-2016-6304

Issue reported by Shi Lei.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-22 09:28:07 +01:00
Richard Levitte
d8e94b0d8f Fix error message typo, wrong function code
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit a449b47c7d)
2016-09-22 09:26:37 +01:00
Richard Levitte
2178c52a8b test/x509aux.c: Fix argv loop
There are cases when argc is more trustable than proper argv termination.
Since we trust argc in all other test programs, we might as well treat it
the same way in this program.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 780bbb96bf)
2016-09-22 09:01:22 +01:00
Andy Polyakov
db610cb29c CHANGES: mention removal of solaris-x86-cc.
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-21 23:21:33 +02:00
Matt Caswell
df6b5e29ff Excessive allocation of memory in dtls1_preprocess_fragment()
This issue is very similar to CVE-2016-6307 described in the previous
commit. The underlying defect is different but the security analysis and
impacts are the same except that it impacts DTLS.

A DTLS message includes 3 bytes for its length in the header for the
message.
This would allow for messages up to 16Mb in length. Messages of this length
are excessive and OpenSSL includes a check to ensure that a peer is sending
reasonably sized messages in order to avoid too much memory being consumed
to service a connection. A flaw in the logic of version 1.1.0 means that
memory for the message is allocated too early, prior to the excessive
message length check. Due to way memory is allocated in OpenSSL this could
mean an attacker could force up to 21Mb to be allocated to service a
connection. This could lead to a Denial of Service through memory
exhaustion. However, the excessive message length check still takes place,
and this would cause the connection to immediately fail. Assuming that the
application calls SSL_free() on the failed conneciton in a timely manner
then the 21Mb of allocated memory will then be immediately freed again.
Therefore the excessive memory allocation will be transitory in nature.
This then means that there is only a security impact if:

1) The application does not call SSL_free() in a timely manner in the
event that the connection fails
or
2) The application is working in a constrained environment where there
is very little free memory
or
3) The attacker initiates multiple connection attempts such that there
are multiple connections in a state where memory has been allocated for
the connection; SSL_free() has not yet been called; and there is
insufficient memory to service the multiple requests.

Except in the instance of (1) above any Denial Of Service is likely to
be transitory because as soon as the connection fails the memory is
subsequently freed again in the SSL_free() call. However there is an
increased risk during this period of application crashes due to the lack
of memory - which would then mean a more serious Denial of Service.

This issue does not affect TLS users.

Issue was reported by Shi Lei (Gear Team, Qihoo 360 Inc.).

CVE-2016-6308

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 48c054fec3)
2016-09-21 20:45:45 +01:00
Matt Caswell
4b390b6c3f Excessive allocation of memory in tls_get_message_header()
A TLS message includes 3 bytes for its length in the header for the message.
This would allow for messages up to 16Mb in length. Messages of this length
are excessive and OpenSSL includes a check to ensure that a peer is sending
reasonably sized messages in order to avoid too much memory being consumed
to service a connection. A flaw in the logic of version 1.1.0 means that
memory for the message is allocated too early, prior to the excessive
message length check. Due to way memory is allocated in OpenSSL this could
mean an attacker could force up to 21Mb to be allocated to service a
connection. This could lead to a Denial of Service through memory
exhaustion. However, the excessive message length check still takes place,
and this would cause the connection to immediately fail. Assuming that the
application calls SSL_free() on the failed conneciton in a timely manner
then the 21Mb of allocated memory will then be immediately freed again.
Therefore the excessive memory allocation will be transitory in nature.
This then means that there is only a security impact if:

1) The application does not call SSL_free() in a timely manner in the
event that the connection fails
or
2) The application is working in a constrained environment where there
is very little free memory
or
3) The attacker initiates multiple connection attempts such that there
are multiple connections in a state where memory has been allocated for
the connection; SSL_free() has not yet been called; and there is
insufficient memory to service the multiple requests.

Except in the instance of (1) above any Denial Of Service is likely to
be transitory because as soon as the connection fails the memory is
subsequently freed again in the SSL_free() call. However there is an
increased risk during this period of application crashes due to the lack
of memory - which would then mean a more serious Denial of Service.

This issue does not affect DTLS users.

Issue was reported by Shi Lei (Gear Team, Qihoo 360 Inc.).

CVE-2016-6307

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit c1ef7c971d)
2016-09-21 20:45:45 +01:00
Andy Polyakov
f757ce2a3d Configure: clarify and refine -static.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 047d97afd9)
2016-09-21 21:38:25 +02:00
Matt Caswell
1fdeda4cc9 Don't leak on an OPENSSL_realloc() failure
If OPENSSL_sk_insert() calls OPENSSL_realloc() and it fails, it was leaking
the originally allocated memory.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 41bff723c6)
2016-09-21 20:30:25 +01:00
Matt Caswell
6915f39e68 Don't allow too many consecutive warning alerts
Certain warning alerts are ignored if they are received. This can mean that
no progress will be made if one peer continually sends those warning alerts.
Implement a count so that we abort the connection if we receive too many.

Issue reported by Shi Lei.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit af58be768e)
2016-09-21 20:21:57 +01:00
Andy Polyakov
e7498968e2 rand/randfile.c: treat empty string in RAND_file_name as error.
Suggested in GH#1589.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 7dc0ad4d6d)
2016-09-21 21:10:27 +02:00
Andy Polyakov
13af417ba4 rand/randfile.c: rationalize __OpenBSD__ code path.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit ba8fa4e53a)
2016-09-21 21:10:18 +02:00
Andy Polyakov
098dc9be43 rand/randfile.c: restore fallback to $HOME for non-setuid programs.
Reported in GH#1589, but solution is different from suggested.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 799c1293fc)
2016-09-21 21:10:07 +02:00
Rich Salz
7b368cd6d9 Dcoument -alpn flag
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 776e15f939)
2016-09-21 11:23:38 -04:00
Rich Salz
bf0404fe4a GH1555: Don't bump size on realloc failure
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 6fcace45bd)
2016-09-21 10:41:13 -04:00
Alessandro Ghedini
64d1cc09f9 Use switch instead of multiple ifs
Makes the logic a little bit clearer.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1571)
(cherry picked from commit 4f8a5f4da9)
2016-09-21 10:39:33 -04:00
Matt Caswell
6bdd2637da Fix a missing NULL check in dsa_builtin_paramgen
We should check the last BN_CTX_get() call to ensure that it isn't NULL
before we try and use any of the allocated BIGNUMs.

Issue reported by Shi Lei.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 1ff7425d61)
2016-09-21 13:35:38 +01:00
Richard Levitte
cade326432 VMS: add [.util]shlib_wrap.exe and its build instructions
This is a program for VMS that corresponds to util/shlib_wrap.sh.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit f3ff481f31)
2016-09-21 02:41:38 +02:00
Richard Levitte
79844cbba5 descrip.mms.tmpl: in obj2bin, make sure an empty @deps means no empty lines
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 47852e6ae7)
2016-09-21 02:40:13 +02:00
Richard Levitte
87030f54b2 util/dofile.pl: report if a template couldn't be loaded
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit f6be8315cb)
2016-09-21 02:40:11 +02:00
Rich Salz
d6637ce17e RT3669: dgst can only sign/verify one file.
Check arg count and print an error message.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 13a461831a)
2016-09-20 15:48:23 -04:00
Richard Levitte
e5cb5dbd3c apps/apps.c: include sys/socket.h to declare recv()
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit a19228b7f4)
2016-09-20 20:33:04 +02:00
Richard Levitte
435972c172 Documentation fixup; no more ECDHParameters
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 6e836806ad)
2016-09-20 18:25:13 +02:00
Richard Levitte
9c067c8991 Crude VMS build files for demos/bio/
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 8c88c88b5a)
2016-09-20 18:25:13 +02:00
Richard Levitte
0430efa62f Crude Makefile for demos/bio/
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit f4566dff06)
2016-09-20 18:25:13 +02:00
Richard Levitte
3ed2d8a4b8 Don't ignore Makefiles in demos/
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit ccf11f7ee4)
2016-09-20 18:25:12 +02:00
Richard Levitte
b90348c7c5 Fixup BIO demos for OpenSSL 1.1.x
Call SSL_CTX_new() before doing any configuration.
(or call OPENSSL_ssl_init())

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 54d72ef0f0)
2016-09-20 18:25:12 +02:00
Richard Levitte
d575693883 Fixup BIO demos for OpenSSL 1.1.x
'ECDHParameters = Automatic' isn't accepted.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 3656ea1c22)
2016-09-20 18:25:12 +02:00
Richard Levitte
f506d82477 Fixup BIO demos for OpenSSL 1.1.x
Note: server-cmod doesn't seem to do things right...  from loading
cmod.cnf, it tries to load libssl_conf.so.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 16c6deed2c)
2016-09-20 18:25:12 +02:00
FdaSilvaYY
3fd181a8b5 Remove an option related to a deprecated flag
CMS_NOOLDMIMETYPE and PKCS7_NOOLDMIMETYPE  are unused in pkcs7/cms code.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1585)
(cherry picked from commit 28aef3d955)
2016-09-19 21:28:09 -04:00
FdaSilvaYY
90edd7ad0f Fix various missing option help messages ...
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1585)
(cherry picked from commit 12d56b2992)
2016-09-19 21:27:25 -04:00
Matt Caswell
57106f55a5 Convert num_alloc to a size_t in stack.c and tweak style
We were casting num_alloc to size_t in lots of places, or just using it in
a context where size_t makes more sense - so convert it. This simplifies
the code a bit.

Also tweak the style in stack.c a bit following on from the previous
commit

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 9205ebeb8e)
2016-09-19 23:31:03 +01:00
Guido Vranken
05f754f6a6 Prevent overflows in stack API
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 9731a9ce7d)
2016-09-19 23:31:03 +01:00
FdaSilvaYY
322b739be5 Update INSTALL about no-md5 removal
no-rsa is no longer an option since 7ec8de1

Fix a typo about poly1305

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1582)
(cherry picked from commit e2562bbbe1)
2016-09-19 17:11:19 -04:00
Richard Levitte
6f99d9c22f Fix no-ocsp
Some compilers complain about unused variables, and some tests do
not run well without OCSP.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 057c676afb)
2016-09-19 16:29:32 +02:00
Richard Levitte
11bb654c60 Have the configuration options 'no-err' and 'no-async' work again
In an earlier attempt to simplify the processing of disabled options,
'no-err' and 'no-async' stopped working properly.  'err' and 'async'
are directories under 'crypto/', but they are special insofar that
they can't be simply skipped, like all the algorithm directories can,
so they need special treatment among the disablable things.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 66fe388aa4)
2016-09-17 23:22:16 +02:00
Richard Levitte
ebae51f490 Simplify configudata.pm dependency generation
While we're at it, correct the fault in windows-makefile.tmpl

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 41240e68d7)
2016-09-17 21:16:36 +02:00
FdaSilvaYY
f0d0e783df Remove an useless definition.
APP_INFO is currently a field of MEM struct.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1583)
(cherry picked from commit 76dc356384)
2016-09-17 12:36:43 -04:00
Richard Levitte
2172993088 Simplify the dependencies for remaking configdata.pm
Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit c5ad3076a6)
2016-09-16 11:53:30 +02:00
Richard Levitte
5dab48340e Rearrange the storage of build file template names in %config
They are now relative paths as well

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 1967a42eb5)
2016-09-16 11:53:30 +02:00
Richard Levitte
b5edd178ca Use the registered conf file names as dependencies to build configdata.pm
Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit dc660c70b5)
2016-09-16 11:53:30 +02:00
Richard Levitte
efd2379412 Register the name of the config file each config target was found in
Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit ee9b0bbb4c)
2016-09-16 11:53:29 +02:00
Matt Caswell
ea6e2d5436 Revert "Abort on unrecognised warning alerts"
This reverts commit 77a6be4dfc.

There were some unexpected side effects to this commit, e.g. in SSLv3 a
warning alert gets sent "no_certificate" if a client does not send a
Certificate during Client Auth. With the above commit this causes the
connection to abort, which is incorrect. There may be some other edge cases
like this so we need to have a rethink on this.

Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-09-15 22:51:06 +01:00
Richard Levitte
2abbe94828 Finally, make sure vms_term_sock.c is built on VMS
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit d602c2b680)
2016-09-15 23:28:24 +02:00
Richard Levitte
9b498c9f0f Refactor to avoid unnecessary preprocessor logic
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 51e5133d55)
2016-09-15 23:28:24 +02:00
Richard Levitte
34b3563243 Reformat to fit OpenSSL source code standards
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit c7bdb6a31f)
2016-09-15 23:28:23 +02:00
Richard Levitte
07ebdfab07 Add copyright and license on apps/vms_term_sock.[ch]
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 0d0723e813)
2016-09-15 23:28:23 +02:00
Richard Levitte
ae6e317e32 VSI submission: redirect terminal input through socket
This is needed, because on VMS, select() can only be used on sockets.  being
able to use select() on all kinds of file descriptors is unique to Unix.

So, the solution for VMS is to create a layer that translates input from
standard input to socket communication.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 0d3b65832c)
2016-09-15 23:28:23 +02:00
Rich Salz
03a8bf079c Make reference to other manpage more explicit
Where -curves, etc., are defined: SSL_CONF_cmd

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit ddb30bde105a50d6a79a9662eeaf27e8cb29c606)
2016-09-14 18:25:20 -04:00
Rich Salz
1850451676 Add -h and -help for c_rehash script and app
Resolves GH1515 and GH1509.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 7d959c358a)
2016-09-14 09:03:49 -04:00
Matt Caswell
9496cf577e Add some sanity checks around usage of t_fromb64()
The internal SRP function t_fromb64() converts from base64 to binary. It
does not validate that the size of the destination is sufficiently large -
that is up to the callers. In some places there was such a check, but not
in others.

Add an argument to t_fromb64() to provide the size of the destination
buffer and validate that we don't write too much data. Also add some sanity
checks to the callers where appropriate.

With thanks to Shi Lei for reporting this issue.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 73f0df8331)
2016-09-14 10:09:41 +01:00
Richard Levitte
f735859536 Add a test for 'openssl passwd'
Also, enlarge test group 20 to include openssl commands that aren't
tested otherwise

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 497f3bf9a7)
2016-09-14 00:31:26 +02:00
Richard Levitte
9fd47a0370 Fix 'openssl passwd' with arguments -1 or -apr1
RT#4674

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 9f9f962d96)
2016-09-14 00:31:26 +02:00
Andy Grundman
8ff785f4eb Remove -xtarget=ultra from solaris(64)-sparcv9-cc builds.
This flag got moved after -xarch=v9 in 1.1.0 and had the unexpected
side effect of the compiler building for 32-bit v8plusa instead of v9.

GH#1521
CLA: none; trivial

Signed-off-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit fa4618a280)
2016-09-13 15:30:03 +02:00
Viktor Szakats
799398ca42 bio.h: fix number of arguments passed to BIO_ptr_ctrl()
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1520)
(cherry picked from commit c2efa78309)
2016-09-13 09:24:39 -04:00
Viktor Szakats
e631d60280 s_client: avoid warning on Windows/MS-DOS systems
it appears when using gcc/mingw:
```
apps/s_client.c:815:9: warning: variable 'at_eof' set but not used [-Wunused-but-set-variable]
     int at_eof = 0;
         ^~~~~~
```
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1512)
(cherry picked from commit d485640b80)
2016-09-13 09:24:20 -04:00
Andy Polyakov
1556abd043 Configure: detect gcc's dependency generation capability more accurately.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 35c11bfc69)
2016-09-13 14:04:21 +02:00
Andy Polyakov
ce7d2e152e bn/bn_lcl.h: improve interoperability with clang and Android NDK.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit cc2cb7bf63)
2016-09-13 13:35:07 +02:00
Matt Caswell
44c9339ca8 util/shlib_wrap.sh is now auto-generated so tell git to ignore it
Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 6462876f8d)
2016-09-13 11:57:20 +01:00
Matt Caswell
4bc54bf8b4 Abort on unrecognised warning alerts
A peer continually sending unrecognised warning alerts could mean that we
make no progress on a connection. We should abort rather than continuing if
we receive an unrecognised warning alert.

Thanks to Shi Lei for reporting this issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 77a6be4dfc)
2016-09-13 11:53:54 +01:00
David Woodhouse
469f593170 Add enginesdir to libcrypto.pc pkg-config file
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit cdbbf99002)
2016-09-12 16:26:15 +02:00
Tim Hudson
718951c2f2 Fix EC_KEY_print so it prints out private key information
even when the public key is not present in an EC_KEY

Reviewed-by: Stephen Henson <steve@openssl.org>
(cherry picked from commit 82f52631b2)
2016-09-10 07:04:42 +10:00
Richard Levitte
0adfd49e47 If errno is ENXIO in BSS_new_file(), set BIO_R_NO_SUCH_FILE
VMS sets that errno when the device part of a file spec is malformed
or a logical name that doesn't exist.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit e82e2186e9)
2016-09-09 00:10:59 +02:00
Richard Levitte
d3fa9addd2 Travis: Do asan and msan with shared libraries
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 047a5da249)
2016-09-08 17:55:39 +02:00
Matt Caswell
ea42bd4059 Fix mem leaks during auto-deinit
Certain functions are automatically called during auto-deinit in order
to deallocate resources. However, if we have never entered a function which
marks lib crypto as inited then they never get called. This can happen if
the user only ever makes use of a small sub-set of functions that don't hit
the auto-init code.

This commit ensures all such resources deallocated by these functions also
init libcrypto when they are initially allocated.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Ben Laurie <ben@openssl.org>
(cherry picked from commit 135648bcd0)
2016-09-08 12:43:04 +01:00
Matt Caswell
baee63371d Ensure trace recognises X25519
Using the -trace option to s_server or s_client was incorrectly printing
UNKNOWN for the X25519 curve.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 2d11f5b2ca)
2016-09-08 12:36:46 +01:00
Andy Polyakov
a0c5ccc7c1 engines/afalg: make it compile with backward compatibility headers.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 4e3997293b)
2016-09-08 09:16:20 +02:00
Andy Polyakov
054ef95f56 Configurations/10-main.cf: AIX "facelift".
Improve interchangeability of aix*-gcc targets by linking shared
libraries with -static-libgcc, and address linking problems with
vendor compiler.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit f780eaad5b)
2016-09-08 09:12:10 +02:00
Andy Polyakov
656bce0357 chacha/asm/chacha-ppc.pl: add missing .text directive.
RT#4667

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit abcbf7ed7e)
2016-09-08 09:07:09 +02:00
Rich Salz
f2befe3444 Add missing debug strings.
Found by turning -Wswitch-enum on.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 252cfef151)
2016-09-07 16:09:01 -04:00
Richard Levitte
c3cfc9962b Allow asan, msan and ubsan to be configured with shared libraries
The background story is that util/shlib_wrap.sh was setting LD_PRELOAD
or similar platform dependent variables, just in case the shared
libraries were built with -rpath.  Unfortunately, this doesn't work
too well with asan, msan or ubsan.

So, the solution is to forbid the combination of shared libraries,
-rpath and any of the sanity analyzers we can configure.

This changes util/shlib_wrap.sh so it only contains the code that sets
LD_PRELOAD when -rpath has been used when configuring.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 342a1a2379)
2016-09-07 21:54:08 +02:00
David Woodhouse
92ed7fa575 Avoid EVP_PKEY_cmp() crash on EC keys without public component
Some hardware devices don't provide the public EC_POINT data. The only
way for X509_check_private_key() to validate that the key matches a
given certificate is to actually perform a sign operation and then
verify it using the public key in the certificate.

Maybe that can come later, as discussed in issue 1532. But for now let's
at least make it fail gracefully and not crash.

GH: 1532

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1547)
2016-09-07 18:21:32 +01:00
Richard Levitte
79e5eae6ab Configure: Reorganise the checking of disabled options
The way we figured out what options are crypto algorithms and what are
something other was somewhat sketchy.  This change bases the
distinction on available sdirs instead.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 3e2dd30d66)
2016-09-07 17:28:08 +02:00
Alex Gaynor
b7d2480c82 GH1537: Avoid double-free in the EVP_PKEY API
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit d65c3615f6)
2016-09-07 09:42:50 -04:00
Rich Salz
e9590d00fc Misc BN fixes
Never output -0; make "negative zero" an impossibility.
Do better checking on BN_rand top/bottom requirements and #bits.
Update doc.
Ignoring trailing garbage in BN_asc2bn.

Port this commit from boringSSL: https://boringssl.googlesource.com/boringssl/+/899b9b19a4cd3fe526aaf5047ab9234cdca19f7d%5E!/
        Ensure |BN_div| never gives negative zero in the no_branch code.

        Have |bn_correct_top| fix |bn->neg| if the input is zero so that we
        don't have negative zeros lying around.

        Thanks to Brian Smith for noticing.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 01c09f9fde)
2016-09-06 10:42:28 -04:00
Richard Levitte
f52d16ac1d Correct detection of group end in map file when testing symbol presence
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 77a42b5f17)
2016-09-06 08:31:23 +02:00
Richard Levitte
578dc1cea3 Unix build: have the makedepend and cc actions in one recipe
In the case of using an independent makedepend, we had split that into
two separate recipes, one depending on the other.  However, there are
cases where the makedepend recipe was always trying, but doesn't
update the time stamp of the .d file because there are no actual
changes, and thereby causing constant updates of the object files.

This change makes one recipe that takes care of both makedepend och
cc, thereby avoiding these extra updates.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 7e5b8b93f2)
2016-09-05 16:08:58 +02:00
Andy Polyakov
90ed28b797 modes/asm/ghash-armv4.pl: improve interoperability with Android NDK.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 6cf412c473)
2016-09-03 10:44:16 +02:00
Andy Polyakov
eba44ca0a6 Configurations/10-main.conf: fix omittions in commentary.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit d5a39c12f0)
2016-09-02 13:23:33 +02:00
Andy Polyakov
96e6c6635e Configurations/10-main.conf: remove solaris-x86-cc target.
Since vendor assembler can't assemble our modules with -KPIC flag,
it, assembly support, was not available as an option. But this
means lack of side-channel resistant code, which is incompatible
with security by todays standards.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 216a0cc4d6)
2016-09-02 13:20:27 +02:00
Richard Levitte
3bcd1b2496 Move 05-test_fuzz.t to 90-test_fuzz.t
This adheres much better to the documentation in test/README

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 377ab6d183)
2016-09-01 22:38:28 +02:00
Richard Levitte
b5d60c2b8d Revert "INSTALL: add information on option no-fuzz-test"
This reverts commit 7f9ae88817.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 967e831e88)
2016-09-01 21:02:23 +02:00
Richard Levitte
eed06638c7 Revert "Make it possible to disable fuzz testing"
This reverts commit eb40eaed72.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit a5e1f1230e)
2016-09-01 21:02:23 +02:00
Richard Levitte
3a10218546 INSTALL: add information on option no-fuzz-test
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 7f9ae88817)
2016-08-31 21:42:11 +02:00
Richard Levitte
5b613a15d0 INSTALL: add information on the environment variable BUILDFILE
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit ed43fe73ea)
2016-08-31 21:42:11 +02:00
Richard Levitte
14ee280a49 INSTALL: clarify OPENSSL_LOCAL_CONFIG_DIR
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit bf98d9dab5)
2016-08-31 21:42:11 +02:00
Richard Levitte
3c8be9c350 Have Configure's HASH or TABLE produce complete lists
Because some targets execute perl code that might die, we risk
incomplete lists.  Make it so dying doesn't happen when we're listing
targets.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit d63c12c697)
2016-08-31 20:44:16 +02:00
Richard Levitte
67d81419f5 Configure's print_table_entry printed incorrect information
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 0c0d78b88d)
2016-08-31 20:44:16 +02:00
Richard Levitte
fd2107e077 Make it possible to disable fuzz testing
These tests take a very long time on some platforms, and arent't
always strictly necessary.  This makes it possible to turn them
off.  The necessary binaries are still built, though, in case
someone still wants to do a manual run.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit eb40eaed72)
2016-08-31 17:44:15 +02:00
Andy Polyakov
ad2aa727cd crypto/bn/*: x86[_64] division instruction doesn't handle constants, change constraint from 'g' to 'r'.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 68b4a6e91f)
2016-08-31 16:45:50 +02:00
Richard Levitte
bbf0074887 The Perl interpreter might be in a path with spaces, so maybe quote it
Note: some shells do not like the command verb to be quoted, so we avoid
it unless it's actually necessary.

RT#4665

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit f879d5ff38)
2016-08-31 16:44:15 +02:00
Rich Salz
5410190ccb Code cleanup UI
Remove NULL check on parameter, and use NULL not ! on buffer.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit bde588df8a)
2016-08-31 09:35:30 -04:00
Matt Caswell
062ed73f58 Add some CertStatus tests
The previous commit revealed a long standing problem where CertStatus
processing was broken in DTLS. This would have been revealed by better
testing - so add some!

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 767ccc3b77)
2016-08-30 21:14:29 +01:00
Matt Caswell
06314c029d Ensure the CertStatus message adds a DTLS message header where needed
The function tls_construct_cert_status() is called by both TLS and DTLS
code. However it only ever constructed a TLS message header for the message
which obviously failed in DTLS.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit f046afb066)
2016-08-30 21:14:29 +01:00
Richard Levitte
b2d10958a3 Configure: save away the value of OPENSSL_LOCAL_CONFIG_DIR for reconf
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit ee4cdb7fdb)
2016-08-30 06:07:06 +02:00
Richard Levitte
b9b3644881 Configure: Redo the logic for finding build file templates
Build file templates would be looked up like this if the user gave us
an additional directory to look for configuration files and build file
templates:

    $OPENSSL_LOCAL_CONFIG_DIR/$OSTYPE-Makefile.tmpl
    $SOURCEDIR/Configurations/$OSTYPE-Makefile.tmpl
    $OPENSSL_LOCAL_CONFIG_DIR/Makefile.tmpl
    $SOURCEDIR/Configurations/Makefile.tmpl

So for example, if the user created his own Makefile.tmpl and tried to
use it with a unixly config, it would never be user because we have a
unix-Makefile.tmpl in our Configurations directory.  This is clearly
wrong, and this change makes it look in this order instead:

    $OPENSSL_LOCAL_CONFIG_DIR/$OSTYPE-Makefile.tmpl
    $OPENSSL_LOCAL_CONFIG_DIR/Makefile.tmpl
    $SOURCEDIR/Configurations/$OSTYPE-Makefile.tmpl
    $SOURCEDIR/Configurations/Makefile.tmpl

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 79822c3cd5)
2016-08-30 06:07:06 +02:00
Richard Levitte
eac33e1cd3 Configure: clean away temporary section of code
We've done away with Makefile as source of information and now use
configdata.pm exclusively.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit acc63c7d6d)
2016-08-30 06:07:06 +02:00
Richard Levitte
b7fa463ff8 Make it possible for the user to specify a different default build file
Make sure the information is kept for reconfiguration too.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 8b5156d188)
2016-08-30 06:07:06 +02:00
Rich Salz
2aca84ffad Remove comment tags from structs (coding style)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit d196305aa0)
2016-08-29 11:21:28 -04:00
Rich Salz
35b3f7fa9a Use uppercase name for PCT_ enum
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 66117ab0f6)
2016-08-29 11:20:43 -04:00
Richard Levitte
e5c4581828 VMS: honor --openssldir setting
Because of a perl operator priority mixup, the --openssldir argument
wasn't honored.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 661a396373)
2016-08-26 22:59:52 +02:00
Rich Salz
14fd205b38 Remove trailing zeros
Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit e5f969a82f)
2016-08-26 15:19:40 -04:00
Richard Levitte
7f8d9b757f Improve the definition of STITCHED_CALL in e_rc4_hmac_md5.c
The definition of STITCHED_CALL relies on OPENSSL_NO_ASM.  However,
when a configuration simply lacks the assembler implementation for RC4
(which is where we have implemented the stitched call), OPENSSL_NO_ASM
isn't implemented.  Better, then, to rely on specific macros that
indicated that RC4 (and MD5) are implemented in assembler.

For this to work properly, we must also make sure Configure adds the
definition of RC4_ASM among the C flags.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 216e8d9103)
2016-08-26 17:34:30 +02:00
Matt Caswell
a35d8fb168 Remove note from CHANGES about EC DRBG
EC DRBG support was added in 7fdcb457 in 2011 and then later removed.
However the CHANGES entry for its original addition was left behind.
This just removes the spurious CHANGES entry.

Reviewed-by: Stephen Henson <steve@openssl.org>
(cherry picked from commit bbf73f84fc)
2016-08-26 09:08:21 +01:00
Matt Caswell
dcb36a995e Prepare for 1.1.0a-dev
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-25 16:30:15 +01:00
Matt Caswell
abd30777cc Prepare for 1.1.0 release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-25 16:29:18 +01:00
224 changed files with 5374 additions and 1269 deletions

3
.gitignore vendored
View File

@@ -16,6 +16,8 @@
# *all* Makefiles
Makefile
# ... except in demos
!/demos/*/Makefile
# Links under apps
/apps/CA.pl
@@ -72,6 +74,7 @@ Makefile
/include/openssl/opensslconf.h
/tools/c_rehash
/tools/c_rehash.pl
/util/shlib_wrap.sh
/tags
/TAGS
/crypto.map

View File

@@ -34,21 +34,24 @@ env:
matrix:
include:
- os: linux
compiler: clang-3.6
env: CONFIG_OPTS="--strict-warnings no-deprecated" BUILDONLY="yes"
- os: linux
compiler: gcc
env: CONFIG_OPTS="--debug --coverage no-asm enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers" COVERALLS="yes"
- os: linux
compiler: clang-3.6
env: CONFIG_OPTS="no-shared enable-asan"
env: CONFIG_OPTS="enable-asan"
- os: linux
compiler: clang-3.6
env: CONFIG_OPTS="no-shared enable-msan"
env: CONFIG_OPTS="enable-msan"
- os: linux
compiler: clang-3.6
env: CONFIG_OPTS="no-asm enable-ubsan enable-rc5 enable-md2 enable-ssl3 enable-ssl3-method -fno-sanitize=alignment"
- os: linux
compiler: clang-3.6
env: CONFIG_OPTS="no-shared no-asm enable-asan enable-rc5 enable-md2"
env: CONFIG_OPTS="no-asm enable-asan enable-rc5 enable-md2"
- os: linux
compiler: clang-3.6
env: CONFIG_OPTS="no-stdio"
@@ -134,5 +137,4 @@ after_success:
notifications:
email:
- openssl-commits@openssl.org
secure: "xeGNgWO7aoaDgRvcZubposqMsj36aU8c6F0oHfw+rUqltCQ14IgYCUwzocmR2O+Pa7B3Cx5VjMfBFHbQaajZsfod8vu7g+aGq/zkjwbhsr/SR4dljJjFJXLGZjIalm9KgP6KInmVDuINfCqP+MHIY5lZkNI7DMcyHDhVc5nSKvCXV7xTDNgmstvh8rB/z51WfHDqGqfBtiuK5FDNxmvYK8OFJ5W94Lu9LDlizcxwK3GAj7arOui7Z5w8bQ6p4seUE3IvJL1Zbj0pZHxvNb6Zeb2Pn8QF1qLlN8YmBktD4aiw0ce4wYRiL87uLgcOxZY7SVXtv2XYFIYWapU/FKjCqa6vK93V/H9eZWEIYNMKnN3wXm2beqVdnKek3OeGJ8v0y7MbSfuLfRtBqbTSNYnpU1Zuo4MQAvHvEPuwCAYkYQajOSRplMH5sULFKptuVqNtOMfjL8jHb8AEoL1acYIk43ydxeYrzzas4fqgCDJ52573/u0RNdF1lkQBLkuM365OB8VRqtpnoxcdEIY/qBc/8TzZ24fxyrs5qdHFcxGSgpN2EP6cJMqpvkemnCNSdhxUqfzm22N7a3O8+4LFSBGOnHto/PwdsvF/01yGYL0LoZTnoO1i6x7AMJPBh+eyDU0ZjGhj/msjmqeb9C8vRqQ+1WjHrIS1iqCD0Czib8tUPD4="

162
CHANGES
View File

@@ -2,7 +2,157 @@
OpenSSL CHANGES
_______________
Changes between 1.0.2h and 1.1.0 [xx XXX xxxx]
Changes between 1.1.0b and 1.1.0c [10 Nov 2016]
*) ChaCha20/Poly1305 heap-buffer-overflow
TLS connections using *-CHACHA20-POLY1305 ciphersuites are susceptible to
a DoS attack by corrupting larger payloads. This can result in an OpenSSL
crash. This issue is not considered to be exploitable beyond a DoS.
This issue was reported to OpenSSL by Robert Święcki (Google Security Team)
(CVE-2016-7054)
[Richard Levitte]
*) CMS Null dereference
Applications parsing invalid CMS structures can crash with a NULL pointer
dereference. This is caused by a bug in the handling of the ASN.1 CHOICE
type in OpenSSL 1.1.0 which can result in a NULL value being passed to the
structure callback if an attempt is made to free certain invalid encodings.
Only CHOICE structures using a callback which do not handle NULL value are
affected.
This issue was reported to OpenSSL by Tyler Nighswander of ForAllSecure.
(CVE-2016-7053)
[Stephen Henson]
*) Montgomery multiplication may produce incorrect results
There is a carry propagating bug in the Broadwell-specific Montgomery
multiplication procedure that handles input lengths divisible by, but
longer than 256 bits. Analysis suggests that attacks against RSA, DSA
and DH private keys are impossible. This is because the subroutine in
question is not used in operations with the private key itself and an input
of the attacker's direct choice. Otherwise the bug can manifest itself as
transient authentication and key negotiation failures or reproducible
erroneous outcome of public-key operations with specially crafted input.
Among EC algorithms only Brainpool P-512 curves are affected and one
presumably can attack ECDH key negotiation. Impact was not analyzed in
detail, because pre-requisites for attack are considered unlikely. Namely
multiple clients have to choose the curve in question and the server has to
share the private key among them, neither of which is default behaviour.
Even then only clients that chose the curve will be affected.
This issue was publicly reported as transient failures and was not
initially recognized as a security issue. Thanks to Richard Morgan for
providing reproducible case.
(CVE-2016-7055)
[Andy Polyakov]
*) OpenSSL now fails if it receives an unrecognised record type in TLS1.0
or TLS1.1. Previously this only happened in SSLv3 and TLS1.2. This is to
prevent issues where no progress is being made and the peer continually
sends unrecognised record types, using up resources processing them.
[Matt Caswell]
*) Removed automatic addition of RPATH in shared libraries and executables,
as this was a remainder from OpenSSL 1.0.x and isn't needed any more.
[Richard Levitte]
Changes between 1.1.0a and 1.1.0b [26 Sep 2016]
*) Fix Use After Free for large message sizes
The patch applied to address CVE-2016-6307 resulted in an issue where if a
message larger than approx 16k is received then the underlying buffer to
store the incoming message is reallocated and moved. Unfortunately a
dangling pointer to the old location is left which results in an attempt to
write to the previously freed location. This is likely to result in a
crash, however it could potentially lead to execution of arbitrary code.
This issue only affects OpenSSL 1.1.0a.
This issue was reported to OpenSSL by Robert Święcki.
(CVE-2016-6309)
[Matt Caswell]
Changes between 1.1.0 and 1.1.0a [22 Sep 2016]
*) OCSP Status Request extension unbounded memory growth
A malicious client can send an excessively large OCSP Status Request
extension. If that client continually requests renegotiation, sending a
large OCSP Status Request extension each time, then there will be unbounded
memory growth on the server. This will eventually lead to a Denial Of
Service attack through memory exhaustion. Servers with a default
configuration are vulnerable even if they do not support OCSP. Builds using
the "no-ocsp" build time option are not affected.
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
(CVE-2016-6304)
[Matt Caswell]
*) SSL_peek() hang on empty record
OpenSSL 1.1.0 SSL/TLS will hang during a call to SSL_peek() if the peer
sends an empty record. This could be exploited by a malicious peer in a
Denial Of Service attack.
This issue was reported to OpenSSL by Alex Gaynor.
(CVE-2016-6305)
[Matt Caswell]
*) Excessive allocation of memory in tls_get_message_header() and
dtls1_preprocess_fragment()
A (D)TLS message includes 3 bytes for its length in the header for the
message. This would allow for messages up to 16Mb in length. Messages of
this length are excessive and OpenSSL includes a check to ensure that a
peer is sending reasonably sized messages in order to avoid too much memory
being consumed to service a connection. A flaw in the logic of version
1.1.0 means that memory for the message is allocated too early, prior to
the excessive message length check. Due to way memory is allocated in
OpenSSL this could mean an attacker could force up to 21Mb to be allocated
to service a connection. This could lead to a Denial of Service through
memory exhaustion. However, the excessive message length check still takes
place, and this would cause the connection to immediately fail. Assuming
that the application calls SSL_free() on the failed conneciton in a timely
manner then the 21Mb of allocated memory will then be immediately freed
again. Therefore the excessive memory allocation will be transitory in
nature. This then means that there is only a security impact if:
1) The application does not call SSL_free() in a timely manner in the event
that the connection fails
or
2) The application is working in a constrained environment where there is
very little free memory
or
3) The attacker initiates multiple connection attempts such that there are
multiple connections in a state where memory has been allocated for the
connection; SSL_free() has not yet been called; and there is insufficient
memory to service the multiple requests.
Except in the instance of (1) above any Denial Of Service is likely to be
transitory because as soon as the connection fails the memory is
subsequently freed again in the SSL_free() call. However there is an
increased risk during this period of application crashes due to the lack of
memory - which would then mean a more serious Denial of Service.
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
(CVE-2016-6307 and CVE-2016-6308)
[Matt Caswell]
*) solaris-x86-cc, i.e. 32-bit configuration with vendor compiler,
had to be removed. Primary reason is that vendor assembler can't
assemble our modules with -KPIC flag. As result it, assembly
support, was not even available as option. But its lack means
lack of side-channel resistant code, which is incompatible with
security by todays standards. Fortunately gcc is readily available
prepackaged option, which we firmly point at...
[Andy Polyakov]
Changes between 1.0.2h and 1.1.0 [25 Aug 2016]
*) Windows command-line tool supports UTF-8 opt-in option for arguments
and console input. Setting OPENSSL_WIN32_UTF8 environment variable
@@ -299,6 +449,12 @@
template in Configurations, like unix-Makefile.tmpl or
descrip.mms.tmpl.
With this change, the library names were also renamed on Windows
and on VMS. They now have names that are closer to the standard
on Unix, and include the major version number, and in certain
cases, the architecture they are built for. See "Notes on shared
libraries" in INSTALL.
We rely heavily on the perl module Text::Template.
[Richard Levitte]
@@ -874,10 +1030,6 @@
combination: call this in fips_test_suite.
[Steve Henson]
*) Add support for Dual EC DRBG from SP800-90. Update DRBG algorithm test
and POST to handle Dual EC cases.
[Steve Henson]
*) Add support for canonical generation of DSA parameter 'g'. See
FIPS 186-3 A.2.3.

View File

@@ -1,4 +1,4 @@
HOW TO CONTRIBUTE TO PATCHES OpenSSL
HOW TO CONTRIBUTE PATCHES TO OpenSSL
------------------------------------
(Please visit https://www.openssl.org/community/getting-started.html for
@@ -11,34 +11,12 @@ OpenSSL community you might want to discuss it on the openssl-dev mailing
list first. Someone may be already working on the same thing or there
may be a good reason as to why that feature isn't implemented.
The best way to submit a patch is to make a pull request on GitHub.
(It is not necessary to send mail to rt@openssl.org to open a ticket!)
If you think the patch could use feedback from the community, please
start a thread on openssl-dev.
To submit a patch, make a pull request on GitHub. If you think the patch
could use feedback from the community, please start a thread on openssl-dev
to discuss it.
You can also submit patches by sending it as mail to rt@openssl.org.
Please include the word "PATCH" and an explanation of what the patch
does in the subject line. If you do this, our preferred format is "git
format-patch" output. For example to provide a patch file containing the
last commit in your local git repository use the following command:
% git format-patch --stdout HEAD^ >mydiffs.patch
Another method of creating an acceptable patch file without using git is as
follows:
% cd openssl-work
...make your changes...
% ./Configure dist; make clean
% cd ..
% diff -ur openssl-orig openssl-work >mydiffs.patch
Note that pull requests are generally easier for the team, and community, to
work with. Pull requests benefit from all of the standard GitHub features,
including code review tools, simpler integration, and CI build support.
No matter how a patch is submitted, the following items will help make
the acceptance and review process faster:
Having addressed the following items before the PR will help make the
acceptance and review process faster:
1. Anything other than trivial contributions will require a contributor
licensing agreement, giving us permission to use your code. See
@@ -55,21 +33,22 @@ the acceptance and review process faster:
in the file LICENSE in the source distribution or at
https://www.openssl.org/source/license.html
3. Patches should be as current as possible. When using GitHub, please
expect to have to rebase and update often. Note that we do not accept merge
commits. You will be asked to remove them before a patch is considered
acceptable.
3. Patches should be as current as possible; expect to have to rebase
often. We do not accept merge commits; You will be asked to remove
them before a patch is considered acceptable.
4. Patches should follow our coding style (see
https://www.openssl.org/policies/codingstyle.html) and compile without
warnings. Where gcc or clang is available you should use the
--strict-warnings Configure option. OpenSSL compiles on many varied
platforms: try to ensure you only use portable features.
Clean builds via Travis and AppVeyor are expected, and done whenever
a PR is created or updated.
5. When at all possible, patches should include tests. These can either be
added to an existing test, or completely new. Please see test/README
for information on the test framework.
5. When at all possible, patches should include tests. These can
either be added to an existing test, or completely new. Please see
test/README for information on the test framework.
6. New features or changed functionality must include documentation. Please
look at the "pod" files in doc/apps, doc/crypto and doc/ssl for examples of
our style.
6. New features or changed functionality must include
documentation. Please look at the "pod" files in doc/apps, doc/crypto
and doc/ssl for examples of our style.

View File

@@ -80,10 +80,11 @@
sub {
unless ($disabled{zlib}) {
if (defined($disabled{"zlib-dynamic"})) {
return $withargs{zlib_lib};
return $withargs{zlib_lib} // "ZLIB1";
}
}
return (); },
return ();
},
ld => "link",
lflags => "/nologo",

View File

@@ -14,7 +14,10 @@ sub vc_win64a_info {
asflags => "/c /Cp /Cx /Zi",
asoutflag => "/Fo" };
} else {
die "NASM not found - please read INSTALL and NOTES.WIN for further details\n";
$die->("NASM not found - please read INSTALL and NOTES.WIN for further details\n");
$vc_win64a_info = { as => "{unknown}",
asflags => "",
asoutflag => "" };
}
}
return $vc_win64a_info;
@@ -36,7 +39,11 @@ sub vc_win32_info {
asoutflag => "/Fo",
perlasm_scheme => "win32" };
} else {
die "NASM not found - please read INSTALL and NOTES.WIN for further details\n";
$die->("NASM not found - please read INSTALL and NOTES.WIN for further details\n");
$vc_win32_info = { as => "{unknown}",
asflags => "",
asoutflag => "",
perlasm_scheme => "win32" };
}
}
return $vc_win32_info;
@@ -46,18 +53,26 @@ my $vc_wince_info = {};
sub vc_wince_info {
unless (%$vc_wince_info) {
# sanity check
die '%OSVERSION% is not defined' if (!defined($ENV{'OSVERSION'}));
die '%PLATFORM% is not defined' if (!defined($ENV{'PLATFORM'}));
die '%TARGETCPU% is not defined' if (!defined($ENV{'TARGETCPU'}));
$die->('%OSVERSION% is not defined') if (!defined($ENV{'OSVERSION'}));
$die->('%PLATFORM% is not defined') if (!defined($ENV{'PLATFORM'}));
$die->('%TARGETCPU% is not defined') if (!defined($ENV{'TARGETCPU'}));
#
# Idea behind this is to mimic flags set by eVC++ IDE...
#
my $wcevers = $ENV{'OSVERSION'}; # WCENNN
die '%OSVERSION% value is insane'
if ($wcevers !~ /^WCE([1-9])([0-9]{2})$/);
my $wcecdefs = "-D_WIN32_WCE=$1$2 -DUNDER_CE=$1$2"; # -D_WIN32_WCE=NNN
my $wcelflag = "/subsystem:windowsce,$1.$2"; # ...,N.NN
my $wcevernum;
my $wceverdotnum;
if ($wcevers =~ /^WCE([1-9])([0-9]{2})$/) {
$wcevernum = "$1$2";
$wceverdotnum = "$1.$2";
} else {
$die->('%OSVERSION% value is insane');
$wcevernum = "{unknown}";
$wceverdotnum = "{unknown}";
}
my $wcecdefs = "-D_WIN32_WCE=$wcevernum -DUNDER_CE=$wcevernum"; # -D_WIN32_WCE=NNN
my $wcelflag = "/subsystem:windowsce,$wceverdotnum"; # ...,N.NN
my $wceplatf = $ENV{'PLATFORM'};
@@ -185,7 +200,7 @@ sub vms_info {
threads("-pthread")),
bn_ops => "BN_LLONG",
shared_cflag => "-fPIC",
shared_ldflag => "-shared",
shared_ldflag => "-shared -static-libgcc",
},
"solaris64-x86_64-gcc" => {
# -shared -static-libgcc might appear controversial, but modules
@@ -210,19 +225,18 @@ sub vms_info {
},
#### Solaris x86 with Sun C setups
"solaris-x86-cc" => {
inherit_from => [ "solaris-common" ],
cc => "cc",
cflags => add_before(picker(default => "-xarch=generic -xstrconst -Xa -DL_ENDIAN",
debug => "-g",
release => "-xO5 -xregs=frameptr -xdepend -xbuiltin"),
threads("-D_REENTRANT")),
lflags => add(threads("-mt")),
ex_libs => add(threads("-lpthread")),
bn_ops => "BN_LLONG RC4_CHAR",
shared_cflag => "-KPIC",
shared_ldflag => "-G -dy -z text",
},
# There used to be solaris-x86-cc target, but it was removed,
# primarily because vendor assembler can't assemble our modules
# with -KPIC flag. As result it, assembly support, was not even
# available as option. But its lack means lack of side-channel
# resistant code, which is incompatible with security by todays
# standards. Fortunately gcc is readily available prepackaged
# option, which we can firmly point at...
#
# On related note, solaris64-x86_64-cc target won't compile code
# paths utilizing AVX and post-Haswell instruction extensions.
# Consider switching to solaris64-x86_64-gcc even here...
#
"solaris64-x86_64-cc" => {
inherit_from => [ "solaris-common", asm("x86_64_asm") ],
cc => "cc",
@@ -294,11 +308,11 @@ sub vms_info {
},
"solaris-sparcv9-cc" => {
inherit_from => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
cflags => add_before("-xarch=v8plus -xtarget=ultra"),
cflags => add_before("-xarch=v8plus"),
},
"solaris64-sparcv9-cc" => {
inherit_from => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
cflags => add_before("-xarch=v9 -xtarget=ultra"),
cflags => add_before("-xarch=v9"),
lflags => add_before("-xarch=v9"),
bn_ops => "BN_LLONG RC4_CHAR",
shared_ldflag => "-xarch=v9 -G -dy -z text",
@@ -617,7 +631,8 @@ sub vms_info {
thread_scheme => "pthreads",
dso_scheme => "dlfcn",
shared_target => "linux-shared",
shared_cflag => "-fPIC",
shared_cflag => "-fPIC -DOPENSSL_USE_NODELETE",
shared_ldflag => "-Wl,-znodelete",
shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
},
"linux-generic64" => {
@@ -633,14 +648,14 @@ sub vms_info {
inherit_from => [ "linux-generic64", asm("ppc64_asm") ],
cflags => add("-m64 -DB_ENDIAN"),
perlasm_scheme => "linux64",
shared_ldflag => "-m64",
shared_ldflag => add("-m64"),
multilib => "64",
},
"linux-ppc64le" => {
inherit_from => [ "linux-generic64", asm("ppc64_asm") ],
cflags => add("-m64 -DL_ENDIAN"),
perlasm_scheme => "linux64le",
shared_ldflag => "-m64",
shared_ldflag => add("-m64"),
},
"linux-armv4" => {
@@ -696,7 +711,7 @@ sub vms_info {
inherit_from => [ "linux-generic32", asm("mips32_asm") ],
cflags => add("-mabi=32 -DBN_DIV3W"),
perlasm_scheme => "o32",
shared_ldflag => "-mabi=32",
shared_ldflag => add("-mabi=32"),
},
# mips32 and mips64 below refer to contemporary MIPS Architecture
# specifications, MIPS32 and MIPS64, rather than to kernel bitness.
@@ -705,14 +720,14 @@ sub vms_info {
cflags => add("-mabi=n32 -DBN_DIV3W"),
bn_ops => "SIXTY_FOUR_BIT RC4_CHAR",
perlasm_scheme => "n32",
shared_ldflag => "-mabi=n32",
shared_ldflag => add("-mabi=n32"),
multilib => "32",
},
"linux64-mips64" => {
inherit_from => [ "linux-generic64", asm("mips64_asm") ],
cflags => add("-mabi=64 -DBN_DIV3W"),
perlasm_scheme => "64",
shared_ldflag => "-mabi=64",
shared_ldflag => add("-mabi=64"),
multilib => "64",
},
@@ -721,7 +736,6 @@ sub vms_info {
inherit_from => [ "linux-generic32", asm("x86_elf_asm") ],
cflags => add(picker(default => "-DL_ENDIAN",
release => "-fomit-frame-pointer")),
ex_libs => add(picker(debug => "-lefence")),
bn_ops => "BN_LLONG",
},
"linux-aout" => {
@@ -740,7 +754,7 @@ sub vms_info {
cflags => add("-m64 -DL_ENDIAN"),
bn_ops => "SIXTY_FOUR_BIT_LONG",
perlasm_scheme => "elf",
shared_ldflag => "-m64",
shared_ldflag => add("-m64"),
multilib => "64",
},
"linux-x86_64-clang" => {
@@ -766,7 +780,7 @@ sub vms_info {
inherit_from => [ "linux-generic64", asm("s390x_asm") ],
cflags => add("-m64 -DB_ENDIAN"),
perlasm_scheme => "64",
shared_ldflag => "-m64",
shared_ldflag => add("-m64"),
multilib => "64",
},
"linux32-s390x" => {
@@ -790,7 +804,7 @@ sub vms_info {
cflags => add("-m31 -Wa,-mzarch -DB_ENDIAN"),
bn_asm_src => sub { my $r=join(" ",@_); $r=~s|asm/s390x\.S|bn_asm.c|; $r; },
perlasm_scheme => "31",
shared_ldflag => "-m31",
shared_ldflag => add("-m31"),
multilib => "/highgprs",
},
@@ -806,14 +820,14 @@ sub vms_info {
# but -Wa,-Av8plus should do the trick no matter what.
inherit_from => [ "linux-generic32", asm("sparcv9_asm") ],
cflags => add("-m32 -mcpu=ultrasparc -Wa,-Av8plus -DB_ENDIAN -DBN_DIV2W"),
shared_ldflag => "-m32",
shared_ldflag => add("-m32"),
},
"linux64-sparcv9" => {
# GCC 3.1 is a requirement
inherit_from => [ "linux-generic64", asm("sparcv9_asm") ],
cflags => add("-m64 -mcpu=ultrasparc -DB_ENDIAN"),
bn_ops => "BN_LLONG RC4_CHAR",
shared_ldflag => "-m64",
shared_ldflag => add("-m64"),
multilib => "64",
},
@@ -842,7 +856,7 @@ sub vms_info {
dso_scheme => "dlfcn",
shared_target => "linux-shared",
shared_cflag => "--pic",
shared_ldflag => "-z --sysv --shared",
shared_ldflag => add("-z --sysv --shared"),
shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
ranlib => "true",
},
@@ -851,7 +865,7 @@ sub vms_info {
#
# It takes pair of prior-set environment variables to make it work:
#
# CROSS_SYSROOT=/some/where/android-ndk-<ver>/platforms/android-<apiver>/arch-<
# CROSS_SYSROOT=/some/where/android-ndk-<ver>/platforms/android-<apiver>/arch-<arch>
# CROSS_COMPILE=<prefix>
#
# As well as PATH adjusted to cover ${CROSS_COMPILE}gcc and company.
@@ -860,7 +874,7 @@ sub vms_info {
# ANDROID_NDK=/some/where/android-ndk-10d
# CROSS_SYSROOT=$ANDROID_NDK/platforms/android-14/arch-arm
# CROSS_COMPILE=arm-linux-adroideabi-
# PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/
# PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/bin
#
"android" => {
inherit_from => [ "linux-generic32" ],
@@ -1128,6 +1142,11 @@ sub vms_info {
},
#### IBM's AIX.
# Below targets assume AIX >=5. Caveat lector. If you are accustomed
# to control compilation "bitness" by setting $OBJECT_MODE environment
# variable, then you should know that in OpenSSL case it's considered
# only in ./config. Once configured, build procedure remains "deaf" to
# current value of $OBJECT_MODE.
"aix-gcc" => {
inherit_from => [ "BASE_unix", asm("ppc32_asm") ],
cc => "gcc",
@@ -1141,7 +1160,7 @@ sub vms_info {
perlasm_scheme => "aix32",
dso_scheme => "dlfcn",
shared_target => "aix-shared",
shared_ldflag => "-shared -Wl,-G",
shared_ldflag => "-shared -static-libgcc -Wl,-G",
shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
arflags => "-X32",
},
@@ -1158,13 +1177,10 @@ sub vms_info {
perlasm_scheme => "aix64",
dso_scheme => "dlfcn",
shared_target => "aix-shared",
shared_ldflag => "-maix64 -shared -Wl,-G",
shared_ldflag => "-maix64 -shared -static-libgcc -Wl,-G",
shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
arflags => "-X64",
},
# Below targets assume AIX 5. Idea is to effectively disregard
# $OBJECT_MODE at build time. $OBJECT_MODE is respected at
# ./config stage!
"aix-cc" => {
inherit_from => [ "BASE_unix", asm("ppc32_asm") ],
cc => "cc",
@@ -1175,6 +1191,7 @@ sub vms_info {
sys_id => "AIX",
bn_ops => "BN_LLONG RC4_CHAR",
thread_scheme => "pthreads",
ex_libs => threads("-lpthreads"),
perlasm_scheme => "aix32",
dso_scheme => "dlfcn",
shared_target => "aix-shared",
@@ -1192,6 +1209,7 @@ sub vms_info {
sys_id => "AIX",
bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
thread_scheme => "pthreads",
ex_libs => threads("-lpthreads"),
perlasm_scheme => "aix64",
dso_scheme => "dlfcn",
shared_target => "aix-shared",
@@ -1240,9 +1258,11 @@ sub vms_info {
cflags => "-W3 -wd4090 -Gs0 -GF -Gy -nologo -DOPENSSL_SYS_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE",
defines => add(sub { my @defs = ();
unless ($disabled{"zlib-dynamic"}) {
my $zlib =
$withargs{zlib_lib} // "ZLIB1";
push @defs,
quotify("perl",
'LIBZ="' . $withargs{zlib_lib} . '"');
'LIBZ="' . $zlib . '"');
}
return [ @defs ];
}),
@@ -1259,6 +1279,7 @@ sub vms_info {
},
"VC-noCE-common" => {
inherit_from => [ "VC-common" ],
template => 1,
cflags => add(picker(default => "-DUNICODE -D_UNICODE",
debug =>
sub {
@@ -1295,6 +1316,7 @@ sub vms_info {
},
"VC-WIN64-common" => {
inherit_from => [ "VC-noCE-common" ],
template => 1,
ex_libs => add(sub {
my @ex_libs = ();
push @ex_libs, 'bufferoverflowu.lib' if (`cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
@@ -1725,9 +1747,10 @@ sub vms_info {
inherit_from => [ "BASE_VMS" ],
template => 1,
cc => "CC/DECC",
cflags => picker(default => "/STANDARD=RELAXED/NOLIST/PREFIX=ALL",
cflags => picker(default => "/STANDARD=(ISOC94,RELAXED)/NOLIST/PREFIX=ALL",
debug => "/NOOPTIMIZE/DEBUG",
release => "/OPTIMIZE/NODEBUG"),
defines => add("OPENSSL_USE_NODELETE"),
lflags => picker(default => "/MAP",
debug => "/DEBUG/TRACEBACK",
release => "/NODEBUG/NOTRACEBACK"),
@@ -1737,7 +1760,7 @@ sub vms_info {
dso_scheme => "vms",
thread_scheme => "pthreads",
apps_aux_src => "vms_decc_init.c",
apps_aux_src => "vms_decc_init.c vms_term_sock.c",
},
"vms-alpha" => {

View File

@@ -12,7 +12,6 @@
cc => "gcc",
cflags => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DOPENSSL_NO_ASM -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror",
thread_scheme => "(unknown)",
ex_libs => add(" ","-lefence"),
},
"debug-erbridge" => {
inherit_from => [ "x86_64_asm" ],
@@ -50,19 +49,6 @@
thread_scheme => "pthreads",
dso_scheme => "dlfcn",
},
"debug-linux-elf-noefence" => {
inherit_from => [ "x86_elf_asm" ],
cc => "gcc",
cflags => combine("-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -Wall",
threads("-D_REENTRANT")),
ex_libs => add(" ","-ldl"),
bn_ops => "BN_LLONG",
thread_scheme => "pthreads",
dso_scheme => "dlfcn",
shared_target => "linux-shared",
shared_cflag => "-fPIC",
shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
},
"debug-linux-ia32-aes" => {
cc => "gcc",
cflags => combine("-DL_ENDIAN -O3 -fomit-frame-pointer -Wall",

View File

@@ -151,7 +151,7 @@ INSTALLTOP={- our $installtop =
$installtop -}
SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
# This is the standard central area to store certificates, private keys...
OPENSSLDIR={- catdir($config{openssldir}) ||
OPENSSLDIR={- catdir($config{openssldir}) or
$config{prefix} ? catdir($config{prefix},"COMMON")
: "SYS\$COMMON:[OPENSSL-COMMON]" -}
# The same, but for C
@@ -223,7 +223,7 @@ NODEBUG=@
$(NODEBUG) !
$(NODEBUG) ! Figure out the architecture
$(NODEBUG) !
$(NODEBUG) arch == f$edit( f$getsyi( "arch_name"), "upcase")
$(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
$(NODEBUG) !
$(NODEBUG) ! Set up logical names for the libraries, so LINK and
$(NODEBUG) ! running programs can use them.
@@ -264,8 +264,10 @@ test tests : build_generated, build_programs_nodep, build_engines_nodep, -
DEFINE SRCTOP {- sourcedir() -}
DEFINE BLDTOP {- builddir() -}
DEFINE OPENSSL_ENGINES {- builddir("engines") -}
DEFINE OPENSSL_DEBUG_MEMORY "on"
IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
$(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
DEASSIGN OPENSSL_DEBUG_MEMORY
DEASSIGN OPENSSL_ENGINES
DEASSIGN BLDTOP
DEASSIGN SRCTOP
@@ -508,7 +510,7 @@ debug_logicals :
# Building targets ###################################################
configdata.pm : {- join(" ", sourcefile("Configurations", "descrip.mms.tmpl"), sourcefile("Configurations", "common.tmpl")) -} $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_infos}}) -}
configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
@ WRITE SYS$OUTPUT "Reconfiguring..."
perl $(SRCDIR)Configure reconf
@ WRITE SYS$OUTPUT "*************************************************"
@@ -677,10 +679,11 @@ EOF
# previous line's file spec as default, so if no directory spec
# is present in the current line and the previous line has one that
# doesn't apply, you're in for a surprise.
my $write_opt =
my $write_opt1 =
join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
"WRITE OPT_FILE \"$x" } @objs).
"\"\n\t".
"\"";
my $write_opt2 =
join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
$x =~ s|(\.EXE)|$1/SHARE|;
$x =~ s|(\.OLB)|$1/LIB|;
@@ -690,7 +693,8 @@ EOF
$lib.EXE : $deps
OPEN/WRITE/SHARE=READ OPT_FILE $lib.OPT
TYPE $engine_opt /OUTPUT=OPT_FILE:
$write_opt
$write_opt1
$write_opt2
CLOSE OPT_FILE
LINK /MAP=$lib.MAP /FULL/SHARE=$lib.EXE $lib.OPT/OPT \$(EX_LIBS)
- PURGE $lib.EXE,$lib.OPT,$lib.MAP
@@ -723,10 +727,11 @@ EOF
# previous line's file spec as default, so if no directory spec
# is present in the current line and the previous line has one that
# doesn't apply, you're in for a surprise.
my $write_opt =
my $write_opt1 =
join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
"WRITE OPT_FILE \"$x" } @objs).
"\"\n\t".
"\"";
my $write_opt2 =
join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
$x =~ s|(\.EXE)|$1/SHARE|;
$x =~ s|(\.OLB)|$1/LIB|;
@@ -735,7 +740,8 @@ EOF
return <<"EOF";
$bin.EXE : $deps
OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
$write_opt
$write_opt1
$write_opt2
CLOSE OPT_FILE
LINK/EXEC=$bin.EXE \$(LDFLAGS) $bin.OPT/OPT \$(EX_LIBS)
- PURGE $bin.EXE,$bin.OPT

View File

@@ -153,6 +153,10 @@ LIBDIR={- #
ENGINESDIR={- use File::Spec::Functions;
catdir($prefix,$libdir,"engines-$sover") -}
# Convenience variable for those who want to set the rpath in shared
# libraries and applications
LIBRPATH=$(INSTALLTOP)/$(LIBDIR)
MANDIR=$(INSTALLTOP)/share/man
DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
HTMLDIR=$(DOCDIR)/html
@@ -173,20 +177,7 @@ LDFLAGS= {- $target{lflags} -}
PLIB_LDFLAGS= {- $target{plib_lflags} -}
EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
LIB_CFLAGS={- $target{shared_cflag} || "" -}
LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag}
# Unlike other OSes (like Solaris, Linux, Tru64,
# IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
# and FreeBSD) "demand" RPATH set on .so objects.
# Apparently application RPATH is not global and
# does not apply to .so linked with other .so.
# Problem manifests itself when libssl.so fails to
# load libcrypto.so. One can argue that we should
# engrave this into Makefile.shared rules or into
# BSD-* config lines above. Meanwhile let's try to
# be cautious and pass -rpath to linker only when
# $prefix is not /usr.
. ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag} -}
DSO_CFLAGS={- $target{shared_cflag} || "" -}
DSO_LDFLAGS=$(LIB_LDFLAGS)
BIN_CFLAGS={- $target{bin_cflags} -}
@@ -255,6 +246,7 @@ test: tests
PERL="$(PERL)" \
EXE_EXT={- $exeext -} \
OPENSSL_ENGINES=../$(BLDDIR)/engines \
OPENSSL_DEBUG_MEMORY=on \
$(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
@ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
@echo "Tests are not supported with your chosen Configure options"
@@ -301,14 +293,12 @@ distclean: clean
$(RM) configdata.pm
$(RM) Makefile
# This exists solely for those who still type 'make depend'
#
# We check if any depfile is newer than Makefile and decide to
# concatenate only if that is true.
depend:
@: {- output_off() if $disabled{makedepend}; "" -}
@if [ -n "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then \
( sed -e '/^# DO NOT DELETE THIS LINE.*/,$$d' < Makefile; \
@if egrep "^# DO NOT DELETE THIS LINE" Makefile >/dev/null && [ -z "`find $(DEPS) -newer Makefile 2>/dev/null; exit 0`" ]; then :; else \
( $(PERL) -pe 'exit 0 if /^# DO NOT DELETE THIS LINE.*/' < Makefile; \
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.'; \
echo; \
for f in $(DEPS); do \
@@ -771,22 +761,18 @@ tar:
cd $(SRCDIR); ls -l $(TARFILE).gz
dist:
@$(MAKE) PREPARE_CMD='./Configure dist' tar
@$(MAKE) PREPARE_CMD='$(PERL) ./Configure dist' tar
# Helper targets #####################################################
link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
link-utils: $(BLDDIR)/util/opensslwrap.sh
$(BLDDIR)/util/opensslwrap.sh: configdata.pm
@if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
mkdir -p "$(BLDDIR)/util"; \
ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
fi
$(BLDDIR)/util/shlib_wrap.sh: configdata.pm
@if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
mkdir -p "$(BLDDIR)/util"; \
ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
fi
FORCE:
# Building targets ###################################################
@@ -797,6 +783,7 @@ libcrypto.pc:
echo 'exec_prefix=$${prefix}'; \
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
echo 'includedir=$${prefix}/include'; \
echo 'enginesdir=$${libdir}/engines-{- $sover -}'; \
echo ''; \
echo 'Name: OpenSSL-libcrypto'; \
echo 'Description: OpenSSL cryptography library'; \
@@ -830,10 +817,10 @@ openssl.pc:
echo 'Version: '$(VERSION); \
echo 'Requires: libssl libcrypto' ) > openssl.pc
configdata.pm: {- $config{build_file_template} -} $(SRCDIR)/Configurations/common.tmpl $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_infos}}) -}
configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
@echo "Detected changed: $?"
@echo "Reconfiguring..."
$(SRCDIR)/Configure reconf
$(PERL) $(SRCDIR)/Configure reconf
@echo "**************************************************"
@echo "*** ***"
@echo "*** Please run the same make command again ***"
@@ -944,30 +931,11 @@ EOF
dso => '$(DSO_CFLAGS)',
bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
my $makedepprog = $config{makedepprog};
my $recipe = "";
if (!$disabled{makedepend} && $makedepprog =~ /\/makedepend/) {
$recipe .= <<"EOF";
$obj$depext: $deps
-\$(MAKEDEPEND) -f- -o"|$obj$objext" -- $incs \$(CFLAGS) $ecflags -- $srcs \\
>\$\@.tmp 2>/dev/null
-\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' \$\@.tmp
\@if cmp \$\@.tmp \$\@ > /dev/null 2> /dev/null; then \\
rm -f \$\@.tmp; \\
else \\
mv \$\@.tmp \$\@; \\
fi
EOF
$deps = $obj.$depext;
}
if ($disabled{makedepend} || $makedepprog =~ /\/makedepend/) {
$recipe .= <<"EOF";
my $recipe = <<"EOF";
$obj$objext: $deps
\$(CC) $incs \$(CFLAGS) $ecflags -c -o \$\@ $srcs
EOF
}
if (!$disabled{makedepend} && $makedepprog !~ /\/makedepend/) {
$recipe .= <<"EOF";
$obj$objext: $deps
\$(CC) $incs \$(CFLAGS) $ecflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
\@touch $obj$depext.tmp
\@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
@@ -976,6 +944,22 @@ $obj$objext: $deps
mv $obj$depext.tmp $obj$depext; \\
fi
EOF
} else {
$recipe .= <<"EOF";
\$(CC) $incs \$(CFLAGS) $ecflags -c -o \$\@ $srcs
EOF
if (!$disabled{makedepend} && $makedepprog =~ /\/makedepend/) {
$recipe .= <<"EOF";
-\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs \$(CFLAGS) $ecflags -- $srcs \\
>$obj$depext.tmp 2>/dev/null
-\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
\@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
rm -f $obj$depext.tmp; \\
else \\
mv $obj$depext.tmp $obj$depext; \\
fi
EOF
}
}
return $recipe;
}
@@ -1085,7 +1069,7 @@ $bin$exeext: $objs $deps
APPNAME=$bin$exeext OBJECTS="$objs" \\
LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(BIN_CFLAGS)' \\
LDFLAGS='\$(LDFLAGS)' LIBRPATH='\$(INSTALLTOP)/\$(LIBDIR)' \\
LDFLAGS='\$(LDFLAGS)' \\
link_app.$shlib_target
EOF
}

View File

@@ -198,6 +198,7 @@ tests: build_generated build_programs_nodep build_engines_nodep depend
set SRCTOP=$(SRCDIR)
set BLDTOP=$(BLDDIR)
set PERL=$(PERL)
set OPENSSL_DEBUG_MEMORY=on
"$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
@rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
@echo "Tests are not supported with your chosen Configure options"
@@ -322,7 +323,7 @@ uninstall_html_docs:
# Building targets ###################################################
configdata.pm: "{- $config{build_file_template} -}" "$(SRCDIR)\Configurations\common.tmpl" "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_infos}}) -}
configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
@echo "Detected changed: $?"
@echo "Reconfiguring..."
"$(PERL)" "$(SRCDIR)\Configure" reconf

317
Configure
View File

@@ -66,6 +66,22 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [-Dxxx] [-lx
# no-sse2 disables IA-32 SSE2 code, above option implies no-sse2
# no-<cipher> build without specified algorithm (rsa, idea, rc5, ...)
# -<xxx> +<xxx> compiler options are passed through
# -static while -static is also a pass-through compiler option (and
# as such is limited to environments where it's actually
# meaningful), it triggers a number configuration options,
# namely no-dso, no-pic, no-shared and no-threads. It is
# argued that the only reason to produce statically linked
# binaries (and in context it means executables linked with
# -static flag, and not just executables linked with static
# libcrypto.a) is to eliminate dependency on specific run-time,
# a.k.a. libc version. The mentioned config options are meant
# to achieve just that. Unfortunately on Linux it's impossible
# to eliminate the dependency completely for openssl executable
# because of getaddrinfo and gethostbyname calls, which can
# invoke dynamically loadable library facility anyway to meet
# the lookup requests. For this reason on Linux statically
# linked openssl executable has rather debugging value than
# production quality.
#
# DEBUG_SAFESTACK use type-safe stacks to enforce type-safety on stack items
# provided to stack calls. Generates unique stack functions for
@@ -184,6 +200,45 @@ my $local_config_envname = 'OPENSSL_LOCAL_CONFIG_DIR';
$config{sourcedir} = abs2rel($srcdir);
$config{builddir} = abs2rel($blddir);
# Collect reconfiguration information if needed
my @argvcopy=@ARGV;
if (grep /^reconf(igure)?$/, @argvcopy) {
if (-f "./configdata.pm") {
my $file = "./configdata.pm";
unless (my $return = do $file) {
die "couldn't parse $file: $@" if $@;
die "couldn't do $file: $!" unless defined $return;
die "couldn't run $file" unless $return;
}
@argvcopy = defined($configdata::config{perlargv}) ?
@{$configdata::config{perlargv}} : ();
die "Incorrect data to reconfigure, please do a normal configuration\n"
if (grep(/^reconf/,@argvcopy));
$ENV{CROSS_COMPILE} = $configdata::config{cross_compile_prefix}
if defined($configdata::config{cross_compile_prefix});
$ENV{CC} = $configdata::config{cc}
if defined($configdata::config{cc});
$ENV{BUILDFILE} = $configdata::config{build_file}
if defined($configdata::config{build_file});
$ENV{$local_config_envname} = $configdata::config{local_config_dir}
if defined($configdata::config{local_config_dir});
print "Reconfiguring with: ", join(" ",@argvcopy), "\n";
print " CROSS_COMPILE = ",$ENV{CROSS_COMPILE},"\n"
if $ENV{CROSS_COMPILE};
print " CC = ",$ENV{CC},"\n" if $ENV{CC};
print " BUILDFILE = ",$ENV{BUILDFILE},"\n" if $ENV{BUILDFILE};
print " $local_config_envname = ",$ENV{$local_config_envname},"\n"
if $ENV{$local_config_envname};
} else {
die "Insufficient data to reconfigure, please do a normal configuration\n";
}
}
$config{perlargv} = [ @argvcopy ];
# Collect version numbers
$config{version} = "unknown";
$config{version_num} = "unknown";
@@ -230,7 +285,7 @@ if (defined $ENV{$local_config_envname}) {
}
print "Configuring OpenSSL version $config{version} (0x$config{version_num})\n";
print "Configuring OpenSSL version $config{version} ($config{version_num})\n";
$config{prefix}="";
$config{openssldir}="";
@@ -245,7 +300,7 @@ my $default_ranlib;
$config{fips}=0;
# Top level directories to build
$config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "tools", "fuzz" ];
$config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "util", "tools", "fuzz" ];
# crypto/ subdirectories to build
$config{sdirs} = [
"objects",
@@ -483,62 +538,11 @@ my $target="";
$config{options}="";
$config{build_type} = "release";
my @argvcopy=@ARGV;
if (grep /^reconf(igure)?$/, @argvcopy) {
if (-f "./configdata.pm") {
my $file = "./configdata.pm";
unless (my $return = do $file) {
die "couldn't parse $file: $@" if $@;
die "couldn't do $file: $!" unless defined $return;
die "couldn't run $file" unless $return;
}
@argvcopy = defined($configdata::config{perlargv}) ?
@{$configdata::config{perlargv}} : ();
die "Incorrect data to reconfigure, please do a normal configuration\n"
if (grep(/^reconf/,@argvcopy));
$ENV{CROSS_COMPILE} = $configdata::config{cross_compile_prefix}
if defined($configdata::config{cross_compile_prefix});
$ENV{CC} = $configdata::config{cc}
if defined($configdata::config{cc});
print "Reconfiguring with: ", join(" ",@argvcopy), "\n";
print " CROSS_COMPILE = ",$ENV{CROSS_COMPILE},"\n"
if $ENV{CROSS_COMPILE};
print " CC = ",$ENV{CC},"\n" if $ENV{CC};
} elsif (open IN, "<Makefile") {
#
# THIS SECTION IS TEMPORARY, it helps transitioning from Makefile
# centered information gathering the reading configdata.pm
#
while (<IN>) {
s|\R$||;
if (/^CONFIGURE_ARGS=\s*(.*)\s*/) {
# Older form, we split the string and hope for the best
@argvcopy = split /\s+/, $_;
die "Incorrect data to reconfigure, please do a normal configuration\n"
if (grep(/^reconf/,@argvcopy));
} elsif (/^CROSS_COMPILE=\s*(.*)/) {
$ENV{CROSS_COMPILE}=$1;
} elsif (/^CC=\s*(?:\$\(CROSS_COMPILE\))?(.*?)$/) {
$ENV{CC}=$1;
}
}
#
# END OF TEMPORARY SECTION
#
} else {
die "Insufficient data to reconfigure, please do a normal configuration\n";
}
}
$config{perlargv} = [ @argvcopy ];
my %unsupported_options = ();
my %deprecated_options = ();
foreach (@argvcopy)
while (@argvcopy)
{
$_ = shift @argvcopy;
# VMS is a case insensitive environment, and depending on settings
# out of our control, we may receive options uppercased. Let's
# downcase at least the part before any equal sign.
@@ -725,9 +729,18 @@ foreach (@argvcopy)
{
$libs.=$_." ";
}
elsif (/^-rpath$/ or /^-R$/)
# -rpath is the OSF1 rpath flag
# -R is the old Solaris rpath flag
{
my $rpath = shift(@argvcopy) || "";
$rpath .= " " if $rpath ne "";
$libs.=$_." ".$rpath;
}
elsif (/^-static$/)
{
$libs.=$_." ";
$disabled{"dso"} = "forced";
$disabled{"pic"} = "forced";
$disabled{"shared"} = "forced";
$disabled{"threads"} = "forced";
@@ -776,6 +789,13 @@ foreach (@argvcopy)
}
}
if ($libs =~ /(^|\s)-Wl,-rpath,/
&& !$disabled{shared}
&& !($disabled{asan} && $disabled{msan} && $disabled{ubsan})) {
die "***** Cannot simultaneously use -rpath, shared libraries, and\n",
"***** any of asan, msan or ubsan\n";
}
if ($config{fips})
{
delete $disabled{"shared"} if ($disabled{"shared"} =~ /^default/);
@@ -800,7 +820,9 @@ while (@tocheckfor) {
@tocheckfor = (keys %new_tocheckfor);
}
our $die = sub { die @_; };
if ($target eq "TABLE") {
local $die = sub { warn @_; };
foreach (sort keys %table) {
print_table_entry($_, "TABLE");
}
@@ -815,6 +837,7 @@ if ($target eq "LIST") {
}
if ($target eq "HASH") {
local $die = sub { warn @_; };
print "%table = (\n";
foreach (sort keys %table) {
print_table_entry($_, "HASH");
@@ -856,33 +879,35 @@ foreach (sort (keys %disabled))
@{$config{dirs}} = grep !/^engines$/, @{$config{dirs}};
@{$config{sdirs}} = grep !/^engine$/, @{$config{sdirs}};
push @{$config{openssl_other_defines}}, "OPENSSL_NO_ENGINE";
print " OPENSSL_NO_ENGINE (skip engines)";
}
else
{
my ($ALGO, $algo);
($ALGO = $algo = $_) =~ tr/[\-a-z]/[_A-Z]/;
my ($WHAT, $what);
if (/^asm$/ || /^err$/ || /^hw$/ || /^hw-/ || /^async$/
|| /^autoalginit/ || /^autoerrinit/)
($WHAT = $what = $_) =~ tr/[\-a-z]/[_A-Z]/;
# Fix up C macro end names
$WHAT = "RMD160" if $what eq "ripemd";
# fix-up crypto/directory name(s)
$what = "ripemd" if $what eq "rmd160";
$what = "whrlpool" if $what eq "whirlpool";
if ($what ne "async" && $what ne "err"
&& grep { $_ eq $what } @{$config{sdirs}})
{
push @{$config{openssl_other_defines}}, "OPENSSL_NO_$ALGO";
print " OPENSSL_NO_$ALGO";
push @{$config{openssl_algorithm_defines}}, "OPENSSL_NO_$WHAT";
@{$config{sdirs}} = grep { $_ ne $what} @{$config{sdirs}};
if (/^err$/) { push @user_defines, "OPENSSL_NO_ERR"; }
print " OPENSSL_NO_$WHAT (skip dir)";
}
else
{
($ALGO,$algo) = ("RMD160","rmd160") if ($algo eq "ripemd");
push @{$config{openssl_other_defines}}, "OPENSSL_NO_$WHAT";
print " OPENSSL_NO_$WHAT";
push @{$config{openssl_algorithm_defines}}, "OPENSSL_NO_$ALGO";
print " OPENSSL_NO_$ALGO";
# fix-up crypto/directory name(s)
$algo="whrlpool" if $algo eq "whirlpool";
$algo="ripemd" if $algo eq "rmd160";
@{$config{sdirs}} = grep { $_ ne $algo} @{$config{sdirs}};
print " (skip dir)";
if (/^err$/) { push @user_defines, "OPENSSL_NO_ERR"; }
}
}
@@ -906,6 +931,8 @@ my %target = resolve_config($target);
&usage if (!%target || $target{template});
my %conf_files = map { $_ => 1 } (@{$target{_conf_fname_int}});
$config{conf_files} = [ sort keys %conf_files ];
%target = ( %{$table{DEFAULTS}}, %target );
$target{exe_extension}="";
@@ -938,8 +965,12 @@ $target{nm} = $ENV{'NM'} || $target{nm} || "nm";
$target{rc} =
$ENV{'RC'} || $ENV{'WINDRES'} || $target{rc} || "windres";
# Cache the C compiler command for reconfiguration
# Allow overriding the build file name
$target{build_file} = $ENV{BUILDFILE} || $target{build_file} || "Makefile";
# Cache information necessary for reconfiguration
$config{cc} = $target{cc};
$config{build_file} = $target{build_file};
# For cflags, lflags, plib_lflags, ex_libs and defines, add the debug_
# or release_ attributes.
@@ -1126,6 +1157,9 @@ unless ($disabled{asm}) {
push @{$config{defines}}, "SHA256_ASM" if ($target{sha1_asm_src} =~ /sha256/);
push @{$config{defines}}, "SHA512_ASM" if ($target{sha1_asm_src} =~ /sha512/);
}
if ($target{rc4_asm_src} ne $table{DEFAULTS}->{rc4_asm_src}) {
push @{$config{defines}}, "RC4_ASM";
}
if ($target{md5_asm_src}) {
push @{$config{defines}}, "MD5_ASM";
}
@@ -1176,7 +1210,7 @@ if ($^O ne "VMS" && !$disabled{makedepend}) {
# We know that GNU C version 3 and up as well as all clang
# versions support dependency generation
$config{makedepprog} = $ccpcc
if (/clang/ || (/gcc/ && $compiler_major > 3));
if (/clang/ || (/gcc/ && $compiler_major >= 3));
$ecc = "clang" if /clang/;
$ecc = "gcc" if /gcc/;
last if ($config{makedepprog} || !$lines--);
@@ -1292,31 +1326,6 @@ my %unified_info = ();
my $buildinfo_debug = defined($ENV{CONFIGURE_DEBUG_BUILDINFO});
if ($builder eq "unified") {
# Store the name of the template file we will build the build file from
# in %config. This may be useful for the build file itself.
my $build_file_template;
for my $filename (( $builder_platform."-".$target{build_file}.".tmpl",
$target{build_file}.".tmpl" )) {
if (defined $ENV{$local_config_envname}) {
if ($^O eq 'VMS') {
# VMS environment variables are logical names,
# which can be used as is
$build_file_template = $local_config_envname . ':' . $filename;
} else {
$build_file_template = catfile($ENV{$local_config_envname},
$filename);
}
}
last if -f $build_file_template;
$build_file_template = catfile($srcdir, "Configurations", $filename);
last if -f $build_file_template;
}
$config{build_file_template} = $build_file_template;
use lib catdir(dirname(__FILE__),"util");
use with_fallback qw(Text::Template);
@@ -1353,6 +1362,47 @@ if ($builder eq "unified") {
return $res;
}
# Store the name of the template file we will build the build file from
# in %config. This may be useful for the build file itself.
my @build_file_template_names =
( $builder_platform."-".$target{build_file}.".tmpl",
$target{build_file}.".tmpl" );
my @build_file_templates = ();
# First, look in the user provided directory, if given
if (defined $ENV{$local_config_envname}) {
@build_file_templates =
map {
if ($^O eq 'VMS') {
# VMS environment variables are logical names,
# which can be used as is
$local_config_envname . ':' . $_;
} else {
catfile($ENV{$local_config_envname}, $_);
}
}
@build_file_template_names;
}
# Then, look in our standard directory
push @build_file_templates,
( map { cleanfile($srcdir, catfile("Configurations", $_), $blddir) }
@build_file_template_names );
my $build_file_template;
for $_ (@build_file_templates) {
$build_file_template = $_;
last if -f $build_file_template;
$build_file_template = undef;
}
if (!defined $build_file_template) {
die "*** Couldn't find any of:\n", join("\n", @build_file_templates), "\n";
}
$config{build_file_templates}
= [ $build_file_template,
cleanfile($srcdir, catfile("Configurations", "common.tmpl"),
$blddir) ];
my @build_infos = ( [ ".", "build.info" ] );
foreach (@{$config{dirs}}) {
push @build_infos, [ $_, "build.info" ]
@@ -2028,8 +2078,7 @@ print "RC4 uses $config{rc4_int}\n" if $config{rc4_int} ne $def_int;
my %builders = (
unified => sub {
run_dofile(catfile($blddir, $target{build_file}),
$config{build_file_template},
catfile($srcdir, "Configurations", "common.tmpl"));
@{$config{build_file_templates}});
},
);
@@ -2207,7 +2256,8 @@ sub read_config {
close(CONFFILE);
my %targets = ();
{
local %table = %::table; # Protect %table from tampering
# Protect certain tables from tampering
local %table = %::table;
eval $content;
warn $@ if $@;
@@ -2222,7 +2272,9 @@ sub read_config {
warn "Misconfigured target configuration for $_ (should be a hash table), ignoring...\n";
}
delete $targets{$_};
}
} else {
$targets{$_}->{_conf_fname_int} = add([ $fname ]);
}
}
%table = (%table, %targets);
@@ -2391,7 +2443,8 @@ sub run_dofile
foreach (@templates) {
die "Can't open $_, $!" unless -f $_;
}
my $cmd = "$config{perl} \"-I.\" \"-Mconfigdata\" \"$dofile\" -o\"Configure\" \"".join("\" \"",@templates)."\" > \"$out.new\"";
my $perlcmd = (quotify("maybeshell", $config{perl}))[0];
my $cmd = "$perlcmd \"-I.\" \"-Mconfigdata\" \"$dofile\" -o\"Configure\" \"".join("\" \"",@templates)."\" > \"$out.new\"";
#print STDERR "DEBUG[run_dofile]: \$cmd = $cmd\n";
system($cmd);
exit 1 if $? != 0;
@@ -2438,41 +2491,53 @@ sub print_table_entry
"unistd",
"ld",
"lflags",
"loutflag",
"plib_lflags",
"ex_libs",
"bn_ops",
"cpuid_obj",
"bn_obj",
"ec_obj",
"des_obj",
"aes_obj",
"bf_obj",
"md5_obj",
"sha1_obj",
"cast_obj",
"rc4_obj",
"rmd160_obj",
"rc5_obj",
"wp_obj",
"cmll_obj",
"modes_obj",
"padlock_obj",
"apps_aux_src",
"cpuid_asm_src",
"uplink_aux_src",
"bn_asm_src",
"ec_asm_src",
"des_asm_src",
"aes_asm_src",
"bf_asm_src",
"md5_asm_src",
"cast_asm_src",
"sha1_asm_src",
"rc4_asm_src",
"rmd160_asm_src",
"rc5_asm_src",
"wp_asm_src",
"cmll_asm_src",
"modes_asm_src",
"padlock_asm_src",
"chacha_asm_src",
"poly1035_asm_src",
"thread_scheme",
"perlasm_scheme",
"dso_scheme",
"shared_target",
"shared_cflag",
"shared_defines",
"shared_ldflag",
"shared_rcflag",
"shared_extension",
"shared_extension_simple",
"shared_import_extension",
"dso_extension",
"obj_extension",
"exe_extension",
"ranlib",
"ar",
"arflags",
"aroutflag",
"rc",
"rcflags",
"rcoutflag",
"mt",
"mtflags",
"mtinflag",
"mtoutflag",
"multilib",
"build_scheme",
);
@@ -2551,6 +2616,14 @@ sub quotify {
perl => sub { my $x = shift;
$x =~ s/([\\\$\@"])/\\$1/g;
return '"'.$x.'"'; },
maybeshell => sub { my $x = shift;
(my $y = $x) =~ s/([\\\"])/\\$1/g;
if ($x ne $y || $x =~ m|\s|) {
return '"'.$y.'"';
} else {
return $x;
}
},
);
my $for = shift;
my $processor =

80
INSTALL
View File

@@ -479,10 +479,9 @@
no-<alg>
Build without support for the specified algorithm, where
<alg> is one of: bf, blake2, camellia, cast, chacha, cmac,
des, dh, dsa, ecdh, ecdsa, idea, md4, md5, mdc2, ocb,
ploy1305, rc2, rc4, rmd160, scrypt, seed or whirlpool. The
"ripemd" algorithm is deprecated and if used is synonymous
with rmd160.
des, dh, dsa, ecdh, ecdsa, idea, md4, mdc2, ocb, poly1305,
rc2, rc4, rmd160, scrypt, seed or whirlpool. The "ripemd"
algorithm is deprecated and if used is synonymous with rmd160.
-Dxxx, -lxxx, -Lxxx, -fxxx, -mXXX, -Kxxx
These system specific options will be passed through to the
@@ -602,17 +601,14 @@
("openssl"). The libraries will be built in the top-level directory,
and the binary will be in the "apps" subdirectory.
If the build fails, look at the output. There may be reasons for
the failure that aren't problems in OpenSSL itself (like missing
standard headers). If you are having problems you can get help by
sending an email to the openssl-users email list (see
https://www.openssl.org/community/mailinglists.html for details). If it
is a bug with OpenSSL itself, please report the problem to
<rt@openssl.org> (note that your message will be recorded in the request
tracker publicly readable at
https://www.openssl.org/community/index.html#bugs and will be
forwarded to a public mailing list). Please check out the request
tracker. Maybe the bug was already reported or has already been
If the build fails, look at the output. There may be reasons
for the failure that aren't problems in OpenSSL itself (like
missing standard headers). If you are having problems you can
get help by sending an email to the openssl-users email list (see
https://www.openssl.org/community/mailinglists.html for details). If
it is a bug with OpenSSL itself, please open an issue on GitHub, at
https://github.com/openssl/openssl/issues. Please review the existing
ones first; maybe the bug was already reported or has already been
fixed.
(If you encounter assembler error messages, try the "no-asm"
@@ -770,6 +766,13 @@
AR
The name of the ar executable to use.
BUILDFILE
Use a different build file name than the platform default
("Makefile" on Unixly platforms, "makefile" on native Windows,
"descrip.mms" on OpenVMS). This requires that there is a
corresponding build file template. See Configurations/README
for further information.
CC
The compiler to use. Configure will attempt to pick a default
compiler for your platform but this choice can be overridden
@@ -786,13 +789,19 @@
OPENSSL_LOCAL_CONFIG_DIR
OpenSSL comes with a database of information about how it
should be built on different platforms. This information is
held in ".conf" files in the Configurations directory. See the
should be built on different platforms as well as build file
templates for those platforms. The database is comprised of
".conf" files in the Configurations directory. The build
file templates reside there as well as ".tmpl" files. See the
file Configurations/README for further information about the
format of ".conf" files. As well as the standard ".conf" files
it is possible to create your own ".conf" files and store them
locally, outside the OpenSSL source tree. This environment
variable can be set to the directory where these files are held.
format of ".conf" files as well as information on the ".tmpl"
files.
In addition to the standard ".conf" and ".tmpl" files, it is
possible to create your own ".conf" and ".tmpl" files and store
them locally, outside the OpenSSL source tree. This environment
variable can be set to the directory where these files are held
and will have Configure to consider them in addition to the
standard ones.
PERL
The name of the Perl executable to use when building OpenSSL.
@@ -887,8 +896,8 @@
supported. If your platform does not provide pthreads or Windows threads then
you should Configure with the "no-threads" option.
Note on shared libraries
------------------------
Notes on shared libraries
-------------------------
For most systems the OpenSSL Configure script knows what is needed to
build shared libraries for libcrypto and libssl. On these systems
@@ -897,6 +906,31 @@
where OpenSSL does not know how to build shared libraries the "no-shared"
option will be forced and only static libraries will be created.
Shared libraries are named a little differently on different platforms.
One way or another, they all have the major OpenSSL version number as
part of the file name, i.e. for OpenSSL 1.1.x, 1.1 is somehow part of
the name.
On most POSIXly platforms, shared libraries are named libcrypto.so.1.1
and libssl.so.1.1.
on Cygwin, shared libraries are named cygcrypto-1.1.dll and cygssl-1.1.dll
with import libraries libcrypto.dll.a and libssl.dll.a.
On Windows build with MSVC or using MingW, shared libraries are named
libcrypto-1_1.dll and libssl-1_1.dll for 32-bit Windows, libcrypto-1_1-x64.dll
and libssl-1_1-x64.dll for 64-bit x86_64 Windows, and libcrypto-1_1-ia64.dll
and libssl-1_1-ia64.dll for IA64 Windows. With MSVC, the import libraries
are named libcrypto.lib and libssl.lib, while with MingW, they are named
libcrypto.dll.a and libssl.dll.a.
On VMS, shareable images (VMS speak for shared libraries) are named
ossl$libcrypto0101_shr.exe and ossl$libssl0101_shr.exe. However, when
OpenSSL is specifically built for 32-bit pointers, the shareable images
are named ossl$libcrypto0101_shr32.exe and ossl$libssl0101_shr32.exe
instead, and when built for 64-bit pointers, they are named
ossl$libcrypto0101_shr64.exe and ossl$libssl0101_shr64.exe.
Note on random number generation
--------------------------------

View File

@@ -150,8 +150,8 @@ LINK_SO_DSO= INHIBIT_SYMLINKS=yes; SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
LINK_SO_SHLIB_VIA_O= \
SHOBJECTS=$(DSTDIR)/lib$(LIBNAME).o; \
ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
( echo ld $(LDFLAGS) -r -o $$SHOBJECTS.o $$ALL lib$(LIBNAME).a $(LIBEXTRAS); \
ld $(LDFLAGS) -r -o $$SHOBJECTS.o $$ALL $(DSTDIR)/lib$(LIBNAME).a $(LIBEXTRAS) ); \
( echo ld $(LDFLAGS) -r -o $$SHOBJECTS $$ALL lib$(LIBNAME).a $(LIBEXTRAS); \
ld $(LDFLAGS) -r -o $$SHOBJECTS $$ALL $(DSTDIR)/lib$(LIBNAME).a $(LIBEXTRAS) ); \
$(LINK_SO) && ( echo rm -f $$SHOBJECTS; rm -f $$SHOBJECTS )
LINK_SO_SHLIB_UNPACKED= \
@@ -176,7 +176,7 @@ DO_GNU_SO=\
ALLSYMSFLAGS='-Wl,--whole-archive'; \
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
$(DO_GNU_SO_COMMON)
DO_GNU_APP=LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBRPATH)"
DO_GNU_APP=LDFLAGS="$(CFLAGS) $(LDFLAGS)"
#This is rather special. It's a special target with which one can link
#applications without bothering with any features that have anything to
@@ -220,7 +220,7 @@ link_shlib.bsd:
fi; $(LINK_SO_SHLIB)
link_app.bsd:
@if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBPATH)"; \
LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \
fi; $(LINK_APP)
# For Darwin AKA Mac OS/X (dyld)
@@ -352,7 +352,7 @@ link_app.alpha-osf1:
@if $(DETECT_GNU_LD); then \
$(DO_GNU_APP); \
else \
LDFLAGS="$(CFLAGS) $(LDFLAGS) -rpath $(LIBRPATH)"; \
LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \
fi; \
$(LINK_APP)
@@ -385,7 +385,7 @@ link_app.solaris:
@ if $(DETECT_GNU_LD); then \
$(DO_GNU_APP); \
else \
LDFLAGS="$(CFLAGS) $(LDFLAGS) -R $(LIBRPATH)"; \
LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \
fi; \
$(LINK_APP)
@@ -476,7 +476,7 @@ link_shlib.irix:
fi; \
$(LINK_SO_SHLIB)
link_app.irix:
@LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
@LDFLAGS="$(CFLAGS) $(LDFLAGS)"; \
$(LINK_APP)
# 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
@@ -497,8 +497,8 @@ link_dso.hpux:
expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
fi; \
rm -f $$SHLIB$$SHLIB_SUFFIX || :; \
$(LINK_SO_DSO) && chmod a=rx $$SHLIB$$SHLIB_SUFFIX
rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX || :; \
$(LINK_SO_DSO) && chmod a=rx $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX
link_shlib.hpux:
@if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
$(CALC_VERSIONS); \
@@ -510,11 +510,11 @@ link_shlib.hpux:
expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
fi; \
rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
$(LINK_SO_SHLIB) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
$(LINK_SO_SHLIB) && chmod a=rx $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
link_app.hpux:
@if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,+s,+cdp,../:,+cdp,./:"; \
fi; \
$(LINK_APP)
@@ -526,6 +526,7 @@ link_dso.aix:
ALLSYMSFLAGS=''; \
NOALLSYMSFLAGS=''; \
SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SOVER 2>&1 > /dev/null ; \
$(LINK_SO_DSO);
link_shlib.aix:
@ $(CALC_VERSIONS); \
@@ -536,9 +537,10 @@ link_shlib.aix:
ALLSYMSFLAGS='-bnogc'; \
NOALLSYMSFLAGS=''; \
SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SOVER 2>&1 > /dev/null ; \
$(LINK_SO_SHLIB_VIA_O)
link_app.aix:
LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
LDFLAGS="$(CFLAGS) -Wl,-bsvr4 $(LDFLAGS)"; \
$(LINK_APP)

21
NEWS
View File

@@ -5,7 +5,26 @@
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.2h and OpenSSL 1.1.0 [in pre-release]
Major changes between OpenSSL 1.1.0b and OpenSSL 1.1.0c [10 Nov 2016]
o ChaCha20/Poly1305 heap-buffer-overflow (CVE-2016-7054)
o CMS Null dereference (CVE-2016-7053)
o Montgomery multiplication may produce incorrect results (CVE-2016-7055)
Major changes between OpenSSL 1.1.0a and OpenSSL 1.1.0b [26 Sep 2016]
o Fix Use After Free for large message sizes (CVE-2016-6309)
Major changes between OpenSSL 1.1.0 and OpenSSL 1.1.0a [22 Sep 2016]
o OCSP Status Request extension unbounded memory growth (CVE-2016-6304)
o SSL_peek() hang on empty record (CVE-2016-6305)
o Excessive allocation of memory in tls_get_message_header()
(CVE-2016-6307)
o Excessive allocation of memory in dtls1_preprocess_fragment()
(CVE-2016-6308)
Major changes between OpenSSL 1.0.2h and OpenSSL 1.1.0 [25 Aug 2016]
o Copyright text was shrunk to a boilerplate that points to the license
o "shared" builds are now the default when possible

View File

@@ -36,7 +36,7 @@
PREFIX: %ProgramFiles(86)%\OpenSSL
OPENSSLDIR: %CommonProgramFiles(86)%\SSL
For VC-WIN32, the following defaults are use:
For VC-WIN64, the following defaults are use:
PREFIX: %ProgramW6432%\OpenSSL
OPENSSLDIR: %CommonProgramW6432%\SSL

35
README
View File

@@ -1,5 +1,5 @@
OpenSSL 1.1.0-pre7-dev
OpenSSL 1.1.0c 10 Nov 2016
Copyright (c) 1998-2016 The OpenSSL Project
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
@@ -59,13 +59,13 @@
If you have any problems with OpenSSL then please take the following steps
first:
- Download the current snapshot from ftp://ftp.openssl.org/snapshot/
- Download the latest version from the repository
to see if the problem has already been addressed
- Remove ASM versions of libraries
- Configure with no-asm
- Remove compiler optimisation flags
If you wish to report a bug then please include the following information in
any bug report:
If you wish to report a bug then please include the following information
and create an issue on GitHub:
- OpenSSL version: output of 'openssl version -a'
- Any "Configure" options that you selected during compilation of the
@@ -76,27 +76,10 @@
- Problem Description (steps that will reproduce the problem, if known)
- Stack Traceback (if the application dumps core)
Email the report to:
rt@openssl.org
In order to avoid spam, this is a moderated mailing list, and it might
take a couple of days for the ticket to show up. (We also scan posts to make
sure that security disclosures aren't publicly posted by mistake.) Mail
to this address is recorded in the public RT (request tracker) database
(see https://www.openssl.org/community/index.html#bugs for details) and
also forwarded the public openssl-dev mailing list. Confidential mail
may be sent to openssl-security@openssl.org (PGP key available from the
key servers).
Please do NOT use this for general assistance or support queries.
Just because something doesn't work the way you expect does not mean it
is necessarily a bug in OpenSSL. Use the openssl-users email list for this type
of query.
You can also make GitHub pull requests. See the CONTRIBUTING file for more
details.
HOW TO CONTRIBUTE TO OpenSSL
----------------------------
@@ -105,7 +88,7 @@
LEGALITIES
----------
A number of nations, in particular the U.S., restrict the use or export
of cryptography. If you are potentially subject to such restrictions
you should seek competent professional legal advice before attempting to
develop or distribute cryptographic code.
A number of nations restrict the use or export of cryptography. If you
are potentially subject to such restrictions you should seek competent
professional legal advice before attempting to develop or distribute
cryptographic code.

View File

@@ -692,7 +692,10 @@ EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
BIO_printf(bio_err, "no engine specified\n");
else {
#ifndef OPENSSL_NO_ENGINE
pkey = ENGINE_load_private_key(e, file, ui_method, &cb_data);
if (ENGINE_init(e)) {
pkey = ENGINE_load_private_key(e, file, ui_method, &cb_data);
ENGINE_finish(e);
}
if (pkey == NULL) {
BIO_printf(bio_err, "cannot load %s from engine\n", key_descrip);
ERR_print_errors(bio_err);
@@ -1240,11 +1243,13 @@ static ENGINE *try_load_engine(const char *engine)
}
return e;
}
#endif
ENGINE *setup_engine(const char *engine, int debug)
{
ENGINE *e = NULL;
#ifndef OPENSSL_NO_ENGINE
if (engine) {
if (strcmp(engine, "auto") == 0) {
BIO_printf(bio_err, "enabling auto ENGINE support\n");
@@ -1269,13 +1274,19 @@ ENGINE *setup_engine(const char *engine, int debug)
}
BIO_printf(bio_err, "engine \"%s\" set.\n", ENGINE_get_id(e));
/* Free our "structural" reference. */
ENGINE_free(e);
}
#endif
return e;
}
void release_engine(ENGINE *e)
{
#ifndef OPENSSL_NO_ENGINE
if (e != NULL)
/* Free our "structural" reference. */
ENGINE_free(e);
#endif
}
static unsigned long index_serial_hash(const OPENSSL_CSTRING *a)
{
@@ -2300,6 +2311,36 @@ int app_isdir(const char *name)
#endif
/* raw_read|write section */
#if defined(__VMS)
# include "vms_term_sock.h"
static int stdin_sock = -1;
static void close_stdin_sock(void)
{
TerminalSocket (TERM_SOCK_DELETE, &stdin_sock);
}
int fileno_stdin(void)
{
if (stdin_sock == -1) {
TerminalSocket(TERM_SOCK_CREATE, &stdin_sock);
atexit(close_stdin_sock);
}
return stdin_sock;
}
#else
int fileno_stdin(void)
{
return fileno(stdin);
}
#endif
int fileno_stdout(void)
{
return fileno(stdout);
}
#if defined(_WIN32) && defined(STD_INPUT_HANDLE)
int raw_read_stdin(void *buf, int siz)
{
@@ -2309,10 +2350,17 @@ int raw_read_stdin(void *buf, int siz)
else
return (-1);
}
#elif defined(__VMS)
#include <sys/socket.h>
int raw_read_stdin(void *buf, int siz)
{
return recv(fileno_stdin(), buf, siz, 0);
}
#else
int raw_read_stdin(void *buf, int siz)
{
return read(fileno(stdin), buf, siz);
return read(fileno_stdin(), buf, siz);
}
#endif
@@ -2328,7 +2376,7 @@ int raw_write_stdout(const void *buf, int siz)
#else
int raw_write_stdout(const void *buf, int siz)
{
return write(fileno(stdout), buf, siz);
return write(fileno_stdout(), buf, siz);
}
#endif

View File

@@ -430,11 +430,9 @@ __owur int ctx_set_ctlog_list_file(SSL_CTX *ctx, const char *path);
#endif
# ifdef OPENSSL_NO_ENGINE
# define setup_engine(engine, debug) NULL
# else
ENGINE *setup_engine(const char *engine, int debug);
# endif
void release_engine(ENGINE *e);
# ifndef OPENSSL_NO_OCSP
OCSP_RESPONSE *process_responder(OCSP_REQUEST *req,
const char *host, const char *path,
@@ -548,6 +546,8 @@ void store_setup_crl_download(X509_STORE *st);
int app_isdir(const char *);
int app_access(const char *, int flag);
int fileno_stdin(void);
int fileno_stdout(void);
int raw_read_stdin(void *, int);
int raw_write_stdout(const void *, int);

View File

@@ -1236,6 +1236,7 @@ end_of_options:
X509_CRL_free(crl);
NCONF_free(conf);
NCONF_free(extconf);
release_engine(e);
return (ret);
}
@@ -1916,7 +1917,6 @@ static int certify_spkac(X509 **xret, const char *infile, EVP_PKEY *pkey,
sk = CONF_get_section(parms, "default");
if (sk_CONF_VALUE_num(sk) == 0) {
BIO_printf(bio_err, "no name/value pairs found in %s\n", infile);
CONF_free(parms);
goto end;
}

View File

@@ -72,7 +72,7 @@ typedef enum OPTION_choice {
OPT_ASCIICRLF, OPT_NOINTERN, OPT_NOVERIFY, OPT_NOCERTS,
OPT_NOATTR, OPT_NODETACH, OPT_NOSMIMECAP, OPT_BINARY, OPT_KEYID,
OPT_NOSIGS, OPT_NO_CONTENT_VERIFY, OPT_NO_ATTR_VERIFY, OPT_INDEF,
OPT_NOINDEF, OPT_NOOLDMIME, OPT_CRLFEOL, OPT_NOOUT, OPT_RR_PRINT,
OPT_NOINDEF, OPT_CRLFEOL, OPT_NOOUT, OPT_RR_PRINT,
OPT_RR_ALL, OPT_RR_FIRST, OPT_RCTFORM, OPT_CERTFILE, OPT_CAFILE,
OPT_CAPATH, OPT_NOCAPATH, OPT_NOCAFILE,OPT_CONTENT, OPT_PRINT,
OPT_SECRETKEY, OPT_SECRETKEYID, OPT_PWRI_PASSWORD, OPT_ECONTENT_TYPE,
@@ -99,7 +99,7 @@ OPTIONS cms_options[] = {
{"decrypt", OPT_DECRYPT, '-', "Decrypt encrypted message"},
{"sign", OPT_SIGN, '-', "Sign message"},
{"sign_receipt", OPT_SIGN_RECEIPT, '-', "Generate a signed receipt for the message"},
{"resign", OPT_RESIGN, '-'},
{"resign", OPT_RESIGN, '-', "Resign a signed message"},
{"verify", OPT_VERIFY, '-', "Verify signed message"},
{"verify_retcode", OPT_VERIFY_RETCODE, '-'},
{"verify_receipt", OPT_VERIFY_RECEIPT, '<'},
@@ -122,22 +122,21 @@ OPTIONS cms_options[] = {
"Don't include signers certificate when signing"},
{"noattr", OPT_NOATTR, '-', "Don't include any signed attributes"},
{"nodetach", OPT_NODETACH, '-', "Use opaque signing"},
{"nosmimecap", OPT_NOSMIMECAP, '-'},
{"nosmimecap", OPT_NOSMIMECAP, '-', "Omit the SMIMECapabilities attribute"},
{"binary", OPT_BINARY, '-', "Don't translate message to text"},
{"keyid", OPT_KEYID, '-', "Use subject key identifier"},
{"nosigs", OPT_NOSIGS, '-', "Don't verify message signature"},
{"no_content_verify", OPT_NO_CONTENT_VERIFY, '-'},
{"no_attr_verify", OPT_NO_ATTR_VERIFY, '-'},
{"stream", OPT_INDEF, '-'},
{"indef", OPT_INDEF, '-'},
{"noindef", OPT_NOINDEF, '-'},
{"nooldmime", OPT_NOOLDMIME, '-'},
{"crlfeol", OPT_CRLFEOL, '-'},
{"stream", OPT_INDEF, '-', "Enable CMS streaming"},
{"indef", OPT_INDEF, '-', "Same as -stream"},
{"noindef", OPT_NOINDEF, '-', "Disable CMS streaming"},
{"crlfeol", OPT_CRLFEOL, '-', "Use CRLF as EOL termination instead of CR only" },
{"noout", OPT_NOOUT, '-', "For the -cmsout operation do not output the parsed CMS structure"},
{"receipt_request_print", OPT_RR_PRINT, '-'},
{"receipt_request_print", OPT_RR_PRINT, '-', "Print CMS Receipt Request" },
{"receipt_request_all", OPT_RR_ALL, '-'},
{"receipt_request_first", OPT_RR_FIRST, '-'},
{"rctform", OPT_RCTFORM, 'F'},
{"rctform", OPT_RCTFORM, 'F', "Receipt file format"},
{"certfile", OPT_CERTFILE, '<', "Other certificates file"},
{"CAfile", OPT_CAFILE, '<', "Trusted certificates file"},
{"CApath", OPT_CAPATH, '/', "trusted certificates directory"},
@@ -147,7 +146,8 @@ OPTIONS cms_options[] = {
"Do not load certificates from the default certificates directory"},
{"content", OPT_CONTENT, '<',
"Supply or override content for detached signature"},
{"print", OPT_PRINT, '-', "For the -cmsout operation print out all fields of the CMS structure"},
{"print", OPT_PRINT, '-',
"For the -cmsout operation print out all fields of the CMS structure"},
{"secretkey", OPT_SECRETKEY, 's'},
{"secretkeyid", OPT_SECRETKEYID, 's'},
{"pwri_password", OPT_PWRI_PASSWORD, 's'},
@@ -346,9 +346,6 @@ int cms_main(int argc, char **argv)
case OPT_NOINDEF:
flags &= ~CMS_STREAM;
break;
case OPT_NOOLDMIME:
flags |= CMS_NOOLDMIMETYPE;
break;
case OPT_CRLFEOL:
mime_eol = "\r\n";
flags |= CMS_CRLFEOL;
@@ -1112,6 +1109,7 @@ int cms_main(int argc, char **argv)
EVP_PKEY_free(key);
CMS_ContentInfo_free(cms);
CMS_ContentInfo_free(rcms);
release_engine(e);
BIO_free(rctin);
BIO_free(in);
BIO_free(indata);

View File

@@ -41,7 +41,7 @@ OPTIONS crl_options[] = {
{"fingerprint", OPT_FINGERPRINT, '-', "Print the crl fingerprint"},
{"crlnumber", OPT_CRLNUMBER, '-', "Print CRL number"},
{"badsig", OPT_BADSIG, '-', "Corrupt last byte of loaded CRL signature (for test)" },
{"gendelta", OPT_GENDELTA, '<'},
{"gendelta", OPT_GENDELTA, '<', "Other CRL to compare/diff to the Input one"},
{"CApath", OPT_CAPATH, '/', "Verify CRL using certificates in dir"},
{"CAfile", OPT_CAFILE, '<', "Verify CRL using certificates in file name"},
{"no-CAfile", OPT_NOCAFILE, '-',

View File

@@ -185,6 +185,10 @@ int dgst_main(int argc, char **argv)
}
argc = opt_num_rest();
argv = opt_rest();
if (keyfile != NULL && argc > 1) {
BIO_printf(bio_err, "%s: Can only sign or verify one file.\n", prog);
goto end;
}
if (do_verify && !sigfile) {
BIO_printf(bio_err,
@@ -394,6 +398,7 @@ int dgst_main(int argc, char **argv)
sk_OPENSSL_STRING_free(macopts);
OPENSSL_free(sigbuf);
BIO_free(bmd);
release_engine(e);
return (ret);
}

View File

@@ -70,6 +70,7 @@ int dhparam_main(int argc, char **argv)
BIO *in = NULL, *out = NULL;
DH *dh = NULL;
char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;
ENGINE *e = NULL;
#ifndef OPENSSL_NO_DSA
int dsaparam = 0;
#endif
@@ -104,7 +105,7 @@ int dhparam_main(int argc, char **argv)
outfile = opt_arg();
break;
case OPT_ENGINE:
(void)setup_engine(opt_arg(), 0);
e = setup_engine(opt_arg(), 0);
break;
case OPT_CHECK:
check = 1;
@@ -356,6 +357,7 @@ int dhparam_main(int argc, char **argv)
BIO_free(in);
BIO_free_all(out);
DH_free(dh);
release_engine(e);
return (ret);
}

View File

@@ -249,6 +249,7 @@ int dsa_main(int argc, char **argv)
end:
BIO_free_all(out);
DSA_free(dsa);
release_engine(e);
OPENSSL_free(passin);
OPENSSL_free(passout);
return (ret);

View File

@@ -66,6 +66,7 @@ OPTIONS dsaparam_options[] = {
int dsaparam_main(int argc, char **argv)
{
ENGINE *e = NULL;
DSA *dsa = NULL;
BIO *in = NULL, *out = NULL;
BN_GENCB *cb = NULL;
@@ -105,7 +106,7 @@ int dsaparam_main(int argc, char **argv)
outfile = opt_arg();
break;
case OPT_ENGINE:
(void)setup_engine(opt_arg(), 0);
e = setup_engine(opt_arg(), 0);
break;
case OPT_TIMEBOMB:
# ifdef GENCB_TEST
@@ -285,6 +286,7 @@ int dsaparam_main(int argc, char **argv)
BIO_free(in);
BIO_free_all(out);
DSA_free(dsa);
release_engine(e);
return (ret);
}

View File

@@ -273,6 +273,7 @@ int ec_main(int argc, char **argv)
BIO_free(in);
BIO_free_all(out);
EC_KEY_free(eckey);
release_engine(e);
OPENSSL_free(passin);
OPENSSL_free(passout);
return (ret);

View File

@@ -87,6 +87,7 @@ static OPT_PAIR encodings[] = {
int ecparam_main(int argc, char **argv)
{
ENGINE *e = NULL;
BIGNUM *ec_gen = NULL, *ec_order = NULL, *ec_cofactor = NULL;
BIGNUM *ec_p = NULL, *ec_a = NULL, *ec_b = NULL;
BIO *in = NULL, *out = NULL;
@@ -168,7 +169,7 @@ int ecparam_main(int argc, char **argv)
need_rand = 1;
break;
case OPT_ENGINE:
(void)setup_engine(opt_arg(), 0);
e = setup_engine(opt_arg(), 0);
break;
}
}
@@ -454,9 +455,10 @@ int ecparam_main(int argc, char **argv)
BN_free(ec_order);
BN_free(ec_cofactor);
OPENSSL_free(buffer);
EC_GROUP_free(group);
release_engine(e);
BIO_free(in);
BIO_free_all(out);
EC_GROUP_free(group);
return (ret);
}

View File

@@ -82,6 +82,7 @@ int enc_main(int argc, char **argv)
{
static char buf[128];
static const char magic[] = "Salted__";
ENGINE *e = NULL;
BIO *in = NULL, *out = NULL, *b64 = NULL, *benc = NULL, *rbio =
NULL, *wbio = NULL;
EVP_CIPHER_CTX *ctx = NULL;
@@ -151,7 +152,7 @@ int enc_main(int argc, char **argv)
passarg = opt_arg();
break;
case OPT_ENGINE:
(void)setup_engine(opt_arg(), 0);
e = setup_engine(opt_arg(), 0);
break;
case OPT_D:
enc = 0;
@@ -552,6 +553,7 @@ int enc_main(int argc, char **argv)
#ifdef ZLIB
BIO_free(bzl);
#endif
release_engine(e);
OPENSSL_free(pass);
return (ret);
}

View File

@@ -34,7 +34,7 @@ OPTIONS gendsa_options[] = {
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
{"help", OPT_HELP, '-', "Display this summary"},
{"out", OPT_OUT, '>', "Output the key to the specified file"},
{"passout", OPT_PASSOUT, 's'},
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
{"rand", OPT_RAND, 's',
"Load the file(s) into the random number generator"},
{"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"},
@@ -46,6 +46,7 @@ OPTIONS gendsa_options[] = {
int gendsa_main(int argc, char **argv)
{
ENGINE *e = NULL;
BIO *out = NULL, *in = NULL;
DSA *dsa = NULL;
const EVP_CIPHER *enc = NULL;
@@ -74,7 +75,7 @@ int gendsa_main(int argc, char **argv)
passoutarg = opt_arg();
break;
case OPT_ENGINE:
(void)setup_engine(opt_arg(), 0);
e = setup_engine(opt_arg(), 0);
break;
case OPT_RAND:
inrand = opt_arg();
@@ -139,6 +140,7 @@ int gendsa_main(int argc, char **argv)
BIO_free(in);
BIO_free_all(out);
DSA_free(dsa);
release_engine(e);
OPENSSL_free(passout);
return (ret);
}

View File

@@ -193,8 +193,8 @@ int genpkey_main(int argc, char **argv)
EVP_PKEY_CTX_free(ctx);
BIO_free_all(out);
BIO_free(in);
release_engine(e);
OPENSSL_free(pass);
return ret;
}

View File

@@ -166,6 +166,7 @@ int genrsa_main(int argc, char **argv)
BN_GENCB_free(cb);
RSA_free(rsa);
BIO_free_all(out);
release_engine(eng);
OPENSSL_free(passout);
if (ret != 0)
ERR_print_errors(bio_err);

View File

@@ -107,7 +107,8 @@ OPTIONS ocsp_options[] = {
{"url", OPT_URL, 's', "Responder URL"},
{"host", OPT_HOST, 's', "TCP/IP hostname:port to connect to"},
{"port", OPT_PORT, 'p', "Port to run responder on"},
{"ignore_err", OPT_IGNORE_ERR, '-'},
{"ignore_err", OPT_IGNORE_ERR, '-',
"Ignore Error response from OCSP responder, and retry "},
{"noverify", OPT_NOVERIFY, '-', "Don't verify response at all"},
{"nonce", OPT_NONCE, '-', "Add OCSP nonce to request"},
{"no_nonce", OPT_NO_NONCE, '-', "Don't add OCSP nonce to request"},
@@ -124,7 +125,8 @@ OPTIONS ocsp_options[] = {
{"no_chain", OPT_NO_CHAIN, '-', "Don't chain verify response"},
{"no_cert_checks", OPT_NO_CERT_CHECKS, '-',
"Don't do additional checks on signing certificate"},
{"no_explicit", OPT_NO_EXPLICIT, '-'},
{"no_explicit", OPT_NO_EXPLICIT, '-',
"Do not explicitly check the chain, just verify the root"},
{"trust_other", OPT_TRUST_OTHER, '-',
"Don't verify additional certificates"},
{"no_intern", OPT_NO_INTERN, '-',

View File

@@ -319,6 +319,7 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
|| !EVP_DigestUpdate(md, magic, magic_len)
|| !EVP_DigestUpdate(md, "$", 1)
|| !EVP_DigestUpdate(md, salt_out, salt_len))
goto err;
md2 = EVP_MD_CTX_new();
if (md2 == NULL

View File

@@ -574,6 +574,7 @@ int pkcs12_main(int argc, char **argv)
PKCS12_free(p12);
if (export_cert || inrand)
app_RAND_write_file(NULL);
release_engine(e);
BIO_free(in);
BIO_free_all(out);
sk_OPENSSL_STRING_free(canames);

View File

@@ -33,7 +33,7 @@ OPTIONS pkcs7_options[] = {
{"out", OPT_OUT, '>', "Output file"},
{"noout", OPT_NOOUT, '-', "Don't output encoded data"},
{"text", OPT_TEXT, '-', "Print full details of certificates"},
{"print", OPT_PRINT, '-'},
{"print", OPT_PRINT, '-', "Print out all fields of the PKCS7 structure"},
{"print_certs", OPT_PRINT_CERTS, '-',
"Print_certs print any certs or crl in the input"},
#ifndef OPENSSL_NO_ENGINE
@@ -44,6 +44,7 @@ OPTIONS pkcs7_options[] = {
int pkcs7_main(int argc, char **argv)
{
ENGINE *e = NULL;
PKCS7 *p7 = NULL;
BIO *in = NULL, *out = NULL;
int informat = FORMAT_PEM, outformat = FORMAT_PEM;
@@ -90,7 +91,7 @@ int pkcs7_main(int argc, char **argv)
print_certs = 1;
break;
case OPT_ENGINE:
(void)setup_engine(opt_arg(), 0);
e = setup_engine(opt_arg(), 0);
break;
}
}
@@ -189,6 +190,7 @@ int pkcs7_main(int argc, char **argv)
ret = 0;
end:
PKCS7_free(p7);
release_engine(e);
BIO_free(in);
BIO_free_all(out);
return (ret);

View File

@@ -38,7 +38,7 @@ OPTIONS pkcs8_options[] = {
{"nocrypt", OPT_NOCRYPT, '-', "Use or expect unencrypted private key"},
{"v2", OPT_V2, 's', "Use PKCS#5 v2.0 and cipher"},
{"v1", OPT_V1, 's', "Use PKCS#5 v1.5 and cipher"},
{"v2prf", OPT_V2PRF, 's'},
{"v2prf", OPT_V2PRF, 's', "Set the PRF algorithm to use with PKCS#5 v2.0"},
{"iter", OPT_ITER, 'p', "Specify the iteration count"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
@@ -343,6 +343,7 @@ int pkcs8_main(int argc, char **argv)
X509_SIG_free(p8);
PKCS8_PRIV_KEY_INFO_free(p8inf);
EVP_PKEY_free(pkey);
release_engine(e);
BIO_free_all(out);
BIO_free(in);
OPENSSL_free(passin);

View File

@@ -180,6 +180,7 @@ int pkey_main(int argc, char **argv)
end:
EVP_PKEY_free(pkey);
release_engine(e);
BIO_free_all(out);
BIO_free(in);
OPENSSL_free(passin);

View File

@@ -33,6 +33,7 @@ OPTIONS pkeyparam_options[] = {
int pkeyparam_main(int argc, char **argv)
{
ENGINE *e = NULL;
BIO *in = NULL, *out = NULL;
EVP_PKEY *pkey = NULL;
int text = 0, noout = 0, ret = 1;
@@ -58,7 +59,7 @@ int pkeyparam_main(int argc, char **argv)
outfile = opt_arg();
break;
case OPT_ENGINE:
(void)setup_engine(opt_arg(), 0);
e = setup_engine(opt_arg(), 0);
break;
case OPT_TEXT:
text = 1;
@@ -95,6 +96,7 @@ int pkeyparam_main(int argc, char **argv)
end:
EVP_PKEY_free(pkey);
release_engine(e);
BIO_free_all(out);
BIO_free(in);

View File

@@ -323,6 +323,7 @@ int pkeyutl_main(int argc, char **argv)
end:
EVP_PKEY_CTX_free(ctx);
release_engine(e);
BIO_free(in);
BIO_free_all(out);
OPENSSL_free(buf_in);

View File

@@ -39,6 +39,7 @@ OPTIONS rand_options[] = {
int rand_main(int argc, char **argv)
{
ENGINE *e = NULL;
BIO *out = NULL;
char *inrand = NULL, *outfile = NULL, *prog;
OPTION_CHOICE o;
@@ -60,7 +61,7 @@ int rand_main(int argc, char **argv)
outfile = opt_arg();
break;
case OPT_ENGINE:
(void)setup_engine(opt_arg(), 0);
e = setup_engine(opt_arg(), 0);
break;
case OPT_RAND:
inrand = opt_arg();
@@ -125,6 +126,7 @@ int rand_main(int argc, char **argv)
end:
if (ret != 0)
ERR_print_errors(bio_err);
release_engine(e);
BIO_free_all(out);
return (ret);
}

View File

@@ -403,6 +403,7 @@ OPTIONS rehash_options[] = {
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [cert-directory...]\n"},
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
{"help", OPT_HELP, '-', "Display this summary"},
{"h", OPT_HELP, '-', "Display this summary"},
{"compat", OPT_COMPAT, '-', "Create both new- and old-style hash links"},
{"old", OPT_OLD, '-', "Use old-style hash to generate links"},
{"n", OPT_N, '-', "Do not remove existing links"},

View File

@@ -820,6 +820,7 @@ int req_main(int argc, char **argv)
X509_REQ_free(req);
X509_free(x509ss);
ASN1_INTEGER_free(serial);
release_engine(e);
if (passin != nofree_passin)
OPENSSL_free(passin);
if (passout != nofree_passout)

View File

@@ -294,6 +294,7 @@ int rsa_main(int argc, char **argv)
} else
ret = 0;
end:
release_engine(e);
BIO_free_all(out);
RSA_free(rsa);
OPENSSL_free(passin);

View File

@@ -267,6 +267,7 @@ int rsautl_main(int argc, char **argv)
BIO_write(out, rsa_out, rsa_outlen);
end:
RSA_free(rsa);
release_engine(e);
BIO_free(in);
BIO_free_all(out);
OPENSSL_free(rsa_in);

View File

@@ -577,8 +577,8 @@ OPTIONS s_client_options[] = {
{"cert", OPT_CERT, '<', "Certificate file to use, PEM format assumed"},
{"certform", OPT_CERTFORM, 'F',
"Certificate format (PEM or DER) PEM default"},
{"key", OPT_KEY, '<', "Private key file to use, if not in -cert file"},
{"keyform", OPT_KEYFORM, 'F', "Key format (PEM or DER) PEM default"},
{"key", OPT_KEY, 's', "Private key file to use, if not in -cert file"},
{"keyform", OPT_KEYFORM, 'E', "Key format (PEM, DER or engine) PEM default"},
{"pass", OPT_PASS, 's', "Private key file pass phrase source"},
{"CApath", OPT_CAPATH, '/', "PEM format directory of CA's"},
{"CAfile", OPT_CAFILE, '<', "PEM format file of CA's"},
@@ -812,7 +812,9 @@ int s_client_main(int argc, char **argv)
int socket_family = AF_UNSPEC, socket_type = SOCK_STREAM;
int starttls_proto = PROTO_OFF, crl_format = FORMAT_PEM, crl_download = 0;
int write_tty, read_tty, write_ssl, read_ssl, tty_on, ssl_pending;
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS)
int at_eof = 0;
#endif
int read_buf_len = 0;
int fallback_scsv = 0;
long randamt = 0;
@@ -854,7 +856,10 @@ int s_client_main(int argc, char **argv)
enum { use_inet, use_unix, use_unknown } connect_type = use_unknown;
int count4or6 = 0;
int c_nbio = 0, c_msg = 0, c_ign_eof = 0, c_brief = 0;
int c_tlsextdebug = 0, c_status_req = 0;
int c_tlsextdebug = 0;
#ifndef OPENSSL_NO_OCSP
int c_status_req = 0;
#endif
BIO *bio_c_msg = NULL;
FD_ZERO(&readfds);
@@ -1065,7 +1070,9 @@ int s_client_main(int argc, char **argv)
c_tlsextdebug = 1;
break;
case OPT_STATUS:
#ifndef OPENSSL_NO_OCSP
c_status_req = 1;
#endif
break;
case OPT_WDEBUG:
#ifdef WATT32
@@ -1195,7 +1202,7 @@ int s_client_main(int argc, char **argv)
fallback_scsv = 1;
break;
case OPT_KEYFORM:
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &key_format))
if (!opt_format(opt_arg(), OPT_FMT_PDE, &key_format))
goto opthelp;
break;
case OPT_PASS:
@@ -1819,7 +1826,10 @@ int s_client_main(int argc, char **argv)
SSL_set_connect_state(con);
/* ok, lets connect */
width = SSL_get_fd(con) + 1;
if (fileno_stdin() > SSL_get_fd(con))
width = fileno_stdin() + 1;
else
width = SSL_get_fd(con) + 1;
read_tty = 1;
write_tty = 0;
@@ -2148,9 +2158,11 @@ int s_client_main(int argc, char **argv)
* set the flag so we exit.
*/
if (read_tty && !at_eof)
openssl_fdset(fileno(stdin), &readfds);
openssl_fdset(fileno_stdin(), &readfds);
#if !defined(OPENSSL_SYS_VMS)
if (write_tty)
openssl_fdset(fileno(stdout), &writefds);
openssl_fdset(fileno_stdout(), &writefds);
#endif
}
if (read_ssl)
openssl_fdset(SSL_get_fd(con), &readfds);
@@ -2276,11 +2288,11 @@ int s_client_main(int argc, char **argv)
goto shut;
}
}
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VMS)
/* Assume Windows/DOS/BeOS can always write */
else if (!ssl_pending && write_tty)
#else
else if (!ssl_pending && FD_ISSET(fileno(stdout), &writefds))
else if (!ssl_pending && FD_ISSET(fileno_stdout(), &writefds))
#endif
{
#ifdef CHARSET_EBCDIC
@@ -2369,7 +2381,7 @@ int s_client_main(int argc, char **argv)
#if defined(OPENSSL_SYS_MSDOS)
else if (has_stdin_waiting())
#else
else if (FD_ISSET(fileno(stdin), &readfds))
else if (FD_ISSET(fileno_stdin(), &readfds))
#endif
{
if (crlf) {
@@ -2392,9 +2404,10 @@ int s_client_main(int argc, char **argv)
assert(lf_num == 0);
} else
i = raw_read_stdin(cbuf, BUFSIZZ);
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS)
if (i == 0)
at_eof = 1;
#endif
if ((!c_ign_eof) && ((i <= 0) || (cbuf[0] == 'Q' && cmdletters))) {
BIO_printf(bio_err, "DONE\n");
@@ -2461,6 +2474,7 @@ int s_client_main(int argc, char **argv)
#ifndef OPENSSL_NO_SRP
OPENSSL_free(srp_arg.srppassin);
#endif
OPENSSL_free(connectstr);
OPENSSL_free(host);
OPENSSL_free(port);
X509_VERIFY_PARAM_free(vpm);
@@ -2471,6 +2485,7 @@ int s_client_main(int argc, char **argv)
OPENSSL_clear_free(cbuf, BUFSIZZ);
OPENSSL_clear_free(sbuf, BUFSIZZ);
OPENSSL_clear_free(mbuf, BUFSIZZ);
release_engine(e);
BIO_free(bio_c_out);
bio_c_out = NULL;
BIO_free(bio_c_msg);

View File

@@ -932,7 +932,10 @@ int s_server_main(int argc, char *argv[])
const char *s_cert_file = TEST_CERT, *s_key_file = NULL, *s_chain_file = NULL;
const char *s_cert_file2 = TEST_CERT2, *s_key_file2 = NULL;
char *s_dcert_file = NULL, *s_dkey_file = NULL, *s_dchain_file = NULL;
int s_tlsextstatus = 0, no_resume_ephemeral = 0;
#ifndef OPENSSL_NO_OCSP
int s_tlsextstatus = 0;
#endif
int no_resume_ephemeral = 0;
unsigned int split_send_fragment = 0, max_pipelines = 0;
const char *s_serverinfo_file = NULL;
@@ -1206,14 +1209,20 @@ int s_server_main(int argc, char *argv[])
s_tlsextdebug = 1;
break;
case OPT_STATUS:
#ifndef OPENSSL_NO_OCSP
s_tlsextstatus = 1;
#endif
break;
case OPT_STATUS_VERBOSE:
#ifndef OPENSSL_NO_OCSP
s_tlsextstatus = tlscstatp.verbose = 1;
#endif
break;
case OPT_STATUS_TIMEOUT:
#ifndef OPENSSL_NO_OCSP
s_tlsextstatus = 1;
tlscstatp.timeout = atoi(opt_arg());
#endif
break;
case OPT_STATUS_URL:
#ifndef OPENSSL_NO_OCSP
@@ -1954,6 +1963,7 @@ int s_server_main(int argc, char *argv[])
ssl_excert_free(exc);
sk_OPENSSL_STRING_free(ssl_args);
SSL_CONF_CTX_free(cctx);
release_engine(engine);
BIO_free(bio_s_out);
bio_s_out = NULL;
BIO_free(bio_s_msg);
@@ -2107,7 +2117,10 @@ static int sv_body(int s, int stype, unsigned char *context)
SSL_set_tlsext_debug_arg(con, bio_s_out);
}
width = s + 1;
if (fileno_stdin() > s)
width = fileno_stdin() + 1;
else
width = s + 1;
for (;;) {
int read_from_terminal;
int read_from_sslcon;
@@ -2119,7 +2132,7 @@ static int sv_body(int s, int stype, unsigned char *context)
if (!read_from_sslcon) {
FD_ZERO(&readfds);
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS)
openssl_fdset(fileno(stdin), &readfds);
openssl_fdset(fileno_stdin(), &readfds);
#endif
openssl_fdset(s, &readfds);
/*
@@ -2159,7 +2172,7 @@ static int sv_body(int s, int stype, unsigned char *context)
if (i <= 0)
continue;
if (FD_ISSET(fileno(stdin), &readfds))
if (FD_ISSET(fileno_stdin(), &readfds))
read_from_terminal = 1;
#endif
if (FD_ISSET(s, &readfds))
@@ -2186,6 +2199,7 @@ static int sv_body(int s, int stype, unsigned char *context)
assert(lf_num == 0);
} else
i = raw_read_stdin(buf, bufsize);
if (!s_quiet && !s_brief) {
if ((i <= 0) || (buf[0] == 'Q')) {
BIO_printf(bio_s_out, "DONE\n");

View File

@@ -37,7 +37,7 @@ typedef enum OPTION_choice {
OPT_PK7OUT, OPT_TEXT, OPT_NOINTERN, OPT_NOVERIFY, OPT_NOCHAIN,
OPT_NOCERTS, OPT_NOATTR, OPT_NODETACH, OPT_NOSMIMECAP,
OPT_BINARY, OPT_NOSIGS, OPT_STREAM, OPT_INDEF, OPT_NOINDEF,
OPT_NOOLDMIME, OPT_CRLFEOL, OPT_RAND, OPT_ENGINE, OPT_PASSIN,
OPT_CRLFEOL, OPT_RAND, OPT_ENGINE, OPT_PASSIN,
OPT_TO, OPT_FROM, OPT_SUBJECT, OPT_SIGNER, OPT_RECIP, OPT_MD,
OPT_CIPHER, OPT_INKEY, OPT_KEYFORM, OPT_CERTFILE, OPT_CAFILE,
OPT_V_ENUM,
@@ -88,14 +88,14 @@ OPTIONS smime_options[] = {
"Do not load the default certificates file"},
{"no-CApath", OPT_NOCAPATH, '-',
"Do not load certificates from the default certificates directory"},
{"resign", OPT_RESIGN, '-'},
{"nochain", OPT_NOCHAIN, '-'},
{"nosmimecap", OPT_NOSMIMECAP, '-'},
{"stream", OPT_STREAM, '-'},
{"indef", OPT_INDEF, '-'},
{"noindef", OPT_NOINDEF, '-'},
{"nooldmime", OPT_NOOLDMIME, '-'},
{"crlfeol", OPT_CRLFEOL, '-'},
{"resign", OPT_RESIGN, '-', "Resign a signed message"},
{"nochain", OPT_NOCHAIN, '-',
"set PKCS7_NOCHAIN so certificates contained in the message are not used as untrusted CAs" },
{"nosmimecap", OPT_NOSMIMECAP, '-', "Omit the SMIMECapabilities attribute"},
{"stream", OPT_STREAM, '-', "Enable CMS streaming" },
{"indef", OPT_INDEF, '-', "Same as -stream" },
{"noindef", OPT_NOINDEF, '-', "Disable CMS streaming"},
{"crlfeol", OPT_CRLFEOL, '-', "Use CRLF as EOL termination instead of CR only"},
{"rand", OPT_RAND, 's',
"Load the file(s) into the random number generator"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
@@ -220,9 +220,6 @@ int smime_main(int argc, char **argv)
case OPT_NOINDEF:
indef = 0;
break;
case OPT_NOOLDMIME:
flags |= PKCS7_NOOLDMIMETYPE;
break;
case OPT_CRLFEOL:
flags |= PKCS7_CRLFEOL;
mime_eol = "\r\n";
@@ -617,6 +614,7 @@ int smime_main(int argc, char **argv)
X509_free(signer);
EVP_PKEY_free(key);
PKCS7_free(p7);
release_engine(e);
BIO_free(in);
BIO_free(indata);
BIO_free_all(out);

View File

@@ -1219,13 +1219,12 @@ static int run_benchmark(int async_jobs,
int speed_main(int argc, char **argv)
{
ENGINE *e = NULL;
loopargs_t *loopargs = NULL;
int async_init = 0;
int loopargs_len = 0;
char *prog;
#ifndef OPENSSL_NO_ENGINE
const char *engine_id = NULL;
#endif
const EVP_CIPHER *evp_cipher = NULL;
double d = 0.0;
OPTION_CHOICE o;
@@ -1399,9 +1398,7 @@ int speed_main(int argc, char **argv)
* initialised by each child process, not by the parent.
* So store the name here and run setup_engine() later on.
*/
#ifndef OPENSSL_NO_ENGINE
engine_id = opt_arg();
#endif
break;
case OPT_MULTI:
#ifndef NO_FORK
@@ -1566,7 +1563,7 @@ int speed_main(int argc, char **argv)
#endif
/* Initialize the engine after the fork */
(void)setup_engine(engine_id, 0);
e = setup_engine(engine_id, 0);
/* No parameters; turn on everything. */
if ((argc == 0) && !doit[D_EVP]) {
@@ -2819,6 +2816,7 @@ int speed_main(int argc, char **argv)
ASYNC_cleanup_thread();
}
OPENSSL_free(loopargs);
release_engine(e);
return (ret);
}

View File

@@ -38,7 +38,8 @@ OPTIONS spkac_options[] = {
{"noout", OPT_NOOUT, '-', "Don't print SPKAC"},
{"pubkey", OPT_PUBKEY, '-', "Output public key"},
{"verify", OPT_VERIFY, '-', "Verify SPKAC signature"},
{"spksect", OPT_SPKSECT, 's'},
{"spksect", OPT_SPKSECT, 's',
"Specify the name of an SPKAC-dedicated section of configuration"},
#ifndef OPENSSL_NO_ENGINE
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
#endif
@@ -186,6 +187,7 @@ int spkac_main(int argc, char **argv)
NETSCAPE_SPKI_free(spki);
BIO_free_all(out);
EVP_PKEY_free(pkey);
release_engine(e);
OPENSSL_free(passin);
return (ret);
}

View File

@@ -209,6 +209,7 @@ OPTIONS srp_options[] = {
int srp_main(int argc, char **argv)
{
ENGINE *e = NULL;
CA_DB *db = NULL;
CONF *conf = NULL;
int gNindex = -1, maxgN = -1, ret = 1, errors = 0, verbose = 0, i;
@@ -269,7 +270,7 @@ int srp_main(int argc, char **argv)
passoutarg = opt_arg();
break;
case OPT_ENGINE:
(void)setup_engine(opt_arg(), 0);
e = setup_engine(opt_arg(), 0);
break;
}
}
@@ -602,6 +603,7 @@ int srp_main(int argc, char **argv)
app_RAND_write_file(randfile);
NCONF_free(conf);
free_index(db);
release_engine(e);
return (ret);
}
#endif

View File

@@ -107,7 +107,7 @@ OPTIONS ts_options[] = {
{"queryfile", OPT_QUERYFILE, '<', "File containing a TS query"},
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
{"inkey", OPT_INKEY, '<', "File with private key for reply"},
{"signer", OPT_SIGNER, 's'},
{"signer", OPT_SIGNER, 's', "Signer certificate file"},
{"chain", OPT_CHAIN, '<', "File with signer CA chain"},
{"verify", OPT_VERIFY, '-', "Verify a TS response"},
{"CApath", OPT_CAPATH, '/', "Path to trusted CA files"},

View File

@@ -60,6 +60,7 @@ OPTIONS verify_options[] = {
int verify_main(int argc, char **argv)
{
ENGINE *e = NULL;
STACK_OF(X509) *untrusted = NULL, *trusted = NULL;
STACK_OF(X509_CRL) *crls = NULL;
X509_STORE *store = NULL;
@@ -140,7 +141,7 @@ int verify_main(int argc, char **argv)
crl_download = 1;
break;
case OPT_ENGINE:
if (setup_engine(opt_arg(), 0) == NULL) {
if ((e = setup_engine(opt_arg(), 0)) == NULL) {
/* Failure message already displayed */
goto end;
}
@@ -191,6 +192,7 @@ int verify_main(int argc, char **argv)
sk_X509_pop_free(untrusted, X509_free);
sk_X509_pop_free(trusted, X509_free);
sk_X509_CRL_pop_free(crls, X509_CRL_free);
release_engine(e);
return (ret < 0 ? 2 : ret);
}

590
apps/vms_term_sock.c Normal file
View File

@@ -0,0 +1,590 @@
/*
* Copyright 2016 VMS Software, Inc. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#ifdef __VMS
# define OPENSSL_SYS_VMS
# pragma message disable DOLLARID
# include <openssl/opensslconf.h>
# if !defined(_POSIX_C_SOURCE) && defined(OPENSSL_SYS_VMS)
/*
* On VMS, you need to define this to get the declaration of fileno(). The
* value 2 is to make sure no function defined in POSIX-2 is left undefined.
*/
# define _POSIX_C_SOURCE 2
# endif
# include <stdio.h>
# undef _POSIX_C_SOURCE
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <inet.h>
# include <unistd.h>
# include <string.h>
# include <errno.h>
# include <starlet.h>
# include <iodef.h>
# ifdef __alpha
# include <iosbdef.h>
# else
typedef struct _iosb { /* Copied from IOSBDEF.H for Alpha */
# pragma __nomember_alignment
__union {
__struct {
unsigned short int iosb$w_status; /* Final I/O status */
__union {
__struct { /* 16-bit byte count variant */
unsigned short int iosb$w_bcnt; /* 16-bit byte count */
__union {
unsigned int iosb$l_dev_depend; /* 32-bit device dependent info */
unsigned int iosb$l_pid; /* 32-bit pid */
} iosb$r_l;
} iosb$r_bcnt_16;
__struct { /* 32-bit byte count variant */
unsigned int iosb$l_bcnt; /* 32-bit byte count (unaligned) */
unsigned short int iosb$w_dev_depend_high; /* 16-bit device dependent info */
} iosb$r_bcnt_32;
} iosb$r_devdepend;
} iosb$r_io_64;
__struct {
__union {
unsigned int iosb$l_getxxi_status; /* Final GETxxI status */
unsigned int iosb$l_reg_status; /* Final $Registry status */
} iosb$r_l_status;
unsigned int iosb$l_reserved; /* Reserved field */
} iosb$r_get_64;
} iosb$r_io_get;
} IOSB;
# if !defined(__VAXC)
# define iosb$w_status iosb$r_io_get.iosb$r_io_64.iosb$w_status
# define iosb$w_bcnt iosb$r_io_get.iosb$r_io_64.iosb$r_devdepend.iosb$r_bcnt_16.iosb$w_bcnt
# define iosb$r_l iosb$r_io_get.iosb$r_io_64.iosb$r_devdepend.iosb$r_bcnt_16.iosb$r_l
# define iosb$l_dev_depend iosb$r_l.iosb$l_dev_depend
# define iosb$l_pid iosb$r_l.iosb$l_pid
# define iosb$l_bcnt iosb$r_io_get.iosb$r_io_64.iosb$r_devdepend.iosb$r_bcnt_32.iosb$l_bcnt
# define iosb$w_dev_depend_high iosb$r_io_get.iosb$r_io_64.iosb$r_devdepend.iosb$r_bcnt_32.iosb$w_dev_depend_high
# define iosb$l_getxxi_status iosb$r_io_get.iosb$r_get_64.iosb$r_l_status.iosb$l_getxxi_status
# define iosb$l_reg_status iosb$r_io_get.iosb$r_get_64.iosb$r_l_status.iosb$l_reg_status
# endif /* #if !defined(__VAXC) */
# endif /* End of IOSBDEF */
# include <efndef.h>
# include <stdlib.h>
# include <ssdef.h>
# include <time.h>
# include <stdarg.h>
# include <descrip.h>
# include "vms_term_sock.h"
# ifdef __alpha
static struct _iosb TerminalDeviceIosb;
# else
IOSB TerminalDeviceIosb;
# endif
static char TerminalDeviceBuff[255 + 2];
static int TerminalSocketPair[2] = {0, 0};
static unsigned short TerminalDeviceChan = 0;
static int CreateSocketPair (int, int, int, int *);
static void SocketPairTimeoutAst (int);
static int TerminalDeviceAst (int);
static void LogMessage (char *, ...);
/*
** Socket Pair Timeout Value (must be 0-59 seconds)
*/
# define SOCKET_PAIR_TIMEOUT_VALUE 20
/*
** Socket Pair Timeout Block which is passed to timeout AST
*/
typedef struct _SocketPairTimeoutBlock {
unsigned short SockChan1;
unsigned short SockChan2;
} SPTB;
# ifdef TERM_SOCK_TEST
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
int main (int argc, char *argv[], char *envp[])
{
char TermBuff[80];
int TermSock,
status,
len;
LogMessage ("Enter 'q' or 'Q' to quit ...");
while (strcasecmp (TermBuff, "Q")) {
/*
** Create the terminal socket
*/
status = TerminalSocket (TERM_SOCK_CREATE, &TermSock);
if (status != TERM_SOCK_SUCCESS)
exit (1);
/*
** Process the terminal input
*/
LogMessage ("Waiting on terminal I/O ...\n");
len = recv (TermSock, TermBuff, sizeof (TermBuff), 0) ;
TermBuff[len] = '\0';
LogMessage ("Received terminal I/O [%s]", TermBuff);
/*
** Delete the terminal socket
*/
status = TerminalSocket (TERM_SOCK_DELETE, &TermSock);
if (status != TERM_SOCK_SUCCESS)
exit (1);
}
return 1;
}
# endif
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
int TerminalSocket (int FunctionCode, int *ReturnSocket)
{
int status;
$DESCRIPTOR (TerminalDeviceDesc, "SYS$COMMAND");
/*
** Process the requested function code
*/
switch (FunctionCode) {
case TERM_SOCK_CREATE:
/*
** Create a socket pair
*/
status = CreateSocketPair (AF_INET, SOCK_STREAM, 0, TerminalSocketPair);
if (status == -1) {
LogMessage ("TerminalSocket: CreateSocketPair () - %08X", status);
if (TerminalSocketPair[0])
close (TerminalSocketPair[0]);
if (TerminalSocketPair[1])
close (TerminalSocketPair[1]);
return (TERM_SOCK_FAILURE);
}
/*
** Assign a channel to the terminal device
*/
status = sys$assign (&TerminalDeviceDesc,
&TerminalDeviceChan,
0, 0, 0);
if (! (status & 1)) {
LogMessage ("TerminalSocket: SYS$ASSIGN () - %08X", status);
close (TerminalSocketPair[0]);
close (TerminalSocketPair[1]);
return (TERM_SOCK_FAILURE);
}
/*
** Queue an async IO to the terminal device
*/
status = sys$qio (EFN$C_ENF,
TerminalDeviceChan,
IO$_READVBLK,
&TerminalDeviceIosb,
TerminalDeviceAst,
0,
TerminalDeviceBuff,
sizeof (TerminalDeviceBuff) - 2,
0, 0, 0, 0);
if (! (status & 1)) {
LogMessage ("TerminalSocket: SYS$QIO () - %08X", status);
close (TerminalSocketPair[0]);
close (TerminalSocketPair[1]);
return (TERM_SOCK_FAILURE);
}
/*
** Return the input side of the socket pair
*/
*ReturnSocket = TerminalSocketPair[1];
break;
case TERM_SOCK_DELETE:
/*
** Cancel any pending IO on the terminal channel
*/
status = sys$cancel (TerminalDeviceChan);
if (! (status & 1)) {
LogMessage ("TerminalSocket: SYS$CANCEL () - %08X", status);
close (TerminalSocketPair[0]);
close (TerminalSocketPair[1]);
return (TERM_SOCK_FAILURE);
}
/*
** Deassign the terminal channel
*/
status = sys$dassgn (TerminalDeviceChan);
if (! (status & 1)) {
LogMessage ("TerminalSocket: SYS$DASSGN () - %08X", status);
close (TerminalSocketPair[0]);
close (TerminalSocketPair[1]);
return (TERM_SOCK_FAILURE);
}
/*
** Close the terminal socket pair
*/
close (TerminalSocketPair[0]);
close (TerminalSocketPair[1]);
/*
** Return the initialized socket
*/
*ReturnSocket = 0;
break;
default:
/*
** Invalid function code
*/
LogMessage ("TerminalSocket: Invalid Function Code - %d", FunctionCode);
return (TERM_SOCK_FAILURE);
break;
}
/*
** Return success
*/
return (TERM_SOCK_SUCCESS);
}
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static int CreateSocketPair (int SocketFamily,
int SocketType,
int SocketProtocol,
int *SocketPair)
{
struct dsc$descriptor AscTimeDesc = {0, DSC$K_DTYPE_T, DSC$K_CLASS_S, NULL};
static const char* LocalHostAddr = {"127.0.0.1"};
unsigned short TcpAcceptChan = 0,
TcpDeviceChan = 0;
unsigned long BinTimeBuff[2];
struct sockaddr_in sin;
char AscTimeBuff[32];
short LocalHostPort;
int status;
unsigned int slen;
# ifdef __alpha
struct _iosb iosb;
# else
IOSB iosb;
# endif
int SockDesc1 = 0,
SockDesc2 = 0;
SPTB sptb;
$DESCRIPTOR (TcpDeviceDesc, "TCPIP$DEVICE");
/*
** Create a socket
*/
SockDesc1 = socket (SocketFamily, SocketType, 0);
if (SockDesc1 < 0) {
LogMessage ("CreateSocketPair: socket () - %d", errno);
return (-1);
}
/*
** Initialize the socket information
*/
slen = sizeof (sin);
memset ((char *) &sin, 0, slen);
sin.sin_family = SocketFamily;
sin.sin_addr.s_addr = inet_addr (LocalHostAddr);
sin.sin_port = 0;
/*
** Bind the socket to the local IP
*/
status = bind (SockDesc1, (struct sockaddr *) &sin, slen);
if (status < 0) {
LogMessage ("CreateSocketPair: bind () - %d", errno);
close (SockDesc1);
return (-1);
}
/*
** Get the socket name so we can save the port number
*/
status = getsockname (SockDesc1, (struct sockaddr *) &sin, &slen);
if (status < 0) {
LogMessage ("CreateSocketPair: getsockname () - %d", errno);
close (SockDesc1);
return (-1);
} else
LocalHostPort = sin.sin_port;
/*
** Setup a listen for the socket
*/
listen (SockDesc1, 5);
/*
** Get the binary (64-bit) time of the specified timeout value
*/
sprintf (AscTimeBuff, "0 0:0:%02d.00", SOCKET_PAIR_TIMEOUT_VALUE);
AscTimeDesc.dsc$w_length = strlen (AscTimeBuff);
AscTimeDesc.dsc$a_pointer = AscTimeBuff;
status = sys$bintim (&AscTimeDesc, BinTimeBuff);
if (! (status & 1)) {
LogMessage ("CreateSocketPair: SYS$BINTIM () - %08X", status);
close (SockDesc1);
return (-1);
}
/*
** Assign another channel to the TCP/IP device for the accept.
** This is the channel that ends up being connected to.
*/
status = sys$assign (&TcpDeviceDesc, &TcpDeviceChan, 0, 0, 0);
if (! (status & 1)) {
LogMessage ("CreateSocketPair: SYS$ASSIGN () - %08X", status);
close (SockDesc1);
return (-1);
}
/*
** Get the channel of the first socket for the accept
*/
TcpAcceptChan = decc$get_sdc (SockDesc1);
/*
** Perform the accept using $QIO so we can do this asynchronously
*/
status = sys$qio (EFN$C_ENF,
TcpAcceptChan,
IO$_ACCESS | IO$M_ACCEPT,
&iosb,
0, 0, 0, 0, 0,
&TcpDeviceChan,
0, 0);
if (! (status & 1)) {
LogMessage ("CreateSocketPair: SYS$QIO () - %08X", status);
close (SockDesc1);
sys$dassgn (TcpDeviceChan);
return (-1);
}
/*
** Create the second socket to do the connect
*/
SockDesc2 = socket (SocketFamily, SocketType, 0);
if (SockDesc2 < 0) {
LogMessage ("CreateSocketPair: socket () - %d", errno);
sys$cancel (TcpAcceptChan);
close (SockDesc1);
sys$dassgn (TcpDeviceChan);
return (-1) ;
}
/*
** Setup the Socket Pair Timeout Block
*/
sptb.SockChan1 = TcpAcceptChan;
sptb.SockChan2 = decc$get_sdc (SockDesc2);
/*
** Before we block on the connect, set a timer that can cancel I/O on our
** two sockets if it never connects.
*/
status = sys$setimr (EFN$C_ENF,
BinTimeBuff,
SocketPairTimeoutAst,
&sptb,
0);
if (! (status & 1)) {
LogMessage ("CreateSocketPair: SYS$SETIMR () - %08X", status);
sys$cancel (TcpAcceptChan);
close (SockDesc1);
close (SockDesc2);
sys$dassgn (TcpDeviceChan);
return (-1);
}
/*
** Now issue the connect
*/
memset ((char *) &sin, 0, sizeof (sin)) ;
sin.sin_family = SocketFamily;
sin.sin_addr.s_addr = inet_addr (LocalHostAddr) ;
sin.sin_port = LocalHostPort ;
status = connect (SockDesc2, (struct sockaddr *) &sin, sizeof (sin));
if (status < 0 ) {
LogMessage ("CreateSocketPair: connect () - %d", errno);
sys$cantim (&sptb, 0);
sys$cancel (TcpAcceptChan);
close (SockDesc1);
close (SockDesc2);
sys$dassgn (TcpDeviceChan);
return (-1);
}
/*
** Wait for the asynch $QIO to finish. Note that if the I/O was aborted
** (SS$_ABORT), then we probably canceled it from the AST routine - so log
** a timeout.
*/
status = sys$synch (EFN$C_ENF, &iosb);
if (! (iosb.iosb$w_status & 1)) {
if (iosb.iosb$w_status == SS$_ABORT)
LogMessage ("CreateSocketPair: SYS$QIO(iosb) timeout");
else {
LogMessage ("CreateSocketPair: SYS$QIO(iosb) - %d",
iosb.iosb$w_status);
sys$cantim (&sptb, 0);
}
close (SockDesc1);
close (SockDesc2);
sys$dassgn (TcpDeviceChan);
return (-1);
}
/*
** Here we're successfully connected, so cancel the timer, convert the
** I/O channel to a socket fd, close the listener socket and return the
** connected pair.
*/
sys$cantim (&sptb, 0);
close (SockDesc1) ;
SocketPair[0] = SockDesc2 ;
SocketPair[1] = socket_fd (TcpDeviceChan);
return (0) ;
}
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static void SocketPairTimeoutAst (int astparm)
{
SPTB *sptb = (SPTB *) astparm;
sys$cancel (sptb->SockChan2); /* Cancel the connect() */
sys$cancel (sptb->SockChan1); /* Cancel the accept() */
return;
}
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static int TerminalDeviceAst (int astparm)
{
int status;
/*
** Terminate the terminal buffer
*/
TerminalDeviceBuff[TerminalDeviceIosb.iosb$w_bcnt] = '\0';
strcat (TerminalDeviceBuff, "\n");
/*
** Send the data read from the terminal device throught the socket pair
*/
send (TerminalSocketPair[0], TerminalDeviceBuff,
TerminalDeviceIosb.iosb$w_bcnt + 1, 0);
/*
** Queue another async IO to the terminal device
*/
status = sys$qio (EFN$C_ENF,
TerminalDeviceChan,
IO$_READVBLK,
&TerminalDeviceIosb,
TerminalDeviceAst,
0,
TerminalDeviceBuff,
sizeof (TerminalDeviceBuff) - 1,
0, 0, 0, 0);
/*
** Return status
*/
return status;
}
/*----------------------------------------------------------------------------*/
/* */
/*----------------------------------------------------------------------------*/
static void LogMessage (char *msg, ...)
{
char *Month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
static unsigned int pid = 0;
va_list args;
time_t CurTime;
struct tm *LocTime;
char MsgBuff[256];
/*
** Get the process pid
*/
if (pid == 0)
pid = getpid ();
/*
** Convert the current time into local time
*/
CurTime = time (NULL);
LocTime = localtime (&CurTime);
/*
** Format the message buffer
*/
sprintf (MsgBuff, "%02d-%s-%04d %02d:%02d:%02d [%08X] %s\n",
LocTime->tm_mday, Month[LocTime->tm_mon],
(LocTime->tm_year + 1900), LocTime->tm_hour, LocTime->tm_min,
LocTime->tm_sec, pid, msg);
/*
** Get any variable arguments and add them to the print of the message
** buffer
*/
va_start (args, msg);
vfprintf (stderr, MsgBuff, args);
va_end (args);
/*
** Flush standard error output
*/
fsync (fileno (stderr));
return;
}
#endif

30
apps/vms_term_sock.h Normal file
View File

@@ -0,0 +1,30 @@
/*
* Copyright 2016 VMS Software, Inc. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#ifndef TERM_SOCK_H
# define TERM_SOCK_H
/*
** Terminal Socket Function Codes
*/
# define TERM_SOCK_CREATE 1
# define TERM_SOCK_DELETE 2
/*
** Terminal Socket Status Codes
*/
# define TERM_SOCK_FAILURE 0
# define TERM_SOCK_SUCCESS 1
/*
** Terminal Socket Prototype
*/
int TerminalSocket (int FunctionCode, int *ReturnSocket);
#endif

View File

@@ -92,7 +92,7 @@ OPTIONS x509_options[] = {
{"ocsp_uri", OPT_OCSP_URI, '-', "Print OCSP Responder URL(s)"},
{"trustout", OPT_TRUSTOUT, '-', "Output a trusted certificate"},
{"clrtrust", OPT_CLRTRUST, '-', "Clear all trusted purposes"},
{"clrext", OPT_CLREXT, '-', "Clear all rejected purposes"},
{"clrext", OPT_CLREXT, '-', "Clear all certificate extensions"},
{"addtrust", OPT_ADDTRUST, 's', "Trust certificate for a given purpose"},
{"addreject", OPT_ADDREJECT, 's',
"Reject certificate for a given purpose"},
@@ -125,9 +125,10 @@ OPTIONS x509_options[] = {
{"CAform", OPT_CAFORM, 'F', "CA format - default PEM"},
{"CAkeyform", OPT_CAKEYFORM, 'F', "CA key format - default PEM"},
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
{"force_pubkey", OPT_FORCE_PUBKEY, '<'},
{"next_serial", OPT_NEXT_SERIAL, '-'},
{"clrreject", OPT_CLRREJECT, '-'},
{"force_pubkey", OPT_FORCE_PUBKEY, '<', "Force the Key to put inside certificate"},
{"next_serial", OPT_NEXT_SERIAL, '-', "Increment current certificate serial number"},
{"clrreject", OPT_CLRREJECT, '-',
"Clears all the prohibited or rejected uses of the certificate"},
{"badsig", OPT_BADSIG, '-', "Corrupt last byte of certificate signature (for test)"},
{"", OPT_MD, '-', "Any supported digest"},
#ifndef OPENSSL_NO_MD5
@@ -626,10 +627,9 @@ int x509_main(int argc, char **argv)
i2a_ASN1_INTEGER(out, X509_get_serialNumber(x));
BIO_printf(out, "\n");
} else if (next_serial == i) {
BIGNUM *bnser;
ASN1_INTEGER *ser;
ser = X509_get_serialNumber(x);
bnser = ASN1_INTEGER_to_BN(ser, NULL);
ASN1_INTEGER *ser = X509_get_serialNumber(x);
BIGNUM *bnser = ASN1_INTEGER_to_BN(ser, NULL);
if (!bnser)
goto end;
if (!BN_add_word(bnser, 1))
@@ -893,6 +893,7 @@ int x509_main(int argc, char **argv)
sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free);
sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free);
ASN1_OBJECT_free(objtmp);
release_engine(e);
OPENSSL_free(passin);
return (ret);
}

View File

@@ -40,12 +40,7 @@ build_script:
test_script:
- cd _build
- nmake test
- cd ..
# Fake deploy script to test installation
deploy_script:
- mkdir _install
- cd _build
- mkdir ..\_install
- nmake install install_docs DESTDIR=..\_install
- cd ..

View File

@@ -179,6 +179,7 @@
# Haswell 4.44/0.63 0.63 0.73 0.63 0.70
# Skylake 2.62/0.63 0.63 0.63 0.63
# Silvermont 5.75/3.54 3.56 4.12 3.87(*) 4.11
# Goldmont 3.82/1.26 1.26 1.29 1.29 1.50
# Bulldozer 5.77/0.70 0.72 0.90 0.70 0.95
#
# (*) Atom Silvermont ECB result is suboptimal because of penalties

View File

@@ -3011,7 +3011,7 @@ _aesp8_xts_enc5x:
vxor $twk0,$twk0,v31
vcipher $out0,$out0,v26
lvsr $inpperm,r0,$taillen # $in5 is no more
lvsr $inpperm,0,$taillen # $in5 is no more
vcipher $out1,$out1,v26
vcipher $out2,$out2,v26
vcipher $out3,$out3,v26

View File

@@ -48,6 +48,7 @@
# Nehalem(**) 7.63 6.88 +11%
# Atom 17.1 16.4 +4%
# Silvermont - 12.9
# Goldmont - 8.85
#
# (*) Comparison is not completely fair, because "this" is ECB,
# i.e. no extra processing such as counter values calculation
@@ -87,6 +88,7 @@
# Nehalem 7.80
# Atom 17.9
# Silvermont 14.0
# Goldmont 10.2
#
# November 2011.
#

View File

@@ -38,6 +38,7 @@
# Nehalem 29.6/40.3/14.6 10.0/11.8
# Atom 57.3/74.2/32.1 60.9/77.2(***)
# Silvermont 52.7/64.0/19.5 48.8/60.8(***)
# Goldmont 38.9/49.0/17.8 10.6/12.6
#
# (*) "Hyper-threading" in the context refers rather to cache shared
# among multiple cores, than to specifically Intel HTT. As vast

View File

@@ -25,7 +25,7 @@ void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value)
{
if (a->value.ptr != NULL) {
ASN1_TYPE **tmp_a = &a;
asn1_primitive_free((ASN1_VALUE **)tmp_a, NULL);
asn1_primitive_free((ASN1_VALUE **)tmp_a, NULL, 0);
}
a->type = type;
if (type == V_ASN1_BOOLEAN)

View File

@@ -11,6 +11,7 @@
#include <limits.h>
#include "internal/cryptlib.h"
#include <openssl/asn1.h>
#include "asn1_locl.h"
static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
long max);
@@ -314,16 +315,23 @@ ASN1_STRING *ASN1_STRING_type_new(int type)
return (ret);
}
void ASN1_STRING_free(ASN1_STRING *a)
void asn1_string_embed_free(ASN1_STRING *a, int embed)
{
if (a == NULL)
return;
if (!(a->flags & ASN1_STRING_FLAG_NDEF))
OPENSSL_free(a->data);
if (!(a->flags & ASN1_STRING_FLAG_EMBED))
if (embed == 0)
OPENSSL_free(a);
}
void ASN1_STRING_free(ASN1_STRING *a)
{
if (a == NULL)
return;
asn1_string_embed_free(a, a->flags & ASN1_STRING_FLAG_EMBED);
}
void ASN1_STRING_clear_free(ASN1_STRING *a)
{
if (a == NULL)

View File

@@ -45,6 +45,8 @@ DEFINE_STACK_OF(MIME_HEADER)
/* Month values for printing out times */
extern const char *_asn1_mon[12];
void asn1_string_embed_free(ASN1_STRING *a, int embed);
int asn1_get_choice_selector(ASN1_VALUE **pval, const ASN1_ITEM *it);
int asn1_set_choice_selector(ASN1_VALUE **pval, int value,
const ASN1_ITEM *it);
@@ -63,7 +65,7 @@ int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval,
int asn1_enc_save(ASN1_VALUE **pval, const unsigned char *in, int inlen,
const ASN1_ITEM *it);
void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed);
void asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt);
ASN1_OBJECT *c2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp,

View File

@@ -225,16 +225,14 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
/* If field not present, try the next one */
if (ret == -1)
continue;
/*
* Set the choice selector here to ensure that the value is
* correctly freed upon error. It may be partially initialized
* even if parsing failed.
*/
asn1_set_choice_selector(pval, i, it);
/* If positive return, read OK, break loop */
if (ret > 0)
break;
/* Otherwise must be an ASN1 parsing error */
/*
* Must be an ASN1 parsing error.
* Free up any partial choice value
*/
asn1_template_free(pchptr, tt);
errtt = tt;
ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);
goto err;
@@ -252,6 +250,8 @@ static int asn1_item_embed_d2i(ASN1_VALUE **pval, const unsigned char **in,
goto err;
}
asn1_set_choice_selector(pval, i, it);
if (asn1_cb && !asn1_cb(ASN1_OP_D2I_POST, pval, it, NULL))
goto auxerr;
*in = p;

View File

@@ -52,11 +52,11 @@ static void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it,
if (it->templates)
asn1_template_free(pval, it->templates);
else
asn1_primitive_free(pval, it);
asn1_primitive_free(pval, it, embed);
break;
case ASN1_ITYPE_MSTRING:
asn1_primitive_free(pval, it);
asn1_primitive_free(pval, it, embed);
break;
case ASN1_ITYPE_CHOICE:
@@ -147,7 +147,7 @@ void asn1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
}
}
void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
{
int utype;
@@ -195,12 +195,12 @@ void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
break;
case V_ASN1_ANY:
asn1_primitive_free(pval, NULL);
asn1_primitive_free(pval, NULL, 0);
OPENSSL_free(*pval);
break;
default:
ASN1_STRING_free((ASN1_STRING *)*pval);
asn1_string_embed_free((ASN1_STRING *)*pval, embed);
break;
}
*pval = NULL;

View File

@@ -604,6 +604,7 @@ static int addrinfo_wrap(int family, int socktype,
DEFINE_RUN_ONCE_STATIC(do_bio_lookup_init)
{
OPENSSL_init_crypto(0, NULL);
bio_lookup_lock = CRYPTO_THREAD_lock_new();
return bio_lookup_lock != NULL;
}

View File

@@ -73,7 +73,11 @@ BIO *BIO_new_file(const char *filename, const char *mode)
if (file == NULL) {
SYSerr(SYS_F_FOPEN, get_last_sys_error());
ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
if (errno == ENOENT)
if (errno == ENOENT
# ifdef ENXIO
|| errno == ENXIO
# endif
)
BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);
else
BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB);

View File

@@ -203,7 +203,7 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
BN_ULONG ret, waste;
asm("divq %4":"=a"(ret), "=d"(waste)
: "a"(l), "d"(h), "g"(d)
: "a"(l), "d"(h), "r"(d)
: "cc");
return ret;

View File

@@ -1157,18 +1157,17 @@ $code.=<<___;
mulx 2*8($aptr),%r15,%r13 # ...
adox -3*8($tptr),%r11
adcx %r15,%r12
adox $zero,%r12
adox -2*8($tptr),%r12
adcx $zero,%r13
adox $zero,%r13
mov $bptr,8(%rsp) # off-load &b[i]
.byte 0x67
mov $mi,%r15
imulq 24(%rsp),$mi # "t[0]"*n0
xor %ebp,%ebp # xor $zero,$zero # cf=0, of=0
mulx 3*8($aptr),%rax,%r14
mov $mi,%rdx
adox -2*8($tptr),%r12
adcx %rax,%r13
adox -1*8($tptr),%r13
adcx $zero,%r14

View File

@@ -105,7 +105,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
({ asm volatile ( \
"divl %4" \
: "=a"(q), "=d"(rem) \
: "a"(n1), "d"(n0), "g"(d0) \
: "a"(n1), "d"(n0), "r"(d0) \
: "cc"); \
q; \
})
@@ -120,7 +120,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
({ asm volatile ( \
"divq %4" \
: "=a"(q), "=d"(rem) \
: "a"(n1), "d"(n0), "g"(d0) \
: "a"(n1), "d"(n0), "r"(d0) \
: "cc"); \
q; \
})

View File

@@ -428,8 +428,8 @@ unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
# endif
# elif defined(__mips) && (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG))
# if defined(__GNUC__) && __GNUC__>=2
# if __GNUC__>4 || (__GNUC__>=4 && __GNUC_MINOR__>=4)
/* "h" constraint is no more since 4.4 */
# if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16
/* "h" constraint is not an option on R6 and was removed in 4.4 */
# define BN_UMULT_HIGH(a,b) (((__uint128_t)(a)*(b))>>64)
# define BN_UMULT_LOHI(low,high,a,b) ({ \
__uint128_t ret=(__uint128_t)(a)*(b); \

View File

@@ -1031,5 +1031,7 @@ void bn_correct_top(BIGNUM *a)
}
a->top = tmp_top;
}
if (a->top == 0)
a->neg = 0;
bn_pollute(a);
}

View File

@@ -23,12 +23,9 @@ char *BN_bn2hex(const BIGNUM *a)
char *buf;
char *p;
if (a->neg && BN_is_zero(a)) {
/* "-0" == 3 bytes including NULL terminator */
buf = OPENSSL_malloc(3);
} else {
buf = OPENSSL_malloc(a->top * BN_BYTES * 2 + 2);
}
if (BN_is_zero(a))
return OPENSSL_strdup("0");
buf = OPENSSL_malloc(a->top * BN_BYTES * 2 + 2);
if (buf == NULL) {
BNerr(BN_F_BN_BN2HEX, ERR_R_MALLOC_FAILURE);
goto err;
@@ -186,10 +183,12 @@ int BN_hex2bn(BIGNUM **bn, const char *a)
}
ret->top = h;
bn_correct_top(ret);
ret->neg = neg;
*bn = ret;
bn_check_top(ret);
/* Don't set the negative flag if it's zero. */
if (ret->top != 0)
ret->neg = neg;
return (num);
err:
if (*bn == NULL)
@@ -241,7 +240,7 @@ int BN_dec2bn(BIGNUM **bn, const char *a)
if (j == BN_DEC_NUM)
j = 0;
l = 0;
while (*a) {
while (--i >= 0) {
l *= 10;
l += *a - '0';
a++;
@@ -253,11 +252,13 @@ int BN_dec2bn(BIGNUM **bn, const char *a)
j = 0;
}
}
ret->neg = neg;
bn_correct_top(ret);
*bn = ret;
bn_check_top(ret);
/* Don't set the negative flag if it's zero. */
if (ret->top != 0)
ret->neg = neg;
return (num);
err:
if (*bn == NULL)
@@ -268,6 +269,7 @@ int BN_dec2bn(BIGNUM **bn, const char *a)
int BN_asc2bn(BIGNUM **bn, const char *a)
{
const char *p = a;
if (*p == '-')
p++;
@@ -278,7 +280,8 @@ int BN_asc2bn(BIGNUM **bn, const char *a)
if (!BN_dec2bn(bn, p))
return 0;
}
if (*a == '-')
/* Don't set the negative flag if it's zero. */
if (*a == '-' && (*bn)->top != 0)
(*bn)->neg = 1;
return 1;
}

View File

@@ -20,15 +20,14 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
int ret = 0, bit, bytes, mask;
time_t tim;
if (bits < 0 || (bits == 1 && top > 0)) {
BNerr(BN_F_BNRAND, BN_R_BITS_TOO_SMALL);
return 0;
}
if (bits == 0) {
if (top != BN_RAND_TOP_ANY || bottom != BN_RAND_BOTTOM_ANY)
goto toosmall;
BN_zero(rnd);
return 1;
}
if (bits < 0 || (bits == 1 && top > 0))
goto toosmall;
bytes = (bits + 7) / 8;
bit = (bits - 1) % 8;
@@ -88,6 +87,10 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
OPENSSL_clear_free(buf, bytes);
bn_check_top(rnd);
return (ret);
toosmall:
BNerr(BN_F_BNRAND, BN_R_BITS_TOO_SMALL);
return 0;
}
int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
@@ -250,5 +253,6 @@ int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
err:
OPENSSL_free(k_bytes);
OPENSSL_cleanse(private_bytes, sizeof(private_bytes));
return ret;
}

View File

@@ -12,10 +12,9 @@
void BN_RECP_CTX_init(BN_RECP_CTX *recp)
{
memset(recp, 0, sizeof(*recp));
bn_init(&(recp->N));
bn_init(&(recp->Nr));
recp->num_bits = 0;
recp->flags = 0;
}
BN_RECP_CTX *BN_RECP_CTX_new(void)
@@ -25,7 +24,8 @@ BN_RECP_CTX *BN_RECP_CTX_new(void)
if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
return (NULL);
BN_RECP_CTX_init(ret);
bn_init(&(ret->N));
bn_init(&(ret->Nr));
ret->flags = BN_FLG_MALLOCED;
return (ret);
}

View File

@@ -133,6 +133,7 @@ my ($a3,$b3,$c3,$d3)=map(($_&~3)+(($_+1)&3),($a2,$b2,$c2,$d2));
$code.=<<___;
.machine "any"
.text
.globl .ChaCha20_ctr32_int
.align 5

View File

@@ -29,6 +29,7 @@
# Sandy Bridge 10.5/+47% 3.20
# Haswell 8.15/+50% 2.83
# Silvermont 17.4/+36% 8.35
# Goldmont 13.4/+40% 4.36
# Sledgehammer 10.2/+54%
# Bulldozer 13.4/+50% 4.38(*)
#

View File

@@ -29,6 +29,7 @@
# Ivy Bridge 6.71/+46% 5.40/6.49 2.41
# Haswell 5.92/+43% 5.20/6.45 2.42 1.23
# Silvermont 12.0/+33% 7.75/7.40 7.03(iii)
# Goldmont 10.6/+17% 5.10/- 3.28
# Sledgehammer 7.28/+52% -/14.2(ii) -
# Bulldozer 9.66/+28% 9.85/11.1 3.06(iv)
# VIA Nano 10.5/+46% 6.72/8.60 6.05

View File

@@ -100,6 +100,9 @@ int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits,
p = BN_CTX_get(ctx);
test = BN_CTX_get(ctx);
if (test == NULL)
goto err;
if (!BN_lshift(test, BN_value_one(), bits - 1))
goto err;

View File

@@ -22,6 +22,7 @@ static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname);
static char *dl_name_converter(DSO *dso, const char *filename);
static char *dl_merger(DSO *dso, const char *filespec1,
const char *filespec2);
static int dl_pathbyaddr(void *addr, char *path, int sz);
static void *dl_globallookup(const char *name);
static DSO_METHOD dso_meth_dl = {
@@ -34,6 +35,7 @@ static DSO_METHOD dso_meth_dl = {
dl_merger,
NULL, /* init */
NULL, /* finish */
dl_pathbyaddr,
dl_globallookup
};
@@ -235,6 +237,38 @@ static char *dl_name_converter(DSO *dso, const char *filename)
return (translated);
}
static int dl_pathbyaddr(void *addr, char *path, int sz)
{
struct shl_descriptor inf;
int i, len;
if (addr == NULL) {
union {
int (*f) (void *, char *, int);
void *p;
} t = {
dl_pathbyaddr
};
addr = t.p;
}
for (i = -1; shl_get_r(i, &inf) == 0; i++) {
if (((size_t)addr >= inf.tstart && (size_t)addr < inf.tend) ||
((size_t)addr >= inf.dstart && (size_t)addr < inf.dend)) {
len = (int)strlen(inf.filename);
if (sz <= 0)
return len + 1;
if (len >= sz)
len = sz - 1;
memcpy(path, inf.filename, len);
path[len++] = 0;
return len;
}
}
return -1;
}
static void *dl_globallookup(const char *name)
{
void *ret;

View File

@@ -44,6 +44,7 @@ static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname);
static char *dlfcn_name_converter(DSO *dso, const char *filename);
static char *dlfcn_merger(DSO *dso, const char *filespec1,
const char *filespec2);
static int dlfcn_pathbyaddr(void *addr, char *path, int sz);
static void *dlfcn_globallookup(const char *name);
static DSO_METHOD dso_meth_dlfcn = {
@@ -56,6 +57,7 @@ static DSO_METHOD dso_meth_dlfcn = {
dlfcn_merger,
NULL, /* init */
NULL, /* finish */
dlfcn_pathbyaddr,
dlfcn_globallookup
};
@@ -306,6 +308,38 @@ static int dladdr(void *address, Dl_info *dl)
}
# endif /* __sgi */
static int dlfcn_pathbyaddr(void *addr, char *path, int sz)
{
# ifdef HAVE_DLINFO
Dl_info dli;
int len;
if (addr == NULL) {
union {
int (*f) (void *, char *, int);
void *p;
} t = {
dlfcn_pathbyaddr
};
addr = t.p;
}
if (dladdr(addr, &dli)) {
len = (int)strlen(dli.dli_fname);
if (sz <= 0)
return len + 1;
if (len >= sz)
len = sz - 1;
memcpy(path, dli.dli_fname, len);
path[len++] = 0;
return len;
}
ERR_add_error_data(2, "dlfcn_pathbyaddr(): ", dlerror());
# endif
return -1;
}
static void *dlfcn_globallookup(const char *name)
{
void *ret = NULL, *handle = dlopen(NULL, RTLD_LAZY);

View File

@@ -38,6 +38,7 @@ static ERR_STRING_DATA DSO_str_functs[] = {
{ERR_FUNC(DSO_F_DSO_LOAD), "DSO_load"},
{ERR_FUNC(DSO_F_DSO_MERGE), "DSO_merge"},
{ERR_FUNC(DSO_F_DSO_NEW_METHOD), "DSO_new_method"},
{ERR_FUNC(DSO_F_DSO_PATHBYADDR), "DSO_pathbyaddr"},
{ERR_FUNC(DSO_F_DSO_SET_FILENAME), "DSO_set_filename"},
{ERR_FUNC(DSO_F_DSO_UP_REF), "DSO_up_ref"},
{ERR_FUNC(DSO_F_VMS_BIND_SYM), "vms_bind_sym"},
@@ -50,6 +51,7 @@ static ERR_STRING_DATA DSO_str_functs[] = {
{ERR_FUNC(DSO_F_WIN32_LOAD), "win32_load"},
{ERR_FUNC(DSO_F_WIN32_MERGER), "win32_merger"},
{ERR_FUNC(DSO_F_WIN32_NAME_CONVERTER), "win32_name_converter"},
{ERR_FUNC(DSO_F_WIN32_PATHBYADDR), "win32_pathbyaddr"},
{ERR_FUNC(DSO_F_WIN32_SPLITTER), "win32_splitter"},
{ERR_FUNC(DSO_F_WIN32_UNLOAD), "win32_unload"},
{0, NULL}

View File

@@ -73,9 +73,11 @@ int DSO_free(DSO *dso)
return 1;
REF_ASSERT_ISNT(i < 0);
if ((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso)) {
DSOerr(DSO_F_DSO_FREE, DSO_R_UNLOAD_FAILED);
return 0;
if ((dso->flags & DSO_FLAG_NO_UNLOAD_ON_FREE) == 0) {
if ((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso)) {
DSOerr(DSO_F_DSO_FREE, DSO_R_UNLOAD_FAILED);
return 0;
}
}
if ((dso->meth->finish != NULL) && !dso->meth->finish(dso)) {
@@ -304,6 +306,33 @@ char *DSO_convert_filename(DSO *dso, const char *filename)
return (result);
}
int DSO_pathbyaddr(void *addr, char *path, int sz)
{
DSO_METHOD *meth = default_DSO_meth;
if (meth == NULL)
meth = DSO_METHOD_openssl();
if (meth->pathbyaddr == NULL) {
DSOerr(DSO_F_DSO_PATHBYADDR, DSO_R_UNSUPPORTED);
return -1;
}
return (*meth->pathbyaddr) (addr, path, sz);
}
DSO *DSO_dsobyaddr(void *addr, int flags)
{
DSO *ret = NULL;
char *filename = NULL;
int len = DSO_pathbyaddr(addr, NULL, 0);
filename = OPENSSL_malloc(len);
if (filename != NULL
&& DSO_pathbyaddr(addr, filename, len) == len)
ret = DSO_load(NULL, filename, NULL, flags);
OPENSSL_free(filename);
return ret;
}
void *DSO_global_lookup(const char *name)
{
DSO_METHOD *meth = default_DSO_meth;

View File

@@ -99,6 +99,8 @@ struct dso_meth_st {
/* [De]Initialisation handlers. */
int (*init) (DSO *dso);
int (*finish) (DSO *dso);
/* Return pathname of the module containing location */
int (*pathbyaddr) (void *addr, char *path, int sz);
/* Perform global symbol lookup, i.e. among *all* modules */
void *(*globallookup) (const char *symname);
};

View File

@@ -50,7 +50,9 @@ static DSO_METHOD dso_meth_vms = {
vms_name_converter,
vms_merger,
NULL, /* init */
NULL /* finish */
NULL, /* finish */
NULL, /* pathbyaddr */
NULL /* globallookup */
};
/*

View File

@@ -77,6 +77,7 @@ static DSO_METHOD dso_meth_win32 = {
win32_merger,
NULL, /* init */
NULL, /* finish */
NULL, /* pathbyaddr */
win32_globallookup
};

View File

@@ -171,6 +171,8 @@ static int eckey_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b)
const EC_GROUP *group = EC_KEY_get0_group(b->pkey.ec);
const EC_POINT *pa = EC_KEY_get0_public_key(a->pkey.ec),
*pb = EC_KEY_get0_public_key(b->pkey.ec);
if (group == NULL || pa == NULL || pb == NULL)
return -2;
r = EC_POINT_cmp(group, pa, pb, NULL);
if (r == 0)
return 1;
@@ -311,6 +313,8 @@ static int ec_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)
{
const EC_GROUP *group_a = EC_KEY_get0_group(a->pkey.ec),
*group_b = EC_KEY_get0_group(b->pkey.ec);
if (group_a == NULL || group_b == NULL)
return -2;
if (EC_GROUP_cmp(group_a, group_b, NULL))
return 0;
else
@@ -341,7 +345,7 @@ static int do_EC_KEY_print(BIO *bp, const EC_KEY *x, int off, ec_print_t ktype)
return 0;
}
if (ktype != EC_KEY_PRINT_PARAM) {
if (ktype != EC_KEY_PRINT_PARAM && EC_KEY_get0_public_key(x) != NULL) {
publen = EC_KEY_key2buf(x, EC_KEY_get_conv_form(x), &pub, NULL);
if (publen == 0)
goto err;

View File

@@ -169,7 +169,7 @@ struct ec_method_st {
/* custom ECDH operation */
int (*ecdh_compute_key)(unsigned char **pout, size_t *poutlen,
const EC_POINT *pub_key, const EC_KEY *ecdh);
} /* EC_METHOD */ ;
};
/*
* Types and functions to manipulate pre-computed values.
@@ -228,11 +228,16 @@ struct ec_group_st {
/* data for ECDSA inverse */
BN_MONT_CTX *mont_data;
/* precomputed values for speed. */
/*
* Precomputed values for speed. The PCT_xxx names match the
* pre_comp.xxx union names; see the SETPRECOMP and HAVEPRECOMP
* macros, below.
*/
enum {
pct_none,
pct_nistp224, pct_nistp256, pct_nistp521, pct_nistz256,
pct_ec } pre_comp_type;
PCT_none,
PCT_nistp224, PCT_nistp256, PCT_nistp521, PCT_nistz256,
PCT_ec
} pre_comp_type;
union {
NISTP224_PRE_COMP *nistp224;
NISTP256_PRE_COMP *nistp256;
@@ -240,12 +245,12 @@ struct ec_group_st {
NISTZ256_PRE_COMP *nistz256;
EC_PRE_COMP *ec;
} pre_comp;
} /* EC_GROUP */ ;
};
#define SETPRECOMP(g, type, pre) \
g->pre_comp_type = pct_##type, g->pre_comp.type = pre
g->pre_comp_type = PCT_##type, g->pre_comp.type = pre
#define HAVEPRECOMP(g, type) \
g->pre_comp_type == pct_##type && g->pre_comp.type != NULL
g->pre_comp_type == PCT_##type && g->pre_comp.type != NULL
struct ec_key_st {
const EC_KEY_METHOD *meth;
@@ -260,7 +265,7 @@ struct ec_key_st {
int flags;
CRYPTO_EX_DATA ex_data;
CRYPTO_RWLOCK *lock;
} /* EC_KEY */ ;
};
struct ec_point_st {
const EC_METHOD *meth;
@@ -274,7 +279,7 @@ struct ec_point_st {
* Z) represents (X/Z^2, Y/Z^3) if Z != 0 */
int Z_is_one; /* enable optimized point arithmetics for
* special case */
} /* EC_POINT */ ;
};
NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *);
NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);
@@ -574,7 +579,7 @@ struct ec_key_method_st {
const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);
int (*verify_sig)(const unsigned char *dgst, int dgst_len,
const ECDSA_SIG *sig, EC_KEY *eckey);
} /* EC_KEY_METHOD */ ;
};
#define EC_KEY_METHOD_DYNAMIC 1

View File

@@ -69,22 +69,22 @@ void EC_pre_comp_free(EC_GROUP *group)
default:
break;
#ifdef ECP_NISTZ256_REFERENCE_IMPLEMENTATION
case pct_nistz256:
case PCT_nistz256:
EC_nistz256_pre_comp_free(group->pre_comp.nistz256);
break;
#endif
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
case pct_nistp224:
case PCT_nistp224:
EC_nistp224_pre_comp_free(group->pre_comp.nistp224);
break;
case pct_nistp256:
case PCT_nistp256:
EC_nistp256_pre_comp_free(group->pre_comp.nistp256);
break;
case pct_nistp521:
case PCT_nistp521:
EC_nistp521_pre_comp_free(group->pre_comp.nistp521);
break;
#endif
case pct_ec:
case PCT_ec:
EC_ec_pre_comp_free(group->pre_comp.ec);
break;
}
@@ -147,22 +147,22 @@ int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src)
dest->pre_comp.ec = NULL;
break;
#ifdef ECP_NISTZ256_REFERENCE_IMPLEMENTATION
case pct_nistz256:
case PCT_nistz256:
dest->pre_comp.nistz256 = EC_nistz256_pre_comp_dup(src->pre_comp.nistz256);
break;
#endif
#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
case pct_nistp224:
case PCT_nistp224:
dest->pre_comp.nistp224 = EC_nistp224_pre_comp_dup(src->pre_comp.nistp224);
break;
case pct_nistp256:
case PCT_nistp256:
dest->pre_comp.nistp256 = EC_nistp256_pre_comp_dup(src->pre_comp.nistp256);
break;
case pct_nistp521:
case PCT_nistp521:
dest->pre_comp.nistp521 = EC_nistp521_pre_comp_dup(src->pre_comp.nistp521);
break;
#endif
case pct_ec:
case PCT_ec:
dest->pre_comp.ec = EC_ec_pre_comp_dup(src->pre_comp.ec);
break;
}

View File

@@ -856,10 +856,10 @@ cryptodev_engine_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
*cipher = cryptodev_aes_ctr();
break;
case NID_aes_192_ctr:
*cipher = cryptodev_aes_ctr_192();
*cipher = cryptodev_aes_192_ctr();
break;
case NID_aes_256_ctr:
*cipher = cryptodev_aes_ctr_256();
*cipher = cryptodev_aes_256_ctr();
break;
# endif
default:

View File

@@ -18,6 +18,7 @@ CRYPTO_ONCE engine_lock_init = CRYPTO_ONCE_STATIC_INIT;
DEFINE_RUN_ONCE(do_engine_lock_init)
{
OPENSSL_init_crypto(0, NULL);
global_engine_lock = CRYPTO_THREAD_lock_new();
return global_engine_lock != NULL;
}

View File

@@ -251,6 +251,7 @@ static void ERR_STATE_free(ERR_STATE *s)
DEFINE_RUN_ONCE_STATIC(do_err_strings_init)
{
OPENSSL_init_crypto(0, NULL);
err_string_lock = CRYPTO_THREAD_lock_new();
return err_string_lock != NULL;
}
@@ -499,6 +500,9 @@ void ERR_error_string_n(unsigned long e, char *buf, size_t len)
const char *ls, *fs, *rs;
unsigned long l, f, r;
if (len == 0)
return;
l = ERR_GET_LIB(e);
f = ERR_GET_FUNC(e);
r = ERR_GET_REASON(e);

View File

@@ -299,7 +299,7 @@ static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
memcpy(out, actx->tag, POLY1305_BLOCK_SIZE);
} else {
if (CRYPTO_memcmp(temp, in, POLY1305_BLOCK_SIZE)) {
memset(out, 0, plen);
memset(out - plen, 0, plen);
return -1;
}
}

View File

@@ -60,7 +60,7 @@ static int rc4_hmac_md5_init_key(EVP_CIPHER_CTX *ctx,
return 1;
}
# if !defined(OPENSSL_NO_ASM) && ( \
# if defined(RC4_ASM) && defined(MD5_ASM) && ( \
defined(__x86_64) || defined(__x86_64__) || \
defined(_M_AMD64) || defined(_M_X64) )
# define STITCHED_CALL

View File

@@ -398,6 +398,7 @@ void EVP_PKEY_free(EVP_PKEY *x)
return;
REF_ASSERT_ISNT(i < 0);
EVP_PKEY_free_it(x);
CRYPTO_THREAD_lock_free(x->lock);
sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
OPENSSL_free(x);
}
@@ -413,7 +414,6 @@ static void EVP_PKEY_free_it(EVP_PKEY *x)
ENGINE_finish(x->engine);
x->engine = NULL;
#endif
CRYPTO_THREAD_lock_free(x->lock);
}
static int unsup_alg(BIO *out, const EVP_PKEY *pkey, int indent,

View File

@@ -38,6 +38,7 @@ static CRYPTO_ONCE ex_data_init = CRYPTO_ONCE_STATIC_INIT;
DEFINE_RUN_ONCE_STATIC(do_ex_data_init)
{
OPENSSL_init_crypto(0, NULL);
ex_data_lock = CRYPTO_THREAD_lock_new();
return ex_data_lock != NULL;
}

View File

@@ -35,7 +35,7 @@ typedef struct ex_callback_st EX_CALLBACK;
DEFINE_STACK_OF(EX_CALLBACK)
typedef struct app_mem_info_st APP_INFO;
DEFINE_LHASH_OF(APP_INFO);
typedef struct mem_st MEM;
DEFINE_LHASH_OF(MEM);

View File

@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <assert.h>
#include <internal/thread_once.h>
#include <internal/dso.h>
static int stopped = 0;
@@ -79,6 +80,34 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_base)
return 0;
OPENSSL_cpuid_setup();
base_inited = 1;
#ifndef OPENSSL_USE_NODELETE
# ifdef DSO_WIN32
{
HMODULE handle = NULL;
BOOL ret;
/* We don't use the DSO route for WIN32 because there is a better way */
ret = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
| GET_MODULE_HANDLE_EX_FLAG_PIN,
(void *)&base_inited, &handle);
return (ret == TRUE) ? 1 : 0;
}
# else
/*
* Deliberately leak a reference to ourselves. This will force the library
* to remain loaded until the atexit() handler is run a process exit.
*/
{
DSO *dso = NULL;
dso = DSO_dsobyaddr(&base_inited, DSO_FLAG_NO_UNLOAD_ON_FREE);
DSO_free(dso);
}
# endif
#endif
return 1;
}
@@ -103,8 +132,8 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_strings)
"err_load_crypto_strings_int()\n");
# endif
ret = err_load_crypto_strings_int();
#endif
load_crypto_strings_inited = 1;
#endif
return ret;
}
@@ -575,6 +604,47 @@ int OPENSSL_atexit(void (*handler)(void))
{
OPENSSL_INIT_STOP *newhand;
#ifndef OPENSSL_USE_NODELETE
{
union {
void *sym;
void (*func)(void);
} handlersym;
handlersym.func = handler;
# ifdef DSO_WIN32
{
HMODULE handle = NULL;
BOOL ret;
/*
* We don't use the DSO route for WIN32 because there is a better
* way
*/
ret = GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
| GET_MODULE_HANDLE_EX_FLAG_PIN,
handlersym.sym, &handle);
if (!ret)
return 0;
}
# else
/*
* Deliberately leak a reference to the handler. This will force the
* library/code containing the handler to remain loaded until we run the
* atexit handler. If -znodelete has been used then this is
* unneccessary.
*/
{
DSO *dso = NULL;
dso = DSO_dsobyaddr(handlersym.sym, DSO_FLAG_NO_UNLOAD_ON_FREE);
DSO_free(dso);
}
# endif
}
#endif
newhand = OPENSSL_malloc(sizeof(*newhand));
if (newhand == NULL)
return 0;

View File

@@ -213,8 +213,8 @@ static int expand(OPENSSL_LHASH *lh)
j = (int)lh->num_alloc_nodes * 2;
n = OPENSSL_realloc(lh->b, (int)(sizeof(OPENSSL_LH_NODE *) * j));
if (n == NULL) {
/* fputs("realloc error in lhash",stderr); */
lh->error++;
lh->num_nodes--;
lh->p = 0;
return 0;
}

View File

@@ -143,8 +143,10 @@ $code=<<___;
#include "arm_arch.h"
.text
#if defined(__thumb2__)
#if defined(__thumb2__) || defined(__clang__)
.syntax unified
#endif
#if defined(__thumb2__)
.thumb
#else
.code 32

Some files were not shown because too many files have changed in this diff Show More