mirror of https://github.com/wolfSSL/wolfssl.git
add CyaSSL_peek()
parent
5d912d4c2b
commit
dd259b12c7
|
@ -1516,7 +1516,7 @@ CYASSL_LOCAL int SendCertificate(CYASSL*);
|
||||||
CYASSL_LOCAL int SendCertificateRequest(CYASSL*);
|
CYASSL_LOCAL int SendCertificateRequest(CYASSL*);
|
||||||
CYASSL_LOCAL int SendServerKeyExchange(CYASSL*);
|
CYASSL_LOCAL int SendServerKeyExchange(CYASSL*);
|
||||||
CYASSL_LOCAL int SendBuffered(CYASSL*);
|
CYASSL_LOCAL int SendBuffered(CYASSL*);
|
||||||
CYASSL_LOCAL int ReceiveData(CYASSL*, byte*, int);
|
CYASSL_LOCAL int ReceiveData(CYASSL*, byte*, int, int);
|
||||||
CYASSL_LOCAL int SendFinished(CYASSL*);
|
CYASSL_LOCAL int SendFinished(CYASSL*);
|
||||||
CYASSL_LOCAL int SendAlert(CYASSL*, int, int);
|
CYASSL_LOCAL int SendAlert(CYASSL*, int, int);
|
||||||
CYASSL_LOCAL int ProcessReply(CYASSL*);
|
CYASSL_LOCAL int ProcessReply(CYASSL*);
|
||||||
|
|
|
@ -116,6 +116,7 @@ typedef CYASSL_X509_STORE_CTX X509_STORE_CTX;
|
||||||
|
|
||||||
#define SSL_write CyaSSL_write
|
#define SSL_write CyaSSL_write
|
||||||
#define SSL_read CyaSSL_read
|
#define SSL_read CyaSSL_read
|
||||||
|
#define SSL_peek CyaSSL_peek
|
||||||
#define SSL_accept CyaSSL_accept
|
#define SSL_accept CyaSSL_accept
|
||||||
#define SSL_CTX_free CyaSSL_CTX_free
|
#define SSL_CTX_free CyaSSL_CTX_free
|
||||||
#define SSL_free CyaSSL_free
|
#define SSL_free CyaSSL_free
|
||||||
|
|
|
@ -190,6 +190,7 @@ CYASSL_API int CyaSSL_connect(CYASSL*); /* please see note at top of README
|
||||||
if you get an error from connect */
|
if you get an error from connect */
|
||||||
CYASSL_API int CyaSSL_write(CYASSL*, const void*, int);
|
CYASSL_API int CyaSSL_write(CYASSL*, const void*, int);
|
||||||
CYASSL_API int CyaSSL_read(CYASSL*, void*, int);
|
CYASSL_API int CyaSSL_read(CYASSL*, void*, int);
|
||||||
|
CYASSL_API int CyaSSL_peek(CYASSL*, void*, int);
|
||||||
CYASSL_API int CyaSSL_accept(CYASSL*);
|
CYASSL_API int CyaSSL_accept(CYASSL*);
|
||||||
CYASSL_API void CyaSSL_CTX_free(CYASSL_CTX*);
|
CYASSL_API void CyaSSL_CTX_free(CYASSL_CTX*);
|
||||||
CYASSL_API void CyaSSL_free(CYASSL*);
|
CYASSL_API void CyaSSL_free(CYASSL*);
|
||||||
|
|
|
@ -4065,7 +4065,7 @@ int SendData(CYASSL* ssl, const void* data, int sz)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* process input data */
|
/* process input data */
|
||||||
int ReceiveData(CYASSL* ssl, byte* output, int sz)
|
int ReceiveData(CYASSL* ssl, byte* output, int sz, int peek)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
|
@ -4104,8 +4104,11 @@ int ReceiveData(CYASSL* ssl, byte* output, int sz)
|
||||||
size = ssl->buffers.clearOutputBuffer.length;
|
size = ssl->buffers.clearOutputBuffer.length;
|
||||||
|
|
||||||
XMEMCPY(output, ssl->buffers.clearOutputBuffer.buffer, size);
|
XMEMCPY(output, ssl->buffers.clearOutputBuffer.buffer, size);
|
||||||
|
|
||||||
|
if (peek == 0) {
|
||||||
ssl->buffers.clearOutputBuffer.length -= size;
|
ssl->buffers.clearOutputBuffer.length -= size;
|
||||||
ssl->buffers.clearOutputBuffer.buffer += size;
|
ssl->buffers.clearOutputBuffer.buffer += size;
|
||||||
|
}
|
||||||
|
|
||||||
if (ssl->buffers.clearOutputBuffer.length == 0 &&
|
if (ssl->buffers.clearOutputBuffer.length == 0 &&
|
||||||
ssl->buffers.inputBuffer.dynamicFlag)
|
ssl->buffers.inputBuffer.dynamicFlag)
|
||||||
|
|
24
src/ssl.c
24
src/ssl.c
|
@ -380,19 +380,19 @@ int CyaSSL_write(CYASSL* ssl, const void* data, int sz)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CyaSSL_read(CYASSL* ssl, void* data, int sz)
|
static int CyaSSL_read_internal(CYASSL* ssl, void* data, int sz, int peek)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
CYASSL_ENTER("SSL_read()");
|
CYASSL_ENTER("CyaSSL_read_internal()");
|
||||||
|
|
||||||
#ifdef HAVE_ERRNO_H
|
#ifdef HAVE_ERRNO_H
|
||||||
errno = 0;
|
errno = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = ReceiveData(ssl, (byte*)data, min(sz, OUTPUT_RECORD_SIZE));
|
ret = ReceiveData(ssl, (byte*)data, min(sz, OUTPUT_RECORD_SIZE), peek);
|
||||||
|
|
||||||
CYASSL_LEAVE("SSL_read()", ret);
|
CYASSL_LEAVE("CyaSSL_read_internal()", ret);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return SSL_FATAL_ERROR;
|
return SSL_FATAL_ERROR;
|
||||||
|
@ -401,6 +401,22 @@ int CyaSSL_read(CYASSL* ssl, void* data, int sz)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CyaSSL_peek(CYASSL* ssl, void* data, int sz)
|
||||||
|
{
|
||||||
|
CYASSL_ENTER("CyaSSL_peek()");
|
||||||
|
|
||||||
|
return CyaSSL_read_internal(ssl, data, sz, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CyaSSL_read(CYASSL* ssl, void* data, int sz)
|
||||||
|
{
|
||||||
|
CYASSL_ENTER("CyaSSL_read()");
|
||||||
|
|
||||||
|
return CyaSSL_read_internal(ssl, data, sz, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int CyaSSL_send(CYASSL* ssl, const void* data, int sz, int flags)
|
int CyaSSL_send(CYASSL* ssl, const void* data, int sz, int flags)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
Loading…
Reference in New Issue