Add md/shaXXX_clone() API
Will be used in the SSL/TLS modules
diff --git a/include/mbedtls/md2.h b/include/mbedtls/md2.h
index 8d01266..151a8f4 100644
--- a/include/mbedtls/md2.h
+++ b/include/mbedtls/md2.h
@@ -67,6 +67,15 @@
void mbedtls_md2_free( mbedtls_md2_context *ctx );
/**
+ * \brief Clone (the state of) an MD2 context
+ *
+ * \param dst The destination context
+ * \param src The context to be cloned
+ */
+void mbedtls_md2_clone( mbedtls_md2_context *dst,
+ const mbedtls_md2_context *src );
+
+/**
* \brief MD2 context setup
*
* \param ctx context to be initialized
diff --git a/include/mbedtls/md4.h b/include/mbedtls/md4.h
index 96dcc44..fd756b9 100644
--- a/include/mbedtls/md4.h
+++ b/include/mbedtls/md4.h
@@ -67,6 +67,15 @@
void mbedtls_md4_free( mbedtls_md4_context *ctx );
/**
+ * \brief Clone (the state of) an MD4 context
+ *
+ * \param dst The destination context
+ * \param src The context to be cloned
+ */
+void mbedtls_md4_clone( mbedtls_md4_context *dst,
+ const mbedtls_md4_context *src );
+
+/**
* \brief MD4 context setup
*
* \param ctx context to be initialized
diff --git a/include/mbedtls/md5.h b/include/mbedtls/md5.h
index 163780a..40273d4 100644
--- a/include/mbedtls/md5.h
+++ b/include/mbedtls/md5.h
@@ -67,6 +67,15 @@
void mbedtls_md5_free( mbedtls_md5_context *ctx );
/**
+ * \brief Clone (the state of) an MD5 context
+ *
+ * \param dst The destination context
+ * \param src The context to be cloned
+ */
+void mbedtls_md5_clone( mbedtls_md5_context *dst,
+ const mbedtls_md5_context *src );
+
+/**
* \brief MD5 context setup
*
* \param ctx context to be initialized
diff --git a/include/mbedtls/ripemd160.h b/include/mbedtls/ripemd160.h
index e66c46a..9013f20 100644
--- a/include/mbedtls/ripemd160.h
+++ b/include/mbedtls/ripemd160.h
@@ -67,6 +67,15 @@
void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx );
/**
+ * \brief Clone (the state of) an RIPEMD-160 context
+ *
+ * \param dst The destination context
+ * \param src The context to be cloned
+ */
+void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
+ const mbedtls_ripemd160_context *src );
+
+/**
* \brief RIPEMD-160 context setup
*
* \param ctx context to be initialized
diff --git a/include/mbedtls/sha1.h b/include/mbedtls/sha1.h
index 74fb855..e8bd65e 100644
--- a/include/mbedtls/sha1.h
+++ b/include/mbedtls/sha1.h
@@ -67,6 +67,15 @@
void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
/**
+ * \brief Clone (the state of) a SHA-1 context
+ *
+ * \param dst The destination context
+ * \param src The context to be cloned
+ */
+void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
+ const mbedtls_sha1_context *src );
+
+/**
* \brief SHA-1 context setup
*
* \param ctx context to be initialized
diff --git a/include/mbedtls/sha256.h b/include/mbedtls/sha256.h
index 113c23b..0dbc4b2 100644
--- a/include/mbedtls/sha256.h
+++ b/include/mbedtls/sha256.h
@@ -68,6 +68,15 @@
void mbedtls_sha256_free( mbedtls_sha256_context *ctx );
/**
+ * \brief Clone (the state of) a SHA-256 context
+ *
+ * \param dst The destination context
+ * \param src The context to be cloned
+ */
+void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
+ const mbedtls_sha256_context *src );
+
+/**
* \brief SHA-256 context setup
*
* \param ctx context to be initialized
diff --git a/include/mbedtls/sha512.h b/include/mbedtls/sha512.h
index 6b09a48..7e1bc1e 100644
--- a/include/mbedtls/sha512.h
+++ b/include/mbedtls/sha512.h
@@ -68,6 +68,15 @@
void mbedtls_sha512_free( mbedtls_sha512_context *ctx );
/**
+ * \brief Clone (the state of) a SHA-512 context
+ *
+ * \param dst The destination context
+ * \param src The context to be cloned
+ */
+void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
+ const mbedtls_sha512_context *src );
+
+/**
* \brief SHA-512 context setup
*
* \param ctx context to be initialized
diff --git a/library/md2.c b/library/md2.c
index 5cd024a..d1fea12 100644
--- a/library/md2.c
+++ b/library/md2.c
@@ -97,6 +97,12 @@
mbedtls_zeroize( ctx, sizeof( mbedtls_md2_context ) );
}
+void mbedtls_md2_clone( mbedtls_md2_context *dst,
+ const mbedtls_md2_context *src )
+{
+ *dst = *src;
+}
+
/*
* MD2 context setup
*/
diff --git a/library/md4.c b/library/md4.c
index 9062358..b71d2c9 100644
--- a/library/md4.c
+++ b/library/md4.c
@@ -90,6 +90,12 @@
mbedtls_zeroize( ctx, sizeof( mbedtls_md4_context ) );
}
+void mbedtls_md4_clone( mbedtls_md4_context *dst,
+ const mbedtls_md4_context *src )
+{
+ *dst = *src;
+}
+
/*
* MD4 context setup
*/
diff --git a/library/md5.c b/library/md5.c
index 599debc..7c846be 100644
--- a/library/md5.c
+++ b/library/md5.c
@@ -89,6 +89,12 @@
mbedtls_zeroize( ctx, sizeof( mbedtls_md5_context ) );
}
+void mbedtls_md5_clone( mbedtls_md5_context *dst,
+ const mbedtls_md5_context *src )
+{
+ *dst = *src;
+}
+
/*
* MD5 context setup
*/
diff --git a/library/ripemd160.c b/library/ripemd160.c
index d8a451d..ecaeea0 100644
--- a/library/ripemd160.c
+++ b/library/ripemd160.c
@@ -88,6 +88,12 @@
mbedtls_zeroize( ctx, sizeof( mbedtls_ripemd160_context ) );
}
+void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst,
+ const mbedtls_ripemd160_context *src )
+{
+ *dst = *src;
+}
+
/*
* RIPEMD-160 context setup
*/
diff --git a/library/sha1.c b/library/sha1.c
index 9a21bcb..7ca8350 100644
--- a/library/sha1.c
+++ b/library/sha1.c
@@ -89,6 +89,12 @@
mbedtls_zeroize( ctx, sizeof( mbedtls_sha1_context ) );
}
+void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
+ const mbedtls_sha1_context *src )
+{
+ *dst = *src;
+}
+
/*
* SHA-1 context setup
*/
diff --git a/library/sha256.c b/library/sha256.c
index cf0b15f..4b393d0 100644
--- a/library/sha256.c
+++ b/library/sha256.c
@@ -89,6 +89,12 @@
mbedtls_zeroize( ctx, sizeof( mbedtls_sha256_context ) );
}
+void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
+ const mbedtls_sha256_context *src )
+{
+ *dst = *src;
+}
+
/*
* SHA-256 context setup
*/
diff --git a/library/sha512.c b/library/sha512.c
index f09b0f7..3daf080 100644
--- a/library/sha512.c
+++ b/library/sha512.c
@@ -150,6 +150,12 @@
mbedtls_zeroize( ctx, sizeof( mbedtls_sha512_context ) );
}
+void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
+ const mbedtls_sha512_context *src )
+{
+ *dst = *src;
+}
+
/*
* SHA-512 context setup
*/