summaryrefslogtreecommitdiffstats
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/misc.c b/misc.c
index 11f1d16..212a362 100644
--- a/misc.c
+++ b/misc.c
@@ -1658,23 +1658,26 @@ void
get_user_pass_auto_userid (struct user_pass *up, const char *tag)
{
struct gc_arena gc = gc_new ();
- MD5_CTX ctx;
struct buffer buf;
uint8_t macaddr[6];
static uint8_t digest [MD5_DIGEST_LENGTH];
static const uint8_t hashprefix[] = "AUTO_USERID_DIGEST";
+ const md_kt_t *md5_kt = md_kt_get("MD5");
+ md_ctx_t ctx;
+
CLEAR (*up);
buf_set_write (&buf, (uint8_t*)up->username, USER_PASS_LEN);
buf_printf (&buf, "%s", get_platform_prefix ());
if (get_default_gateway_mac_addr (macaddr))
{
dmsg (D_AUTO_USERID, "GUPAU: macaddr=%s", format_hex_ex (macaddr, sizeof (macaddr), 0, 1, ":", &gc));
- MD5_Init (&ctx);
- MD5_Update (&ctx, hashprefix, sizeof (hashprefix) - 1);
- MD5_Update (&ctx, macaddr, sizeof (macaddr));
- MD5_Final (digest, &ctx);
- buf_printf (&buf, "%s", format_hex_ex (digest, sizeof (digest), 0, 256, " ", &gc));
+ md_ctx_init(&ctx, md5_kt);
+ md_ctx_update(&ctx, hashprefix, sizeof (hashprefix) - 1);
+ md_ctx_update(&ctx, macaddr, sizeof (macaddr));
+ md_ctx_final(&ctx, digest);
+ md_ctx_cleanup(&ctx)
+ buf_printf(&buf, "%s", format_hex_ex (digest, sizeof (digest), 0, 256, " ", &gc));
}
else
{