From: Andreas Schneider Date: Thu, 11 Oct 2018 16:29:11 +0000 (+0200) Subject: s4:utils: Use gnutls SHA256 in oLschema2ldif X-Git-Tag: tdb-1.4.1~264 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6fb7837385ea8bcf9c96f674ac8f30d7a0ccff98;p=thirdparty%2Fsamba.git s4:utils: Use gnutls SHA256 in oLschema2ldif Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- 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));