Add RIPEMD-160 to the generic MD layer
diff --git a/library/md_wrap.c b/library/md_wrap.c
index 038b132..bc159ba 100644
--- a/library/md_wrap.c
+++ b/library/md_wrap.c
@@ -45,6 +45,10 @@
#include "polarssl/md5.h"
#endif
+#if defined(POLARSSL_RMD160_C)
+#include "polarssl/rmd160.h"
+#endif
+
#if defined(POLARSSL_SHA1_C)
#include "polarssl/sha1.h"
#endif
@@ -320,6 +324,90 @@
#endif
+#if defined(POLARSSL_RMD160_C)
+
+static void rmd160_starts_wrap( void *ctx )
+{
+ rmd160_starts( (rmd160_context *) ctx );
+}
+
+static void rmd160_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
+{
+ rmd160_update( (rmd160_context *) ctx, input, ilen );
+}
+
+static void rmd160_finish_wrap( void *ctx, unsigned char *output )
+{
+ rmd160_finish( (rmd160_context *) ctx, output );
+}
+
+static int rmd160_file_wrap( const char *path, unsigned char *output )
+{
+#if defined(POLARSSL_FS_IO)
+ return rmd160_file( path, output );
+#else
+ ((void) path);
+ ((void) output);
+ return POLARSSL_ERR_MD_FEATURE_UNAVAILABLE;
+#endif
+}
+
+static void rmd160_hmac_starts_wrap( void *ctx, const unsigned char *key, size_t keylen )
+{
+ rmd160_hmac_starts( (rmd160_context *) ctx, key, keylen );
+}
+
+static void rmd160_hmac_update_wrap( void *ctx, const unsigned char *input, size_t ilen )
+{
+ rmd160_hmac_update( (rmd160_context *) ctx, input, ilen );
+}
+
+static void rmd160_hmac_finish_wrap( void *ctx, unsigned char *output )
+{
+ rmd160_hmac_finish( (rmd160_context *) ctx, output );
+}
+
+static void rmd160_hmac_reset_wrap( void *ctx )
+{
+ rmd160_hmac_reset( (rmd160_context *) ctx );
+}
+
+static void * rmd160_ctx_alloc( void )
+{
+ return polarssl_malloc( sizeof( rmd160_context ) );
+}
+
+static void rmd160_ctx_free( void *ctx )
+{
+ polarssl_free( ctx );
+}
+
+static void rmd160_process_wrap( void *ctx, const unsigned char *data )
+{
+ rmd160_process( (rmd160_context *) ctx, data );
+}
+
+const md_info_t rmd160_info = {
+ POLARSSL_MD_RMD160,
+ "RMD160",
+ 20,
+ rmd160_starts_wrap,
+ rmd160_update_wrap,
+ rmd160_finish_wrap,
+ rmd160,
+ rmd160_file_wrap,
+ rmd160_hmac_starts_wrap,
+ rmd160_hmac_update_wrap,
+ rmd160_hmac_finish_wrap,
+ rmd160_hmac_reset_wrap,
+ rmd160_hmac,
+ rmd160_ctx_alloc,
+ rmd160_ctx_free,
+ rmd160_process_wrap,
+};
+
+#endif
+
#if defined(POLARSSL_SHA1_C)
static void sha1_starts_wrap( void *ctx )