From 6a5f65b0e971f068ebae5b2f93a6dfccfaa93b26 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 21 Jan 2013 12:43:00 +1100 Subject: [PATCH] vfs: Add helper function hash_blob_sha256 to vfs_acl_common.c Signed-off-by: Andrew Bartlett Reviewed-by: Christian Ambach --- source3/modules/vfs_acl_common.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/source3/modules/vfs_acl_common.c b/source3/modules/vfs_acl_common.c index 4e3aa72d378..e1555c7d9e6 100644 --- a/source3/modules/vfs_acl_common.c +++ b/source3/modules/vfs_acl_common.c @@ -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); } /******************************************************************* -- 2.11.4.GIT