1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-01 10:06:53 +03:00

Use generic x509_get_pubkey() for RSA functions

This commit is contained in:
Manuel Pégourié-Gonnard
2013-07-10 09:46:30 +02:00
committed by Paul Bakker
parent 4fa0476675
commit 244569f4b1
4 changed files with 54 additions and 90 deletions

View File

@ -46,6 +46,7 @@ void pk_init( pk_context *ctx )
ctx->type = POLARSSL_PK_NONE;
ctx->data = NULL;
ctx->dont_free = 0;
}
/*
@ -75,7 +76,8 @@ void pk_free( pk_context *ctx )
#endif
}
free( ctx-> data );
if( ! ctx->dont_free )
free( ctx->data );
ctx->type = POLARSSL_PK_NONE;
ctx->data = NULL;
@ -121,3 +123,20 @@ int pk_set_type( pk_context *ctx, pk_type_t type )
return( 0 );
}
#if defined(POLARSSL_RSA_C)
/*
* Wrap an RSA context in a PK context
*/
int pk_wrap_rsa( pk_context *ctx, const rsa_context *rsa)
{
if( ctx->type != POLARSSL_PK_NONE )
return( POLARSSL_ERR_PK_TYPE_MISMATCH );
ctx->type = POLARSSL_PK_RSA;
ctx->data = (rsa_context *) rsa;
ctx->dont_free = 1;
return( 0 );
}
#endif