From 0db107e4baabbeaf33fd914bd13eb63cd9ee9e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 19 Mar 2015 14:01:57 +0000 Subject: [PATCH] Fix pk_can_do() constness issue --- include/mbedtls/pk.h | 2 +- library/pk.c | 4 ++-- library/ssl_tls.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/mbedtls/pk.h b/include/mbedtls/pk.h index 8d9407c41..14ac65e0e 100644 --- a/include/mbedtls/pk.h +++ b/include/mbedtls/pk.h @@ -292,7 +292,7 @@ static inline size_t pk_get_len( const pk_context *ctx ) * \return 0 if context can't do the operations, * 1 otherwise. */ -int pk_can_do( pk_context *ctx, pk_type_t type ); +int pk_can_do( const pk_context *ctx, pk_type_t type ); /** * \brief Verify signature (including padding if relevant). diff --git a/library/pk.c b/library/pk.c index 7652510c5..af4a302f9 100644 --- a/library/pk.c +++ b/library/pk.c @@ -144,7 +144,7 @@ int pk_init_ctx_rsa_alt( pk_context *ctx, void * key, /* * Tell if a PK can do the operations of the given type */ -int pk_can_do( pk_context *ctx, pk_type_t type ) +int pk_can_do( const pk_context *ctx, pk_type_t type ) { /* null or NONE context can't do anything */ if( ctx == NULL || ctx->pk_info == NULL ) @@ -351,7 +351,7 @@ int pk_debug( const pk_context *ctx, pk_debug_item *items ) /* * Access the PK type name */ -const char * pk_get_name( const pk_context *ctx ) +const char *pk_get_name( const pk_context *ctx ) { if( ctx == NULL || ctx->pk_info == NULL ) return( "invalid PK" ); diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 25d7d259a..6cb359090 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -3992,7 +3992,7 @@ int ssl_parse_certificate( ssl_context *ssl ) #if defined(POLARSSL_SSL_SET_CURVES) { - pk_context *pk = &ssl->session_negotiate->peer_cert->pk; + const pk_context *pk = &ssl->session_negotiate->peer_cert->pk; /* If certificate uses an EC key, make sure the curve is OK */ if( pk_can_do( pk, POLARSSL_PK_ECKEY ) &&