1
0
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:
Glenn Strauss
2022-02-04 10:32:17 -05:00
parent 6a0b1ef27e
commit 72bd4e4d6a
3 changed files with 39 additions and 0 deletions

View File

@ -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 );