1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

libcli:auth: Use gnutls_error_to_ntstatus() in credentials

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andreas Schneider 2019-06-11 15:11:30 +02:00 committed by Andreas Schneider
parent c7cea1d49c
commit 702ae15853

View File

@ -26,6 +26,7 @@
#include "libcli/auth/libcli_auth.h" #include "libcli/auth/libcli_auth.h"
#include "../libcli/security/dom_sid.h" #include "../libcli/security/dom_sid.h"
#include "libcli/util/gnutls_error.h"
#include <gnutls/gnutls.h> #include <gnutls/gnutls.h>
#include <gnutls/crypto.h> #include <gnutls/crypto.h>
@ -88,26 +89,23 @@ static NTSTATUS netlogon_creds_init_128bit(struct netlogon_creds_CredentialState
rc = gnutls_hash_init(&hash_hnd, GNUTLS_DIG_MD5); rc = gnutls_hash_init(&hash_hnd, GNUTLS_DIG_MD5);
if (rc < 0) { if (rc < 0) {
if (rc == GNUTLS_E_UNWANTED_ALGORITHM) { return gnutls_error_to_ntstatus(rc, NT_STATUS_HASH_NOT_SUPPORTED);
return NT_STATUS_HASH_NOT_SUPPORTED;
}
return NT_STATUS_NO_MEMORY;
} }
rc = gnutls_hash(hash_hnd, zero, sizeof(zero)); rc = gnutls_hash(hash_hnd, zero, sizeof(zero));
if (rc < 0) { if (rc < 0) {
gnutls_hash_deinit(hash_hnd, NULL); gnutls_hash_deinit(hash_hnd, NULL);
return NT_STATUS_INTERNAL_ERROR; return gnutls_error_to_ntstatus(rc, NT_STATUS_HASH_NOT_SUPPORTED);
} }
rc = gnutls_hash(hash_hnd, client_challenge->data, 8); rc = gnutls_hash(hash_hnd, client_challenge->data, 8);
if (rc < 0) { if (rc < 0) {
gnutls_hash_deinit(hash_hnd, NULL); gnutls_hash_deinit(hash_hnd, NULL);
return NT_STATUS_INTERNAL_ERROR; return gnutls_error_to_ntstatus(rc, NT_STATUS_HASH_NOT_SUPPORTED);
} }
rc = gnutls_hash(hash_hnd, server_challenge->data, 8); rc = gnutls_hash(hash_hnd, server_challenge->data, 8);
if (rc < 0) { if (rc < 0) {
gnutls_hash_deinit(hash_hnd, NULL); gnutls_hash_deinit(hash_hnd, NULL);
return NT_STATUS_INTERNAL_ERROR; return gnutls_error_to_ntstatus(rc, NT_STATUS_HASH_NOT_SUPPORTED);
} }
gnutls_hash_deinit(hash_hnd, tmp); gnutls_hash_deinit(hash_hnd, tmp);
@ -122,7 +120,7 @@ static NTSTATUS netlogon_creds_init_128bit(struct netlogon_creds_CredentialState
ZERO_ARRAY(tmp); ZERO_ARRAY(tmp);
if (rc < 0) { if (rc < 0) {
return NT_STATUS_INTERNAL_ERROR; return gnutls_error_to_ntstatus(rc, NT_STATUS_HASH_NOT_SUPPORTED);
} }
return NT_STATUS_OK; return NT_STATUS_OK;
@ -149,21 +147,21 @@ static NTSTATUS netlogon_creds_init_hmac_sha256(struct netlogon_creds_Credential
machine_password->hash, machine_password->hash,
sizeof(machine_password->hash)); sizeof(machine_password->hash));
if (rc < 0) { if (rc < 0) {
return NT_STATUS_NO_MEMORY; return gnutls_error_to_ntstatus(rc, NT_STATUS_HMAC_NOT_SUPPORTED);
} }
rc = gnutls_hmac(hmac_hnd, rc = gnutls_hmac(hmac_hnd,
client_challenge->data, client_challenge->data,
8); 8);
if (rc < 0) { if (rc < 0) {
gnutls_hmac_deinit(hmac_hnd, NULL); gnutls_hmac_deinit(hmac_hnd, NULL);
return NT_STATUS_INTERNAL_ERROR; return gnutls_error_to_ntstatus(rc, NT_STATUS_HMAC_NOT_SUPPORTED);
} }
rc = gnutls_hmac(hmac_hnd, rc = gnutls_hmac(hmac_hnd,
server_challenge->data, server_challenge->data,
8); 8);
if (rc < 0) { if (rc < 0) {
gnutls_hmac_deinit(hmac_hnd, NULL); gnutls_hmac_deinit(hmac_hnd, NULL);
return NT_STATUS_INTERNAL_ERROR; return gnutls_error_to_ntstatus(rc, NT_STATUS_HMAC_NOT_SUPPORTED);
} }
gnutls_hmac_deinit(hmac_hnd, digest); gnutls_hmac_deinit(hmac_hnd, digest);