mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
adjust read ahead, some sanity checks and rebase
This commit is contained in:
@@ -1292,7 +1292,9 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
if (wolfSSL_CTX_get_read_ahead(ctx) != 0) {
|
if (wolfSSL_CTX_get_read_ahead(ctx) != 0) {
|
||||||
err_sys("bad read ahead default value");
|
err_sys("bad read ahead default value");
|
||||||
}
|
}
|
||||||
/* wolfSSL_CTX_set_read_ahead(ctx, 1); use not recommended */
|
if (wolfSSL_CTX_set_read_ahead(ctx, 1) != SSL_SUCCESS) {
|
||||||
|
err_sys("error setting read ahead value");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ssl = wolfSSL_new(ctx);
|
ssl = wolfSSL_new(ctx);
|
||||||
|
@@ -9384,15 +9384,6 @@ static int GetInputData(WOLFSSL *ssl, word32 size)
|
|||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OPENSSL_EXTRA
|
|
||||||
/* if read ahead then try to read the full buffer size */
|
|
||||||
if (ssl->readAhead != 0 && ssl->options.usingNonblock) {
|
|
||||||
if (maxLength > inSz) {
|
|
||||||
inSz = maxLength;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* OPENSSL_EXTRA */
|
|
||||||
|
|
||||||
/* Put buffer data at start if not there */
|
/* Put buffer data at start if not there */
|
||||||
if (usedLength > 0 && ssl->buffers.inputBuffer.idx != 0)
|
if (usedLength > 0 && ssl->buffers.inputBuffer.idx != 0)
|
||||||
XMEMMOVE(ssl->buffers.inputBuffer.buffer,
|
XMEMMOVE(ssl->buffers.inputBuffer.buffer,
|
||||||
@@ -9504,7 +9495,7 @@ int ProcessReply(WOLFSSL* ssl)
|
|||||||
int ret = 0, type, readSz;
|
int ret = 0, type, readSz;
|
||||||
int atomicUser = 0;
|
int atomicUser = 0;
|
||||||
word32 startIdx = 0;
|
word32 startIdx = 0;
|
||||||
#if defined(WOLFSSL_DTLS) || defined(OPENSSL_EXTRA)
|
#if defined(WOLFSSL_DTLS)
|
||||||
int used;
|
int used;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -9535,18 +9526,6 @@ int ProcessReply(WOLFSSL* ssl)
|
|||||||
|
|
||||||
/* get header or return error */
|
/* get header or return error */
|
||||||
if (!ssl->options.dtls) {
|
if (!ssl->options.dtls) {
|
||||||
#ifdef OPENSSL_EXTRA
|
|
||||||
(void)used;
|
|
||||||
if (ssl->readAhead != 0 && ssl->options.usingNonblock) {
|
|
||||||
/* read ahead may already have header */
|
|
||||||
used = ssl->buffers.inputBuffer.length -
|
|
||||||
ssl->buffers.inputBuffer.idx;
|
|
||||||
if (used < readSz)
|
|
||||||
if ((ret = GetInputData(ssl, readSz)) < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif /* OPENSSL_EXTRA */
|
|
||||||
if ((ret = GetInputData(ssl, readSz)) < 0)
|
if ((ret = GetInputData(ssl, readSz)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
@@ -9603,17 +9582,6 @@ int ProcessReply(WOLFSSL* ssl)
|
|||||||
|
|
||||||
/* get sz bytes or return error */
|
/* get sz bytes or return error */
|
||||||
if (!ssl->options.dtls) {
|
if (!ssl->options.dtls) {
|
||||||
#ifdef OPENSSL_EXTRA
|
|
||||||
if (ssl->readAhead != 0 && ssl->options.usingNonblock) {
|
|
||||||
/* read ahead may already have */
|
|
||||||
used = ssl->buffers.inputBuffer.length -
|
|
||||||
ssl->buffers.inputBuffer.idx;
|
|
||||||
if (used < ssl->curSize)
|
|
||||||
if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif /* OPENSSL_EXTRA */
|
|
||||||
if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
|
if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
@@ -9675,17 +9643,6 @@ int ProcessReply(WOLFSSL* ssl)
|
|||||||
|
|
||||||
/* get sz bytes or return error */
|
/* get sz bytes or return error */
|
||||||
if (!ssl->options.dtls) {
|
if (!ssl->options.dtls) {
|
||||||
#ifdef OPENSSL_EXTRA
|
|
||||||
if (ssl->readAhead != 0 && ssl->options.usingNonblock) {
|
|
||||||
/* read ahead may already have header */
|
|
||||||
used = ssl->buffers.inputBuffer.length -
|
|
||||||
ssl->buffers.inputBuffer.idx;
|
|
||||||
if (used < ssl->curSize)
|
|
||||||
if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif /* OPENSSL_EXTRA */
|
|
||||||
if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
|
if ((ret = GetInputData(ssl, ssl->curSize)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -2991,6 +2991,8 @@ static void test_wolfSSL_BIO(void)
|
|||||||
AssertIntEQ(BIO_write(f_bio2, cert, sizeof(cert)), sizeof(cert));
|
AssertIntEQ(BIO_write(f_bio2, cert, sizeof(cert)), sizeof(cert));
|
||||||
|
|
||||||
AssertIntEQ((int)BIO_get_fp(f_bio2, &f2), SSL_SUCCESS);
|
AssertIntEQ((int)BIO_get_fp(f_bio2, &f2), SSL_SUCCESS);
|
||||||
|
AssertIntEQ(BIO_reset(f_bio2), 0);
|
||||||
|
AssertIntEQ(BIO_seek(f_bio2, 4), 0);
|
||||||
|
|
||||||
BIO_free(f_bio1);
|
BIO_free(f_bio1);
|
||||||
BIO_free(f_bio2);
|
BIO_free(f_bio2);
|
||||||
|
@@ -78,7 +78,7 @@ WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_free(WOLFSSL_EVP_CIPHER_CTX *ctx)
|
|||||||
WOLFSSL_API int wolfSSL_EVP_EncryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
WOLFSSL_API int wolfSSL_EVP_EncryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||||
unsigned char *out, int *outl)
|
unsigned char *out, int *outl)
|
||||||
{
|
{
|
||||||
if (ctx->enc){
|
if (ctx && ctx->enc){
|
||||||
WOLFSSL_ENTER("wolfSSL_EVP_EncryptFinal");
|
WOLFSSL_ENTER("wolfSSL_EVP_EncryptFinal");
|
||||||
return wolfSSL_EVP_CipherFinal(ctx, out, outl);
|
return wolfSSL_EVP_CipherFinal(ctx, out, outl);
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ WOLFSSL_API int wolfSSL_EVP_EncryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
|||||||
WOLFSSL_API int wolfSSL_EVP_EncryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
WOLFSSL_API int wolfSSL_EVP_EncryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||||
unsigned char *out, int *outl)
|
unsigned char *out, int *outl)
|
||||||
{
|
{
|
||||||
if (ctx->enc){
|
if (ctx && ctx->enc){
|
||||||
WOLFSSL_ENTER("wolfSSL_EVP_EncryptFinal_ex");
|
WOLFSSL_ENTER("wolfSSL_EVP_EncryptFinal_ex");
|
||||||
return wolfSSL_EVP_CipherFinal(ctx, out, outl);
|
return wolfSSL_EVP_CipherFinal(ctx, out, outl);
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ WOLFSSL_API int wolfSSL_EVP_EncryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
|||||||
WOLFSSL_API int wolfSSL_EVP_DecryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
WOLFSSL_API int wolfSSL_EVP_DecryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||||
unsigned char *out, int *outl)
|
unsigned char *out, int *outl)
|
||||||
{
|
{
|
||||||
if (ctx->enc)
|
if (ctx && ctx->enc)
|
||||||
return 0;
|
return 0;
|
||||||
else{
|
else{
|
||||||
WOLFSSL_ENTER("wolfSSL_EVP_DecryptFinal");
|
WOLFSSL_ENTER("wolfSSL_EVP_DecryptFinal");
|
||||||
@@ -111,7 +111,7 @@ WOLFSSL_API int wolfSSL_EVP_DecryptFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
|||||||
WOLFSSL_API int wolfSSL_EVP_DecryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
WOLFSSL_API int wolfSSL_EVP_DecryptFinal_ex(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||||
unsigned char *out, int *outl)
|
unsigned char *out, int *outl)
|
||||||
{
|
{
|
||||||
if (ctx->enc)
|
if (ctx && ctx->enc)
|
||||||
return 0;
|
return 0;
|
||||||
else{
|
else{
|
||||||
WOLFSSL_ENTER("wolfSSL_EVP_CipherFinal_ex");
|
WOLFSSL_ENTER("wolfSSL_EVP_CipherFinal_ex");
|
||||||
|
Reference in New Issue
Block a user