Compare commits
106 Commits
OpenSSL_1_
...
OpenSSL_1_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fcb93613a | ||
|
|
ecb58c1628 | ||
|
|
a969ca5cc8 | ||
|
|
1e4406a854 | ||
|
|
94fbee800b | ||
|
|
c50847c28b | ||
|
|
b1ce2d24dd | ||
|
|
743fb51d2c | ||
|
|
0ed781740d | ||
|
|
d0e542fdc9 | ||
|
|
457863efdf | ||
|
|
5bd4fcc5c2 | ||
|
|
3dd2eebfbc | ||
|
|
d079b387a3 | ||
|
|
8eeaeb4b04 | ||
|
|
0041925844 | ||
|
|
14fa016b2b | ||
|
|
7fdccda37d | ||
|
|
cdc575c46b | ||
|
|
2f0aaf76f3 | ||
|
|
6b7887b0ab | ||
|
|
9ad1b440ae | ||
|
|
9275ad321f | ||
|
|
216a2a5fc6 | ||
|
|
c2c6044933 | ||
|
|
dc95c53c6f | ||
|
|
b24a53dd9a | ||
|
|
ffbe7cd0c5 | ||
|
|
97183a312e | ||
|
|
46ed8aff6d | ||
|
|
6a0a48433b | ||
|
|
ad3d95222d | ||
|
|
18ea747ce4 | ||
|
|
f4f512a853 | ||
|
|
9c2bed0b65 | ||
|
|
ad83334e73 | ||
|
|
2cf4bc9ecd | ||
|
|
c8ac945d59 | ||
|
|
92aa50bc03 | ||
|
|
2f31308b17 | ||
|
|
468d58e712 | ||
|
|
dd4b50ff6a | ||
|
|
030d5b8c97 | ||
|
|
9b73be38ab | ||
|
|
e5bf2f5d4c | ||
|
|
a7096946fa | ||
|
|
4a8362a68b | ||
|
|
25128a11fb | ||
|
|
3deb968fec | ||
|
|
276eb93218 | ||
|
|
29c33e16ac | ||
|
|
bffb696f65 | ||
|
|
fd2d78e70b | ||
|
|
6b1fb9179e | ||
|
|
702175817f | ||
|
|
703ec840dc | ||
|
|
04d706d42a | ||
|
|
b996cecc32 | ||
|
|
7e927da2a5 | ||
|
|
7aa6d2fcf9 | ||
|
|
27b1f137ff | ||
|
|
f63c927e8e | ||
|
|
d572544a2c | ||
|
|
9100840258 | ||
|
|
0f32c83c91 | ||
|
|
80b570142d | ||
|
|
a99b6fcb7c | ||
|
|
02d1a6b3aa | ||
|
|
08e8d58785 | ||
|
|
c90c41f09d | ||
|
|
c47b636a2c | ||
|
|
7200b39ecd | ||
|
|
84c95826de | ||
|
|
63819e6f00 | ||
|
|
8206dba75c | ||
|
|
528ef87850 | ||
|
|
9004c53107 | ||
|
|
f47f99f295 | ||
|
|
00f473b3cc | ||
|
|
356de7146e | ||
|
|
9eab925395 | ||
|
|
22d89c501e | ||
|
|
c06916db9f | ||
|
|
ef7545a3e6 | ||
|
|
fecb4ff331 | ||
|
|
2a4adf19c8 | ||
|
|
44c854ddb9 | ||
|
|
47091035f1 | ||
|
|
f3d51d7740 | ||
|
|
70d3b4b653 | ||
|
|
2fb94e4861 | ||
|
|
1b84893905 | ||
|
|
68b5330040 | ||
|
|
da7ae62abd | ||
|
|
f53337b89c | ||
|
|
f70a5895e3 | ||
|
|
d41bbd0db5 | ||
|
|
49956294fc | ||
|
|
48373e55d1 | ||
|
|
42369021ed | ||
|
|
b00fe7ce18 | ||
|
|
872e3fd502 | ||
|
|
c11ada6c99 | ||
|
|
8f0968850b | ||
|
|
0b96f60a56 | ||
|
|
ab06ff6bee |
171
CHANGES
171
CHANGES
@@ -2,6 +2,116 @@
|
||||
OpenSSL CHANGES
|
||||
_______________
|
||||
|
||||
Changes between 1.0.0i and 1.0.0j [10 May 2012]
|
||||
|
||||
*) Sanity check record length before skipping explicit IV in DTLS
|
||||
to fix DoS attack.
|
||||
|
||||
Thanks to Codenomicon for discovering this issue using Fuzz-o-Matic
|
||||
fuzzing as a service testing platform.
|
||||
(CVE-2012-2333)
|
||||
[Steve Henson]
|
||||
|
||||
*) Initialise tkeylen properly when encrypting CMS messages.
|
||||
Thanks to Solar Designer of Openwall for reporting this issue.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.0h and 1.0.0i [19 Apr 2012]
|
||||
|
||||
*) Check for potentially exploitable overflows in asn1_d2i_read_bio
|
||||
BUF_mem_grow and BUF_mem_grow_clean. Refuse attempts to shrink buffer
|
||||
in CRYPTO_realloc_clean.
|
||||
|
||||
Thanks to Tavis Ormandy, Google Security Team, for discovering this
|
||||
issue and to Adam Langley <agl@chromium.org> for fixing it.
|
||||
(CVE-2012-2110)
|
||||
[Adam Langley (Google), Tavis Ormandy, Google Security Team]
|
||||
|
||||
Changes between 1.0.0g and 1.0.0h [12 Mar 2012]
|
||||
|
||||
*) Fix MMA (Bleichenbacher's attack on PKCS #1 v1.5 RSA padding) weakness
|
||||
in CMS and PKCS7 code. When RSA decryption fails use a random key for
|
||||
content decryption and always return the same error. Note: this attack
|
||||
needs on average 2^20 messages so it only affects automated senders. The
|
||||
old behaviour can be reenabled in the CMS code by setting the
|
||||
CMS_DEBUG_DECRYPT flag: this is useful for debugging and testing where
|
||||
an MMA defence is not necessary.
|
||||
Thanks to Ivan Nestlerode <inestlerode@us.ibm.com> for discovering
|
||||
this issue. (CVE-2012-0884)
|
||||
[Steve Henson]
|
||||
|
||||
*) Fix CVE-2011-4619: make sure we really are receiving a
|
||||
client hello before rejecting multiple SGC restarts. Thanks to
|
||||
Ivan Nestlerode <inestlerode@us.ibm.com> for discovering this bug.
|
||||
[Steve Henson]
|
||||
|
||||
Changes between 1.0.0f and 1.0.0g [18 Jan 2012]
|
||||
|
||||
*) Fix for DTLS DoS issue introduced by fix for CVE-2011-4109.
|
||||
Thanks to Antonio Martin, Enterprise Secure Access Research and
|
||||
Development, Cisco Systems, Inc. for discovering this bug and
|
||||
preparing a fix. (CVE-2012-0050)
|
||||
[Antonio Martin]
|
||||
|
||||
Changes between 1.0.0e and 1.0.0f [4 Jan 2012]
|
||||
|
||||
*) Nadhem Alfardan and Kenny Paterson have discovered an extension
|
||||
of the Vaudenay padding oracle attack on CBC mode encryption
|
||||
which enables an efficient plaintext recovery attack against
|
||||
the OpenSSL implementation of DTLS. Their attack exploits timing
|
||||
differences arising during decryption processing. A research
|
||||
paper describing this attack can be found at:
|
||||
http://www.isg.rhul.ac.uk/~kp/dtls.pdf
|
||||
Thanks go to Nadhem Alfardan and Kenny Paterson of the Information
|
||||
Security Group at Royal Holloway, University of London
|
||||
(www.isg.rhul.ac.uk) for discovering this flaw and to Robin Seggelmann
|
||||
<seggelmann@fh-muenster.de> and Michael Tuexen <tuexen@fh-muenster.de>
|
||||
for preparing the fix. (CVE-2011-4108)
|
||||
[Robin Seggelmann, Michael Tuexen]
|
||||
|
||||
*) Clear bytes used for block padding of SSL 3.0 records.
|
||||
(CVE-2011-4576)
|
||||
[Adam Langley (Google)]
|
||||
|
||||
*) Only allow one SGC handshake restart for SSL/TLS. Thanks to George
|
||||
Kadianakis <desnacked@gmail.com> for discovering this issue and
|
||||
Adam Langley for preparing the fix. (CVE-2011-4619)
|
||||
[Adam Langley (Google)]
|
||||
|
||||
*) Check parameters are not NULL in GOST ENGINE. (CVE-2012-0027)
|
||||
[Andrey Kulikov <amdeich@gmail.com>]
|
||||
|
||||
*) Prevent malformed RFC3779 data triggering an assertion failure.
|
||||
Thanks to Andrew Chi, BBN Technologies, for discovering the flaw
|
||||
and Rob Austein <sra@hactrn.net> for fixing it. (CVE-2011-4577)
|
||||
[Rob Austein <sra@hactrn.net>]
|
||||
|
||||
*) Improved PRNG seeding for VOS.
|
||||
[Paul Green <Paul.Green@stratus.com>]
|
||||
|
||||
*) Fix ssl_ciph.c set-up race.
|
||||
[Adam Langley (Google)]
|
||||
|
||||
*) Fix spurious failures in ecdsatest.c.
|
||||
[Emilia K<>sper (Google)]
|
||||
|
||||
*) Fix the BIO_f_buffer() implementation (which was mixing different
|
||||
interpretations of the '..._len' fields).
|
||||
[Adam Langley (Google)]
|
||||
|
||||
*) Fix handling of BN_BLINDING: now BN_BLINDING_invert_ex (rather than
|
||||
BN_BLINDING_invert_ex) calls BN_BLINDING_update, ensuring that concurrent
|
||||
threads won't reuse the same blinding coefficients.
|
||||
|
||||
This also avoids the need to obtain the CRYPTO_LOCK_RSA_BLINDING
|
||||
lock to call BN_BLINDING_invert_ex, and avoids one use of
|
||||
BN_BLINDING_update for each BN_BLINDING structure (previously,
|
||||
the last update always remained unused).
|
||||
[Emilia K<>sper (Google)]
|
||||
|
||||
*) In ssl3_clear, preserve s3->init_extra along with s3->rbuf.
|
||||
[Bob Buckholz (Google)]
|
||||
|
||||
Changes between 1.0.0d and 1.0.0e [6 Sep 2011]
|
||||
|
||||
*) Fix bug where CRLs with nextUpdate in the past are sometimes accepted
|
||||
@@ -906,8 +1016,67 @@
|
||||
|
||||
*) Change 'Configure' script to enable Camellia by default.
|
||||
[NTT]
|
||||
|
||||
Changes between 0.9.8s and 0.9.8t [18 Jan 2012]
|
||||
|
||||
*) Fix for DTLS DoS issue introduced by fix for CVE-2011-4109.
|
||||
Thanks to Antonio Martin, Enterprise Secure Access Research and
|
||||
Development, Cisco Systems, Inc. for discovering this bug and
|
||||
preparing a fix. (CVE-2012-0050)
|
||||
[Antonio Martin]
|
||||
|
||||
Changes between 0.9.8r and 0.9.8s [xx XXX xxxx]
|
||||
Changes between 0.9.8r and 0.9.8s [4 Jan 2012]
|
||||
|
||||
*) Nadhem Alfardan and Kenny Paterson have discovered an extension
|
||||
of the Vaudenay padding oracle attack on CBC mode encryption
|
||||
which enables an efficient plaintext recovery attack against
|
||||
the OpenSSL implementation of DTLS. Their attack exploits timing
|
||||
differences arising during decryption processing. A research
|
||||
paper describing this attack can be found at:
|
||||
http://www.isg.rhul.ac.uk/~kp/dtls.pdf
|
||||
Thanks go to Nadhem Alfardan and Kenny Paterson of the Information
|
||||
Security Group at Royal Holloway, University of London
|
||||
(www.isg.rhul.ac.uk) for discovering this flaw and to Robin Seggelmann
|
||||
<seggelmann@fh-muenster.de> and Michael Tuexen <tuexen@fh-muenster.de>
|
||||
for preparing the fix. (CVE-2011-4108)
|
||||
[Robin Seggelmann, Michael Tuexen]
|
||||
|
||||
*) Stop policy check failure freeing same buffer twice. (CVE-2011-4109)
|
||||
[Ben Laurie, Kasper <ekasper@google.com>]
|
||||
|
||||
*) Clear bytes used for block padding of SSL 3.0 records.
|
||||
(CVE-2011-4576)
|
||||
[Adam Langley (Google)]
|
||||
|
||||
*) Only allow one SGC handshake restart for SSL/TLS. Thanks to George
|
||||
Kadianakis <desnacked@gmail.com> for discovering this issue and
|
||||
Adam Langley for preparing the fix. (CVE-2011-4619)
|
||||
[Adam Langley (Google)]
|
||||
|
||||
*) Prevent malformed RFC3779 data triggering an assertion failure.
|
||||
Thanks to Andrew Chi, BBN Technologies, for discovering the flaw
|
||||
and Rob Austein <sra@hactrn.net> for fixing it. (CVE-2011-4577)
|
||||
[Rob Austein <sra@hactrn.net>]
|
||||
|
||||
*) Fix ssl_ciph.c set-up race.
|
||||
[Adam Langley (Google)]
|
||||
|
||||
*) Fix spurious failures in ecdsatest.c.
|
||||
[Emilia K<>sper (Google)]
|
||||
|
||||
*) Fix the BIO_f_buffer() implementation (which was mixing different
|
||||
interpretations of the '..._len' fields).
|
||||
[Adam Langley (Google)]
|
||||
|
||||
*) Fix handling of BN_BLINDING: now BN_BLINDING_invert_ex (rather than
|
||||
BN_BLINDING_invert_ex) calls BN_BLINDING_update, ensuring that concurrent
|
||||
threads won't reuse the same blinding coefficients.
|
||||
|
||||
This also avoids the need to obtain the CRYPTO_LOCK_RSA_BLINDING
|
||||
lock to call BN_BLINDING_invert_ex, and avoids one use of
|
||||
BN_BLINDING_update for each BN_BLINDING structure (previously,
|
||||
the last update always remained unused).
|
||||
[Emilia K<>sper (Google)]
|
||||
|
||||
*) Fix SSL memory handling for (EC)DH ciphersuites, in particular
|
||||
for multi-threaded use of ECDH.
|
||||
|
||||
10
Configure
10
Configure
@@ -196,8 +196,8 @@ my %table=(
|
||||
"cc", "cc:-O::(unknown)::::::",
|
||||
|
||||
####VOS Configurations
|
||||
"vos-gcc","gcc:-O3 -Wall -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN::(unknown):VOS:-Wl,-map:BN_LLONG:${no_asm}:::::.so:",
|
||||
"debug-vos-gcc","gcc:-O0 -g -Wall -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG::(unknown):VOS:-Wl,-map:BN_LLONG:${no_asm}:::::.so:",
|
||||
"vos-gcc","gcc:-O3 -Wall -DOPENSSL_SYSNAME_VOS -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN::(unknown):VOS:-Wl,-map:BN_LLONG:${no_asm}:::::.so:",
|
||||
"debug-vos-gcc","gcc:-O0 -g -Wall -DOPENSSL_SYSNAME_VOS -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG::(unknown):VOS:-Wl,-map:BN_LLONG:${no_asm}:::::.so:",
|
||||
|
||||
#### Solaris x86 with GNU C setups
|
||||
# -DOPENSSL_NO_INLINE_ASM switches off inline assembler. We have to do it
|
||||
@@ -553,7 +553,7 @@ my %table=(
|
||||
"darwin64-ppc-cc","cc:-arch ppc64 -O3 -DB_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc64_asm}:osx64:dlfcn:darwin-shared:-fPIC -fno-common:-arch ppc64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"darwin-i386-cc","cc:-arch i386 -O3 -fomit-frame-pointer -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"debug-darwin-i386-cc","cc:-arch i386 -g3 -DL_ENDIAN::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:BN_LLONG RC4_INT RC4_CHUNK DES_UNROLL BF_PTR:${x86_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch i386 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"darwin64-x86_64-cc","cc:-arch x86_64 -O3 -DL_ENDIAN -DMD32_REG_T=int -Wall::-D_REENTRANT:MACOSX:-Wl,-search_paths_first%:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL:".eval{my $asm=$x86_64_asm;$asm=~s/rc4\-[^:]+//;$asm}.":macosx:dlfcn:darwin-shared:-fPIC -fno-common:-arch x86_64 -dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
"debug-darwin-ppc-cc","cc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG -DB_ENDIAN -g -Wall -O::-D_REENTRANT:MACOSX::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:${ppc32_asm}:osx32:dlfcn:darwin-shared:-fPIC:-dynamiclib:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
|
||||
|
||||
##### A/UX
|
||||
@@ -1015,6 +1015,8 @@ foreach (sort (keys %disabled))
|
||||
else
|
||||
{
|
||||
push @skip, $algo;
|
||||
# fix-up crypto/directory name(s)
|
||||
@skip[$#skip]="whrlpool" if $algo eq "whirlpool";
|
||||
print " (skip dir)";
|
||||
|
||||
$depflags .= " -DOPENSSL_NO_$ALGO";
|
||||
@@ -1415,7 +1417,7 @@ else {
|
||||
$aes_obj=$aes_enc;
|
||||
}
|
||||
$wp_obj="" if ($wp_obj =~ /mmx/ && $processor eq "386");
|
||||
if ($wp_obj =~ /\.o$/)
|
||||
if ($wp_obj =~ /\.o$/ && !$disabled{"whirlpool"})
|
||||
{
|
||||
$cflags.=" -DWHIRLPOOL_ASM";
|
||||
}
|
||||
|
||||
22
FAQ
22
FAQ
@@ -10,6 +10,7 @@ OpenSSL - Frequently Asked Questions
|
||||
* Why aren't tools like 'autoconf' and 'libtool' used?
|
||||
* What is an 'engine' version?
|
||||
* How do I check the authenticity of the OpenSSL distribution?
|
||||
* How does the versioning scheme work?
|
||||
|
||||
[LEGAL] Legal questions
|
||||
|
||||
@@ -82,7 +83,7 @@ OpenSSL - Frequently Asked Questions
|
||||
* Which is the current version of OpenSSL?
|
||||
|
||||
The current version is available from <URL: http://www.openssl.org>.
|
||||
OpenSSL 1.0.0e was released on Sep 6th, 2011.
|
||||
OpenSSL 1.0.1c was released on May 10th, 2012.
|
||||
|
||||
In addition to the current stable release, you can also access daily
|
||||
snapshots of the OpenSSL development version at <URL:
|
||||
@@ -108,7 +109,9 @@ In addition, you can read the most current versions at
|
||||
<URL: http://www.openssl.org/docs/>. Note that the online documents refer
|
||||
to the very latest development versions of OpenSSL and may include features
|
||||
not present in released versions. If in doubt refer to the documentation
|
||||
that came with the version of OpenSSL you are using.
|
||||
that came with the version of OpenSSL you are using. The pod format
|
||||
documentation is included in each OpenSSL distribution under the docs
|
||||
directory.
|
||||
|
||||
For information on parts of libcrypto that are not yet documented, you
|
||||
might want to read Ariel Glenn's documentation on SSLeay 0.9, OpenSSL's
|
||||
@@ -173,6 +176,19 @@ just do:
|
||||
|
||||
pgp TARBALL.asc
|
||||
|
||||
* How does the versioning scheme work?
|
||||
|
||||
After the release of OpenSSL 1.0.0 the versioning scheme changed. Letter
|
||||
releases (e.g. 1.0.1a) can only contain bug and security fixes and no
|
||||
new features. Minor releases change the last number (e.g. 1.0.2) and
|
||||
can contain new features that retain binary compatibility. Changes to
|
||||
the middle number are considered major releases and neither source nor
|
||||
binary compatibility is guaranteed.
|
||||
|
||||
Therefore the answer to the common question "when will feature X be
|
||||
backported to OpenSSL 1.0.0/0.9.8?" is "never" but it could appear
|
||||
in the next minor release.
|
||||
|
||||
[LEGAL] =======================================================================
|
||||
|
||||
* Do I need patent licenses to use OpenSSL?
|
||||
@@ -284,7 +300,7 @@ current directory in this case, but this has changed with 0.9.6a.)
|
||||
Check out the CA.pl(1) manual page. This provides a simple wrapper round
|
||||
the 'req', 'verify', 'ca' and 'pkcs12' utilities. For finer control check
|
||||
out the manual pages for the individual utilities and the certificate
|
||||
extensions documentation (currently in doc/openssl.txt).
|
||||
extensions documentation (in ca(1), req(1), x509v3_config(5) )
|
||||
|
||||
|
||||
* Why can't I create certificate requests?
|
||||
|
||||
11
Makefile.org
11
Makefile.org
@@ -172,7 +172,7 @@ CLEARENV= TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS} \
|
||||
$${EXHEADER+EXHEADER} $${HEADER+HEADER} \
|
||||
$${GENERAL+GENERAL} $${CFLAGS+CFLAGS} \
|
||||
$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \
|
||||
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} \
|
||||
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \
|
||||
$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \
|
||||
$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS}
|
||||
|
||||
@@ -322,7 +322,8 @@ libcrypto.pc: Makefile
|
||||
echo 'Description: OpenSSL cryptography library'; \
|
||||
echo 'Version: '$(VERSION); \
|
||||
echo 'Requires: '; \
|
||||
echo 'Libs: -L$${libdir} -lcrypto $(EX_LIBS)'; \
|
||||
echo 'Libs: -L$${libdir} -lcrypto'; \
|
||||
echo 'Libs.private: $(EX_LIBS)'; \
|
||||
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libcrypto.pc
|
||||
|
||||
libssl.pc: Makefile
|
||||
@@ -335,7 +336,8 @@ libssl.pc: Makefile
|
||||
echo 'Description: Secure Sockets Layer and cryptography libraries'; \
|
||||
echo 'Version: '$(VERSION); \
|
||||
echo 'Requires: '; \
|
||||
echo 'Libs: -L$${libdir} -lssl -lcrypto $(EX_LIBS)'; \
|
||||
echo 'Libs: -L$${libdir} -lssl -lcrypto'; \
|
||||
echo 'Libs.private: $(EX_LIBS)'; \
|
||||
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libssl.pc
|
||||
|
||||
openssl.pc: Makefile
|
||||
@@ -348,7 +350,8 @@ openssl.pc: Makefile
|
||||
echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
|
||||
echo 'Version: '$(VERSION); \
|
||||
echo 'Requires: '; \
|
||||
echo 'Libs: -L$${libdir} -lssl -lcrypto $(EX_LIBS)'; \
|
||||
echo 'Libs: -L$${libdir} -lssl -lcrypto'; \
|
||||
echo 'Libs.private: $(EX_LIBS)'; \
|
||||
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > openssl.pc
|
||||
|
||||
Makefile: Makefile.org Configure config
|
||||
|
||||
26
NEWS
26
NEWS
@@ -5,6 +5,32 @@
|
||||
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.0i and OpenSSL 1.0.0j:
|
||||
|
||||
o Fix DTLS record length checking bug CVE-2012-2333
|
||||
|
||||
Major changes between OpenSSL 1.0.0h and OpenSSL 1.0.0i:
|
||||
|
||||
o Fix for ASN1 overflow bug CVE-2012-2110
|
||||
|
||||
Major changes between OpenSSL 1.0.0g and OpenSSL 1.0.0h:
|
||||
|
||||
o Fix for CMS/PKCS#7 MMA CVE-2012-0884
|
||||
o Corrected fix for CVE-2011-4619
|
||||
o Various DTLS fixes.
|
||||
|
||||
Major changes between OpenSSL 1.0.0f and OpenSSL 1.0.0g:
|
||||
|
||||
o Fix for DTLS DoS issue CVE-2012-0050
|
||||
|
||||
Major changes between OpenSSL 1.0.0e and OpenSSL 1.0.0f:
|
||||
|
||||
o Fix for DTLS plaintext recovery attack CVE-2011-4108
|
||||
o Clear block padding bytes of SSL 3.0 records CVE-2011-4576
|
||||
o Only allow one SGC handshake restart for SSL/TLS CVE-2011-4619
|
||||
o Check parameters are not NULL in GOST ENGINE CVE-2012-0027
|
||||
o Check for malformed RFC3779 data CVE-2011-4577
|
||||
|
||||
Major changes between OpenSSL 1.0.0d and OpenSSL 1.0.0e:
|
||||
|
||||
o Fix for CRL vulnerability issue CVE-2011-3207
|
||||
|
||||
2
README
2
README
@@ -1,5 +1,5 @@
|
||||
|
||||
OpenSSL 1.0.0e 6 Sep 2011
|
||||
OpenSSL 1.0.0j 10 May 2012
|
||||
|
||||
Copyright (c) 1998-2011 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
|
||||
7
STATUS
7
STATUS
@@ -1,11 +1,16 @@
|
||||
|
||||
OpenSSL STATUS Last modified at
|
||||
______________ $Date: 2011/09/06 13:01:41 $
|
||||
______________ $Date: 2012/05/10 14:48:54 $
|
||||
|
||||
DEVELOPMENT STATE
|
||||
|
||||
o OpenSSL 1.1.0: Under development...
|
||||
o OpenSSL 1.0.1: Under development...
|
||||
o OpenSSL 1.0.0j: Released on May 10th, 2012
|
||||
o OpenSSL 1.0.0i: Released on April 19th, 2012
|
||||
o OpenSSL 1.0.0h: Released on March 12th, 2012
|
||||
o OpenSSL 1.0.0g: Released on January 18th, 2012
|
||||
o OpenSSL 1.0.0f: Released on January 4th, 2012
|
||||
o OpenSSL 1.0.0e: Released on September 6th, 2011
|
||||
o OpenSSL 1.0.0d: Released on February 8nd, 2011
|
||||
o OpenSSL 1.0.0c: Released on December 2nd, 2010
|
||||
|
||||
6
TABLE
6
TABLE
@@ -1287,7 +1287,7 @@ $bf_obj =
|
||||
$md5_obj = md5-x86_64.o
|
||||
$sha1_obj = sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o
|
||||
$cast_obj =
|
||||
$rc4_obj = rc4-x86_64.o
|
||||
$rc4_obj =
|
||||
$rmd160_obj =
|
||||
$rc5_obj =
|
||||
$wp_obj = wp-x86_64.o
|
||||
@@ -2482,7 +2482,7 @@ $multilib =
|
||||
|
||||
*** debug-vos-gcc
|
||||
$cc = gcc
|
||||
$cflags = -O0 -g -Wall -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG
|
||||
$cflags = -O0 -g -Wall -DOPENSSL_SYSNAME_VOS -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN -DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DCRYPTO_MDEBUG
|
||||
$unistd =
|
||||
$thread_cflag = (unknown)
|
||||
$sys_id = VOS
|
||||
@@ -5303,7 +5303,7 @@ $multilib =
|
||||
|
||||
*** vos-gcc
|
||||
$cc = gcc
|
||||
$cflags = -O3 -Wall -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN
|
||||
$cflags = -O3 -Wall -DOPENSSL_SYSNAME_VOS -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN
|
||||
$unistd =
|
||||
$thread_cflag = (unknown)
|
||||
$sys_id = VOS
|
||||
|
||||
@@ -6,6 +6,7 @@ $! P2: Zlib object library path (optional).
|
||||
$!
|
||||
$! Input: [.UTIL]LIBEAY.NUM,[.xxx.EXE.CRYPTO]SSL_LIBCRYPTO[32].OLB
|
||||
$! [.UTIL]SSLEAY.NUM,[.xxx.EXE.SSL]SSL_LIBSSL[32].OLB
|
||||
$! [.CRYPTO.xxx]OPENSSLCONF.H
|
||||
$! Output: [.xxx.EXE.CRYPTO]SSL_LIBCRYPTO_SHR[32].OPT,.MAP,.EXE
|
||||
$! [.xxx.EXE.SSL]SSL_LIBSSL_SRH[32].OPT,.MAP,.EXE
|
||||
$!
|
||||
@@ -70,6 +71,9 @@ $ endif
|
||||
$ endif
|
||||
$ endif
|
||||
$!
|
||||
$! ----- Prepare info for processing: disabled algorithms info
|
||||
$ gosub read_disabled_algorithms_info
|
||||
$!
|
||||
$ ZLIB = p2
|
||||
$ zlib_lib = ""
|
||||
$ if (ZLIB .nes. "")
|
||||
@@ -384,8 +388,7 @@ $ alg_i = alg_i + 1
|
||||
$ if alg_entry .eqs. "" then goto loop2
|
||||
$ if alg_entry .nes. ","
|
||||
$ then
|
||||
$ if alg_entry .eqs. "KRB5" then goto loop ! Special for now
|
||||
$ if alg_entry .eqs. "STATIC_ENGINE" then goto loop ! Special for now
|
||||
$ if disabled_algorithms - ("," + alg_entry + ",") .nes disabled_algorithms then goto loop
|
||||
$ if f$trnlnm("OPENSSL_NO_"+alg_entry) .nes. "" then goto loop
|
||||
$ goto loop2
|
||||
$ endif
|
||||
@@ -452,3 +455,22 @@ $ endif
|
||||
$ endloop_rvi:
|
||||
$ close vf
|
||||
$ return
|
||||
$
|
||||
$! The disabled algorithms reader
|
||||
$ read_disabled_algorithms_info:
|
||||
$ disabled_algorithms = ","
|
||||
$ open /read cf [.CRYPTO.'ARCH']OPENSSLCONF.H
|
||||
$ loop_rci:
|
||||
$ read/err=endloop_rci/end=endloop_rci cf rci_line
|
||||
$ rci_line = f$edit(rci_line,"TRIM,COMPRESS")
|
||||
$ rci_ei = 0
|
||||
$ if f$extract(0,9,rci_line) .eqs. "# define " then rci_ei = 2
|
||||
$ if f$extract(0,8,rci_line) .eqs. "#define " then rci_ei = 1
|
||||
$ if rci_ei .eq. 0 then goto loop_rci
|
||||
$ rci_e = f$element(rci_ei," ",rci_line)
|
||||
$ if f$extract(0,11,rci_e) .nes. "OPENSSL_NO_" then goto loop_rci
|
||||
$ disabled_algorithms = disabled_algorithms + f$extract(11,999,rci_e) + ","
|
||||
$ goto loop_rci
|
||||
$ endloop_rci:
|
||||
$ close cf
|
||||
$ return
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _POSIX_C_SOURCE
|
||||
#if !defined(_POSIX_C_SOURCE) && defined(OPENSSL_SYS_VMS)
|
||||
#define _POSIX_C_SOURCE 2 /* On VMS, you need to define this to get
|
||||
the declaration of fileno(). The value
|
||||
2 is to make sure no function defined
|
||||
@@ -1215,7 +1215,8 @@ STACK_OF(X509) *load_certs(BIO *err, const char *file, int format,
|
||||
const char *pass, ENGINE *e, const char *desc)
|
||||
{
|
||||
STACK_OF(X509) *certs;
|
||||
load_certs_crls(err, file, format, pass, e, desc, &certs, NULL);
|
||||
if (!load_certs_crls(err, file, format, pass, e, desc, &certs, NULL))
|
||||
return NULL;
|
||||
return certs;
|
||||
}
|
||||
|
||||
@@ -1223,7 +1224,8 @@ STACK_OF(X509_CRL) *load_crls(BIO *err, const char *file, int format,
|
||||
const char *pass, ENGINE *e, const char *desc)
|
||||
{
|
||||
STACK_OF(X509_CRL) *crls;
|
||||
load_certs_crls(err, file, format, pass, e, desc, NULL, &crls);
|
||||
if (!load_certs_crls(err, file, format, pass, e, desc, NULL, &crls))
|
||||
return NULL;
|
||||
return crls;
|
||||
}
|
||||
|
||||
|
||||
@@ -2536,7 +2536,7 @@ static int get_certificate_status(const char *serial, CA_DB *db)
|
||||
|
||||
/* Make it Upper Case */
|
||||
for (i=0; row[DB_serial][i] != '\0'; i++)
|
||||
row[DB_serial][i] = toupper(row[DB_serial][i]);
|
||||
row[DB_serial][i] = toupper((unsigned char)row[DB_serial][i]);
|
||||
|
||||
|
||||
ok=1;
|
||||
|
||||
@@ -618,7 +618,7 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf (bio_err, "-certsout file certificate output file\n");
|
||||
BIO_printf (bio_err, "-signer file signer certificate file\n");
|
||||
BIO_printf (bio_err, "-recip file recipient certificate file for decryption\n");
|
||||
BIO_printf (bio_err, "-skeyid use subject key identifier\n");
|
||||
BIO_printf (bio_err, "-keyid use subject key identifier\n");
|
||||
BIO_printf (bio_err, "-in file input file\n");
|
||||
BIO_printf (bio_err, "-inform arg input format SMIME (default), PEM or DER\n");
|
||||
BIO_printf (bio_err, "-inkey file input private key (if not signer or recipient)\n");
|
||||
|
||||
@@ -145,7 +145,7 @@ localityName = Locality Name (eg, city)
|
||||
organizationalUnitName = Organizational Unit Name (eg, section)
|
||||
#organizationalUnitName_default =
|
||||
|
||||
commonName = Common Name (eg, YOUR name)
|
||||
commonName = Common Name (e.g. server FQDN or YOUR name)
|
||||
commonName_max = 64
|
||||
|
||||
emailAddress = Email Address
|
||||
|
||||
@@ -145,7 +145,7 @@ localityName = Locality Name (eg, city)
|
||||
organizationalUnitName = Organizational Unit Name (eg, section)
|
||||
#organizationalUnitName_default =
|
||||
|
||||
commonName = Common Name (eg, YOUR name)
|
||||
commonName = Common Name (e.g. server FQDN or YOUR name)
|
||||
commonName_max = 64
|
||||
|
||||
emailAddress = Email Address
|
||||
|
||||
@@ -440,13 +440,7 @@ int MAIN(int argc, char **argv)
|
||||
char *jpake_secret = NULL;
|
||||
#endif
|
||||
|
||||
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv23_client_method();
|
||||
#elif !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv3_client_method();
|
||||
#elif !defined(OPENSSL_NO_SSL2)
|
||||
meth=SSLv2_client_method();
|
||||
#endif
|
||||
|
||||
apps_startup();
|
||||
c_Pause=0;
|
||||
@@ -581,7 +575,7 @@ int MAIN(int argc, char **argv)
|
||||
psk_key=*(++argv);
|
||||
for (j = 0; j < strlen(psk_key); j++)
|
||||
{
|
||||
if (isxdigit((int)psk_key[j]))
|
||||
if (isxdigit((unsigned char)psk_key[j]))
|
||||
continue;
|
||||
BIO_printf(bio_err,"Not a hex number '%s'\n",*argv);
|
||||
goto bad;
|
||||
@@ -749,14 +743,13 @@ bad:
|
||||
goto end;
|
||||
}
|
||||
psk_identity = "JPAKE";
|
||||
if (cipher)
|
||||
{
|
||||
BIO_printf(bio_err, "JPAKE sets cipher to PSK\n");
|
||||
goto end;
|
||||
}
|
||||
cipher = "PSK";
|
||||
}
|
||||
|
||||
if (cipher)
|
||||
{
|
||||
BIO_printf(bio_err, "JPAKE sets cipher to PSK\n");
|
||||
goto end;
|
||||
}
|
||||
cipher = "PSK";
|
||||
#endif
|
||||
|
||||
OpenSSL_add_ssl_algorithms();
|
||||
|
||||
@@ -872,13 +872,7 @@ int MAIN(int argc, char *argv[])
|
||||
/* by default do not send a PSK identity hint */
|
||||
static char *psk_identity_hint=NULL;
|
||||
#endif
|
||||
#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv23_server_method();
|
||||
#elif !defined(OPENSSL_NO_SSL3)
|
||||
meth=SSLv3_server_method();
|
||||
#elif !defined(OPENSSL_NO_SSL2)
|
||||
meth=SSLv2_server_method();
|
||||
#endif
|
||||
|
||||
local_argc=argc;
|
||||
local_argv=argv;
|
||||
@@ -1103,7 +1097,7 @@ int MAIN(int argc, char *argv[])
|
||||
psk_key=*(++argv);
|
||||
for (i=0; i<strlen(psk_key); i++)
|
||||
{
|
||||
if (isxdigit((int)psk_key[i]))
|
||||
if (isxdigit((unsigned char)psk_key[i]))
|
||||
continue;
|
||||
BIO_printf(bio_err,"Not a hex number '%s'\n",*argv);
|
||||
goto bad;
|
||||
|
||||
@@ -987,7 +987,7 @@ bad:
|
||||
else
|
||||
{
|
||||
pk=load_key(bio_err,
|
||||
keyfile, FORMAT_PEM, 0,
|
||||
keyfile, keyformat, 0,
|
||||
passin, e, "request key");
|
||||
if (pk == NULL) goto end;
|
||||
}
|
||||
|
||||
6
config
6
config
@@ -825,9 +825,11 @@ esac
|
||||
# options="$options -DATALLA"
|
||||
#fi
|
||||
|
||||
($CC -Wa,--help -c -o /dev/null -x assembler /dev/null 2>&1 | \
|
||||
grep \\--noexecstack) 2>&1 > /dev/null && \
|
||||
if expr "$options" : '.*no\-asm' > /dev/null; then :; else
|
||||
sh -c "$CROSS_COMPILE${CC:-gcc} -Wa,--help -c -o /tmp/null.$$.o -x assembler /dev/null && rm /tmp/null.$$.o" 2>&1 | \
|
||||
grep \\--noexecstack >/dev/null && \
|
||||
options="$options -Wa,--noexecstack"
|
||||
fi
|
||||
|
||||
# gcc < 2.8 does not support -march=ultrasparc
|
||||
if [ "$OUT" = solaris-sparcv9-gcc -a $GCCVER -lt 28 ]
|
||||
|
||||
@@ -1176,6 +1176,7 @@ ___
|
||||
# As UltraSPARC T1, a.k.a. Niagara, has shared FPU, FP nops can have
|
||||
# undesired effect, so just omit them and sacrifice some portion of
|
||||
# percent in performance...
|
||||
$code =~ s/fmovs.*$//gem;
|
||||
$code =~ s/fmovs.*$//gm;
|
||||
|
||||
print $code;
|
||||
close STDOUT; # ensure flush
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/asn1_mac.h>
|
||||
@@ -143,17 +144,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
BUF_MEM *b;
|
||||
unsigned char *p;
|
||||
int i;
|
||||
int ret=-1;
|
||||
ASN1_const_CTX c;
|
||||
int want=HEADER_SIZE;
|
||||
size_t want=HEADER_SIZE;
|
||||
int eos=0;
|
||||
#if defined(__GNUC__) && defined(__ia64)
|
||||
/* pathetic compiler bug in all known versions as of Nov. 2002 */
|
||||
long off=0;
|
||||
#else
|
||||
int off=0;
|
||||
#endif
|
||||
int len=0;
|
||||
size_t off=0;
|
||||
size_t len=0;
|
||||
|
||||
b=BUF_MEM_new();
|
||||
if (b == NULL)
|
||||
@@ -169,7 +164,7 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
{
|
||||
want-=(len-off);
|
||||
|
||||
if (!BUF_MEM_grow_clean(b,len+want))
|
||||
if (len + want < len || !BUF_MEM_grow_clean(b,len+want))
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
@@ -181,7 +176,14 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
goto err;
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
if (len+i < len)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
len+=i;
|
||||
}
|
||||
}
|
||||
/* else data already loaded */
|
||||
|
||||
@@ -206,6 +208,11 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
{
|
||||
/* no data body so go round again */
|
||||
eos++;
|
||||
if (eos < 0)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_HEADER_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
want=HEADER_SIZE;
|
||||
}
|
||||
else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC))
|
||||
@@ -220,10 +227,16 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
else
|
||||
{
|
||||
/* suck in c.slen bytes of data */
|
||||
want=(int)c.slen;
|
||||
want=c.slen;
|
||||
if (want > (len-off))
|
||||
{
|
||||
want-=(len-off);
|
||||
if (want > INT_MAX /* BIO_read takes an int length */ ||
|
||||
len+want < len)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
if (!BUF_MEM_grow_clean(b,len+want))
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ERR_R_MALLOC_FAILURE);
|
||||
@@ -238,11 +251,18 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
ASN1_R_NOT_ENOUGH_DATA);
|
||||
goto err;
|
||||
}
|
||||
/* This can't overflow because
|
||||
* |len+want| didn't overflow. */
|
||||
len+=i;
|
||||
want -= i;
|
||||
want-=i;
|
||||
}
|
||||
}
|
||||
off+=(int)c.slen;
|
||||
if (off + c.slen < off)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
off+=c.slen;
|
||||
if (eos <= 0)
|
||||
{
|
||||
break;
|
||||
@@ -252,9 +272,15 @@ static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
|
||||
}
|
||||
}
|
||||
|
||||
if (off > INT_MAX)
|
||||
{
|
||||
ASN1err(ASN1_F_ASN1_D2I_READ_BIO,ASN1_R_TOO_LONG);
|
||||
goto err;
|
||||
}
|
||||
|
||||
*pb = b;
|
||||
return off;
|
||||
err:
|
||||
if (b != NULL) BUF_MEM_free(b);
|
||||
return(ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -386,8 +386,8 @@ long ASN1_INTEGER_get(const ASN1_INTEGER *a)
|
||||
|
||||
if (a->length > (int)sizeof(long))
|
||||
{
|
||||
/* hmm... a bit ugly */
|
||||
return(0xffffffffL);
|
||||
/* hmm... a bit ugly, return all ones */
|
||||
return -1;
|
||||
}
|
||||
if (a->data == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -377,8 +377,12 @@ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
|
||||
BIO *tmpbio;
|
||||
const ASN1_AUX *aux = it->funcs;
|
||||
ASN1_STREAM_ARG sarg;
|
||||
int rv = 1;
|
||||
|
||||
if (!(flags & SMIME_DETACHED))
|
||||
/* If data is not deteched or resigning then the output BIO is
|
||||
* already set up to finalise when it is written through.
|
||||
*/
|
||||
if (!(flags & SMIME_DETACHED) || (flags & PKCS7_REUSE_DIGEST))
|
||||
{
|
||||
SMIME_crlf_copy(data, out, flags);
|
||||
return 1;
|
||||
@@ -405,7 +409,7 @@ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
|
||||
|
||||
/* Finalize structure */
|
||||
if (aux->asn1_cb(ASN1_OP_DETACHED_POST, &val, it, &sarg) <= 0)
|
||||
return 0;
|
||||
rv = 0;
|
||||
|
||||
/* Now remove any digests prepended to the BIO */
|
||||
|
||||
@@ -416,7 +420,7 @@ static int asn1_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
|
||||
sarg.ndef_bio = tmpbio;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
@@ -486,9 +490,9 @@ ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it)
|
||||
|
||||
if(strcmp(hdr->value, "application/x-pkcs7-signature") &&
|
||||
strcmp(hdr->value, "application/pkcs7-signature")) {
|
||||
sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
|
||||
ASN1err(ASN1_F_SMIME_READ_ASN1,ASN1_R_SIG_INVALID_MIME_TYPE);
|
||||
ERR_add_error_data(2, "type: ", hdr->value);
|
||||
sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
|
||||
sk_BIO_pop_free(parts, BIO_vfree);
|
||||
return NULL;
|
||||
}
|
||||
@@ -801,7 +805,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
|
||||
if(name) {
|
||||
if(!(tmpname = BUF_strdup(name))) return NULL;
|
||||
for(p = tmpname ; *p; p++) {
|
||||
c = *p;
|
||||
c = (unsigned char)*p;
|
||||
if(isupper(c)) {
|
||||
c = tolower(c);
|
||||
*p = c;
|
||||
@@ -811,7 +815,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
|
||||
if(value) {
|
||||
if(!(tmpval = BUF_strdup(value))) return NULL;
|
||||
for(p = tmpval ; *p; p++) {
|
||||
c = *p;
|
||||
c = (unsigned char)*p;
|
||||
if(isupper(c)) {
|
||||
c = tolower(c);
|
||||
*p = c;
|
||||
@@ -835,7 +839,7 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
|
||||
tmpname = BUF_strdup(name);
|
||||
if(!tmpname) return 0;
|
||||
for(p = tmpname ; *p; p++) {
|
||||
c = *p;
|
||||
c = (unsigned char)*p;
|
||||
if(isupper(c)) {
|
||||
c = tolower(c);
|
||||
*p = c;
|
||||
@@ -858,12 +862,17 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
|
||||
static int mime_hdr_cmp(const MIME_HEADER * const *a,
|
||||
const MIME_HEADER * const *b)
|
||||
{
|
||||
if (!(*a)->name || !(*b)->name)
|
||||
return !!(*a)->name - !!(*b)->name;
|
||||
|
||||
return(strcmp((*a)->name, (*b)->name));
|
||||
}
|
||||
|
||||
static int mime_param_cmp(const MIME_PARAM * const *a,
|
||||
const MIME_PARAM * const *b)
|
||||
{
|
||||
if (!(*a)->param_name || !(*b)->param_name)
|
||||
return !!(*a)->param_name - !!(*b)->param_name;
|
||||
return(strcmp((*a)->param_name, (*b)->param_name));
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
|
||||
if (bs->length <= 4)
|
||||
{
|
||||
l=ASN1_INTEGER_get(bs);
|
||||
if (l < 0)
|
||||
if (bs->type == V_ASN1_NEG_INTEGER)
|
||||
{
|
||||
l= -l;
|
||||
neg="-";
|
||||
|
||||
@@ -446,11 +446,11 @@ static int asn1_print_fsname(BIO *out, int indent,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int asn1_print_boolean_ctx(BIO *out, const int bool,
|
||||
static int asn1_print_boolean_ctx(BIO *out, int boolval,
|
||||
const ASN1_PCTX *pctx)
|
||||
{
|
||||
const char *str;
|
||||
switch (bool)
|
||||
switch (boolval)
|
||||
{
|
||||
case -1:
|
||||
str = "BOOL ABSENT";
|
||||
@@ -574,10 +574,10 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
{
|
||||
case V_ASN1_BOOLEAN:
|
||||
{
|
||||
int bool = *(int *)fld;
|
||||
if (bool == -1)
|
||||
bool = it->size;
|
||||
ret = asn1_print_boolean_ctx(out, bool, pctx);
|
||||
int boolval = *(int *)fld;
|
||||
if (boolval == -1)
|
||||
boolval = it->size;
|
||||
ret = asn1_print_boolean_ctx(out, boolval, pctx);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -399,8 +399,7 @@ static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in)
|
||||
/* If type not in bitmask just copy string across */
|
||||
if (!(ASN1_tag2bit(in->type) & ASN1_MASK_CANON))
|
||||
{
|
||||
out->type = in->type;
|
||||
if (!ASN1_STRING_set(out, in->data, in->length))
|
||||
if (!ASN1_STRING_copy(out, in))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,16 @@ EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
|
||||
goto error;
|
||||
}
|
||||
|
||||
key->pkey = ret;
|
||||
/* Check to see if another thread set key->pkey first */
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_EVP_PKEY);
|
||||
if (key->pkey)
|
||||
{
|
||||
EVP_PKEY_free(ret);
|
||||
ret = key->pkey;
|
||||
}
|
||||
else
|
||||
key->pkey = ret;
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_EVP_PKEY);
|
||||
CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY);
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -960,7 +960,6 @@ int BIO_set_tcp_ndelay(int s, int on)
|
||||
#endif
|
||||
return(ret == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int BIO_socket_nbio(int s, int mode)
|
||||
{
|
||||
@@ -973,3 +972,4 @@ int BIO_socket_nbio(int s, int mode)
|
||||
#endif
|
||||
return(ret == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -209,7 +209,7 @@ start:
|
||||
/* add to buffer and return */
|
||||
if (i >= inl)
|
||||
{
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]),in,inl);
|
||||
memcpy(&(ctx->obuf[ctx->obuf_off+ctx->obuf_len]),in,inl);
|
||||
ctx->obuf_len+=inl;
|
||||
return(num+inl);
|
||||
}
|
||||
@@ -219,7 +219,7 @@ start:
|
||||
{
|
||||
if (i > 0) /* lets fill it up if we can */
|
||||
{
|
||||
memcpy(&(ctx->obuf[ctx->obuf_len]),in,i);
|
||||
memcpy(&(ctx->obuf[ctx->obuf_off+ctx->obuf_len]),in,i);
|
||||
in+=i;
|
||||
inl-=i;
|
||||
num+=i;
|
||||
@@ -294,9 +294,9 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
case BIO_C_GET_BUFF_NUM_LINES:
|
||||
ret=0;
|
||||
p1=ctx->ibuf;
|
||||
for (i=ctx->ibuf_off; i<ctx->ibuf_len; i++)
|
||||
for (i=0; i<ctx->ibuf_len; i++)
|
||||
{
|
||||
if (p1[i] == '\n') ret++;
|
||||
if (p1[ctx->ibuf_off + i] == '\n') ret++;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_WPENDING:
|
||||
@@ -399,17 +399,18 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
for (;;)
|
||||
{
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ctx->obuf_len > ctx->obuf_off)
|
||||
if (ctx->obuf_len > 0)
|
||||
{
|
||||
r=BIO_write(b->next_bio,
|
||||
&(ctx->obuf[ctx->obuf_off]),
|
||||
ctx->obuf_len-ctx->obuf_off);
|
||||
ctx->obuf_len);
|
||||
#if 0
|
||||
fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len-ctx->obuf_off,r);
|
||||
fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len,r);
|
||||
#endif
|
||||
BIO_copy_next_retry(b);
|
||||
if (r <= 0) return((long)r);
|
||||
ctx->obuf_off+=r;
|
||||
ctx->obuf_len-=r;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -146,6 +146,7 @@ extern "C" {
|
||||
/* #endif */
|
||||
|
||||
#define BIO_CTRL_DGRAM_QUERY_MTU 40 /* as kernel for current MTU */
|
||||
#define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47
|
||||
#define BIO_CTRL_DGRAM_GET_MTU 41 /* get cached value for MTU */
|
||||
#define BIO_CTRL_DGRAM_SET_MTU 42 /* set cached value for
|
||||
* MTU. want to use this
|
||||
@@ -306,6 +307,15 @@ DECLARE_STACK_OF(BIO)
|
||||
|
||||
typedef struct bio_f_buffer_ctx_struct
|
||||
{
|
||||
/* Buffers are setup like this:
|
||||
*
|
||||
* <---------------------- size ----------------------->
|
||||
* +---------------------------------------------------+
|
||||
* | consumed | remaining | free space |
|
||||
* +---------------------------------------------------+
|
||||
* <-- off --><------- len ------->
|
||||
*/
|
||||
|
||||
/* BIO *bio; */ /* this is now in the BIO struct */
|
||||
int ibuf_size; /* how big is the input buffer */
|
||||
int obuf_size; /* how big is the output buffer */
|
||||
|
||||
@@ -521,40 +521,40 @@ void BIO_free_all(BIO *bio)
|
||||
|
||||
BIO *BIO_dup_chain(BIO *in)
|
||||
{
|
||||
BIO *ret=NULL,*eoc=NULL,*bio,*new;
|
||||
BIO *ret=NULL,*eoc=NULL,*bio,*new_bio;
|
||||
|
||||
for (bio=in; bio != NULL; bio=bio->next_bio)
|
||||
{
|
||||
if ((new=BIO_new(bio->method)) == NULL) goto err;
|
||||
new->callback=bio->callback;
|
||||
new->cb_arg=bio->cb_arg;
|
||||
new->init=bio->init;
|
||||
new->shutdown=bio->shutdown;
|
||||
new->flags=bio->flags;
|
||||
if ((new_bio=BIO_new(bio->method)) == NULL) goto err;
|
||||
new_bio->callback=bio->callback;
|
||||
new_bio->cb_arg=bio->cb_arg;
|
||||
new_bio->init=bio->init;
|
||||
new_bio->shutdown=bio->shutdown;
|
||||
new_bio->flags=bio->flags;
|
||||
|
||||
/* This will let SSL_s_sock() work with stdin/stdout */
|
||||
new->num=bio->num;
|
||||
new_bio->num=bio->num;
|
||||
|
||||
if (!BIO_dup_state(bio,(char *)new))
|
||||
if (!BIO_dup_state(bio,(char *)new_bio))
|
||||
{
|
||||
BIO_free(new);
|
||||
BIO_free(new_bio);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* copy app data */
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new->ex_data,
|
||||
if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_BIO, &new_bio->ex_data,
|
||||
&bio->ex_data))
|
||||
goto err;
|
||||
|
||||
if (ret == NULL)
|
||||
{
|
||||
eoc=new;
|
||||
eoc=new_bio;
|
||||
ret=eoc;
|
||||
}
|
||||
else
|
||||
{
|
||||
BIO_push(eoc,new);
|
||||
eoc=new;
|
||||
BIO_push(eoc,new_bio);
|
||||
eoc=new_bio;
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
|
||||
@@ -547,6 +547,27 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
ret = 0;
|
||||
#endif
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_FALLBACK_MTU:
|
||||
switch (data->peer.sa.sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
ret = 576 - 20 - 8;
|
||||
break;
|
||||
#if OPENSSL_USE_IPV6
|
||||
case AF_INET6:
|
||||
#ifdef IN6_IS_ADDR_V4MAPPED
|
||||
if (IN6_IS_ADDR_V4MAPPED(&data->peer.sa_in6.sin6_addr))
|
||||
ret = 576 - 20 - 8;
|
||||
else
|
||||
#endif
|
||||
ret = 1280 - 40 - 8;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret = 576 - 20 - 8;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BIO_CTRL_DGRAM_GET_MTU:
|
||||
return data->mtu;
|
||||
break;
|
||||
|
||||
@@ -949,7 +949,7 @@ $data=<<EOF;
|
||||
addze r11,r0
|
||||
#mul_add_c(a[3],b[2],c3,c1,c2);
|
||||
$LD r6,`3*$BNSZ`(r4)
|
||||
$LD r7,`2*$BNSZ`(r4)
|
||||
$LD r7,`2*$BNSZ`(r5)
|
||||
$UMULL r8,r6,r7
|
||||
$UMULH r9,r6,r7
|
||||
addc r12,r8,r12
|
||||
|
||||
@@ -527,8 +527,10 @@ $sbit=$num;
|
||||
&jle (&label("sqradd"));
|
||||
|
||||
&mov ($carry,"edx");
|
||||
&lea ("edx",&DWP(0,$sbit,"edx",2));
|
||||
&add ("edx","edx");
|
||||
&shr ($carry,31);
|
||||
&add ("edx",$sbit);
|
||||
&adc ($carry,0);
|
||||
&set_label("sqrlast");
|
||||
&mov ($word,$_n0);
|
||||
&mov ($inp,$_np);
|
||||
|
||||
@@ -126,7 +126,7 @@ struct bn_blinding_st
|
||||
* used only by crypto/rsa/rsa_eay.c, rsa_lib.c */
|
||||
#endif
|
||||
CRYPTO_THREADID tid;
|
||||
unsigned int counter;
|
||||
int counter;
|
||||
unsigned long flags;
|
||||
BN_MONT_CTX *m_ctx;
|
||||
int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
@@ -160,7 +160,10 @@ BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod)
|
||||
if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0)
|
||||
BN_set_flags(ret->mod, BN_FLG_CONSTTIME);
|
||||
|
||||
ret->counter = BN_BLINDING_COUNTER;
|
||||
/* Set the counter to the special value -1
|
||||
* to indicate that this is never-used fresh blinding
|
||||
* that does not need updating before first use. */
|
||||
ret->counter = -1;
|
||||
CRYPTO_THREADID_current(&ret->tid);
|
||||
return(ret);
|
||||
err:
|
||||
@@ -190,7 +193,10 @@ int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (--(b->counter) == 0 && b->e != NULL &&
|
||||
if (b->counter == -1)
|
||||
b->counter = 0;
|
||||
|
||||
if (++b->counter == BN_BLINDING_COUNTER && b->e != NULL &&
|
||||
!(b->flags & BN_BLINDING_NO_RECREATE))
|
||||
{
|
||||
/* re-create blinding parameters */
|
||||
@@ -205,8 +211,8 @@ int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx)
|
||||
|
||||
ret=1;
|
||||
err:
|
||||
if (b->counter == 0)
|
||||
b->counter = BN_BLINDING_COUNTER;
|
||||
if (b->counter == BN_BLINDING_COUNTER)
|
||||
b->counter = 0;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -227,6 +233,12 @@ int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx)
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (b->counter == -1)
|
||||
/* Fresh blinding, doesn't need updating. */
|
||||
b->counter = 0;
|
||||
else if (!BN_BLINDING_update(b,ctx))
|
||||
return(0);
|
||||
|
||||
if (r != NULL)
|
||||
{
|
||||
if (!BN_copy(r, b->Ai)) ret=0;
|
||||
@@ -247,22 +259,19 @@ int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ct
|
||||
int ret;
|
||||
|
||||
bn_check_top(n);
|
||||
if ((b->A == NULL) || (b->Ai == NULL))
|
||||
{
|
||||
BNerr(BN_F_BN_BLINDING_INVERT_EX,BN_R_NOT_INITIALIZED);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (r != NULL)
|
||||
ret = BN_mod_mul(n, n, r, b->mod, ctx);
|
||||
else
|
||||
ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx);
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
if (!BN_BLINDING_update(b,ctx))
|
||||
if (b->Ai == NULL)
|
||||
{
|
||||
BNerr(BN_F_BN_BLINDING_INVERT_EX,BN_R_NOT_INITIALIZED);
|
||||
return(0);
|
||||
}
|
||||
ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx);
|
||||
}
|
||||
|
||||
bn_check_top(n);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,11 @@
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/buffer.h>
|
||||
|
||||
/* LIMIT_BEFORE_EXPANSION is the maximum n such that (n+3)/3*4 < 2**31. That
|
||||
* function is applied in several functions in this file and this limit ensures
|
||||
* that the result fits in an int. */
|
||||
#define LIMIT_BEFORE_EXPANSION 0x5ffffffc
|
||||
|
||||
BUF_MEM *BUF_MEM_new(void)
|
||||
{
|
||||
BUF_MEM *ret;
|
||||
@@ -105,6 +110,12 @@ int BUF_MEM_grow(BUF_MEM *str, size_t len)
|
||||
str->length=len;
|
||||
return(len);
|
||||
}
|
||||
/* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */
|
||||
if (len > LIMIT_BEFORE_EXPANSION)
|
||||
{
|
||||
BUFerr(BUF_F_BUF_MEM_GROW,ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
n=(len+3)/3*4;
|
||||
if (str->data == NULL)
|
||||
ret=OPENSSL_malloc(n);
|
||||
@@ -142,6 +153,12 @@ int BUF_MEM_grow_clean(BUF_MEM *str, size_t len)
|
||||
str->length=len;
|
||||
return(len);
|
||||
}
|
||||
/* This limit is sufficient to ensure (len+3)/3*4 < 2**31 */
|
||||
if (len > LIMIT_BEFORE_EXPANSION)
|
||||
{
|
||||
BUFerr(BUF_F_BUF_MEM_GROW_CLEAN,ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
n=(len+3)/3*4;
|
||||
if (str->data == NULL)
|
||||
ret=OPENSSL_malloc(n);
|
||||
|
||||
@@ -111,6 +111,7 @@ DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
|
||||
#define CMS_PARTIAL 0x4000
|
||||
#define CMS_REUSE_DIGEST 0x8000
|
||||
#define CMS_USE_KEYID 0x10000
|
||||
#define CMS_DEBUG_DECRYPT 0x20000
|
||||
|
||||
const ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms);
|
||||
|
||||
|
||||
@@ -73,6 +73,8 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
|
||||
const EVP_CIPHER *ciph;
|
||||
X509_ALGOR *calg = ec->contentEncryptionAlgorithm;
|
||||
unsigned char iv[EVP_MAX_IV_LENGTH], *piv = NULL;
|
||||
unsigned char *tkey = NULL;
|
||||
size_t tkeylen;
|
||||
|
||||
int ok = 0;
|
||||
|
||||
@@ -137,32 +139,57 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
|
||||
CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
if (enc && !ec->key)
|
||||
tkeylen = EVP_CIPHER_CTX_key_length(ctx);
|
||||
/* Generate random session key */
|
||||
if (!enc || !ec->key)
|
||||
{
|
||||
/* Generate random key */
|
||||
if (!ec->keylen)
|
||||
ec->keylen = EVP_CIPHER_CTX_key_length(ctx);
|
||||
ec->key = OPENSSL_malloc(ec->keylen);
|
||||
if (!ec->key)
|
||||
tkey = OPENSSL_malloc(tkeylen);
|
||||
if (!tkey)
|
||||
{
|
||||
CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,
|
||||
ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if (EVP_CIPHER_CTX_rand_key(ctx, ec->key) <= 0)
|
||||
if (EVP_CIPHER_CTX_rand_key(ctx, tkey) <= 0)
|
||||
goto err;
|
||||
keep_key = 1;
|
||||
}
|
||||
else if (ec->keylen != (unsigned int)EVP_CIPHER_CTX_key_length(ctx))
|
||||
|
||||
if (!ec->key)
|
||||
{
|
||||
ec->key = tkey;
|
||||
ec->keylen = tkeylen;
|
||||
tkey = NULL;
|
||||
if (enc)
|
||||
keep_key = 1;
|
||||
else
|
||||
ERR_clear_error();
|
||||
|
||||
}
|
||||
|
||||
if (ec->keylen != tkeylen)
|
||||
{
|
||||
/* If necessary set key length */
|
||||
if (EVP_CIPHER_CTX_set_key_length(ctx, ec->keylen) <= 0)
|
||||
{
|
||||
CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,
|
||||
CMS_R_INVALID_KEY_LENGTH);
|
||||
goto err;
|
||||
/* Only reveal failure if debugging so we don't
|
||||
* leak information which may be useful in MMA.
|
||||
*/
|
||||
if (enc || ec->debug)
|
||||
{
|
||||
CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO,
|
||||
CMS_R_INVALID_KEY_LENGTH);
|
||||
goto err;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Use random key */
|
||||
OPENSSL_cleanse(ec->key, ec->keylen);
|
||||
OPENSSL_free(ec->key);
|
||||
ec->key = tkey;
|
||||
ec->keylen = tkeylen;
|
||||
tkey = NULL;
|
||||
ERR_clear_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +225,11 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
|
||||
OPENSSL_free(ec->key);
|
||||
ec->key = NULL;
|
||||
}
|
||||
if (tkey)
|
||||
{
|
||||
OPENSSL_cleanse(tkey, tkeylen);
|
||||
OPENSSL_free(tkey);
|
||||
}
|
||||
if (ok)
|
||||
return b;
|
||||
BIO_free(b);
|
||||
|
||||
@@ -371,6 +371,8 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms,
|
||||
unsigned char *ek = NULL;
|
||||
size_t eklen;
|
||||
int ret = 0;
|
||||
CMS_EncryptedContentInfo *ec;
|
||||
ec = cms->d.envelopedData->encryptedContentInfo;
|
||||
|
||||
if (ktri->pkey == NULL)
|
||||
{
|
||||
@@ -417,8 +419,14 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms,
|
||||
|
||||
ret = 1;
|
||||
|
||||
cms->d.envelopedData->encryptedContentInfo->key = ek;
|
||||
cms->d.envelopedData->encryptedContentInfo->keylen = eklen;
|
||||
if (ec->key)
|
||||
{
|
||||
OPENSSL_cleanse(ec->key, ec->keylen);
|
||||
OPENSSL_free(ec->key);
|
||||
}
|
||||
|
||||
ec->key = ek;
|
||||
ec->keylen = eklen;
|
||||
|
||||
err:
|
||||
if (pctx)
|
||||
|
||||
@@ -175,6 +175,8 @@ struct CMS_EncryptedContentInfo_st
|
||||
const EVP_CIPHER *cipher;
|
||||
unsigned char *key;
|
||||
size_t keylen;
|
||||
/* Set to 1 if we are debugging decrypt and don't fake keys for MMA */
|
||||
int debug;
|
||||
};
|
||||
|
||||
struct CMS_RecipientInfo_st
|
||||
|
||||
@@ -611,7 +611,10 @@ int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert)
|
||||
STACK_OF(CMS_RecipientInfo) *ris;
|
||||
CMS_RecipientInfo *ri;
|
||||
int i, r;
|
||||
int debug = 0;
|
||||
ris = CMS_get0_RecipientInfos(cms);
|
||||
if (ris)
|
||||
debug = cms->d.envelopedData->encryptedContentInfo->debug;
|
||||
for (i = 0; i < sk_CMS_RecipientInfo_num(ris); i++)
|
||||
{
|
||||
ri = sk_CMS_RecipientInfo_value(ris, i);
|
||||
@@ -625,17 +628,38 @@ int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert)
|
||||
CMS_RecipientInfo_set0_pkey(ri, pk);
|
||||
r = CMS_RecipientInfo_decrypt(cms, ri);
|
||||
CMS_RecipientInfo_set0_pkey(ri, NULL);
|
||||
if (r > 0)
|
||||
return 1;
|
||||
if (cert)
|
||||
{
|
||||
/* If not debugging clear any error and
|
||||
* return success to avoid leaking of
|
||||
* information useful to MMA
|
||||
*/
|
||||
if (!debug)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return 1;
|
||||
}
|
||||
if (r > 0)
|
||||
return 1;
|
||||
CMSerr(CMS_F_CMS_DECRYPT_SET1_PKEY,
|
||||
CMS_R_DECRYPT_ERROR);
|
||||
return 0;
|
||||
}
|
||||
ERR_clear_error();
|
||||
/* If no cert and not debugging don't leave loop
|
||||
* after first successful decrypt. Always attempt
|
||||
* to decrypt all recipients to avoid leaking timing
|
||||
* of a successful decrypt.
|
||||
*/
|
||||
else if (r > 0 && debug)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* If no cert and not debugging always return success */
|
||||
if (!cert && !debug)
|
||||
{
|
||||
ERR_clear_error();
|
||||
return 1;
|
||||
}
|
||||
|
||||
CMSerr(CMS_F_CMS_DECRYPT_SET1_PKEY, CMS_R_NO_MATCHING_RECIPIENT);
|
||||
return 0;
|
||||
@@ -694,9 +718,14 @@ int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert,
|
||||
}
|
||||
if (!dcont && !check_content(cms))
|
||||
return 0;
|
||||
if (flags & CMS_DEBUG_DECRYPT)
|
||||
cms->d.envelopedData->encryptedContentInfo->debug = 1;
|
||||
else
|
||||
cms->d.envelopedData->encryptedContentInfo->debug = 0;
|
||||
if (!pk && !cert && !dcont && !out)
|
||||
return 1;
|
||||
if (pk && !CMS_decrypt_set1_pkey(cms, pk, cert))
|
||||
return 0;
|
||||
|
||||
cont = CMS_dataInit(cms, dcont);
|
||||
if (!cont)
|
||||
return 0;
|
||||
|
||||
@@ -887,7 +887,7 @@ int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_
|
||||
field_sqr = group->meth->field_sqr;
|
||||
|
||||
/* only support affine coordinates */
|
||||
if (!point->Z_is_one) goto err;
|
||||
if (!point->Z_is_one) return -1;
|
||||
|
||||
if (ctx == NULL)
|
||||
{
|
||||
|
||||
@@ -286,9 +286,13 @@ int test_builtin(BIO *out)
|
||||
size_t crv_len = 0, n = 0;
|
||||
EC_KEY *eckey = NULL, *wrong_eckey = NULL;
|
||||
EC_GROUP *group;
|
||||
ECDSA_SIG *ecdsa_sig = NULL;
|
||||
unsigned char digest[20], wrong_digest[20];
|
||||
unsigned char *signature = NULL;
|
||||
unsigned int sig_len;
|
||||
unsigned char *signature = NULL;
|
||||
const unsigned char *sig_ptr;
|
||||
unsigned char *sig_ptr2;
|
||||
unsigned char *raw_buf = NULL;
|
||||
unsigned int sig_len, degree, r_len, s_len, bn_len, buf_len;
|
||||
int nid, ret = 0;
|
||||
|
||||
/* fill digest values with some random data */
|
||||
@@ -338,7 +342,8 @@ int test_builtin(BIO *out)
|
||||
if (EC_KEY_set_group(eckey, group) == 0)
|
||||
goto builtin_err;
|
||||
EC_GROUP_free(group);
|
||||
if (EC_GROUP_get_degree(EC_KEY_get0_group(eckey)) < 160)
|
||||
degree = EC_GROUP_get_degree(EC_KEY_get0_group(eckey));
|
||||
if (degree < 160)
|
||||
/* drop the curve */
|
||||
{
|
||||
EC_KEY_free(eckey);
|
||||
@@ -414,26 +419,89 @@ int test_builtin(BIO *out)
|
||||
}
|
||||
BIO_printf(out, ".");
|
||||
(void)BIO_flush(out);
|
||||
/* modify a single byte of the signature */
|
||||
offset = signature[10] % sig_len;
|
||||
dirt = signature[11];
|
||||
signature[offset] ^= dirt ? dirt : 1;
|
||||
/* wrong length */
|
||||
if (ECDSA_verify(0, digest, 20, signature, sig_len - 1,
|
||||
eckey) == 1)
|
||||
{
|
||||
BIO_printf(out, " failed\n");
|
||||
goto builtin_err;
|
||||
}
|
||||
BIO_printf(out, ".");
|
||||
(void)BIO_flush(out);
|
||||
|
||||
/* Modify a single byte of the signature: to ensure we don't
|
||||
* garble the ASN1 structure, we read the raw signature and
|
||||
* modify a byte in one of the bignums directly. */
|
||||
sig_ptr = signature;
|
||||
if ((ecdsa_sig = d2i_ECDSA_SIG(NULL, &sig_ptr, sig_len)) == NULL)
|
||||
{
|
||||
BIO_printf(out, " failed\n");
|
||||
goto builtin_err;
|
||||
}
|
||||
|
||||
/* Store the two BIGNUMs in raw_buf. */
|
||||
r_len = BN_num_bytes(ecdsa_sig->r);
|
||||
s_len = BN_num_bytes(ecdsa_sig->s);
|
||||
bn_len = (degree + 7) / 8;
|
||||
if ((r_len > bn_len) || (s_len > bn_len))
|
||||
{
|
||||
BIO_printf(out, " failed\n");
|
||||
goto builtin_err;
|
||||
}
|
||||
buf_len = 2 * bn_len;
|
||||
if ((raw_buf = OPENSSL_malloc(buf_len)) == NULL)
|
||||
goto builtin_err;
|
||||
/* Pad the bignums with leading zeroes. */
|
||||
memset(raw_buf, 0, buf_len);
|
||||
BN_bn2bin(ecdsa_sig->r, raw_buf + bn_len - r_len);
|
||||
BN_bn2bin(ecdsa_sig->s, raw_buf + buf_len - s_len);
|
||||
|
||||
/* Modify a single byte in the buffer. */
|
||||
offset = raw_buf[10] % buf_len;
|
||||
dirt = raw_buf[11] ? raw_buf[11] : 1;
|
||||
raw_buf[offset] ^= dirt;
|
||||
/* Now read the BIGNUMs back in from raw_buf. */
|
||||
if ((BN_bin2bn(raw_buf, bn_len, ecdsa_sig->r) == NULL) ||
|
||||
(BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL))
|
||||
goto builtin_err;
|
||||
|
||||
sig_ptr2 = signature;
|
||||
sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr2);
|
||||
if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) == 1)
|
||||
{
|
||||
BIO_printf(out, " failed\n");
|
||||
goto builtin_err;
|
||||
}
|
||||
/* Sanity check: undo the modification and verify signature. */
|
||||
raw_buf[offset] ^= dirt;
|
||||
if ((BN_bin2bn(raw_buf, bn_len, ecdsa_sig->r) == NULL) ||
|
||||
(BN_bin2bn(raw_buf + bn_len, bn_len, ecdsa_sig->s) == NULL))
|
||||
goto builtin_err;
|
||||
|
||||
sig_ptr2 = signature;
|
||||
sig_len = i2d_ECDSA_SIG(ecdsa_sig, &sig_ptr2);
|
||||
if (ECDSA_verify(0, digest, 20, signature, sig_len, eckey) != 1)
|
||||
{
|
||||
BIO_printf(out, " failed\n");
|
||||
goto builtin_err;
|
||||
}
|
||||
BIO_printf(out, ".");
|
||||
(void)BIO_flush(out);
|
||||
|
||||
BIO_printf(out, " ok\n");
|
||||
/* cleanup */
|
||||
/* clean bogus errors */
|
||||
ERR_clear_error();
|
||||
OPENSSL_free(signature);
|
||||
signature = NULL;
|
||||
EC_KEY_free(eckey);
|
||||
eckey = NULL;
|
||||
EC_KEY_free(wrong_eckey);
|
||||
wrong_eckey = NULL;
|
||||
ECDSA_SIG_free(ecdsa_sig);
|
||||
ecdsa_sig = NULL;
|
||||
OPENSSL_free(raw_buf);
|
||||
raw_buf = NULL;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
@@ -442,8 +510,12 @@ builtin_err:
|
||||
EC_KEY_free(eckey);
|
||||
if (wrong_eckey)
|
||||
EC_KEY_free(wrong_eckey);
|
||||
if (ecdsa_sig)
|
||||
ECDSA_SIG_free(ecdsa_sig);
|
||||
if (signature)
|
||||
OPENSSL_free(signature);
|
||||
if (raw_buf)
|
||||
OPENSSL_free(raw_buf);
|
||||
if (curves)
|
||||
OPENSSL_free(curves);
|
||||
|
||||
|
||||
@@ -79,8 +79,6 @@ struct dev_crypto_state {
|
||||
unsigned char digest_res[HASH_MAX_LEN];
|
||||
char *mac_data;
|
||||
int mac_len;
|
||||
|
||||
int copy;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -200,6 +198,7 @@ get_dev_crypto(void)
|
||||
|
||||
if ((fd = open_dev_crypto()) == -1)
|
||||
return (-1);
|
||||
#ifndef CRIOGET_NOT_NEEDED
|
||||
if (ioctl(fd, CRIOGET, &retfd) == -1)
|
||||
return (-1);
|
||||
|
||||
@@ -208,9 +207,19 @@ get_dev_crypto(void)
|
||||
close(retfd);
|
||||
return (-1);
|
||||
}
|
||||
#else
|
||||
retfd = fd;
|
||||
#endif
|
||||
return (retfd);
|
||||
}
|
||||
|
||||
static void put_dev_crypto(int fd)
|
||||
{
|
||||
#ifndef CRIOGET_NOT_NEEDED
|
||||
close(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Caching version for asym operations */
|
||||
static int
|
||||
get_asym_dev_crypto(void)
|
||||
@@ -252,7 +261,7 @@ get_cryptodev_ciphers(const int **cnids)
|
||||
ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
|
||||
nids[count++] = ciphers[i].nid;
|
||||
}
|
||||
close(fd);
|
||||
put_dev_crypto(fd);
|
||||
|
||||
if (count > 0)
|
||||
*cnids = nids;
|
||||
@@ -291,7 +300,7 @@ get_cryptodev_digests(const int **cnids)
|
||||
ioctl(fd, CIOCFSESSION, &sess.ses) != -1)
|
||||
nids[count++] = digests[i].nid;
|
||||
}
|
||||
close(fd);
|
||||
put_dev_crypto(fd);
|
||||
|
||||
if (count > 0)
|
||||
*cnids = nids;
|
||||
@@ -436,7 +445,7 @@ cryptodev_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
sess->cipher = cipher;
|
||||
|
||||
if (ioctl(state->d_fd, CIOCGSESSION, sess) == -1) {
|
||||
close(state->d_fd);
|
||||
put_dev_crypto(state->d_fd);
|
||||
state->d_fd = -1;
|
||||
return (0);
|
||||
}
|
||||
@@ -473,7 +482,7 @@ cryptodev_cleanup(EVP_CIPHER_CTX *ctx)
|
||||
} else {
|
||||
ret = 1;
|
||||
}
|
||||
close(state->d_fd);
|
||||
put_dev_crypto(state->d_fd);
|
||||
state->d_fd = -1;
|
||||
|
||||
return (ret);
|
||||
@@ -686,7 +695,7 @@ static int cryptodev_digest_init(EVP_MD_CTX *ctx)
|
||||
sess->mac = digest;
|
||||
|
||||
if (ioctl(state->d_fd, CIOCGSESSION, sess) < 0) {
|
||||
close(state->d_fd);
|
||||
put_dev_crypto(state->d_fd);
|
||||
state->d_fd = -1;
|
||||
printf("cryptodev_digest_init: Open session failed\n");
|
||||
return (0);
|
||||
@@ -758,14 +767,12 @@ static int cryptodev_digest_final(EVP_MD_CTX *ctx, unsigned char *md)
|
||||
if (! (ctx->flags & EVP_MD_CTX_FLAG_ONESHOT) ) {
|
||||
/* if application doesn't support one buffer */
|
||||
memset(&cryp, 0, sizeof(cryp));
|
||||
|
||||
cryp.ses = sess->ses;
|
||||
cryp.flags = 0;
|
||||
cryp.len = state->mac_len;
|
||||
cryp.src = state->mac_data;
|
||||
cryp.dst = NULL;
|
||||
cryp.mac = (caddr_t)md;
|
||||
|
||||
if (ioctl(state->d_fd, CIOCCRYPT, &cryp) < 0) {
|
||||
printf("cryptodev_digest_final: digest failed\n");
|
||||
return (0);
|
||||
@@ -786,6 +793,9 @@ static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
|
||||
struct dev_crypto_state *state = ctx->md_data;
|
||||
struct session_op *sess = &state->d_sess;
|
||||
|
||||
if (state == NULL)
|
||||
return 0;
|
||||
|
||||
if (state->d_fd < 0) {
|
||||
printf("cryptodev_digest_cleanup: illegal input\n");
|
||||
return (0);
|
||||
@@ -797,16 +807,13 @@ static int cryptodev_digest_cleanup(EVP_MD_CTX *ctx)
|
||||
state->mac_len = 0;
|
||||
}
|
||||
|
||||
if (state->copy)
|
||||
return 1;
|
||||
|
||||
if (ioctl(state->d_fd, CIOCFSESSION, &sess->ses) < 0) {
|
||||
printf("cryptodev_digest_cleanup: failed to close session\n");
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = 1;
|
||||
}
|
||||
close(state->d_fd);
|
||||
put_dev_crypto(state->d_fd);
|
||||
state->d_fd = -1;
|
||||
|
||||
return (ret);
|
||||
@@ -816,15 +823,39 @@ static int cryptodev_digest_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from)
|
||||
{
|
||||
struct dev_crypto_state *fstate = from->md_data;
|
||||
struct dev_crypto_state *dstate = to->md_data;
|
||||
struct session_op *sess;
|
||||
int digest;
|
||||
|
||||
memcpy(dstate, fstate, sizeof(struct dev_crypto_state));
|
||||
if (dstate == NULL || fstate == NULL)
|
||||
return 1;
|
||||
|
||||
if (fstate->mac_len != 0) {
|
||||
dstate->mac_data = OPENSSL_malloc(fstate->mac_len);
|
||||
memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len);
|
||||
memcpy(dstate, fstate, sizeof(struct dev_crypto_state));
|
||||
|
||||
sess = &dstate->d_sess;
|
||||
|
||||
digest = digest_nid_to_cryptodev(to->digest->type);
|
||||
|
||||
sess->mackey = dstate->dummy_mac_key;
|
||||
sess->mackeylen = digest_key_length(to->digest->type);
|
||||
sess->mac = digest;
|
||||
|
||||
dstate->d_fd = get_dev_crypto();
|
||||
|
||||
if (ioctl(dstate->d_fd, CIOCGSESSION, sess) < 0) {
|
||||
put_dev_crypto(dstate->d_fd);
|
||||
dstate->d_fd = -1;
|
||||
printf("cryptodev_digest_init: Open session failed\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
dstate->copy = 1;
|
||||
if (fstate->mac_len != 0) {
|
||||
if (fstate->mac_data != NULL)
|
||||
{
|
||||
dstate->mac_data = OPENSSL_malloc(fstate->mac_len);
|
||||
memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len);
|
||||
dstate->mac_len = fstate->mac_len;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1347,11 +1378,11 @@ ENGINE_load_cryptodev(void)
|
||||
* find out what asymmetric crypto algorithms we support
|
||||
*/
|
||||
if (ioctl(fd, CIOCASYMFEAT, &cryptodev_asymfeat) == -1) {
|
||||
close(fd);
|
||||
put_dev_crypto(fd);
|
||||
ENGINE_free(engine);
|
||||
return;
|
||||
}
|
||||
close(fd);
|
||||
put_dev_crypto(fd);
|
||||
|
||||
if (!ENGINE_set_id(engine, "cryptodev") ||
|
||||
!ENGINE_set_name(engine, "BSD cryptodev engine") ||
|
||||
|
||||
@@ -361,6 +361,10 @@ void *CRYPTO_realloc_clean(void *str, int old_len, int num, const char *file,
|
||||
|
||||
if (num <= 0) return NULL;
|
||||
|
||||
/* We don't support shrinking the buffer. Note the memcpy that copies
|
||||
* |old_len| bytes to the new buffer, below. */
|
||||
if (num < old_len) return NULL;
|
||||
|
||||
if (realloc_debug_func != NULL)
|
||||
realloc_debug_func(str, NULL, num, file, line, 0);
|
||||
ret=malloc_ex_func(num,file,line);
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
#define OPENSSL_VERSION_NUMBER 0x1000005fL
|
||||
#define OPENSSL_VERSION_NUMBER 0x100000afL
|
||||
#ifdef OPENSSL_FIPS
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0e-fips 6 Sep 2011"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0j-fips 10 May 2012"
|
||||
#else
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0e 6 Sep 2011"
|
||||
#define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0j 10 May 2012"
|
||||
#endif
|
||||
#define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT
|
||||
|
||||
|
||||
@@ -62,12 +62,8 @@ my $flavour = shift;
|
||||
my $output = shift;
|
||||
if ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
|
||||
|
||||
{ my ($stddev,$stdino,@junk)=stat(STDOUT);
|
||||
my ($outdev,$outino,@junk)=stat($output);
|
||||
|
||||
open STDOUT,">$output" || die "can't open $output: $!"
|
||||
if ($stddev!=$outdev || $stdino!=$outino);
|
||||
}
|
||||
open STDOUT,">$output" || die "can't open $output: $!"
|
||||
if (defined($output));
|
||||
|
||||
my $gas=1; $gas=0 if ($output =~ /\.asm$/);
|
||||
my $elf=1; $elf=0 if (!$gas);
|
||||
@@ -555,7 +551,8 @@ my %globals;
|
||||
$v.=" READONLY";
|
||||
$v.=" ALIGN(".($1 eq "p" ? 4 : 8).")" if ($masm>=$masmref);
|
||||
} elsif ($line=~/\.CRT\$/i) {
|
||||
$v.=" READONLY DWORD";
|
||||
$v.=" READONLY ";
|
||||
$v.=$masm>=$masmref ? "ALIGN(8)" : "DWORD";
|
||||
}
|
||||
}
|
||||
$current_segment = $line;
|
||||
|
||||
@@ -167,7 +167,7 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
|
||||
if (cert && *cert)
|
||||
X509_free(*cert);
|
||||
if (x)
|
||||
X509_free(*cert);
|
||||
X509_free(x);
|
||||
if (ocerts)
|
||||
sk_X509_pop_free(ocerts, X509_free);
|
||||
return 0;
|
||||
|
||||
@@ -204,11 +204,11 @@ static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,
|
||||
unsigned char *ek = NULL;
|
||||
size_t eklen;
|
||||
|
||||
int ret = 0;
|
||||
int ret = -1;
|
||||
|
||||
pctx = EVP_PKEY_CTX_new(pkey, NULL);
|
||||
if (!pctx)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
if (EVP_PKEY_decrypt_init(pctx) <= 0)
|
||||
goto err;
|
||||
@@ -235,12 +235,19 @@ static int pkcs7_decrypt_rinfo(unsigned char **pek, int *peklen,
|
||||
if (EVP_PKEY_decrypt(pctx, ek, &eklen,
|
||||
ri->enc_key->data, ri->enc_key->length) <= 0)
|
||||
{
|
||||
ret = 0;
|
||||
PKCS7err(PKCS7_F_PKCS7_DECRYPT_RINFO, ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
if (*pek)
|
||||
{
|
||||
OPENSSL_cleanse(*pek, *peklen);
|
||||
OPENSSL_free(*pek);
|
||||
}
|
||||
|
||||
*pek = ek;
|
||||
*peklen = eklen;
|
||||
|
||||
@@ -423,6 +430,8 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
STACK_OF(X509_ALGOR) *md_sk=NULL;
|
||||
STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL;
|
||||
PKCS7_RECIP_INFO *ri=NULL;
|
||||
unsigned char *ek = NULL, *tkey = NULL;
|
||||
int eklen = 0, tkeylen = 0;
|
||||
|
||||
i=OBJ_obj2nid(p7->type);
|
||||
p7->state=PKCS7_S_HEADER;
|
||||
@@ -500,8 +509,6 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
int max;
|
||||
X509_OBJECT ret;
|
||||
#endif
|
||||
unsigned char *ek = NULL;
|
||||
int eklen;
|
||||
|
||||
if ((etmp=BIO_new(BIO_f_cipher())) == NULL)
|
||||
{
|
||||
@@ -534,29 +541,28 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
}
|
||||
|
||||
/* If we haven't got a certificate try each ri in turn */
|
||||
|
||||
if (pcert == NULL)
|
||||
{
|
||||
/* Always attempt to decrypt all rinfo even
|
||||
* after sucess as a defence against MMA timing
|
||||
* attacks.
|
||||
*/
|
||||
for (i=0; i<sk_PKCS7_RECIP_INFO_num(rsk); i++)
|
||||
{
|
||||
ri=sk_PKCS7_RECIP_INFO_value(rsk,i);
|
||||
|
||||
if (pkcs7_decrypt_rinfo(&ek, &eklen,
|
||||
ri, pkey) > 0)
|
||||
break;
|
||||
ri, pkey) < 0)
|
||||
goto err;
|
||||
ERR_clear_error();
|
||||
ri = NULL;
|
||||
}
|
||||
if (ri == NULL)
|
||||
{
|
||||
PKCS7err(PKCS7_F_PKCS7_DATADECODE,
|
||||
PKCS7_R_NO_RECIPIENT_MATCHES_KEY);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) <= 0)
|
||||
/* Only exit on fatal errors, not decrypt failure */
|
||||
if (pkcs7_decrypt_rinfo(&ek, &eklen, ri, pkey) < 0)
|
||||
goto err;
|
||||
ERR_clear_error();
|
||||
}
|
||||
|
||||
evp_ctx=NULL;
|
||||
@@ -565,6 +571,19 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
goto err;
|
||||
if (EVP_CIPHER_asn1_to_param(evp_ctx,enc_alg->parameter) < 0)
|
||||
goto err;
|
||||
/* Generate random key as MMA defence */
|
||||
tkeylen = EVP_CIPHER_CTX_key_length(evp_ctx);
|
||||
tkey = OPENSSL_malloc(tkeylen);
|
||||
if (!tkey)
|
||||
goto err;
|
||||
if (EVP_CIPHER_CTX_rand_key(evp_ctx, tkey) <= 0)
|
||||
goto err;
|
||||
if (ek == NULL)
|
||||
{
|
||||
ek = tkey;
|
||||
eklen = tkeylen;
|
||||
tkey = NULL;
|
||||
}
|
||||
|
||||
if (eklen != EVP_CIPHER_CTX_key_length(evp_ctx)) {
|
||||
/* Some S/MIME clients don't use the same key
|
||||
@@ -573,11 +592,16 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
*/
|
||||
if(!EVP_CIPHER_CTX_set_key_length(evp_ctx, eklen))
|
||||
{
|
||||
PKCS7err(PKCS7_F_PKCS7_DATADECODE,
|
||||
PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH);
|
||||
goto err;
|
||||
/* Use random key as MMA defence */
|
||||
OPENSSL_cleanse(ek, eklen);
|
||||
OPENSSL_free(ek);
|
||||
ek = tkey;
|
||||
eklen = tkeylen;
|
||||
tkey = NULL;
|
||||
}
|
||||
}
|
||||
/* Clear errors so we don't leak information useful in MMA */
|
||||
ERR_clear_error();
|
||||
if (EVP_CipherInit_ex(evp_ctx,NULL,NULL,ek,NULL,0) <= 0)
|
||||
goto err;
|
||||
|
||||
@@ -585,6 +609,13 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
{
|
||||
OPENSSL_cleanse(ek,eklen);
|
||||
OPENSSL_free(ek);
|
||||
ek = NULL;
|
||||
}
|
||||
if (tkey)
|
||||
{
|
||||
OPENSSL_cleanse(tkey,tkeylen);
|
||||
OPENSSL_free(tkey);
|
||||
tkey = NULL;
|
||||
}
|
||||
|
||||
if (out == NULL)
|
||||
@@ -627,6 +658,16 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert)
|
||||
if (0)
|
||||
{
|
||||
err:
|
||||
if (ek)
|
||||
{
|
||||
OPENSSL_cleanse(ek,eklen);
|
||||
OPENSSL_free(ek);
|
||||
}
|
||||
if (tkey)
|
||||
{
|
||||
OPENSSL_cleanse(tkey,tkeylen);
|
||||
OPENSSL_free(tkey);
|
||||
}
|
||||
if (out != NULL) BIO_free_all(out);
|
||||
if (btmp != NULL) BIO_free_all(btmp);
|
||||
if (etmp != NULL) BIO_free_all(etmp);
|
||||
|
||||
@@ -573,15 +573,34 @@ int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags)
|
||||
return 0;
|
||||
}
|
||||
ret = SMIME_text(bread, data);
|
||||
if (ret > 0 && BIO_method_type(tmpmem) == BIO_TYPE_CIPHER)
|
||||
{
|
||||
if (!BIO_get_cipher_status(tmpmem))
|
||||
ret = 0;
|
||||
}
|
||||
BIO_free_all(bread);
|
||||
return ret;
|
||||
} else {
|
||||
for(;;) {
|
||||
i = BIO_read(tmpmem, buf, sizeof(buf));
|
||||
if(i <= 0) break;
|
||||
BIO_write(data, buf, i);
|
||||
if(i <= 0)
|
||||
{
|
||||
ret = 1;
|
||||
if (BIO_method_type(tmpmem) == BIO_TYPE_CIPHER)
|
||||
{
|
||||
if (!BIO_get_cipher_status(tmpmem))
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
if (BIO_write(data, buf, i) != i)
|
||||
{
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
BIO_free_all(tmpmem);
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ Loop: lwarx r5,0,r3
|
||||
Little: mtctr r4
|
||||
stb r0,0(r3)
|
||||
addi r3,r3,1
|
||||
bdnz- \$-8
|
||||
bdnz \$-8
|
||||
blr
|
||||
Lot: andi. r5,r3,3
|
||||
beq Laligned
|
||||
@@ -85,7 +85,7 @@ Laligned:
|
||||
mtctr r5
|
||||
stw r0,0(r3)
|
||||
addi r3,r3,4
|
||||
bdnz- \$-8
|
||||
bdnz \$-8
|
||||
andi. r4,r4,3
|
||||
bne Little
|
||||
blr
|
||||
|
||||
@@ -133,47 +133,87 @@
|
||||
# define FD_SETSIZE (8*sizeof(fd_set))
|
||||
#endif
|
||||
|
||||
#ifdef __VOS__
|
||||
#if defined(OPENSSL_SYS_VOS)
|
||||
|
||||
/* The following algorithm repeatedly samples the real-time clock
|
||||
(RTC) to generate a sequence of unpredictable data. The algorithm
|
||||
relies upon the uneven execution speed of the code (due to factors
|
||||
such as cache misses, interrupts, bus activity, and scheduling) and
|
||||
upon the rather large relative difference between the speed of the
|
||||
clock and the rate at which it can be read.
|
||||
|
||||
If this code is ported to an environment where execution speed is
|
||||
more constant or where the RTC ticks at a much slower rate, or the
|
||||
clock can be read with fewer instructions, it is likely that the
|
||||
results would be far more predictable.
|
||||
|
||||
As a precaution, we generate 4 times the minimum required amount of
|
||||
seed data. */
|
||||
|
||||
int RAND_poll(void)
|
||||
{
|
||||
unsigned char buf[ENTROPY_NEEDED];
|
||||
short int code;
|
||||
gid_t curr_gid;
|
||||
pid_t curr_pid;
|
||||
uid_t curr_uid;
|
||||
static int first=1;
|
||||
int i;
|
||||
long rnd = 0;
|
||||
int i, k;
|
||||
struct timespec ts;
|
||||
unsigned seed;
|
||||
unsigned char v;
|
||||
|
||||
/* The VOS random() function starts from a static seed so its
|
||||
initial value is predictable. If random() returns the
|
||||
initial value, reseed it with dynamic data. The VOS
|
||||
real-time clock has a granularity of 1 nsec so it should be
|
||||
reasonably difficult to predict its exact value. Do not
|
||||
gratuitously reseed the PRNG because other code in this
|
||||
process or thread may be using it. */
|
||||
#ifdef OPENSSL_SYS_VOS_HPPA
|
||||
long duration;
|
||||
extern void s$sleep (long *_duration, short int *_code);
|
||||
#else
|
||||
#ifdef OPENSSL_SYS_VOS_IA32
|
||||
long long duration;
|
||||
extern void s$sleep2 (long long *_duration, short int *_code);
|
||||
#else
|
||||
#error "Unsupported Platform."
|
||||
#endif /* OPENSSL_SYS_VOS_IA32 */
|
||||
#endif /* OPENSSL_SYS_VOS_HPPA */
|
||||
|
||||
if (first) {
|
||||
first = 0;
|
||||
rnd = random ();
|
||||
if (rnd == 1804289383) {
|
||||
clock_gettime (CLOCK_REALTIME, &ts);
|
||||
curr_pid = getpid();
|
||||
curr_uid = getuid();
|
||||
seed = ts.tv_sec ^ ts.tv_nsec ^ curr_pid ^ curr_uid;
|
||||
srandom (seed);
|
||||
}
|
||||
/* Seed with the gid, pid, and uid, to ensure *some*
|
||||
variation between different processes. */
|
||||
|
||||
curr_gid = getgid();
|
||||
RAND_add (&curr_gid, sizeof curr_gid, 1);
|
||||
curr_gid = 0;
|
||||
|
||||
curr_pid = getpid();
|
||||
RAND_add (&curr_pid, sizeof curr_pid, 1);
|
||||
curr_pid = 0;
|
||||
|
||||
curr_uid = getuid();
|
||||
RAND_add (&curr_uid, sizeof curr_uid, 1);
|
||||
curr_uid = 0;
|
||||
|
||||
for (i=0; i<(ENTROPY_NEEDED*4); i++)
|
||||
{
|
||||
/* burn some cpu; hope for interrupts, cache
|
||||
collisions, bus interference, etc. */
|
||||
for (k=0; k<99; k++)
|
||||
ts.tv_nsec = random ();
|
||||
|
||||
#ifdef OPENSSL_SYS_VOS_HPPA
|
||||
/* sleep for 1/1024 of a second (976 us). */
|
||||
duration = 1;
|
||||
s$sleep (&duration, &code);
|
||||
#else
|
||||
#ifdef OPENSSL_SYS_VOS_IA32
|
||||
/* sleep for 1/65536 of a second (15 us). */
|
||||
duration = 1;
|
||||
s$sleep2 (&duration, &code);
|
||||
#endif /* OPENSSL_SYS_VOS_IA32 */
|
||||
#endif /* OPENSSL_SYS_VOS_HPPA */
|
||||
|
||||
/* get wall clock time. */
|
||||
clock_gettime (CLOCK_REALTIME, &ts);
|
||||
|
||||
/* take 8 bits */
|
||||
v = (unsigned char) (ts.tv_nsec % 256);
|
||||
RAND_add (&v, sizeof v, 1);
|
||||
v = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(buf); i++) {
|
||||
if (i % 4 == 0)
|
||||
rnd = random();
|
||||
buf[i] = rnd;
|
||||
rnd >>= 8;
|
||||
}
|
||||
RAND_add(buf, sizeof(buf), ENTROPY_NEEDED);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
return 1;
|
||||
}
|
||||
#elif defined __OpenBSD__
|
||||
|
||||
@@ -137,7 +137,7 @@ int RAND_load_file(const char *file, long bytes)
|
||||
in=fopen(file,"rb");
|
||||
#endif
|
||||
if (in == NULL) goto err;
|
||||
#if defined(S_IFBLK) && defined(S_IFCHR) && !defined(OPNESSL_NO_POSIX_IO)
|
||||
#if defined(S_IFBLK) && defined(S_IFCHR) && !defined(OPENSSL_NO_POSIX_IO)
|
||||
if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
|
||||
/* this file is a device. we don't want read an infinite number
|
||||
* of bytes from a random device, nor do we want to use buffered
|
||||
|
||||
@@ -314,51 +314,56 @@ static BN_BLINDING *rsa_get_blinding(RSA *rsa, int *local, BN_CTX *ctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rsa_blinding_convert(BN_BLINDING *b, int local, BIGNUM *f,
|
||||
BIGNUM *r, BN_CTX *ctx)
|
||||
{
|
||||
if (local)
|
||||
static int rsa_blinding_convert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
if (unblind == NULL)
|
||||
/* Local blinding: store the unblinding factor
|
||||
* in BN_BLINDING. */
|
||||
return BN_BLINDING_convert_ex(f, NULL, b, ctx);
|
||||
else
|
||||
{
|
||||
int ret;
|
||||
CRYPTO_r_lock(CRYPTO_LOCK_RSA_BLINDING);
|
||||
ret = BN_BLINDING_convert_ex(f, r, b, ctx);
|
||||
CRYPTO_r_unlock(CRYPTO_LOCK_RSA_BLINDING);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
static int rsa_blinding_invert(BN_BLINDING *b, int local, BIGNUM *f,
|
||||
BIGNUM *r, BN_CTX *ctx)
|
||||
{
|
||||
if (local)
|
||||
return BN_BLINDING_invert_ex(f, NULL, b, ctx);
|
||||
else
|
||||
{
|
||||
/* Shared blinding: store the unblinding factor
|
||||
* outside BN_BLINDING. */
|
||||
int ret;
|
||||
CRYPTO_w_lock(CRYPTO_LOCK_RSA_BLINDING);
|
||||
ret = BN_BLINDING_invert_ex(f, r, b, ctx);
|
||||
ret = BN_BLINDING_convert_ex(f, unblind, b, ctx);
|
||||
CRYPTO_w_unlock(CRYPTO_LOCK_RSA_BLINDING);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind,
|
||||
BN_CTX *ctx)
|
||||
{
|
||||
/* For local blinding, unblind is set to NULL, and BN_BLINDING_invert_ex
|
||||
* will use the unblinding factor stored in BN_BLINDING.
|
||||
* If BN_BLINDING is shared between threads, unblind must be non-null:
|
||||
* BN_BLINDING_invert_ex will then use the local unblinding factor,
|
||||
* and will only read the modulus from BN_BLINDING.
|
||||
* In both cases it's safe to access the blinding without a lock.
|
||||
*/
|
||||
return BN_BLINDING_invert_ex(f, unblind, b, ctx);
|
||||
}
|
||||
|
||||
/* signing */
|
||||
static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa, int padding)
|
||||
{
|
||||
BIGNUM *f, *ret, *br, *res;
|
||||
BIGNUM *f, *ret, *res;
|
||||
int i,j,k,num=0,r= -1;
|
||||
unsigned char *buf=NULL;
|
||||
BN_CTX *ctx=NULL;
|
||||
int local_blinding = 0;
|
||||
/* Used only if the blinding structure is shared. A non-NULL unblind
|
||||
* instructs rsa_blinding_convert() and rsa_blinding_invert() to store
|
||||
* the unblinding factor outside the blinding structure. */
|
||||
BIGNUM *unblind = NULL;
|
||||
BN_BLINDING *blinding = NULL;
|
||||
|
||||
if ((ctx=BN_CTX_new()) == NULL) goto err;
|
||||
BN_CTX_start(ctx);
|
||||
f = BN_CTX_get(ctx);
|
||||
br = BN_CTX_get(ctx);
|
||||
ret = BN_CTX_get(ctx);
|
||||
num = BN_num_bytes(rsa->n);
|
||||
buf = OPENSSL_malloc(num);
|
||||
@@ -406,8 +411,15 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
|
||||
}
|
||||
|
||||
if (blinding != NULL)
|
||||
if (!rsa_blinding_convert(blinding, local_blinding, f, br, ctx))
|
||||
{
|
||||
if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL))
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if (!rsa_blinding_convert(blinding, f, unblind, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
|
||||
((rsa->p != NULL) &&
|
||||
@@ -441,7 +453,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
|
||||
}
|
||||
|
||||
if (blinding)
|
||||
if (!rsa_blinding_invert(blinding, local_blinding, ret, br, ctx))
|
||||
if (!rsa_blinding_invert(blinding, ret, unblind, ctx))
|
||||
goto err;
|
||||
|
||||
if (padding == RSA_X931_PADDING)
|
||||
@@ -480,18 +492,21 @@ err:
|
||||
static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
|
||||
unsigned char *to, RSA *rsa, int padding)
|
||||
{
|
||||
BIGNUM *f, *ret, *br;
|
||||
BIGNUM *f, *ret;
|
||||
int j,num=0,r= -1;
|
||||
unsigned char *p;
|
||||
unsigned char *buf=NULL;
|
||||
BN_CTX *ctx=NULL;
|
||||
int local_blinding = 0;
|
||||
/* Used only if the blinding structure is shared. A non-NULL unblind
|
||||
* instructs rsa_blinding_convert() and rsa_blinding_invert() to store
|
||||
* the unblinding factor outside the blinding structure. */
|
||||
BIGNUM *unblind = NULL;
|
||||
BN_BLINDING *blinding = NULL;
|
||||
|
||||
if((ctx = BN_CTX_new()) == NULL) goto err;
|
||||
BN_CTX_start(ctx);
|
||||
f = BN_CTX_get(ctx);
|
||||
br = BN_CTX_get(ctx);
|
||||
ret = BN_CTX_get(ctx);
|
||||
num = BN_num_bytes(rsa->n);
|
||||
buf = OPENSSL_malloc(num);
|
||||
@@ -529,8 +544,15 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
|
||||
}
|
||||
|
||||
if (blinding != NULL)
|
||||
if (!rsa_blinding_convert(blinding, local_blinding, f, br, ctx))
|
||||
{
|
||||
if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL))
|
||||
{
|
||||
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if (!rsa_blinding_convert(blinding, f, unblind, ctx))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* do the decrypt */
|
||||
if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
|
||||
@@ -564,7 +586,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from,
|
||||
}
|
||||
|
||||
if (blinding)
|
||||
if (!rsa_blinding_invert(blinding, local_blinding, ret, br, ctx))
|
||||
if (!rsa_blinding_invert(blinding, ret, unblind, ctx))
|
||||
goto err;
|
||||
|
||||
p=buf;
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
* sigaction and fileno included. -pedantic would be more appropriate for
|
||||
* the intended purposes, but we can't prevent users from adding -ansi.
|
||||
*/
|
||||
#ifndef _POSIX_C_SOURCE
|
||||
#if !defined(_POSIX_C_SOURCE) && defined(OPENSSL_SYS_VMS)
|
||||
#define _POSIX_C_SOURCE 2
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
@@ -87,7 +87,7 @@ void X509_LOOKUP_free(X509_LOOKUP *ctx)
|
||||
if (ctx == NULL) return;
|
||||
if ( (ctx->method != NULL) &&
|
||||
(ctx->method->free != NULL))
|
||||
ctx->method->free(ctx);
|
||||
(*ctx->method->free)(ctx);
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,6 @@ static int x509_subject_cmp(X509 **a, X509 **b)
|
||||
int X509_verify_cert(X509_STORE_CTX *ctx)
|
||||
{
|
||||
X509 *x,*xtmp,*chain_ss=NULL;
|
||||
X509_NAME *xn;
|
||||
int bad_chain = 0;
|
||||
X509_VERIFY_PARAM *param = ctx->param;
|
||||
int depth,i,ok=0;
|
||||
@@ -205,7 +204,6 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
|
||||
*/
|
||||
|
||||
/* If we are self signed, we break */
|
||||
xn=X509_get_issuer_name(x);
|
||||
if (ctx->check_issued(ctx, x,x)) break;
|
||||
|
||||
/* If we were passed a cert chain, use it first */
|
||||
@@ -242,7 +240,6 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
|
||||
|
||||
i=sk_X509_num(ctx->chain);
|
||||
x=sk_X509_value(ctx->chain,i-1);
|
||||
xn = X509_get_subject_name(x);
|
||||
if (ctx->check_issued(ctx, x, x))
|
||||
{
|
||||
/* we have a self signed certificate */
|
||||
@@ -291,7 +288,6 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
|
||||
if (depth < num) break;
|
||||
|
||||
/* If we are self signed, we break */
|
||||
xn=X509_get_issuer_name(x);
|
||||
if (ctx->check_issued(ctx,x,x)) break;
|
||||
|
||||
ok = ctx->get_issuer(&xtmp, ctx, x);
|
||||
@@ -310,7 +306,6 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
|
||||
}
|
||||
|
||||
/* we now have our chain, lets check it... */
|
||||
xn=X509_get_issuer_name(x);
|
||||
|
||||
/* Is last certificate looked up self signed? */
|
||||
if (!ctx->check_issued(ctx,x,x))
|
||||
@@ -1732,7 +1727,7 @@ int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time)
|
||||
atm.length=sizeof(buff2);
|
||||
atm.data=(unsigned char *)buff2;
|
||||
|
||||
if (X509_time_adj(&atm,-offset*60, cmp_time) == NULL)
|
||||
if (X509_time_adj(&atm, offset*60, cmp_time) == NULL)
|
||||
return 0;
|
||||
|
||||
if (ctm->type == V_ASN1_UTCTIME)
|
||||
|
||||
@@ -142,12 +142,13 @@ unsigned int v3_addr_get_afi(const IPAddressFamily *f)
|
||||
* Expand the bitstring form of an address into a raw byte array.
|
||||
* At the moment this is coded for simplicity, not speed.
|
||||
*/
|
||||
static void addr_expand(unsigned char *addr,
|
||||
static int addr_expand(unsigned char *addr,
|
||||
const ASN1_BIT_STRING *bs,
|
||||
const int length,
|
||||
const unsigned char fill)
|
||||
{
|
||||
OPENSSL_assert(bs->length >= 0 && bs->length <= length);
|
||||
if (bs->length < 0 || bs->length > length)
|
||||
return 0;
|
||||
if (bs->length > 0) {
|
||||
memcpy(addr, bs->data, bs->length);
|
||||
if ((bs->flags & 7) != 0) {
|
||||
@@ -159,6 +160,7 @@ static void addr_expand(unsigned char *addr,
|
||||
}
|
||||
}
|
||||
memset(addr + bs->length, fill, length - bs->length);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -181,15 +183,13 @@ static int i2r_address(BIO *out,
|
||||
return 0;
|
||||
switch (afi) {
|
||||
case IANA_AFI_IPV4:
|
||||
if (bs->length > 4)
|
||||
if (!addr_expand(addr, bs, 4, fill))
|
||||
return 0;
|
||||
addr_expand(addr, bs, 4, fill);
|
||||
BIO_printf(out, "%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]);
|
||||
break;
|
||||
case IANA_AFI_IPV6:
|
||||
if (bs->length > 16)
|
||||
if (!addr_expand(addr, bs, 16, fill))
|
||||
return 0;
|
||||
addr_expand(addr, bs, 16, fill);
|
||||
for (n = 16; n > 1 && addr[n-1] == 0x00 && addr[n-2] == 0x00; n -= 2)
|
||||
;
|
||||
for (i = 0; i < n; i += 2)
|
||||
@@ -315,6 +315,12 @@ static int i2r_IPAddrBlocks(const X509V3_EXT_METHOD *method,
|
||||
/*
|
||||
* Sort comparison function for a sequence of IPAddressOrRange
|
||||
* elements.
|
||||
*
|
||||
* There's no sane answer we can give if addr_expand() fails, and an
|
||||
* assertion failure on externally supplied data is seriously uncool,
|
||||
* so we just arbitrarily declare that if given invalid inputs this
|
||||
* function returns -1. If this messes up your preferred sort order
|
||||
* for garbage input, tough noogies.
|
||||
*/
|
||||
static int IPAddressOrRange_cmp(const IPAddressOrRange *a,
|
||||
const IPAddressOrRange *b,
|
||||
@@ -326,22 +332,26 @@ static int IPAddressOrRange_cmp(const IPAddressOrRange *a,
|
||||
|
||||
switch (a->type) {
|
||||
case IPAddressOrRange_addressPrefix:
|
||||
addr_expand(addr_a, a->u.addressPrefix, length, 0x00);
|
||||
if (!addr_expand(addr_a, a->u.addressPrefix, length, 0x00))
|
||||
return -1;
|
||||
prefixlen_a = addr_prefixlen(a->u.addressPrefix);
|
||||
break;
|
||||
case IPAddressOrRange_addressRange:
|
||||
addr_expand(addr_a, a->u.addressRange->min, length, 0x00);
|
||||
if (!addr_expand(addr_a, a->u.addressRange->min, length, 0x00))
|
||||
return -1;
|
||||
prefixlen_a = length * 8;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (b->type) {
|
||||
case IPAddressOrRange_addressPrefix:
|
||||
addr_expand(addr_b, b->u.addressPrefix, length, 0x00);
|
||||
if (!addr_expand(addr_b, b->u.addressPrefix, length, 0x00))
|
||||
return -1;
|
||||
prefixlen_b = addr_prefixlen(b->u.addressPrefix);
|
||||
break;
|
||||
case IPAddressOrRange_addressRange:
|
||||
addr_expand(addr_b, b->u.addressRange->min, length, 0x00);
|
||||
if (!addr_expand(addr_b, b->u.addressRange->min, length, 0x00))
|
||||
return -1;
|
||||
prefixlen_b = length * 8;
|
||||
break;
|
||||
}
|
||||
@@ -383,6 +393,7 @@ static int range_should_be_prefix(const unsigned char *min,
|
||||
unsigned char mask;
|
||||
int i, j;
|
||||
|
||||
OPENSSL_assert(memcmp(min, max, length) <= 0);
|
||||
for (i = 0; i < length && min[i] == max[i]; i++)
|
||||
;
|
||||
for (j = length - 1; j >= 0 && min[j] == 0x00 && max[j] == 0xFF; j--)
|
||||
@@ -601,10 +612,10 @@ static IPAddressOrRanges *make_prefix_or_range(IPAddrBlocks *addr,
|
||||
return NULL;
|
||||
switch (afi) {
|
||||
case IANA_AFI_IPV4:
|
||||
sk_IPAddressOrRange_set_cmp_func(aors, v4IPAddressOrRange_cmp);
|
||||
(void) sk_IPAddressOrRange_set_cmp_func(aors, v4IPAddressOrRange_cmp);
|
||||
break;
|
||||
case IANA_AFI_IPV6:
|
||||
sk_IPAddressOrRange_set_cmp_func(aors, v6IPAddressOrRange_cmp);
|
||||
(void) sk_IPAddressOrRange_set_cmp_func(aors, v6IPAddressOrRange_cmp);
|
||||
break;
|
||||
}
|
||||
f->ipAddressChoice->type = IPAddressChoice_addressesOrRanges;
|
||||
@@ -656,22 +667,22 @@ int v3_addr_add_range(IPAddrBlocks *addr,
|
||||
/*
|
||||
* Extract min and max values from an IPAddressOrRange.
|
||||
*/
|
||||
static void extract_min_max(IPAddressOrRange *aor,
|
||||
static int extract_min_max(IPAddressOrRange *aor,
|
||||
unsigned char *min,
|
||||
unsigned char *max,
|
||||
int length)
|
||||
{
|
||||
OPENSSL_assert(aor != NULL && min != NULL && max != NULL);
|
||||
if (aor == NULL || min == NULL || max == NULL)
|
||||
return 0;
|
||||
switch (aor->type) {
|
||||
case IPAddressOrRange_addressPrefix:
|
||||
addr_expand(min, aor->u.addressPrefix, length, 0x00);
|
||||
addr_expand(max, aor->u.addressPrefix, length, 0xFF);
|
||||
return;
|
||||
return (addr_expand(min, aor->u.addressPrefix, length, 0x00) &&
|
||||
addr_expand(max, aor->u.addressPrefix, length, 0xFF));
|
||||
case IPAddressOrRange_addressRange:
|
||||
addr_expand(min, aor->u.addressRange->min, length, 0x00);
|
||||
addr_expand(max, aor->u.addressRange->max, length, 0xFF);
|
||||
return;
|
||||
return (addr_expand(min, aor->u.addressRange->min, length, 0x00) &&
|
||||
addr_expand(max, aor->u.addressRange->max, length, 0xFF));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -687,9 +698,10 @@ int v3_addr_get_range(IPAddressOrRange *aor,
|
||||
if (aor == NULL || min == NULL || max == NULL ||
|
||||
afi_length == 0 || length < afi_length ||
|
||||
(aor->type != IPAddressOrRange_addressPrefix &&
|
||||
aor->type != IPAddressOrRange_addressRange))
|
||||
aor->type != IPAddressOrRange_addressRange) ||
|
||||
!extract_min_max(aor, min, max, afi_length))
|
||||
return 0;
|
||||
extract_min_max(aor, min, max, afi_length);
|
||||
|
||||
return afi_length;
|
||||
}
|
||||
|
||||
@@ -771,8 +783,9 @@ int v3_addr_is_canonical(IPAddrBlocks *addr)
|
||||
IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, j);
|
||||
IPAddressOrRange *b = sk_IPAddressOrRange_value(aors, j + 1);
|
||||
|
||||
extract_min_max(a, a_min, a_max, length);
|
||||
extract_min_max(b, b_min, b_max, length);
|
||||
if (!extract_min_max(a, a_min, a_max, length) ||
|
||||
!extract_min_max(b, b_min, b_max, length))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Punt misordered list, overlapping start, or inverted range.
|
||||
@@ -800,14 +813,17 @@ int v3_addr_is_canonical(IPAddrBlocks *addr)
|
||||
}
|
||||
|
||||
/*
|
||||
* Check final range to see if it should be a prefix.
|
||||
* Check range to see if it's inverted or should be a
|
||||
* prefix.
|
||||
*/
|
||||
j = sk_IPAddressOrRange_num(aors) - 1;
|
||||
{
|
||||
IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, j);
|
||||
if (a->type == IPAddressOrRange_addressRange) {
|
||||
extract_min_max(a, a_min, a_max, length);
|
||||
if (range_should_be_prefix(a_min, a_max, length) >= 0)
|
||||
if (a != NULL && a->type == IPAddressOrRange_addressRange) {
|
||||
if (!extract_min_max(a, a_min, a_max, length))
|
||||
return 0;
|
||||
if (memcmp(a_min, a_max, length) > 0 ||
|
||||
range_should_be_prefix(a_min, a_max, length) >= 0)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -841,8 +857,16 @@ static int IPAddressOrRanges_canonize(IPAddressOrRanges *aors,
|
||||
unsigned char a_min[ADDR_RAW_BUF_LEN], a_max[ADDR_RAW_BUF_LEN];
|
||||
unsigned char b_min[ADDR_RAW_BUF_LEN], b_max[ADDR_RAW_BUF_LEN];
|
||||
|
||||
extract_min_max(a, a_min, a_max, length);
|
||||
extract_min_max(b, b_min, b_max, length);
|
||||
if (!extract_min_max(a, a_min, a_max, length) ||
|
||||
!extract_min_max(b, b_min, b_max, length))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Punt inverted ranges.
|
||||
*/
|
||||
if (memcmp(a_min, a_max, length) > 0 ||
|
||||
memcmp(b_min, b_max, length) > 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Punt overlaps.
|
||||
@@ -860,8 +884,8 @@ static int IPAddressOrRanges_canonize(IPAddressOrRanges *aors,
|
||||
IPAddressOrRange *merged;
|
||||
if (!make_addressRange(&merged, a_min, b_max, length))
|
||||
return 0;
|
||||
sk_IPAddressOrRange_set(aors, i, merged);
|
||||
sk_IPAddressOrRange_delete(aors, i + 1);
|
||||
(void) sk_IPAddressOrRange_set(aors, i, merged);
|
||||
(void) sk_IPAddressOrRange_delete(aors, i + 1);
|
||||
IPAddressOrRange_free(a);
|
||||
IPAddressOrRange_free(b);
|
||||
--i;
|
||||
@@ -869,6 +893,20 @@ static int IPAddressOrRanges_canonize(IPAddressOrRanges *aors,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for inverted final range.
|
||||
*/
|
||||
j = sk_IPAddressOrRange_num(aors) - 1;
|
||||
{
|
||||
IPAddressOrRange *a = sk_IPAddressOrRange_value(aors, j);
|
||||
if (a != NULL && a->type == IPAddressOrRange_addressRange) {
|
||||
unsigned char a_min[ADDR_RAW_BUF_LEN], a_max[ADDR_RAW_BUF_LEN];
|
||||
extract_min_max(a, a_min, a_max, length);
|
||||
if (memcmp(a_min, a_max, length) > 0)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -885,7 +923,7 @@ int v3_addr_canonize(IPAddrBlocks *addr)
|
||||
v3_addr_get_afi(f)))
|
||||
return 0;
|
||||
}
|
||||
sk_IPAddressFamily_set_cmp_func(addr, IPAddressFamily_cmp);
|
||||
(void) sk_IPAddressFamily_set_cmp_func(addr, IPAddressFamily_cmp);
|
||||
sk_IPAddressFamily_sort(addr);
|
||||
OPENSSL_assert(v3_addr_is_canonical(addr));
|
||||
return 1;
|
||||
@@ -1017,6 +1055,11 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,
|
||||
X509V3_conf_err(val);
|
||||
goto err;
|
||||
}
|
||||
if (memcmp(min, max, length_from_afi(afi)) > 0) {
|
||||
X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_EXTENSION_VALUE_ERROR);
|
||||
X509V3_conf_err(val);
|
||||
goto err;
|
||||
}
|
||||
if (!v3_addr_add_range(addr, afi, safi, min, max)) {
|
||||
X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
@@ -1102,13 +1145,15 @@ static int addr_contains(IPAddressOrRanges *parent,
|
||||
|
||||
p = 0;
|
||||
for (c = 0; c < sk_IPAddressOrRange_num(child); c++) {
|
||||
extract_min_max(sk_IPAddressOrRange_value(child, c),
|
||||
c_min, c_max, length);
|
||||
if (!extract_min_max(sk_IPAddressOrRange_value(child, c),
|
||||
c_min, c_max, length))
|
||||
return -1;
|
||||
for (;; p++) {
|
||||
if (p >= sk_IPAddressOrRange_num(parent))
|
||||
return 0;
|
||||
extract_min_max(sk_IPAddressOrRange_value(parent, p),
|
||||
p_min, p_max, length);
|
||||
if (!extract_min_max(sk_IPAddressOrRange_value(parent, p),
|
||||
p_min, p_max, length))
|
||||
return 0;
|
||||
if (memcmp(p_max, c_max, length) < 0)
|
||||
continue;
|
||||
if (memcmp(p_min, c_min, length) > 0)
|
||||
@@ -1130,7 +1175,7 @@ int v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b)
|
||||
return 1;
|
||||
if (b == NULL || v3_addr_inherits(a) || v3_addr_inherits(b))
|
||||
return 0;
|
||||
sk_IPAddressFamily_set_cmp_func(b, IPAddressFamily_cmp);
|
||||
(void) sk_IPAddressFamily_set_cmp_func(b, IPAddressFamily_cmp);
|
||||
for (i = 0; i < sk_IPAddressFamily_num(a); i++) {
|
||||
IPAddressFamily *fa = sk_IPAddressFamily_value(a, i);
|
||||
int j = sk_IPAddressFamily_find(b, fa);
|
||||
@@ -1195,7 +1240,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx,
|
||||
}
|
||||
if (!v3_addr_is_canonical(ext))
|
||||
validation_err(X509_V_ERR_INVALID_EXTENSION);
|
||||
sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp);
|
||||
(void) sk_IPAddressFamily_set_cmp_func(ext, IPAddressFamily_cmp);
|
||||
if ((child = sk_IPAddressFamily_dup(ext)) == NULL) {
|
||||
X509V3err(X509V3_F_V3_ADDR_VALIDATE_PATH_INTERNAL, ERR_R_MALLOC_FAILURE);
|
||||
ret = 0;
|
||||
@@ -1221,7 +1266,7 @@ static int v3_addr_validate_path_internal(X509_STORE_CTX *ctx,
|
||||
}
|
||||
continue;
|
||||
}
|
||||
sk_IPAddressFamily_set_cmp_func(x->rfc3779_addr, IPAddressFamily_cmp);
|
||||
(void) sk_IPAddressFamily_set_cmp_func(x->rfc3779_addr, IPAddressFamily_cmp);
|
||||
for (j = 0; j < sk_IPAddressFamily_num(child); j++) {
|
||||
IPAddressFamily *fc = sk_IPAddressFamily_value(child, j);
|
||||
int k = sk_IPAddressFamily_find(x->rfc3779_addr, fc);
|
||||
|
||||
@@ -358,6 +358,20 @@ static int ASIdentifierChoice_is_canonical(ASIdentifierChoice *choice)
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for inverted range.
|
||||
*/
|
||||
i = sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1;
|
||||
{
|
||||
ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
|
||||
ASN1_INTEGER *a_min, *a_max;
|
||||
if (a != NULL && a->type == ASIdOrRange_range) {
|
||||
extract_min_max(a, &a_min, &a_max);
|
||||
if (ASN1_INTEGER_cmp(a_min, a_max) > 0)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
done:
|
||||
@@ -392,9 +406,18 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
* We have a list. Sort it.
|
||||
* If not a list, or if empty list, it's broken.
|
||||
*/
|
||||
if (choice->type != ASIdentifierChoice_asIdsOrRanges ||
|
||||
sk_ASIdOrRange_num(choice->u.asIdsOrRanges) == 0) {
|
||||
X509V3err(X509V3_F_ASIDENTIFIERCHOICE_CANONIZE,
|
||||
X509V3_R_EXTENSION_VALUE_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* We have a non-empty list. Sort it.
|
||||
*/
|
||||
OPENSSL_assert(choice->type == ASIdentifierChoice_asIdsOrRanges);
|
||||
sk_ASIdOrRange_sort(choice->u.asIdsOrRanges);
|
||||
|
||||
/*
|
||||
@@ -414,6 +437,13 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
|
||||
*/
|
||||
OPENSSL_assert(ASN1_INTEGER_cmp(a_min, b_min) <= 0);
|
||||
|
||||
/*
|
||||
* Punt inverted ranges.
|
||||
*/
|
||||
if (ASN1_INTEGER_cmp(a_min, a_max) > 0 ||
|
||||
ASN1_INTEGER_cmp(b_min, b_max) > 0)
|
||||
goto done;
|
||||
|
||||
/*
|
||||
* Check for overlaps.
|
||||
*/
|
||||
@@ -465,12 +495,26 @@ static int ASIdentifierChoice_canonize(ASIdentifierChoice *choice)
|
||||
break;
|
||||
}
|
||||
ASIdOrRange_free(b);
|
||||
sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1);
|
||||
(void) sk_ASIdOrRange_delete(choice->u.asIdsOrRanges, i + 1);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for final inverted range.
|
||||
*/
|
||||
i = sk_ASIdOrRange_num(choice->u.asIdsOrRanges) - 1;
|
||||
{
|
||||
ASIdOrRange *a = sk_ASIdOrRange_value(choice->u.asIdsOrRanges, i);
|
||||
ASN1_INTEGER *a_min, *a_max;
|
||||
if (a != NULL && a->type == ASIdOrRange_range) {
|
||||
extract_min_max(a, &a_min, &a_max);
|
||||
if (ASN1_INTEGER_cmp(a_min, a_max) > 0)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
OPENSSL_assert(ASIdentifierChoice_is_canonical(choice)); /* Paranoia */
|
||||
|
||||
ret = 1;
|
||||
@@ -498,6 +542,7 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method,
|
||||
struct v3_ext_ctx *ctx,
|
||||
STACK_OF(CONF_VALUE) *values)
|
||||
{
|
||||
ASN1_INTEGER *min = NULL, *max = NULL;
|
||||
ASIdentifiers *asid = NULL;
|
||||
int i;
|
||||
|
||||
@@ -508,7 +553,6 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method,
|
||||
|
||||
for (i = 0; i < sk_CONF_VALUE_num(values); i++) {
|
||||
CONF_VALUE *val = sk_CONF_VALUE_value(values, i);
|
||||
ASN1_INTEGER *min = NULL, *max = NULL;
|
||||
int i1, i2, i3, is_range, which;
|
||||
|
||||
/*
|
||||
@@ -578,18 +622,19 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method,
|
||||
max = s2i_ASN1_INTEGER(NULL, s + i2);
|
||||
OPENSSL_free(s);
|
||||
if (min == NULL || max == NULL) {
|
||||
ASN1_INTEGER_free(min);
|
||||
ASN1_INTEGER_free(max);
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if (ASN1_INTEGER_cmp(min, max) > 0) {
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, X509V3_R_EXTENSION_VALUE_ERROR);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (!v3_asid_add_id_or_range(asid, which, min, max)) {
|
||||
ASN1_INTEGER_free(min);
|
||||
ASN1_INTEGER_free(max);
|
||||
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
min = max = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -601,6 +646,8 @@ static void *v2i_ASIdentifiers(const struct v3_ext_method *method,
|
||||
|
||||
err:
|
||||
ASIdentifiers_free(asid);
|
||||
ASN1_INTEGER_free(min);
|
||||
ASN1_INTEGER_free(max);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ following methods:
|
||||
|
||||
- in all other cases, proxy certificate validation can be enabled
|
||||
before starting the application by setting the envirnoment variable
|
||||
OPENSSL_ALLOW_PROXY with some non-empty value.
|
||||
OPENSSL_ALLOW_PROXY_CERTS with some non-empty value.
|
||||
|
||||
There are thoughts to allow proxy certificates with a line in the
|
||||
default openssl.cnf, but that's still in the future.
|
||||
|
||||
@@ -6,7 +6,8 @@ EVP_MD_CTX_init, EVP_MD_CTX_create, EVP_DigestInit_ex, EVP_DigestUpdate,
|
||||
EVP_DigestFinal_ex, EVP_MD_CTX_cleanup, EVP_MD_CTX_destroy, EVP_MAX_MD_SIZE,
|
||||
EVP_MD_CTX_copy_ex, EVP_MD_CTX_copy, EVP_MD_type, EVP_MD_pkey_type, EVP_MD_size,
|
||||
EVP_MD_block_size, EVP_MD_CTX_md, EVP_MD_CTX_size, EVP_MD_CTX_block_size, EVP_MD_CTX_type,
|
||||
EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_dss, EVP_dss1, EVP_mdc2,
|
||||
EVP_md_null, EVP_md2, EVP_md5, EVP_sha, EVP_sha1, EVP_sha224, EVP_sha256,
|
||||
EVP_sha384, EVP_sha512, EVP_dss, EVP_dss1, EVP_mdc2,
|
||||
EVP_ripemd160, EVP_get_digestbyname, EVP_get_digestbynid, EVP_get_digestbyobj -
|
||||
EVP digest routines
|
||||
|
||||
@@ -33,16 +34,15 @@ EVP digest routines
|
||||
|
||||
int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in);
|
||||
|
||||
#define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
|
||||
#define EVP_MAX_MD_SIZE 64 /* SHA512 */
|
||||
|
||||
int EVP_MD_type(const EVP_MD *md);
|
||||
int EVP_MD_pkey_type(const EVP_MD *md);
|
||||
int EVP_MD_size(const EVP_MD *md);
|
||||
int EVP_MD_block_size(const EVP_MD *md);
|
||||
|
||||
#define EVP_MD_type(e) ((e)->type)
|
||||
#define EVP_MD_pkey_type(e) ((e)->pkey_type)
|
||||
#define EVP_MD_size(e) ((e)->md_size)
|
||||
#define EVP_MD_block_size(e) ((e)->block_size)
|
||||
|
||||
#define EVP_MD_CTX_md(e) (e)->digest)
|
||||
#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
|
||||
const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
|
||||
#define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e))
|
||||
#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
|
||||
#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
|
||||
|
||||
@@ -56,6 +56,11 @@ EVP digest routines
|
||||
const EVP_MD *EVP_mdc2(void);
|
||||
const EVP_MD *EVP_ripemd160(void);
|
||||
|
||||
const EVP_MD *EVP_sha224(void);
|
||||
const EVP_MD *EVP_sha256(void);
|
||||
const EVP_MD *EVP_sha384(void);
|
||||
const EVP_MD *EVP_sha512(void);
|
||||
|
||||
const EVP_MD *EVP_get_digestbyname(const char *name);
|
||||
#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
|
||||
#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
|
||||
@@ -124,12 +129,14 @@ B<EVP_MD_CTX>.
|
||||
|
||||
EVP_MD_pkey_type() returns the NID of the public key signing algorithm associated
|
||||
with this digest. For example EVP_sha1() is associated with RSA so this will
|
||||
return B<NID_sha1WithRSAEncryption>. This "link" between digests and signature
|
||||
algorithms may not be retained in future versions of OpenSSL.
|
||||
return B<NID_sha1WithRSAEncryption>. Since digests and signature algorithms
|
||||
are no longer linked this function is only retained for compatibility
|
||||
reasons.
|
||||
|
||||
EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_mdc2() and EVP_ripemd160()
|
||||
return B<EVP_MD> structures for the MD2, MD5, SHA, SHA1, MDC2 and RIPEMD160 digest
|
||||
algorithms respectively. The associated signature algorithm is RSA in each case.
|
||||
EVP_md2(), EVP_md5(), EVP_sha(), EVP_sha1(), EVP_sha224(), EVP_sha256(),
|
||||
EVP_sha384(), EVP_sha512(), EVP_mdc2() and EVP_ripemd160() return B<EVP_MD>
|
||||
structures for the MD2, MD5, SHA, SHA1, SHA224, SHA256, SHA384, SHA512, MDC2
|
||||
and RIPEMD160 digest algorithms respectively.
|
||||
|
||||
EVP_dss() and EVP_dss1() return B<EVP_MD> structures for SHA and SHA1 digest
|
||||
algorithms but using DSS (DSA) for the signature algorithm. Note: there is
|
||||
@@ -171,8 +178,8 @@ The B<EVP> interface to message digests should almost always be used in
|
||||
preference to the low level interfaces. This is because the code then becomes
|
||||
transparent to the digest used and much more flexible.
|
||||
|
||||
SHA1 is the digest of choice for new applications. The other digest algorithms
|
||||
are still in common use.
|
||||
New applications should use the SHA2 digest algorithms such as SHA256.
|
||||
The other digest algorithms are still in common use.
|
||||
|
||||
For most applications the B<impl> parameter to EVP_DigestInit_ex() will be
|
||||
set to NULL to use the default digest implementation.
|
||||
@@ -187,6 +194,19 @@ implementations of digests to be specified.
|
||||
In OpenSSL 0.9.7 and later if digest contexts are not cleaned up after use
|
||||
memory leaks will occur.
|
||||
|
||||
Stack allocation of EVP_MD_CTX structures is common, for example:
|
||||
|
||||
EVP_MD_CTX mctx;
|
||||
EVP_MD_CTX_init(&mctx);
|
||||
|
||||
This will cause binary compatibility issues if the size of EVP_MD_CTX
|
||||
structure changes (this will only happen with a major release of OpenSSL).
|
||||
Applications wishing to avoid this should use EVP_MD_CTX_create() instead:
|
||||
|
||||
EVP_MD_CTX *mctx;
|
||||
mctx = EVP_MD_CTX_create();
|
||||
|
||||
|
||||
=head1 EXAMPLE
|
||||
|
||||
This example digests the data "Test Message\n" and "Hello World\n", using the
|
||||
@@ -197,7 +217,7 @@ digest name passed on the command line.
|
||||
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
EVP_MD_CTX mdctx;
|
||||
EVP_MD_CTX *mdctx;
|
||||
const EVP_MD *md;
|
||||
char mess1[] = "Test Message\n";
|
||||
char mess2[] = "Hello World\n";
|
||||
@@ -218,12 +238,12 @@ digest name passed on the command line.
|
||||
exit(1);
|
||||
}
|
||||
|
||||
EVP_MD_CTX_init(&mdctx);
|
||||
EVP_DigestInit_ex(&mdctx, md, NULL);
|
||||
EVP_DigestUpdate(&mdctx, mess1, strlen(mess1));
|
||||
EVP_DigestUpdate(&mdctx, mess2, strlen(mess2));
|
||||
EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
|
||||
EVP_MD_CTX_cleanup(&mdctx);
|
||||
mdctx = EVP_MD_CTX_create();
|
||||
EVP_DigestInit_ex(mdctx, md, NULL);
|
||||
EVP_DigestUpdate(mdctx, mess1, strlen(mess1));
|
||||
EVP_DigestUpdate(mdctx, mess2, strlen(mess2));
|
||||
EVP_DigestFinal_ex(mdctx, md_value, &md_len);
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
|
||||
printf("Digest is: ");
|
||||
for(i = 0; i < md_len; i++) printf("%02x", md_value[i]);
|
||||
|
||||
@@ -114,7 +114,7 @@ using the public key B<eckey>.
|
||||
|
||||
ECDSA_size() returns the maximum length signature or 0 on error.
|
||||
|
||||
ECDSA_sign_setup() and ECDSA_sign() return 1 if successful or -1
|
||||
ECDSA_sign_setup() and ECDSA_sign() return 1 if successful or 0
|
||||
on error.
|
||||
|
||||
ECDSA_verify() and ECDSA_do_verify() return 1 for a valid
|
||||
|
||||
@@ -39,10 +39,16 @@ for a description of the method's properties.
|
||||
SSL_clear() resets the SSL object to allow for another connection. The
|
||||
reset operation however keeps several settings of the last sessions
|
||||
(some of these settings were made automatically during the last
|
||||
handshake). It only makes sense when opening a new session (or reusing
|
||||
an old one) with the same peer that shares these settings.
|
||||
SSL_clear() is not a short form for the sequence
|
||||
L<SSL_free(3)|SSL_free(3)>; L<SSL_new(3)|SSL_new(3)>; .
|
||||
handshake). It only makes sense for a new connection with the exact
|
||||
same peer that shares these settings, and may fail if that peer
|
||||
changes its settings between connections. Use the sequence
|
||||
L<SSL_get_session(3)|SSL_get_session(3)>;
|
||||
L<SSL_new(3)|SSL_new(3)>;
|
||||
L<SSL_set_session(3)|SSL_set_session(3)>;
|
||||
L<SSL_free(3)|SSL_free(3)>
|
||||
instead to avoid such failures
|
||||
(or simply L<SSL_free(3)|SSL_free(3)>; L<SSL_new(3)|SSL_new(3)>
|
||||
if session reuse is not desired).
|
||||
|
||||
=head1 RETURN VALUES
|
||||
|
||||
|
||||
8
e_os2.h
8
e_os2.h
@@ -193,8 +193,14 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* --------------------------------- VOS ----------------------------------- */
|
||||
#ifdef OPENSSL_SYSNAME_VOS
|
||||
#if defined(__VOS__) || defined(OPENSSL_SYSNAME_VOS)
|
||||
# define OPENSSL_SYS_VOS
|
||||
#ifdef __HPPA__
|
||||
# define OPENSSL_SYS_VOS_HPPA
|
||||
#endif
|
||||
#ifdef __IA32__
|
||||
# define OPENSSL_SYS_VOS_IA32
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ------------------------------- VxWorks --------------------------------- */
|
||||
|
||||
@@ -280,6 +280,10 @@ int pkey_GOST01cp_decrypt(EVP_PKEY_CTX *pctx, unsigned char *key, size_t * key_l
|
||||
}
|
||||
|
||||
param = get_encryption_params(gkt->key_agreement_info->cipher);
|
||||
if(!param){
|
||||
goto err;
|
||||
}
|
||||
|
||||
gost_init(&ctx,param->sblock);
|
||||
OPENSSL_assert(gkt->key_agreement_info->eph_iv->length==8);
|
||||
memcpy(wrappedKey,gkt->key_agreement_info->eph_iv->data,8);
|
||||
|
||||
@@ -261,6 +261,10 @@ int pkey_GOST94cp_decrypt(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *key_len
|
||||
}
|
||||
|
||||
param = get_encryption_params(gkt->key_agreement_info->cipher);
|
||||
if(!param){
|
||||
goto err;
|
||||
}
|
||||
|
||||
gost_init(&cctx,param->sblock);
|
||||
OPENSSL_assert(gkt->key_agreement_info->eph_iv->length==8);
|
||||
memcpy(wrappedKey,gkt->key_agreement_info->eph_iv->data,8);
|
||||
|
||||
@@ -123,7 +123,7 @@ static int pkey_gost_ctrl94_str(EVP_PKEY_CTX *ctx,
|
||||
}
|
||||
if (strlen(value) == 1)
|
||||
{
|
||||
switch(toupper(value[0]))
|
||||
switch(toupper((unsigned char)value[0]))
|
||||
{
|
||||
case 'A':
|
||||
param_nid = NID_id_GostR3410_94_CryptoPro_A_ParamSet;
|
||||
@@ -142,9 +142,9 @@ static int pkey_gost_ctrl94_str(EVP_PKEY_CTX *ctx,
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((strlen(value) == 2) && (toupper(value[0]) == 'X'))
|
||||
else if ((strlen(value) == 2) && (toupper((unsigned char)value[0]) == 'X'))
|
||||
{
|
||||
switch (toupper(value[1]))
|
||||
switch (toupper((unsigned char)value[1]))
|
||||
{
|
||||
case 'A':
|
||||
param_nid = NID_id_GostR3410_94_CryptoPro_XchA_ParamSet;
|
||||
@@ -198,7 +198,7 @@ static int pkey_gost_ctrl01_str(EVP_PKEY_CTX *ctx,
|
||||
}
|
||||
if (strlen(value) == 1)
|
||||
{
|
||||
switch(toupper(value[0]))
|
||||
switch(toupper((unsigned char)value[0]))
|
||||
{
|
||||
case 'A':
|
||||
param_nid = NID_id_GostR3410_2001_CryptoPro_A_ParamSet;
|
||||
@@ -217,9 +217,9 @@ static int pkey_gost_ctrl01_str(EVP_PKEY_CTX *ctx,
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((strlen(value) == 2) && (toupper(value[0]) == 'X'))
|
||||
else if ((strlen(value) == 2) && (toupper((unsigned char)value[0]) == 'X'))
|
||||
{
|
||||
switch (toupper(value[1]))
|
||||
switch (toupper((unsigned char)value[1]))
|
||||
{
|
||||
case 'A':
|
||||
param_nid = NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet;
|
||||
@@ -521,6 +521,7 @@ static int pkey_gost_mac_ctrl_str(EVP_PKEY_CTX *ctx,
|
||||
{
|
||||
GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL_STR,
|
||||
GOST_R_INVALID_MAC_KEY_LENGTH);
|
||||
OPENSSL_free(keybuf);
|
||||
return 0;
|
||||
}
|
||||
ret= pkey_gost_mac_ctrl(ctx, EVP_PKEY_CTRL_SET_MAC_KEY,
|
||||
|
||||
@@ -442,28 +442,36 @@ static int capi_init(ENGINE *e)
|
||||
CAPI_CTX *ctx;
|
||||
const RSA_METHOD *ossl_rsa_meth;
|
||||
const DSA_METHOD *ossl_dsa_meth;
|
||||
capi_idx = ENGINE_get_ex_new_index(0, NULL, NULL, NULL, 0);
|
||||
cert_capi_idx = X509_get_ex_new_index(0, NULL, NULL, NULL, 0);
|
||||
|
||||
if (capi_idx < 0)
|
||||
{
|
||||
capi_idx = ENGINE_get_ex_new_index(0, NULL, NULL, NULL, 0);
|
||||
if (capi_idx < 0)
|
||||
goto memerr;
|
||||
|
||||
cert_capi_idx = X509_get_ex_new_index(0, NULL, NULL, NULL, 0);
|
||||
|
||||
/* Setup RSA_METHOD */
|
||||
rsa_capi_idx = RSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
|
||||
ossl_rsa_meth = RSA_PKCS1_SSLeay();
|
||||
capi_rsa_method.rsa_pub_enc = ossl_rsa_meth->rsa_pub_enc;
|
||||
capi_rsa_method.rsa_pub_dec = ossl_rsa_meth->rsa_pub_dec;
|
||||
capi_rsa_method.rsa_mod_exp = ossl_rsa_meth->rsa_mod_exp;
|
||||
capi_rsa_method.bn_mod_exp = ossl_rsa_meth->bn_mod_exp;
|
||||
|
||||
/* Setup DSA Method */
|
||||
dsa_capi_idx = DSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
|
||||
ossl_dsa_meth = DSA_OpenSSL();
|
||||
capi_dsa_method.dsa_do_verify = ossl_dsa_meth->dsa_do_verify;
|
||||
capi_dsa_method.dsa_mod_exp = ossl_dsa_meth->dsa_mod_exp;
|
||||
capi_dsa_method.bn_mod_exp = ossl_dsa_meth->bn_mod_exp;
|
||||
}
|
||||
|
||||
ctx = capi_ctx_new();
|
||||
if (!ctx || (capi_idx < 0))
|
||||
if (!ctx)
|
||||
goto memerr;
|
||||
|
||||
ENGINE_set_ex_data(e, capi_idx, ctx);
|
||||
/* Setup RSA_METHOD */
|
||||
rsa_capi_idx = RSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
|
||||
ossl_rsa_meth = RSA_PKCS1_SSLeay();
|
||||
capi_rsa_method.rsa_pub_enc = ossl_rsa_meth->rsa_pub_enc;
|
||||
capi_rsa_method.rsa_pub_dec = ossl_rsa_meth->rsa_pub_dec;
|
||||
capi_rsa_method.rsa_mod_exp = ossl_rsa_meth->rsa_mod_exp;
|
||||
capi_rsa_method.bn_mod_exp = ossl_rsa_meth->bn_mod_exp;
|
||||
|
||||
/* Setup DSA Method */
|
||||
dsa_capi_idx = DSA_get_ex_new_index(0, NULL, NULL, NULL, 0);
|
||||
ossl_dsa_meth = DSA_OpenSSL();
|
||||
capi_dsa_method.dsa_do_verify = ossl_dsa_meth->dsa_do_verify;
|
||||
capi_dsa_method.dsa_mod_exp = ossl_dsa_meth->dsa_mod_exp;
|
||||
capi_dsa_method.bn_mod_exp = ossl_dsa_meth->bn_mod_exp;
|
||||
|
||||
#ifdef OPENSSL_CAPIENG_DIALOG
|
||||
{
|
||||
@@ -1155,6 +1163,7 @@ static int capi_list_containers(CAPI_CTX *ctx, BIO *out)
|
||||
{
|
||||
CAPIerr(CAPI_F_CAPI_LIST_CONTAINERS, CAPI_R_ENUMCONTAINERS_ERROR);
|
||||
capi_addlasterror();
|
||||
CryptReleaseContext(hprov, 0);
|
||||
return 0;
|
||||
}
|
||||
CAPI_trace(ctx, "Got max container len %d\n", buflen);
|
||||
@@ -1572,6 +1581,8 @@ static int capi_ctx_set_provname(CAPI_CTX *ctx, LPSTR pname, DWORD type, int che
|
||||
}
|
||||
CryptReleaseContext(hprov, 0);
|
||||
}
|
||||
if (ctx->cspname)
|
||||
OPENSSL_free(ctx->cspname);
|
||||
ctx->cspname = BUF_strdup(pname);
|
||||
ctx->csptype = type;
|
||||
return 1;
|
||||
@@ -1581,9 +1592,12 @@ static int capi_ctx_set_provname_idx(CAPI_CTX *ctx, int idx)
|
||||
{
|
||||
LPSTR pname;
|
||||
DWORD type;
|
||||
int res;
|
||||
if (capi_get_provname(ctx, &pname, &type, idx) != 1)
|
||||
return 0;
|
||||
return capi_ctx_set_provname(ctx, pname, type, 0);
|
||||
res = capi_ctx_set_provname(ctx, pname, type, 0);
|
||||
OPENSSL_free(pname);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int cert_issuer_match(STACK_OF(X509_NAME) *ca_dn, X509 *x)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
%define libmaj 1
|
||||
%define libmin 0
|
||||
%define librel 0
|
||||
%define librev e
|
||||
%define librev j
|
||||
Release: 1
|
||||
|
||||
%define openssldir /var/ssl
|
||||
|
||||
@@ -538,6 +538,7 @@ err:
|
||||
|
||||
BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
|
||||
{
|
||||
#ifndef OPENSSL_NO_SOCK
|
||||
BIO *ret=NULL,*con=NULL,*ssl=NULL;
|
||||
|
||||
if ((con=BIO_new(BIO_s_connect())) == NULL)
|
||||
@@ -549,6 +550,7 @@ BIO *BIO_new_ssl_connect(SSL_CTX *ctx)
|
||||
return(ret);
|
||||
err:
|
||||
if (con != NULL) BIO_free(con);
|
||||
#endif
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,6 @@ static unsigned char bitmask_end_values[] = {0xff, 0x01, 0x03, 0x07, 0x0f, 0x1
|
||||
/* XDTLS: figure out the right values */
|
||||
static unsigned int g_probable_mtu[] = {1500 - 28, 512 - 28, 256 - 28};
|
||||
|
||||
static unsigned int dtls1_min_mtu(void);
|
||||
static unsigned int dtls1_guess_mtu(unsigned int curr_mtu);
|
||||
static void dtls1_fix_message_header(SSL *s, unsigned long frag_off,
|
||||
unsigned long frag_len);
|
||||
@@ -228,14 +227,14 @@ int dtls1_do_write(SSL *s, int type)
|
||||
unsigned int len, frag_off, mac_size, blocksize;
|
||||
|
||||
/* AHA! Figure out the MTU, and stick to the right size */
|
||||
if ( ! (SSL_get_options(s) & SSL_OP_NO_QUERY_MTU))
|
||||
if (s->d1->mtu < dtls1_min_mtu() && !(SSL_get_options(s) & SSL_OP_NO_QUERY_MTU))
|
||||
{
|
||||
s->d1->mtu =
|
||||
BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_QUERY_MTU, 0, NULL);
|
||||
|
||||
/* I've seen the kernel return bogus numbers when it doesn't know
|
||||
* (initial write), so just make sure we have a reasonable number */
|
||||
if ( s->d1->mtu < dtls1_min_mtu())
|
||||
if (s->d1->mtu < dtls1_min_mtu())
|
||||
{
|
||||
s->d1->mtu = 0;
|
||||
s->d1->mtu = dtls1_guess_mtu(s->d1->mtu);
|
||||
@@ -264,11 +263,10 @@ int dtls1_do_write(SSL *s, int type)
|
||||
return ret;
|
||||
mtu = s->d1->mtu - (DTLS1_HM_HEADER_LENGTH + DTLS1_RT_HEADER_LENGTH);
|
||||
}
|
||||
|
||||
OPENSSL_assert(mtu > 0); /* should have something reasonable now */
|
||||
|
||||
#endif
|
||||
|
||||
OPENSSL_assert(s->d1->mtu >= dtls1_min_mtu()); /* should have something reasonable now */
|
||||
|
||||
if ( s->init_off == 0 && type == SSL3_RT_HANDSHAKE)
|
||||
OPENSSL_assert(s->init_num ==
|
||||
(int)s->d1->w_msg_hdr.msg_len + DTLS1_HM_HEADER_LENGTH);
|
||||
@@ -795,7 +793,13 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok)
|
||||
*ok = 0;
|
||||
return i;
|
||||
}
|
||||
OPENSSL_assert(i == DTLS1_HM_HEADER_LENGTH);
|
||||
/* Handshake fails if message header is incomplete */
|
||||
if (i != DTLS1_HM_HEADER_LENGTH)
|
||||
{
|
||||
al=SSL_AD_UNEXPECTED_MESSAGE;
|
||||
SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL_R_UNEXPECTED_MESSAGE);
|
||||
goto f_err;
|
||||
}
|
||||
|
||||
/* parse the message fragment header */
|
||||
dtls1_get_message_header(wire, &msg_hdr);
|
||||
@@ -867,7 +871,12 @@ dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok)
|
||||
|
||||
/* XDTLS: an incorrectly formatted fragment should cause the
|
||||
* handshake to fail */
|
||||
OPENSSL_assert(i == (int)frag_len);
|
||||
if (i != (int)frag_len)
|
||||
{
|
||||
al=SSL3_AD_ILLEGAL_PARAMETER;
|
||||
SSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL3_AD_ILLEGAL_PARAMETER);
|
||||
goto f_err;
|
||||
}
|
||||
|
||||
*ok = 1;
|
||||
|
||||
@@ -1367,7 +1376,7 @@ dtls1_write_message_header(SSL *s, unsigned char *p)
|
||||
return p;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
unsigned int
|
||||
dtls1_min_mtu(void)
|
||||
{
|
||||
return (g_probable_mtu[(sizeof(g_probable_mtu) /
|
||||
|
||||
@@ -260,7 +260,6 @@ int dtls1_connect(SSL *s)
|
||||
if (ret <= 0) goto end;
|
||||
else
|
||||
{
|
||||
dtls1_stop_timer(s);
|
||||
if (s->hit)
|
||||
s->state=SSL3_ST_CR_FINISHED_A;
|
||||
else
|
||||
@@ -354,6 +353,7 @@ int dtls1_connect(SSL *s)
|
||||
case SSL3_ST_CR_SRVR_DONE_B:
|
||||
ret=ssl3_get_server_done(s);
|
||||
if (ret <= 0) goto end;
|
||||
dtls1_stop_timer(s);
|
||||
if (s->s3->tmp.cert_req)
|
||||
s->state=SSL3_ST_CW_CERT_A;
|
||||
else
|
||||
|
||||
@@ -260,7 +260,7 @@ int dtls1_enc(SSL *s, int send)
|
||||
}
|
||||
/* TLS 1.0 does not bound the number of padding bytes by the block size.
|
||||
* All of them must have value 'padding_length'. */
|
||||
if (i > (int)rec->length)
|
||||
if (i + bs > (int)rec->length)
|
||||
{
|
||||
/* Incorrect padding. SSLerr() and ssl3_alert are done
|
||||
* by caller: we don't want to reveal whether this is
|
||||
|
||||
49
ssl/d1_lib.c
49
ssl/d1_lib.c
@@ -204,7 +204,8 @@ void dtls1_clear(SSL *s)
|
||||
pqueue buffered_messages;
|
||||
pqueue sent_messages;
|
||||
pqueue buffered_app_data;
|
||||
|
||||
unsigned int mtu;
|
||||
|
||||
if (s->d1)
|
||||
{
|
||||
unprocessed_rcds = s->d1->unprocessed_rcds.q;
|
||||
@@ -212,6 +213,7 @@ void dtls1_clear(SSL *s)
|
||||
buffered_messages = s->d1->buffered_messages;
|
||||
sent_messages = s->d1->sent_messages;
|
||||
buffered_app_data = s->d1->buffered_app_data.q;
|
||||
mtu = s->d1->mtu;
|
||||
|
||||
dtls1_clear_queues(s);
|
||||
|
||||
@@ -222,6 +224,11 @@ void dtls1_clear(SSL *s)
|
||||
s->d1->cookie_len = sizeof(s->d1->cookie);
|
||||
}
|
||||
|
||||
if (SSL_get_options(s) & SSL_OP_NO_QUERY_MTU)
|
||||
{
|
||||
s->d1->mtu = mtu;
|
||||
}
|
||||
|
||||
s->d1->unprocessed_rcds.q = unprocessed_rcds;
|
||||
s->d1->processed_rcds.q = processed_rcds;
|
||||
s->d1->buffered_messages = buffered_messages;
|
||||
@@ -374,6 +381,7 @@ void dtls1_double_timeout(SSL *s)
|
||||
void dtls1_stop_timer(SSL *s)
|
||||
{
|
||||
/* Reset everything */
|
||||
memset(&(s->d1->timeout), 0, sizeof(struct dtls1_timeout_st));
|
||||
memset(&(s->d1->next_timeout), 0, sizeof(struct timeval));
|
||||
s->d1->timeout_duration = 1;
|
||||
BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, &(s->d1->next_timeout));
|
||||
@@ -381,10 +389,28 @@ void dtls1_stop_timer(SSL *s)
|
||||
dtls1_clear_record_buffer(s);
|
||||
}
|
||||
|
||||
int dtls1_check_timeout_num(SSL *s)
|
||||
{
|
||||
s->d1->timeout.num_alerts++;
|
||||
|
||||
/* Reduce MTU after 2 unsuccessful retransmissions */
|
||||
if (s->d1->timeout.num_alerts > 2)
|
||||
{
|
||||
s->d1->mtu = BIO_ctrl(SSL_get_wbio(s), BIO_CTRL_DGRAM_GET_FALLBACK_MTU, 0, NULL);
|
||||
}
|
||||
|
||||
if (s->d1->timeout.num_alerts > DTLS1_TMO_ALERT_COUNT)
|
||||
{
|
||||
/* fail the connection, enough alerts have been sent */
|
||||
SSLerr(SSL_F_DTLS1_CHECK_TIMEOUT_NUM,SSL_R_READ_TIMEOUT_EXPIRED);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dtls1_handle_timeout(SSL *s)
|
||||
{
|
||||
DTLS1_STATE *state;
|
||||
|
||||
/* if no timer is expired, don't do anything */
|
||||
if (!dtls1_is_timer_expired(s))
|
||||
{
|
||||
@@ -392,19 +418,14 @@ int dtls1_handle_timeout(SSL *s)
|
||||
}
|
||||
|
||||
dtls1_double_timeout(s);
|
||||
state = s->d1;
|
||||
state->timeout.num_alerts++;
|
||||
if ( state->timeout.num_alerts > DTLS1_TMO_ALERT_COUNT)
|
||||
{
|
||||
/* fail the connection, enough alerts have been sent */
|
||||
SSLerr(SSL_F_DTLS1_HANDLE_TIMEOUT,SSL_R_READ_TIMEOUT_EXPIRED);
|
||||
return -1;
|
||||
}
|
||||
|
||||
state->timeout.read_timeouts++;
|
||||
if ( state->timeout.read_timeouts > DTLS1_TMO_READ_COUNT)
|
||||
if (dtls1_check_timeout_num(s) < 0)
|
||||
return -1;
|
||||
|
||||
s->d1->timeout.read_timeouts++;
|
||||
if (s->d1->timeout.read_timeouts > DTLS1_TMO_READ_COUNT)
|
||||
{
|
||||
state->timeout.read_timeouts = 1;
|
||||
s->d1->timeout.read_timeouts = 1;
|
||||
}
|
||||
|
||||
dtls1_start_timer(s);
|
||||
|
||||
53
ssl/d1_pkt.c
53
ssl/d1_pkt.c
@@ -179,7 +179,6 @@ static int dtls1_record_needs_buffering(SSL *s, SSL3_RECORD *rr,
|
||||
static int dtls1_buffer_record(SSL *s, record_pqueue *q,
|
||||
unsigned char *priority);
|
||||
static int dtls1_process_record(SSL *s);
|
||||
static void dtls1_clear_timeouts(SSL *s);
|
||||
|
||||
/* copy buffered record into SSL structure */
|
||||
static int
|
||||
@@ -375,6 +374,8 @@ dtls1_process_record(SSL *s)
|
||||
SSL3_RECORD *rr;
|
||||
unsigned int mac_size;
|
||||
unsigned char md[EVP_MAX_MD_SIZE];
|
||||
int decryption_failed_or_bad_record_mac = 0;
|
||||
unsigned char *mac = NULL;
|
||||
|
||||
|
||||
rr= &(s->s3->rrec);
|
||||
@@ -409,13 +410,10 @@ dtls1_process_record(SSL *s)
|
||||
enc_err = s->method->ssl3_enc->enc(s,0);
|
||||
if (enc_err <= 0)
|
||||
{
|
||||
/* decryption failed, silently discard message */
|
||||
if (enc_err < 0)
|
||||
{
|
||||
rr->length = 0;
|
||||
s->packet_length = 0;
|
||||
}
|
||||
goto err;
|
||||
/* To minimize information leaked via timing, we will always
|
||||
* perform all computations before discarding the message.
|
||||
*/
|
||||
decryption_failed_or_bad_record_mac = 1;
|
||||
}
|
||||
|
||||
#ifdef TLS_DEBUG
|
||||
@@ -445,28 +443,32 @@ printf("\n");
|
||||
SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);
|
||||
goto f_err;
|
||||
#else
|
||||
goto err;
|
||||
decryption_failed_or_bad_record_mac = 1;
|
||||
#endif
|
||||
}
|
||||
/* check the MAC for rr->input (it's in mac_size bytes at the tail) */
|
||||
if (rr->length < mac_size)
|
||||
if (rr->length >= mac_size)
|
||||
{
|
||||
#if 0 /* OK only for stream ciphers */
|
||||
al=SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_LENGTH_TOO_SHORT);
|
||||
goto f_err;
|
||||
#else
|
||||
goto err;
|
||||
#endif
|
||||
rr->length -= mac_size;
|
||||
mac = &rr->data[rr->length];
|
||||
}
|
||||
rr->length-=mac_size;
|
||||
else
|
||||
rr->length = 0;
|
||||
i=s->method->ssl3_enc->mac(s,md,0);
|
||||
if (i < 0 || memcmp(md,&(rr->data[rr->length]),mac_size) != 0)
|
||||
if (i < 0 || mac == NULL || memcmp(md, mac, mac_size) != 0)
|
||||
{
|
||||
goto err;
|
||||
decryption_failed_or_bad_record_mac = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (decryption_failed_or_bad_record_mac)
|
||||
{
|
||||
/* decryption failed, silently discard message */
|
||||
rr->length = 0;
|
||||
s->packet_length = 0;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* r->length is now just compressed */
|
||||
if (s->expand != NULL)
|
||||
{
|
||||
@@ -679,7 +681,6 @@ again:
|
||||
goto again; /* get another record */
|
||||
}
|
||||
|
||||
dtls1_clear_timeouts(s); /* done waiting */
|
||||
return(1);
|
||||
|
||||
}
|
||||
@@ -1149,6 +1150,9 @@ start:
|
||||
*/
|
||||
if (msg_hdr.type == SSL3_MT_FINISHED)
|
||||
{
|
||||
if (dtls1_check_timeout_num(s) < 0)
|
||||
return -1;
|
||||
|
||||
dtls1_retransmit_buffered_messages(s);
|
||||
rr->length = 0;
|
||||
goto start;
|
||||
@@ -1762,10 +1766,3 @@ dtls1_reset_seq_numbers(SSL *s, int rw)
|
||||
|
||||
memset(seq, 0x00, seq_bytes);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dtls1_clear_timeouts(SSL *s)
|
||||
{
|
||||
memset(&(s->d1->timeout), 0x00, sizeof(struct dtls1_timeout_st));
|
||||
}
|
||||
|
||||
@@ -485,15 +485,16 @@ int dtls1_accept(SSL *s)
|
||||
ret = ssl3_check_client_hello(s);
|
||||
if (ret <= 0)
|
||||
goto end;
|
||||
dtls1_stop_timer(s);
|
||||
if (ret == 2)
|
||||
{
|
||||
dtls1_stop_timer(s);
|
||||
s->state = SSL3_ST_SR_CLNT_HELLO_C;
|
||||
}
|
||||
else {
|
||||
/* could be sent for a DH cert, even if we
|
||||
* have not asked for it :-) */
|
||||
ret=ssl3_get_client_certificate(s);
|
||||
if (ret <= 0) goto end;
|
||||
dtls1_stop_timer(s);
|
||||
s->init_num=0;
|
||||
s->state=SSL3_ST_SR_KEY_EXCH_A;
|
||||
}
|
||||
@@ -503,7 +504,6 @@ int dtls1_accept(SSL *s)
|
||||
case SSL3_ST_SR_KEY_EXCH_B:
|
||||
ret=ssl3_get_client_key_exchange(s);
|
||||
if (ret <= 0) goto end;
|
||||
dtls1_stop_timer(s);
|
||||
s->state=SSL3_ST_SR_CERT_VRFY_A;
|
||||
s->init_num=0;
|
||||
|
||||
@@ -540,7 +540,6 @@ int dtls1_accept(SSL *s)
|
||||
/* we should decide if we expected this one */
|
||||
ret=ssl3_get_cert_verify(s);
|
||||
if (ret <= 0) goto end;
|
||||
dtls1_stop_timer(s);
|
||||
|
||||
s->state=SSL3_ST_SR_FINISHED_A;
|
||||
s->init_num=0;
|
||||
@@ -772,7 +771,7 @@ int dtls1_send_server_hello(SSL *s)
|
||||
p=s->s3->server_random;
|
||||
Time=(unsigned long)time(NULL); /* Time */
|
||||
l2n(Time,p);
|
||||
RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time));
|
||||
RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-4);
|
||||
/* Do the message type and length last */
|
||||
d=p= &(buf[DTLS1_HM_HEADER_LENGTH]);
|
||||
|
||||
@@ -1271,7 +1270,7 @@ int dtls1_send_server_key_exchange(SSL *s)
|
||||
EVP_SignInit_ex(&md_ctx,EVP_ecdsa(), NULL);
|
||||
EVP_SignUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE);
|
||||
EVP_SignUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE);
|
||||
EVP_SignUpdate(&md_ctx,&(d[4]),n);
|
||||
EVP_SignUpdate(&md_ctx,&(d[DTLS1_HM_HEADER_LENGTH]),n);
|
||||
if (!EVP_SignFinal(&md_ctx,&(p[2]),
|
||||
(unsigned int *)&i,pkey))
|
||||
{
|
||||
|
||||
@@ -953,7 +953,7 @@ int ssl3_get_server_hello(SSL *s)
|
||||
/* wrong packet length */
|
||||
al=SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_BAD_PACKET_LENGTH);
|
||||
goto err;
|
||||
goto f_err;
|
||||
}
|
||||
|
||||
return(1);
|
||||
@@ -1837,7 +1837,7 @@ int ssl3_get_new_session_ticket(SSL *s)
|
||||
if (n < 6)
|
||||
{
|
||||
/* need at least ticket_lifetime_hint + ticket length */
|
||||
al = SSL3_AL_FATAL,SSL_AD_DECODE_ERROR;
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET,SSL_R_LENGTH_MISMATCH);
|
||||
goto f_err;
|
||||
}
|
||||
@@ -1848,7 +1848,7 @@ int ssl3_get_new_session_ticket(SSL *s)
|
||||
/* ticket_lifetime_hint + ticket_length + ticket */
|
||||
if (ticklen + 6 != n)
|
||||
{
|
||||
al = SSL3_AL_FATAL,SSL_AD_DECODE_ERROR;
|
||||
al = SSL_AD_DECODE_ERROR;
|
||||
SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET,SSL_R_LENGTH_MISMATCH);
|
||||
goto f_err;
|
||||
}
|
||||
|
||||
@@ -511,6 +511,9 @@ int ssl3_enc(SSL *s, int send)
|
||||
|
||||
/* we need to add 'i-1' padding bytes */
|
||||
l+=i;
|
||||
/* the last of these zero bytes will be overwritten
|
||||
* with the padding length. */
|
||||
memset(&rec->input[rec->length], 0, i);
|
||||
rec->length+=i;
|
||||
rec->input[l-1]=(i-1);
|
||||
}
|
||||
|
||||
@@ -2177,6 +2177,7 @@ void ssl3_clear(SSL *s)
|
||||
{
|
||||
unsigned char *rp,*wp;
|
||||
size_t rlen, wlen;
|
||||
int init_extra;
|
||||
|
||||
#ifdef TLSEXT_TYPE_opaque_prf_input
|
||||
if (s->s3->client_opaque_prf_input != NULL)
|
||||
@@ -2215,6 +2216,7 @@ void ssl3_clear(SSL *s)
|
||||
wp = s->s3->wbuf.buf;
|
||||
rlen = s->s3->rbuf.len;
|
||||
wlen = s->s3->wbuf.len;
|
||||
init_extra = s->s3->init_extra;
|
||||
if (s->s3->handshake_buffer) {
|
||||
BIO_free(s->s3->handshake_buffer);
|
||||
s->s3->handshake_buffer = NULL;
|
||||
@@ -2227,6 +2229,7 @@ void ssl3_clear(SSL *s)
|
||||
s->s3->wbuf.buf = wp;
|
||||
s->s3->rbuf.len = rlen;
|
||||
s->s3->wbuf.len = wlen;
|
||||
s->s3->init_extra = init_extra;
|
||||
|
||||
ssl_free_wbio_buffer(s);
|
||||
|
||||
|
||||
@@ -258,6 +258,7 @@ int ssl3_accept(SSL *s)
|
||||
}
|
||||
|
||||
s->init_num=0;
|
||||
s->s3->flags &= ~SSL3_FLAGS_SGC_RESTART_DONE;
|
||||
|
||||
if (s->state != SSL_ST_RENEGOTIATE)
|
||||
{
|
||||
@@ -767,6 +768,13 @@ int ssl3_check_client_hello(SSL *s)
|
||||
s->s3->tmp.reuse_message = 1;
|
||||
if (s->s3->tmp.message_type == SSL3_MT_CLIENT_HELLO)
|
||||
{
|
||||
/* We only allow the client to restart the handshake once per
|
||||
* negotiation. */
|
||||
if (s->s3->flags & SSL3_FLAGS_SGC_RESTART_DONE)
|
||||
{
|
||||
SSLerr(SSL_F_SSL3_CHECK_CLIENT_HELLO, SSL_R_MULTIPLE_SGC_RESTARTS);
|
||||
return -1;
|
||||
}
|
||||
/* Throw away what we have done so far in the current handshake,
|
||||
* which will now be aborted. (A full SSL_clear would be too much.) */
|
||||
#ifndef OPENSSL_NO_DH
|
||||
@@ -783,6 +791,7 @@ int ssl3_check_client_hello(SSL *s)
|
||||
s->s3->tmp.ecdh = NULL;
|
||||
}
|
||||
#endif
|
||||
s->s3->flags |= SSL3_FLAGS_SGC_RESTART_DONE;
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
@@ -2130,6 +2139,7 @@ int ssl3_get_client_key_exchange(SSL *s)
|
||||
if (i <= 0)
|
||||
{
|
||||
SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,ERR_R_DH_LIB);
|
||||
BN_clear_free(pub);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -2718,7 +2728,7 @@ int ssl3_get_cert_verify(SSL *s)
|
||||
if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE_VERIFY)
|
||||
{
|
||||
s->s3->tmp.reuse_message=1;
|
||||
if ((peer != NULL) && (type | EVP_PKT_SIGN))
|
||||
if ((peer != NULL) && (type & EVP_PKT_SIGN))
|
||||
{
|
||||
al=SSL_AD_UNEXPECTED_MESSAGE;
|
||||
SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_MISSING_VERIFY_MESSAGE);
|
||||
|
||||
@@ -1825,6 +1825,7 @@ void ERR_load_SSL_strings(void);
|
||||
#define SSL_F_DTLS1_ACCEPT 246
|
||||
#define SSL_F_DTLS1_ADD_CERT_TO_BUF 295
|
||||
#define SSL_F_DTLS1_BUFFER_RECORD 247
|
||||
#define SSL_F_DTLS1_CHECK_TIMEOUT_NUM 305
|
||||
#define SSL_F_DTLS1_CLIENT_HELLO 248
|
||||
#define SSL_F_DTLS1_CONNECT 249
|
||||
#define SSL_F_DTLS1_ENC 250
|
||||
@@ -1882,6 +1883,7 @@ void ERR_load_SSL_strings(void);
|
||||
#define SSL_F_SSL3_CALLBACK_CTRL 233
|
||||
#define SSL_F_SSL3_CHANGE_CIPHER_STATE 129
|
||||
#define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130
|
||||
#define SSL_F_SSL3_CHECK_CLIENT_HELLO 304
|
||||
#define SSL_F_SSL3_CLIENT_HELLO 131
|
||||
#define SSL_F_SSL3_CONNECT 132
|
||||
#define SSL_F_SSL3_CTRL 213
|
||||
@@ -2139,6 +2141,7 @@ void ERR_load_SSL_strings(void);
|
||||
#define SSL_R_MISSING_TMP_RSA_KEY 172
|
||||
#define SSL_R_MISSING_TMP_RSA_PKEY 173
|
||||
#define SSL_R_MISSING_VERIFY_MESSAGE 174
|
||||
#define SSL_R_MULTIPLE_SGC_RESTARTS 346
|
||||
#define SSL_R_NON_SSLV2_INITIAL_PACKET 175
|
||||
#define SSL_R_NO_CERTIFICATES_RETURNED 176
|
||||
#define SSL_R_NO_CERTIFICATE_ASSIGNED 177
|
||||
|
||||
11
ssl/ssl3.h
11
ssl/ssl3.h
@@ -379,6 +379,17 @@ typedef struct ssl3_buffer_st
|
||||
#define SSL3_FLAGS_POP_BUFFER 0x0004
|
||||
#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008
|
||||
#define TLS1_FLAGS_SKIP_CERT_VERIFY 0x0010
|
||||
|
||||
/* SSL3_FLAGS_SGC_RESTART_DONE is set when we
|
||||
* restart a handshake because of MS SGC and so prevents us
|
||||
* from restarting the handshake in a loop. It's reset on a
|
||||
* renegotiation, so effectively limits the client to one restart
|
||||
* per negotiation. This limits the possibility of a DDoS
|
||||
* attack where the client handshakes in a loop using SGC to
|
||||
* restart. Servers which permit renegotiation can still be
|
||||
* effected, but we can't prevent that.
|
||||
*/
|
||||
#define SSL3_FLAGS_SGC_RESTART_DONE 0x0040
|
||||
|
||||
typedef struct ssl3_state_st
|
||||
{
|
||||
|
||||
@@ -446,6 +446,7 @@ static void load_builtin_compressions(void)
|
||||
sk_SSL_COMP_push(ssl_comp_methods,comp);
|
||||
}
|
||||
}
|
||||
sk_SSL_COMP_sort(ssl_comp_methods);
|
||||
}
|
||||
MemCheck_on();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* ssl/ssl_err.c */
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1999-2009 The OpenSSL Project. All rights reserved.
|
||||
* Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -80,6 +80,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
||||
{ERR_FUNC(SSL_F_DTLS1_ACCEPT), "DTLS1_ACCEPT"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_ADD_CERT_TO_BUF), "DTLS1_ADD_CERT_TO_BUF"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_BUFFER_RECORD), "DTLS1_BUFFER_RECORD"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_CHECK_TIMEOUT_NUM), "DTLS1_CHECK_TIMEOUT_NUM"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_CLIENT_HELLO), "DTLS1_CLIENT_HELLO"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_CONNECT), "DTLS1_CONNECT"},
|
||||
{ERR_FUNC(SSL_F_DTLS1_ENC), "DTLS1_ENC"},
|
||||
@@ -137,6 +138,7 @@ static ERR_STRING_DATA SSL_str_functs[]=
|
||||
{ERR_FUNC(SSL_F_SSL3_CALLBACK_CTRL), "SSL3_CALLBACK_CTRL"},
|
||||
{ERR_FUNC(SSL_F_SSL3_CHANGE_CIPHER_STATE), "SSL3_CHANGE_CIPHER_STATE"},
|
||||
{ERR_FUNC(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM), "SSL3_CHECK_CERT_AND_ALGORITHM"},
|
||||
{ERR_FUNC(SSL_F_SSL3_CHECK_CLIENT_HELLO), "SSL3_CHECK_CLIENT_HELLO"},
|
||||
{ERR_FUNC(SSL_F_SSL3_CLIENT_HELLO), "SSL3_CLIENT_HELLO"},
|
||||
{ERR_FUNC(SSL_F_SSL3_CONNECT), "SSL3_CONNECT"},
|
||||
{ERR_FUNC(SSL_F_SSL3_CTRL), "SSL3_CTRL"},
|
||||
@@ -397,6 +399,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
|
||||
{ERR_REASON(SSL_R_MISSING_TMP_RSA_KEY) ,"missing tmp rsa key"},
|
||||
{ERR_REASON(SSL_R_MISSING_TMP_RSA_PKEY) ,"missing tmp rsa pkey"},
|
||||
{ERR_REASON(SSL_R_MISSING_VERIFY_MESSAGE),"missing verify message"},
|
||||
{ERR_REASON(SSL_R_MULTIPLE_SGC_RESTARTS) ,"multiple sgc restarts"},
|
||||
{ERR_REASON(SSL_R_NON_SSLV2_INITIAL_PACKET),"non sslv2 initial packet"},
|
||||
{ERR_REASON(SSL_R_NO_CERTIFICATES_RETURNED),"no certificates returned"},
|
||||
{ERR_REASON(SSL_R_NO_CERTIFICATE_ASSIGNED),"no certificate assigned"},
|
||||
|
||||
@@ -1054,6 +1054,11 @@ long SSL_ctrl(SSL *s,int cmd,long larg,void *parg)
|
||||
s->max_cert_list=larg;
|
||||
return(l);
|
||||
case SSL_CTRL_SET_MTU:
|
||||
#ifndef OPENSSL_NO_DTLS1
|
||||
if (larg < (long)dtls1_min_mtu())
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if (SSL_version(s) == DTLS1_VERSION ||
|
||||
SSL_version(s) == DTLS1_BAD_VER)
|
||||
{
|
||||
@@ -3042,4 +3047,3 @@ IMPLEMENT_STACK_OF(SSL_CIPHER)
|
||||
IMPLEMENT_STACK_OF(SSL_COMP)
|
||||
IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(SSL_CIPHER, SSL_CIPHER,
|
||||
ssl_cipher_id);
|
||||
|
||||
|
||||
@@ -943,6 +943,7 @@ void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr);
|
||||
void dtls1_reset_seq_numbers(SSL *s, int rw);
|
||||
long dtls1_default_timeout(void);
|
||||
struct timeval* dtls1_get_timeout(SSL *s, struct timeval* timeleft);
|
||||
int dtls1_check_timeout_num(SSL *s);
|
||||
int dtls1_handle_timeout(SSL *s);
|
||||
const SSL_CIPHER *dtls1_get_cipher(unsigned int u);
|
||||
void dtls1_start_timer(SSL *s);
|
||||
@@ -950,6 +951,7 @@ void dtls1_stop_timer(SSL *s);
|
||||
int dtls1_is_timer_expired(SSL *s);
|
||||
void dtls1_double_timeout(SSL *s);
|
||||
int dtls1_send_newsession_ticket(SSL *s);
|
||||
unsigned int dtls1_min_mtu(void);
|
||||
|
||||
/* some client-only functions */
|
||||
int ssl3_client_hello(SSL *s);
|
||||
|
||||
@@ -971,6 +971,12 @@ int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, in
|
||||
sdata = data;
|
||||
if (dsize > 0)
|
||||
{
|
||||
if (s->tlsext_ocsp_exts)
|
||||
{
|
||||
sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts,
|
||||
X509_EXTENSION_free);
|
||||
}
|
||||
|
||||
s->tlsext_ocsp_exts =
|
||||
d2i_X509_EXTENSIONS(NULL,
|
||||
&sdata, dsize);
|
||||
|
||||
@@ -100,8 +100,8 @@ echo test sslv2/sslv3 via BIO pair
|
||||
$ssltest $extra || exit 1
|
||||
|
||||
if [ $dsa_cert = NO ]; then
|
||||
echo test sslv2/sslv3 w/o DHE via BIO pair
|
||||
$ssltest -bio_pair -no_dhe $extra || exit 1
|
||||
echo 'test sslv2/sslv3 w/o (EC)DHE via BIO pair'
|
||||
$ssltest -bio_pair -no_dhe -no_ecdhe $extra || exit 1
|
||||
fi
|
||||
|
||||
echo test sslv2/sslv3 with 1024bit DHE via BIO pair
|
||||
@@ -131,8 +131,8 @@ fi
|
||||
if ../util/shlib_wrap.sh ../apps/openssl no-rsa; then
|
||||
echo skipping RSA tests
|
||||
else
|
||||
echo test tls1 with 1024bit RSA, no DHE, multiple handshakes
|
||||
../util/shlib_wrap.sh ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -num 10 -f -time $extra || exit 1
|
||||
echo 'test tls1 with 1024bit RSA, no (EC)DHE, multiple handshakes'
|
||||
../util/shlib_wrap.sh ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -no_ecdhe -num 10 -f -time $extra || exit 1
|
||||
|
||||
if ../util/shlib_wrap.sh ../apps/openssl no-dh; then
|
||||
echo skipping RSA+DHE tests
|
||||
|
||||
@@ -769,7 +769,7 @@ EOF
|
||||
undef %err_reason_strings;
|
||||
}
|
||||
|
||||
if($debug && defined(%notrans)) {
|
||||
if($debug && %notrans) {
|
||||
print STDERR "The following function codes were not translated:\n";
|
||||
foreach(sort keys %notrans)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user