s3:profile: Use SHA1 for hashing in profiling functions.
authorAndreas Schneider <asn@samba.org>
Mon, 1 Jul 2019 14:54:15 +0000 (16:54 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 9 Jul 2019 12:16:10 +0000 (12:16 +0000)
This can use SHA NI instructions if the CPU supports it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14031

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/profile/profile.c

index df0ba5b0af3f700fab3779cb0324bacd08416f59..90a30f01f58f7fdbbe56192d29354057931d50fe 100644 (file)
@@ -124,7 +124,7 @@ static void reqprofile_message(struct messaging_context *msg_ctx,
   ******************************************************************/
 bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
 {
-       unsigned char tmp[16] = {};
+       uint8_t digest[gnutls_hash_get_len(GNUTLS_DIG_SHA1)];
        gnutls_hash_hd_t hash_hnd = NULL;
        char *db_name;
        bool ok = false;
@@ -154,7 +154,7 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
                                   reqprofile_message);
        }
 
-       rc = gnutls_hash_init(&hash_hnd, GNUTLS_DIG_MD5);
+       rc = gnutls_hash_init(&hash_hnd, GNUTLS_DIG_SHA1);
        if (rc < 0) {
                goto out;
        }
@@ -210,15 +210,14 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
                goto out;
        }
 
-       gnutls_hash_deinit(hash_hnd, tmp);
+       gnutls_hash_deinit(hash_hnd, digest);
 
        profile_p = &smbprofile_state.stats.global;
 
-       profile_p->magic = BVAL(tmp, 0);
+       profile_p->magic = BVAL(digest, 0);
        if (profile_p->magic == 0) {
-               profile_p->magic = BVAL(tmp, 8);
+               profile_p->magic = BVAL(digest, 8);
        }
-       ZERO_ARRAY(tmp);
 
        ok = true;
 out: