Blob Blame History Raw
From 8fc821bcdc457b9f22726eb6a83f5a3a08213040 Mon Sep 17 00:00:00 2001
From: Andrew Bartlett <abartlet@samba.org>
Date: Fri, 16 Aug 2019 15:45:43 +1200
Subject: [PATCH 102/187] auth/gensec: Use gnutls_error_to_ntstatus() in
 netsec_do_seal()

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit fa8eddc39b4ea9d316201019b603025df5c2fa5e)
---
 auth/gensec/schannel.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/auth/gensec/schannel.c b/auth/gensec/schannel.c
index 20b0a74e37f..b5e6289ef3f 100644
--- a/auth/gensec/schannel.c
+++ b/auth/gensec/schannel.c
@@ -302,10 +302,8 @@ static NTSTATUS netsec_do_seal(struct schannel_state *state,
 						   confounder,
 						   8);
 			if (rc < 0) {
-				DBG_ERR("ERROR: gnutls_cipher_encrypt: %s\n",
-					gnutls_strerror(errno));
 				gnutls_cipher_deinit(cipher_hnd);
-				return NT_STATUS_INTERNAL_ERROR;
+				return gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
 			}
 
 			/*
@@ -317,20 +315,16 @@ static NTSTATUS netsec_do_seal(struct schannel_state *state,
 						   data,
 						   length);
 			if (rc < 0) {
-				DBG_ERR("ERROR: gnutls_cipher_encrypt: %s\n",
-					gnutls_strerror(errno));
 				gnutls_cipher_deinit(cipher_hnd);
-				return NT_STATUS_INTERNAL_ERROR;
+				return gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
 			}
 		} else {
 			rc = gnutls_cipher_decrypt(cipher_hnd,
 						   confounder,
 						   8);
 			if (rc < 0) {
-				DBG_ERR("ERROR: gnutls_cipher_decrypt: %s\n",
-					gnutls_strerror(errno));
 				gnutls_cipher_deinit(cipher_hnd);
-				return NT_STATUS_INTERNAL_ERROR;
+				return gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
 			}
 
 			/*
@@ -342,10 +336,8 @@ static NTSTATUS netsec_do_seal(struct schannel_state *state,
 						   data,
 						   length);
 			if (rc < 0) {
-				DBG_ERR("ERROR: gnutls_cipher_decrypt: %s\n",
-					gnutls_strerror(errno));
 				gnutls_cipher_deinit(cipher_hnd);
-				return NT_STATUS_INTERNAL_ERROR;
+				return gnutls_error_to_ntstatus(rc, NT_STATUS_CRYPTO_SYSTEM_INVALID);
 			}
 		}
 		gnutls_cipher_deinit(cipher_hnd);
-- 
2.23.0