]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:modules: Use GnuTLS SHA256 in vfs_acl_common
authorAndreas Schneider <asn@samba.org>
Thu, 11 Oct 2018 12:43:24 +0000 (14:43 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 30 Apr 2019 23:18:27 +0000 (23:18 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/modules/vfs_acl_common.c

index 5cc75ca99c0e4afa7b6f1936da950bf67327a25f..315dc2bd7612ecd0e9f684df182d5c271f95fbc2 100644 (file)
 #include "../libcli/security/security.h"
 #include "../librpc/gen_ndr/ndr_security.h"
 #include "../lib/util/bitmap.h"
-#include "lib/crypto/sha256.h"
 #include "passdb/lookup_sid.h"
 
+#include <gnutls/gnutls.h>
+#include <gnutls/crypto.h>
+
 static NTSTATUS create_acl_blob(const struct security_descriptor *psd,
                        DATA_BLOB *pblob,
                        uint16_t hash_type,
@@ -81,13 +83,17 @@ bool init_acl_common_config(vfs_handle_struct *handle,
 static NTSTATUS hash_blob_sha256(DATA_BLOB blob,
                                 uint8_t *hash)
 {
-       SHA256_CTX tctx;
+       int rc;
 
-       memset(hash, '\0', XATTR_SD_HASH_SIZE);
+       ZERO_ARRAY_LEN(hash, XATTR_SD_HASH_SIZE);
 
-       samba_SHA256_Init(&tctx);
-       samba_SHA256_Update(&tctx, blob.data, blob.length);
-       samba_SHA256_Final(hash, &tctx);
+       rc = gnutls_hash_fast(GNUTLS_DIG_SHA256,
+                             blob.data,
+                             blob.length,
+                             hash);
+       if (rc < 0) {
+               return NT_STATUS_INTERNAL_ERROR;
+       }
 
        return NT_STATUS_OK;
 }