Adapt cipher and MD layer with _init() and _free()
diff --git a/include/polarssl/cipher.h b/include/polarssl/cipher.h
index 84993f7..087e590 100644
--- a/include/polarssl/cipher.h
+++ b/include/polarssl/cipher.h
@@ -332,9 +332,25 @@
const cipher_mode_t mode );
/**
+ * \brief Initialize a cipher_context (as NONE)
+ */
+void cipher_init( cipher_context_t *ctx );
+
+/**
+ * \brief Free and clear the cipher-specific context of ctx.
+ * Freeing ctx itself remains the responsibility of the
+ * caller.
+ */
+void cipher_free( cipher_context_t *ctx );
+
+/**
* \brief Initialises and fills the cipher context structure with
* the appropriate values.
*
+ * \note Currently also clears structure. In future versions you
+ * will be required to call cipher_init() on the structure
+ * first.
+ *
* \param ctx context to initialise. May not be NULL.
* \param cipher_info cipher to use.
*
@@ -349,10 +365,11 @@
* \brief Free the cipher-specific context of ctx. Freeing ctx
* itself remains the responsibility of the caller.
*
+ * \note Deprecated: Redirects to cipher_free()
+ *
* \param ctx Free the cipher-specific context
*
- * \returns 0 on success, POLARSSL_ERR_CIPHER_BAD_INPUT_DATA if
- * parameter verification fails.
+ * \returns 0
*/
int cipher_free_ctx( cipher_context_t *ctx );
diff --git a/include/polarssl/md.h b/include/polarssl/md.h
index 8de233a..81d8a2e 100644
--- a/include/polarssl/md.h
+++ b/include/polarssl/md.h
@@ -173,9 +173,25 @@
const md_info_t *md_info_from_type( md_type_t md_type );
/**
+ * \brief Initialize a md_context (as NONE)
+ */
+void md_init( md_context_t *ctx );
+
+/**
+ * \brief Free and clear the message-specific context of ctx.
+ * Freeing ctx itself remains the responsibility of the
+ * caller.
+ */
+void md_free( md_context_t *ctx );
+
+/**
* \brief Initialises and fills the message digest context structure
* with the appropriate values.
*
+ * \note Currently also clears structure. In future versions you
+ * will be required to call md_init() on the structure
+ * first.
+ *
* \param ctx context to initialise. May not be NULL. The
* digest-specific context (ctx->md_ctx) must be NULL. It will
* be allocated, and must be freed using md_free_ctx() later.
@@ -191,10 +207,11 @@
* \brief Free the message-specific context of ctx. Freeing ctx itself
* remains the responsibility of the caller.
*
+ * \note Deprecated: Redirects to md_free()
+ *
* \param ctx Free the message-specific context
*
- * \returns 0 on success, POLARSSL_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \returns 0
*/
int md_free_ctx( md_context_t *ctx );