mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 17:35:38 +01:00
MPS Reader Tests: Accumulator too small
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
This commit is contained in:
parent
7d86b74cef
commit
caf1a3f663
@ -24,3 +24,6 @@ mbedtls_mps_reader_no_pausing_multiple_steps_multiple_rounds:1
|
|||||||
|
|
||||||
MPS Reader: Pausing needed but disabled
|
MPS Reader: Pausing needed but disabled
|
||||||
mbedtls_mps_reader_pausing_needed_disabled:
|
mbedtls_mps_reader_pausing_needed_disabled:
|
||||||
|
|
||||||
|
MPS Reader: Pausing needed + enabled, but buffer too small
|
||||||
|
mbedtls_mps_reader_pausing_needed_buffer_too_small:
|
||||||
|
@ -236,3 +236,36 @@ void mbedtls_mps_reader_pausing_needed_disabled()
|
|||||||
mbedtls_reader_free( &rd );
|
mbedtls_reader_free( &rd );
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
/* BEGIN_CASE depends_on:TEST_SUITE_MPS_READER */
|
||||||
|
void mbedtls_mps_reader_pausing_needed_buffer_too_small()
|
||||||
|
{
|
||||||
|
/* This test exercises the behaviour of the MPS reader with accumulator
|
||||||
|
* in the situation where a read requests goes beyond the bounds of the
|
||||||
|
* current read buffer, _and_ the reader's accumulator is too small to
|
||||||
|
* hold the requested amount of data.
|
||||||
|
*
|
||||||
|
* In this case, we expect the reader to fail. */
|
||||||
|
|
||||||
|
unsigned char buf[100];
|
||||||
|
unsigned char acc[10];
|
||||||
|
unsigned char *tmp;
|
||||||
|
mbedtls_reader rd;
|
||||||
|
for( int i=0; (unsigned) i < sizeof( buf ); i++ )
|
||||||
|
buf[i] = (unsigned char) i;
|
||||||
|
|
||||||
|
/* Preparation (lower layer) */
|
||||||
|
mbedtls_reader_init( &rd, acc, sizeof( acc ) );
|
||||||
|
TEST_ASSERT( mbedtls_reader_feed( &rd, buf, sizeof( buf ) ) == 0 );
|
||||||
|
/* Consumption (upper layer) */
|
||||||
|
TEST_ASSERT( mbedtls_reader_get( &rd, 50, &tmp, NULL ) == 0 );
|
||||||
|
ASSERT_COMPARE( tmp, 50, buf, 50 );
|
||||||
|
TEST_ASSERT( mbedtls_reader_commit( &rd ) == 0 );
|
||||||
|
TEST_ASSERT( mbedtls_reader_get( &rd, 100, &tmp, NULL ) ==
|
||||||
|
MBEDTLS_ERR_MPS_READER_OUT_OF_DATA );
|
||||||
|
/* Wrapup (lower layer) */
|
||||||
|
TEST_ASSERT( mbedtls_reader_reclaim( &rd, NULL ) ==
|
||||||
|
MBEDTLS_ERR_MPS_READER_ACCUMULATOR_TOO_SMALL );
|
||||||
|
mbedtls_reader_free( &rd );
|
||||||
|
}
|
||||||
|
/* END_CASE */
|
||||||
|
Loading…
Reference in New Issue
Block a user