diff options
| author | Michael Biebl <biebl@debian.org> | 2019-03-31 10:11:55 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2019-03-31 10:11:55 +0200 |
| commit | 4b96345400eafd4bfc70fd77ef19e026d690aca0 (patch) | |
| tree | fed6aa242532689235f5333132ff98b82961765f /libnm-core/nm-crypto.c | |
| parent | 8ea1145a9e031c8021590abf780dd7c149e231cf (diff) | |
| parent | f66fcea265a5869667d832386e9337237a44afef (diff) | |
Merge branch 'master' into stretch-backports
Diffstat (limited to 'libnm-core/nm-crypto.c')
| -rw-r--r-- | libnm-core/nm-crypto.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/libnm-core/nm-crypto.c b/libnm-core/nm-crypto.c index dc8f1c15..1af2ea28 100644 --- a/libnm-core/nm-crypto.c +++ b/libnm-core/nm-crypto.c @@ -879,13 +879,10 @@ nm_crypto_md5_hash (const guint8 *salt, gsize buflen) { nm_auto_free_checksum GChecksum *ctx = NULL; -#define MD5_DIGEST_LEN 16 - nm_auto_clear_static_secret_ptr const NMSecretPtr digest = NM_SECRET_PTR_STATIC (MD5_DIGEST_LEN); + nm_auto_clear_static_secret_ptr const NMSecretPtr digest = NM_SECRET_PTR_STATIC (NM_UTILS_CHECKSUM_LENGTH_MD5); gsize bufidx = 0; int i; - nm_assert (g_checksum_type_get_length (G_CHECKSUM_MD5) == MD5_DIGEST_LEN); - g_return_if_fail (password_len == 0 || password); g_return_if_fail (buffer); g_return_if_fail (buflen > 0); @@ -894,25 +891,21 @@ nm_crypto_md5_hash (const guint8 *salt, ctx = g_checksum_new (G_CHECKSUM_MD5); for (;;) { - gsize digest_len; - if (password_len > 0) g_checksum_update (ctx, (const guchar *) password, password_len); if (salt_len > 0) g_checksum_update (ctx, (const guchar *) salt, salt_len); - digest_len = MD5_DIGEST_LEN; - g_checksum_get_digest (ctx, digest.bin, &digest_len); - nm_assert (digest_len == MD5_DIGEST_LEN); + nm_utils_checksum_get_digest_len (ctx, digest.bin, NM_UTILS_CHECKSUM_LENGTH_MD5); - for (i = 0; i < MD5_DIGEST_LEN; i++) { + for (i = 0; i < NM_UTILS_CHECKSUM_LENGTH_MD5; i++) { if (bufidx >= buflen) return; buffer[bufidx++] = digest.bin[i]; } g_checksum_reset (ctx); - g_checksum_update (ctx, digest.ptr, MD5_DIGEST_LEN); + g_checksum_update (ctx, digest.ptr, NM_UTILS_CHECKSUM_LENGTH_MD5); } } |