Remove pk_info from pk_context_t with SINGLE_TYPE
In very reduced configurations, we don't want the overhead of maintaining a
bool just to remember if the context is valid and checking that bit at every
point of entry.
Note: so far this validity bit also served as a proxy to ensure that pk_ctx
was valid (currently this is a pointer to a dynamically-allocated buffer). In
the next series of commits, this will be changed to a statically-allocated
buffer, so there will be no question about its validity.
In the end (after this commit and the next series), a pk_context_t will be
(memory-wise) just the same as a mbedtls_uecc_keypair when SINGLE_TYPE is
enabled - meaning the PK layer will have zero memory overhead in that case.
diff --git a/include/mbedtls/pk.h b/include/mbedtls/pk.h
index 64cd7b5..09a8513 100644
--- a/include/mbedtls/pk.h
+++ b/include/mbedtls/pk.h
@@ -142,7 +142,9 @@
*/
typedef struct mbedtls_pk_context
{
+#if !defined(MBEDTLS_PK_SINGLE_TYPE)
mbedtls_pk_handle_t pk_info; /**< Public key information */
+#endif
void * pk_ctx; /**< Underlying public key context */
} mbedtls_pk_context;