Add a PK can_do() method and simplify code
diff --git a/include/polarssl/pk.h b/include/polarssl/pk.h
index f06ec68..a2d166f 100644
--- a/include/polarssl/pk.h
+++ b/include/polarssl/pk.h
@@ -89,6 +89,9 @@
/** Public key type */
pk_type_t type;
+ /** Tell if the context implements this type (eg ECKEY can do ECDSA) */
+ int (*can_do)( pk_type_t type );
+
/** Verify signature */
int (*verify_func)( void *ctx,
const unsigned char *hash, const md_info_t *md_info,
@@ -131,33 +134,6 @@
*/
int pk_set_type( pk_context *ctx, pk_type_t type );
-#if defined(POLARSSL_ECDSA_C)
-/**
- * \brief Convert a generic EC key into an ECDSA context
- *
- * \param ctx Context to convert
- *
- * \return 0 on success, or
- * POLARSSL_ERR_PK_MALLOC_FAILED or
- * POLARSSL_ERR_PK_TYPE_MISMATCH.
- */
-int pk_ec_to_ecdsa( pk_context *ctx );
-
-/**
- * \brief Tell if a PK context can be used for ECDSA
- *
- * \param ctx Context to check
- *
- * \return 0 if context cannot be used for ECDSA,
- * 1 otherwise
- */
-static inline int pk_can_ecdsa( pk_context ctx )
-{
- return( ctx.type == POLARSSL_PK_ECKEY ||
- ctx.type == POLARSSL_PK_ECDSA );
-}
-#endif /* POLARSSL_ECDSA_C */
-
#if defined(POLARSSL_RSA_C)
/**
* \brief Wrap a RSA context in a PK context