From b3226d54bd468daa8210ed9dfb1137938ade5211 Mon Sep 17 00:00:00 2001 From: tb Date: Wed, 5 Jan 2022 17:01:06 +0000 Subject: [PATCH] Switch snmpd(8) to using EVP_Digest{Init,Final}_ex() and drop a no longer needed EVP_MD_CTX_reset(). ok martijn --- usr.sbin/snmpd/usm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/usr.sbin/snmpd/usm.c b/usr.sbin/snmpd/usm.c index d9129c7116e..a2095373ace 100644 --- a/usr.sbin/snmpd/usm.c +++ b/usr.sbin/snmpd/usm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usm.c,v 1.23 2022/01/05 16:41:42 tb Exp $ */ +/* $OpenBSD: usm.c,v 1.24 2022/01/05 17:01:06 tb Exp $ */ /* * Copyright (c) 2012 GeNUA mbH @@ -720,7 +720,7 @@ usm_passwd2key(const EVP_MD *md, char *passwd, int *maxlen) if ((ctx = EVP_MD_CTX_new()) == NULL) return NULL; - if (!EVP_DigestInit(ctx, md)) { + if (!EVP_DigestInit_ex(ctx, md, NULL)) { EVP_MD_CTX_free(ctx); return NULL; } @@ -737,11 +737,10 @@ usm_passwd2key(const EVP_MD *md, char *passwd, int *maxlen) return NULL; } } - if (!EVP_DigestFinal(ctx, keybuf, &dlen)) { + if (!EVP_DigestFinal_ex(ctx, keybuf, &dlen)) { EVP_MD_CTX_free(ctx); return NULL; } - EVP_MD_CTX_reset(ctx); /* Localize the key */ #ifdef DEBUG @@ -752,10 +751,10 @@ usm_passwd2key(const EVP_MD *md, char *passwd, int *maxlen) snmpd_env->sc_engineid_len); memcpy(pwbuf + dlen + snmpd_env->sc_engineid_len, keybuf, dlen); - if (!EVP_DigestInit(ctx, md) || + if (!EVP_DigestInit_ex(ctx, md, NULL) || !EVP_DigestUpdate(ctx, pwbuf, 2 * dlen + snmpd_env->sc_engineid_len) || - !EVP_DigestFinal(ctx, keybuf, &dlen)) { + !EVP_DigestFinal_ex(ctx, keybuf, &dlen)) { EVP_MD_CTX_free(ctx); return NULL; } -- 2.20.1