2 * Copyright (c) 2019 Andreas Schneider <asn@samba.org>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "gnutls_error.h"
21 #include <gnutls/gnutls.h>
23 NTSTATUS _gnutls_error_to_ntstatus(int gnutls_rc,
24 NTSTATUS blocked_status,
30 if (gnutls_rc == GNUTLS_E_SUCCESS) {
35 case GNUTLS_E_UNWANTED_ALGORITHM:
36 status = blocked_status;
38 case GNUTLS_E_MEMORY_ERROR:
39 status = NT_STATUS_NO_MEMORY;
41 case GNUTLS_E_INVALID_REQUEST:
42 status = NT_STATUS_INVALID_VARIANT;
44 case GNUTLS_E_DECRYPTION_FAILED:
45 status = NT_STATUS_DECRYPTION_FAILED;
47 case GNUTLS_E_ENCRYPTION_FAILED:
48 status = NT_STATUS_ENCRYPTION_FAILED;
50 case GNUTLS_E_SHORT_MEMORY_BUFFER:
51 status = NT_STATUS_INVALID_PARAMETER;
53 case GNUTLS_E_BASE64_DECODING_ERROR:
54 case GNUTLS_E_HASH_FAILED:
55 case GNUTLS_E_LIB_IN_ERROR_STATE:
56 case GNUTLS_E_INTERNAL_ERROR:
58 status = NT_STATUS_INTERNAL_ERROR;
62 D_WARNING("%s: GNUTLS ERROR: %s, NTSTATUS: %s at %s\n",
64 gnutls_strerror_name(gnutls_rc),