mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Add accessor to get buf from mbedtls_pem_context
Co-authored-by: Gilles Peskine <gilles.peskine@arm.com> Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
This commit is contained in:
@ -40,12 +40,21 @@ void mbedtls_pem_read_buffer( char *header, char *footer, char *data,
|
||||
int ret;
|
||||
size_t use_len = 0;
|
||||
size_t pwd_len = strlen( pwd );
|
||||
const unsigned char *buf;
|
||||
|
||||
mbedtls_pem_init( &ctx );
|
||||
|
||||
ret = mbedtls_pem_read_buffer( &ctx, header, footer, (unsigned char *)data,
|
||||
(unsigned char *)pwd, pwd_len, &use_len );
|
||||
TEST_ASSERT( ret == res );
|
||||
if( ret != 0 )
|
||||
goto exit;
|
||||
|
||||
TEST_EQUAL( use_len, ctx.buflen );
|
||||
use_len = 0;
|
||||
buf = mbedtls_pem_get_buffer( &ctx, &use_len );
|
||||
TEST_ASSERT( buf == ctx.buf );
|
||||
TEST_EQUAL( use_len, ctx.buflen );
|
||||
|
||||
exit:
|
||||
mbedtls_pem_free( &ctx );
|
||||
|
Reference in New Issue
Block a user