mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
Add tests
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
fd8929cfd1
commit
a4e8fb0041
@ -1159,6 +1159,12 @@ int mbedtls_ssl_write_fragment(mbedtls_ssl_context *ssl, unsigned char *buf,
|
|||||||
int buf_len, int *written,
|
int buf_len, int *written,
|
||||||
const int expected_fragments)
|
const int expected_fragments)
|
||||||
{
|
{
|
||||||
|
/* Verify that calling mbedtls_ssl_write with a NULL buffer and zero length is
|
||||||
|
* a valid no-op for TLS connections. */
|
||||||
|
if (ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM) {
|
||||||
|
TEST_ASSERT(mbedtls_ssl_write(ssl, NULL, 0) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
int ret = mbedtls_ssl_write(ssl, buf + *written, buf_len - *written);
|
int ret = mbedtls_ssl_write(ssl, buf + *written, buf_len - *written);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
*written += ret;
|
*written += ret;
|
||||||
@ -1197,6 +1203,12 @@ int mbedtls_ssl_read_fragment(mbedtls_ssl_context *ssl, unsigned char *buf,
|
|||||||
int buf_len, int *read,
|
int buf_len, int *read,
|
||||||
int *fragments, const int expected_fragments)
|
int *fragments, const int expected_fragments)
|
||||||
{
|
{
|
||||||
|
/* Verify that calling mbedtls_ssl_write with a NULL buffer and zero length is
|
||||||
|
* a valid no-op for TLS connections. */
|
||||||
|
if (ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM) {
|
||||||
|
TEST_ASSERT(mbedtls_ssl_read(ssl, NULL, 0) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
int ret = mbedtls_ssl_read(ssl, buf + *read, buf_len - *read);
|
int ret = mbedtls_ssl_read(ssl, buf + *read, buf_len - *read);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
(*fragments)++;
|
(*fragments)++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user