s4:ntp_signd: Use gnutls_error_to_ntstatus() in ntp_signd
authorAndreas Schneider <asn@samba.org>
Thu, 13 Jun 2019 09:30:55 +0000 (11:30 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 24 Jun 2019 07:27:21 +0000 (07:27 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jun 24 07:27:21 UTC 2019 on sn-devel-184

source4/ntp_signd/ntp_signd.c

index df45e58aec7fb21364fd59095fcc1edeb0802b29..b7eb2f842acf9e446c4926e3c17a3832ab0bdfe3 100644 (file)
@@ -40,6 +40,7 @@
 #include "system/network.h"
 #include "system/passwd.h"
 
+#include "libcli/util/gnutls_error.h"
 #include <gnutls/gnutls.h>
 #include <gnutls/crypto.h>
 
@@ -248,10 +249,7 @@ static NTSTATUS ntp_signd_process(struct ntp_signd_connection *ntp_signd_conn,
        /* Sign the NTP response with the unicodePwd */
        ret = gnutls_hash_init(&hash_hnd, GNUTLS_DIG_MD5);
        if (ret < 0) {
-               if (ret == GNUTLS_E_UNWANTED_ALGORITHM) {
-                       return NT_STATUS_HASH_NOT_SUPPORTED;
-               }
-               return NT_STATUS_NO_MEMORY;
+               return gnutls_error_to_ntstatus(ret, NT_STATUS_HASH_NOT_SUPPORTED);
        }
 
        ret = gnutls_hash(hash_hnd,
@@ -259,14 +257,14 @@ static NTSTATUS ntp_signd_process(struct ntp_signd_connection *ntp_signd_conn,
                          sizeof(nt_hash->hash));
        if (ret < 0) {
                gnutls_hash_deinit(hash_hnd, NULL);
-               return NT_STATUS_INTERNAL_ERROR;
+               return gnutls_error_to_ntstatus(ret, NT_STATUS_HASH_NOT_SUPPORTED);
        }
        ret = gnutls_hash(hash_hnd,
                          sign_request.packet_to_sign.data,
                          sign_request.packet_to_sign.length);
        if (ret < 0) {
                gnutls_hash_deinit(hash_hnd, NULL);
-               return NT_STATUS_INTERNAL_ERROR;
+               return gnutls_error_to_ntstatus(ret, NT_STATUS_HASH_NOT_SUPPORTED);
        }
 
        gnutls_hash_deinit(hash_hnd,