Skip to content

Commit c9685a7

Browse files
author
Robert Golebiowski
committed
Bug #20168526 YASSL: CORRUPT SSL-KEY CRASHES CLIENT
Affects at least 5.6 and 5.7. In customer case, the "client" happened to be a replication slave, therefore his server crashed. Bug-fix: The bug was in yassl. Todd Ouska has provided us with the patch. (cherry picked from commit 42ffa91aad898b02f0793b669ffd04f5c178ce39)
1 parent bf681d6 commit c9685a7

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

extra/yassl/README

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

1313
*** end Note ***
1414

15+
yaSSL Patch notes, version 2.3.7b (3/18/2015)
16+
This release of yaSSL fixes a potential crash with corrupted private keys.
17+
Also detects bad keys earlier for user.
18+
1519
yaSSL Release notes, version 2.3.7 (12/10/2014)
1620
This release of yaSSL fixes the potential to process duplicate handshake
1721
messages by explicitly marking/checking received handshake messages.

extra/yassl/include/openssl/ssl.h

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

3737

38-
#define YASSL_VERSION "2.3.7"
38+
#define YASSL_VERSION "2.3.7b"
3939

4040

4141
#if defined(__cplusplus)

extra/yassl/src/ssl.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include "file.hpp" // for TaoCrypt Source
3838
#include "coding.hpp" // HexDecoder
3939
#include "helpers.hpp" // for placement new hack
40+
#include "rsa.hpp" // for TaoCrypt RSA key decode
41+
#include "dsa.hpp" // for TaoCrypt DSA key decode
4042
#include <stdio.h>
4143

4244
#ifdef _WIN32
@@ -54,6 +56,8 @@ namespace yaSSL {
5456

5557
int read_file(SSL_CTX* ctx, const char* file, int format, CertType type)
5658
{
59+
int ret = SSL_SUCCESS;
60+
5761
if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM)
5862
return SSL_BAD_FILETYPE;
5963

@@ -141,8 +145,31 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type)
141145
}
142146
}
143147
}
148+
149+
if (type == PrivateKey && ctx->privateKey_) {
150+
// see if key is valid early
151+
TaoCrypt::Source rsaSource(ctx->privateKey_->get_buffer(),
152+
ctx->privateKey_->get_length());
153+
TaoCrypt::RSA_PrivateKey rsaKey;
154+
rsaKey.Initialize(rsaSource);
155+
156+
if (rsaSource.GetError().What()) {
157+
// rsa failed see if DSA works
158+
159+
TaoCrypt::Source dsaSource(ctx->privateKey_->get_buffer(),
160+
ctx->privateKey_->get_length());
161+
TaoCrypt::DSA_PrivateKey dsaKey;
162+
dsaKey.Initialize(dsaSource);
163+
164+
if (rsaSource.GetError().What()) {
165+
// neither worked
166+
ret = SSL_FAILURE;
167+
}
168+
}
169+
}
170+
144171
fclose(input);
145-
return SSL_SUCCESS;
172+
return ret;
146173
}
147174

148175

extra/yassl/taocrypt/src/rsa.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ word32 RSA_BlockType2::UnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
140140
void RSA_BlockType1::Pad(const byte* input, word32 inputLen, byte* pkcsBlock,
141141
word32 pkcsBlockLen, RandomNumberGenerator&) const
142142
{
143+
// sanity checks
144+
if (input == NULL || pkcsBlock == NULL)
145+
return;
146+
143147
// convert from bit length to byte length
144148
if (pkcsBlockLen % 8 != 0)
145149
{

extra/yassl/testsuite/cipher-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55

66

7+
no_pid=-1
78
server_pid=$no_pid
89

910

0 commit comments

Comments
 (0)