break;
if (size == 0)
break;
- message_header_hash_more(&md5_ctx, version, data, size);
+ message_header_hash_more(&hash_method_md5, &md5_ctx, version,
+ data, size);
i_stream_skip(input, size);
}
if (input->stream_errno != 0)
/* Copyright (c) 2013-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
-#include "md5.h"
+#include "hash-method.h"
#include "message-header-hash.h"
-void message_header_hash_more(struct md5_context *md5_ctx,
+void message_header_hash_more(const struct hash_method *method, void *context,
unsigned int version,
const unsigned char *data, size_t size)
{
i_assert(version == 1 || version == 2);
if (version == 1) {
- md5_update(md5_ctx, data, size);
+ method->loop(context, data, size);
return;
}
/* - Dovecot IMAP replaces NULs with 0x80 character.
(data[i] != '\t' && data[i] != '\n')) {
/* remove repeated '?' */
if (start < i || i == 0) {
- md5_update(md5_ctx, data + start, i-start);
- md5_update(md5_ctx, "?", 1);
+ method->loop(context, data + start, i-start);
+ method->loop(context, "?", 1);
}
start = i+1;
}
}
- md5_update(md5_ctx, data + start, i-start);
+ method->loop(context, data + start, i-start);
}
#ifndef MESSAGE_HEADER_HASH_H
#define MESSAGE_HEADER_HASH_H
-struct md5_context;
+struct hash_method;
-void message_header_hash_more(struct md5_context *md5_ctx,
+void message_header_hash_more(const struct hash_method *method, void *context,
unsigned int version,
const unsigned char *data, size_t size);
test_begin("dsync_mail_hash_more v2");
md5_init(&md5_ctx);
- message_header_hash_more(&md5_ctx, 2, test_input, sizeof(test_input)-1);
+ message_header_hash_more(&hash_method_md5, &md5_ctx, 2,
+ test_input, sizeof(test_input)-1);
md5_final(&md5_ctx, md5_input);
md5_init(&md5_ctx);