Skip to content

Commit 601d4e4

Browse files
committed
Merge branch 'mysql-5.5' into mysql-5.6
2 parents 6270c82 + 8c65e08 commit 601d4e4

File tree

6 files changed

+40
-15
lines changed

6 files changed

+40
-15
lines changed

extra/yassl/README

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ before calling SSL_new();
1212

1313
*** end Note ***
1414

15+
yaSSL Release notes, version 2.3.9 (12/01/2015)
16+
This release of yaSSL fixes two client side Diffie-Hellman problems.
17+
yaSSL was only handling the cases of zero or one leading zeros for the key
18+
agreement instead of potentially any number. This caused about 1 in 50,000
19+
connections to fail when using DHE cipher suites. The second problem was
20+
the case where a server would send a public value shorter than the prime
21+
value, causing about 1 in 128 client connections to fail, and also
22+
caused the yaSSL client to read off the end of memory. All client side
23+
DHE cipher suite users should update.
24+
Thanks to Adam Langely ([email protected]) for the detailed report!
25+
1526
yaSSL Release notes, version 2.3.8 (9/17/2015)
1627
This release of yaSSL fixes a high security vulnerability. All users
1728
SHOULD update. If using yaSSL for TLS on the server side with private

extra/yassl/include/crypto_wrapper.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ class DiffieHellman {
377377

378378
uint get_agreedKeyLength() const;
379379
const byte* get_agreedKey() const;
380+
uint get_publicKeyLength() const;
380381
const byte* get_publicKey() const;
381382
void makeAgreement(const byte*, unsigned int);
382383

extra/yassl/include/openssl/ssl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "rsa.h"
3535

3636

37-
#define YASSL_VERSION "2.3.8"
37+
#define YASSL_VERSION "2.3.9"
3838

3939

4040
#if defined(__cplusplus)

extra/yassl/src/crypto_wrapper.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,9 +748,10 @@ struct DiffieHellman::DHImpl {
748748
byte* publicKey_;
749749
byte* privateKey_;
750750
byte* agreedKey_;
751+
uint pubKeyLength_;
751752

752753
DHImpl(TaoCrypt::RandomNumberGenerator& r) : ranPool_(r), publicKey_(0),
753-
privateKey_(0), agreedKey_(0) {}
754+
privateKey_(0), agreedKey_(0), pubKeyLength_(0) {}
754755
~DHImpl()
755756
{
756757
ysArrayDelete(agreedKey_);
@@ -759,7 +760,7 @@ struct DiffieHellman::DHImpl {
759760
}
760761

761762
DHImpl(const DHImpl& that) : dh_(that.dh_), ranPool_(that.ranPool_),
762-
publicKey_(0), privateKey_(0), agreedKey_(0)
763+
publicKey_(0), privateKey_(0), agreedKey_(0), pubKeyLength_(0)
763764
{
764765
uint length = dh_.GetByteLength();
765766
AllocKeys(length, length, length);
@@ -807,7 +808,7 @@ DiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g,
807808
using TaoCrypt::Integer;
808809

809810
pimpl_->dh_.Initialize(Integer(p, pSz).Ref(), Integer(g, gSz).Ref());
810-
pimpl_->publicKey_ = NEW_YS opaque[pubSz];
811+
pimpl_->publicKey_ = NEW_YS opaque[pimpl_->pubKeyLength_ = pubSz];
811812
memcpy(pimpl_->publicKey_, pub, pubSz);
812813
}
813814

@@ -866,6 +867,10 @@ const byte* DiffieHellman::get_agreedKey() const
866867
return pimpl_->agreedKey_;
867868
}
868869

870+
uint DiffieHellman::get_publicKeyLength() const
871+
{
872+
return pimpl_->pubKeyLength_;
873+
}
869874

870875
const byte* DiffieHellman::get_publicKey() const
871876
{

extra/yassl/src/yassl_imp.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,12 @@ void ClientDiffieHellmanPublic::build(SSL& ssl)
109109
uint keyLength = dhClient.get_agreedKeyLength(); // pub and agree same
110110

111111
alloc(keyLength, true);
112-
dhClient.makeAgreement(dhServer.get_publicKey(), keyLength);
112+
dhClient.makeAgreement(dhServer.get_publicKey(),
113+
dhServer.get_publicKeyLength());
113114
c16toa(keyLength, Yc_);
114115
memcpy(Yc_ + KEY_OFFSET, dhClient.get_publicKey(), keyLength);
115116

116-
// because of encoding first byte might be zero, don't use it for preMaster
117-
if (*dhClient.get_agreedKey() == 0)
118-
ssl.set_preMaster(dhClient.get_agreedKey() + 1, keyLength - 1);
119-
else
120-
ssl.set_preMaster(dhClient.get_agreedKey(), keyLength);
117+
ssl.set_preMaster(dhClient.get_agreedKey(), keyLength);
121118
}
122119

123120

@@ -321,11 +318,7 @@ void ClientDiffieHellmanPublic::read(SSL& ssl, input_buffer& input)
321318
}
322319
dh.makeAgreement(Yc_, keyLength);
323320

324-
// because of encoding, first byte might be 0, don't use for preMaster
325-
if (*dh.get_agreedKey() == 0)
326-
ssl.set_preMaster(dh.get_agreedKey() + 1, dh.get_agreedKeyLength() - 1);
327-
else
328-
ssl.set_preMaster(dh.get_agreedKey(), dh.get_agreedKeyLength());
321+
ssl.set_preMaster(dh.get_agreedKey(), dh.get_agreedKeyLength());
329322
ssl.makeMasterSecret();
330323
}
331324

extra/yassl/src/yassl_int.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,19 @@ void SSL::set_random(const opaque* random, ConnectionEnd sender)
859859
// store client pre master secret
860860
void SSL::set_preMaster(const opaque* pre, uint sz)
861861
{
862+
uint i(0); // trim leading zeros
863+
uint fullSz(sz);
864+
865+
while (i++ < fullSz && *pre == 0) {
866+
sz--;
867+
pre++;
868+
}
869+
870+
if (sz == 0) {
871+
SetError(bad_input);
872+
return;
873+
}
874+
862875
secure_.use_connection().AllocPreSecret(sz);
863876
memcpy(secure_.use_connection().pre_master_secret_, pre, sz);
864877
}
@@ -976,6 +989,8 @@ void SSL::order_error()
976989
// Create and store the master secret see page 32, 6.1
977990
void SSL::makeMasterSecret()
978991
{
992+
if (GetError()) return;
993+
979994
if (isTLS())
980995
makeTLSMasterSecret();
981996
else {

0 commit comments

Comments
 (0)