From 6fb7837385ea8bcf9c96f674ac8f30d7a0ccff98 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 11 Oct 2018 18:29:11 +0200 Subject: [PATCH] s4:utils: Use gnutls SHA256 in oLschema2ldif Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- source4/utils/oLschema2ldif/lib.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source4/utils/oLschema2ldif/lib.c b/source4/utils/oLschema2ldif/lib.c index feda4674eb0..ad73bab5325 100644 --- a/source4/utils/oLschema2ldif/lib.c +++ b/source4/utils/oLschema2ldif/lib.c @@ -34,9 +34,11 @@ #include "includes.h" #include "./lib.h" #include "ldb.h" -#include "../lib/crypto/sha256.h" #include "../librpc/gen_ndr/ndr_misc.h" +#include +#include + #define SCHEMA_UNKNOWN 0 #define SCHEMA_NAME 1 #define SCHEMA_SUP 2 @@ -351,8 +353,8 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, struct conv_option char *c, *s; int n; - SHA256_CTX sha256_context; - uint8_t digest[SHA256_DIGEST_LENGTH]; + uint8_t digest[gnutls_hash_get_len(GNUTLS_MAC_SHA256)]; + int rc; struct GUID guid; @@ -410,9 +412,13 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, struct conv_option MSG_ADD_STRING("governsID", s); } - samba_SHA256_Init(&sha256_context); - samba_SHA256_Update(&sha256_context, (uint8_t*)s, strlen(s)); - samba_SHA256_Final(digest, &sha256_context); + rc = gnutls_hash_fast(GNUTLS_DIG_SHA256, + s, + strlen(s), + digest); + if (rc < 0) { + goto failed; + } memcpy(&guid, digest, sizeof(struct GUID)); -- 2.47.3