Declare mbedtls_pk_info_t through macro
New macro MBEDTLS_PK_OPAQUE_INFO_1 to initialize mbedtls_pk_info_t structures.
Document that this macro must be used in engine implementations for forward
compatibility. Use this macro rather than accessing the structure directly
in tests and in the sample engine to set a good example.
diff --git a/include/mbedtls/pk_info.h b/include/mbedtls/pk_info.h
index a852ab8..a808c2c 100644
--- a/include/mbedtls/pk_info.h
+++ b/include/mbedtls/pk_info.h
@@ -71,6 +71,13 @@
* \note If you are using the PK interface to perform operations on
* keys, call the functions in pk.h. The interface in this file should only
* be used by implementers of opaque key engines.
+ *
+ * \warning: Do not declare this structure directly! It may be extended in
+ * future* versions of Mbed TLS. Call the macro
+ * MBEDTLS_PK_OPAQUE_INFO_1() or MBEDTLS_PK_OPAQUE_INFO_ASYNC_1() instead.
+ * These macros are guaranteed to take parameters with the same type
+ * and semantics as previous versions and fill any new field of the
+ * structure with sensible values.
*/
struct mbedtls_pk_info_t
{
@@ -220,6 +227,36 @@
};
+#define MBEDTLS_PK_OPAQUE_INFO_1( \
+ name \
+ , get_bitlen \
+ , can_do \
+ , signature_size_func \
+ , verify_func \
+ , sign_func \
+ , decrypt_func \
+ , encrypt_func \
+ , check_pair_func \
+ , ctx_alloc_func \
+ , ctx_free_func \
+ , debug_func \
+ ) \
+ { \
+ MBEDTLS_PK_OPAQUE \
+ , name \
+ , get_bitlen \
+ , can_do \
+ , signature_size_func \
+ , verify_func \
+ , sign_func \
+ , decrypt_func \
+ , encrypt_func \
+ , check_pair_func \
+ , ctx_alloc_func \
+ , ctx_free_func \
+ , debug_func \
+ }
+
#ifdef __cplusplus
}
#endif