vfs: Add helper function hash_blob_sha256 to vfs_acl_common.c
authorAndrew Bartlett <abartlet@samba.org>
Mon, 21 Jan 2013 01:43:00 +0000 (12:43 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 4 Feb 2013 11:19:29 +0000 (12:19 +0100)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Christian Ambach <ambi@samba.org>
source3/modules/vfs_acl_common.c

index 4e3aa72d378194a8595ce7d1cd904d038dd5e7db..e1555c7d9e6b2f9837bd785b689fcb35729111e0 100644 (file)
@@ -49,11 +49,28 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
  Hash a security descriptor.
 *******************************************************************/
 
+static NTSTATUS hash_blob_sha256(DATA_BLOB blob,
+                                uint8_t *hash)
+{
+       SHA256_CTX tctx;
+
+       memset(hash, '\0', XATTR_SD_HASH_SIZE);
+
+       samba_SHA256_Init(&tctx);
+       samba_SHA256_Update(&tctx, blob.data, blob.length);
+       samba_SHA256_Final(hash, &tctx);
+
+       return NT_STATUS_OK;
+}
+
+/*******************************************************************
+ Hash a security descriptor.
+*******************************************************************/
+
 static NTSTATUS hash_sd_sha256(struct security_descriptor *psd,
                        uint8_t *hash)
 {
        DATA_BLOB blob;
-       SHA256_CTX tctx;
        NTSTATUS status;
 
        memset(hash, '\0', XATTR_SD_HASH_SIZE);
@@ -61,12 +78,7 @@ static NTSTATUS hash_sd_sha256(struct security_descriptor *psd,
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
-
-       samba_SHA256_Init(&tctx);
-       samba_SHA256_Update(&tctx, blob.data, blob.length);
-       samba_SHA256_Final(hash, &tctx);
-
-       return NT_STATUS_OK;
+       return hash_blob_sha256(blob, hash);
 }
 
 /*******************************************************************