summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2002-11-02 08:41:43 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2002-11-02 08:41:43 +0000
commitdfa6f7f9054dd87642c38ff189b4f01d88c88a89 (patch)
tree3675be9cdb0ef4aeb678b31dbbcbb902bafbf911
parentd340158164411d7eef49550781dc147689864b89 (diff)
downloadgnutls-dfa6f7f9054dd87642c38ff189b4f01d88c88a89.tar.gz
Combined GNUTLS_E_INVALID_PARAMETERS wich GNUTLS_E_INVALID_REQUEST. Introduced GNUTLS_E_SHORT_MEMORY_BUFFER.
-rw-r--r--NEWS2
-rw-r--r--lib/ext_cert_type.c11
-rw-r--r--lib/ext_max_record.c11
-rw-r--r--lib/ext_server_name.c11
-rw-r--r--lib/gnutls_alert.c2
-rw-r--r--lib/gnutls_buffers.c14
-rw-r--r--lib/gnutls_cert.c2
-rw-r--r--lib/gnutls_dh_primes.c6
-rw-r--r--lib/gnutls_errors.c6
-rw-r--r--lib/gnutls_errors_int.h6
-rw-r--r--lib/gnutls_handshake.c2
-rw-r--r--lib/gnutls_record.c4
-rw-r--r--lib/gnutls_rsa_export.c6
-rw-r--r--lib/gnutls_session_pack.c6
-rw-r--r--lib/gnutls_ui.c2
-rw-r--r--lib/x509_b64.c8
-rw-r--r--libextra/gnutls_openpgp.c54
-rw-r--r--libextra/gnutls_srp.c4
18 files changed, 79 insertions, 78 deletions
diff --git a/NEWS b/NEWS
index bbab83628a..f08170318a 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ Version 0.5.11
- Documented error codes, and the function reference list is now sorted.
- Optimized buffering code.
- gnutls_x509_extract_certificate_dn_string() was rewritten.
+- Added GNUTLS_E_SHORT_MEMORY_BUFFER error code, which is returned in the
+ case where the memory buffer provided is not long enough.
Version 0.5.10 (13/10/2002)
- Updated documentation.
diff --git a/lib/ext_cert_type.c b/lib/ext_cert_type.c
index 26a2252f1e..407074dfd9 100644
--- a/lib/ext_cert_type.c
+++ b/lib/ext_cert_type.c
@@ -89,7 +89,7 @@ int _gnutls_cert_type_recv_params( gnutls_session session, const opaque* data, s
if (new_type < 0) {
gnutls_assert();
- return GNUTLS_E_ILLEGAL_PARAMETER;
+ return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
}
if ( (ret=_gnutls_session_cert_type_supported( session, new_type)) < 0) {
@@ -107,7 +107,6 @@ int _gnutls_cert_type_recv_params( gnutls_session session, const opaque* data, s
}
/* returns data_size or a negative number on failure
- * data is allocated localy
*/
int _gnutls_cert_type_send_params( gnutls_session session, opaque* data, size_t data_size) {
uint len, i;
@@ -130,7 +129,7 @@ int _gnutls_cert_type_send_params( gnutls_session session, opaque* data, size_t
if (data_size < len + 1) {
gnutls_assert();
- return GNUTLS_E_INVALID_REQUEST;
+ return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
/* this is a vector!
@@ -150,7 +149,7 @@ int _gnutls_cert_type_send_params( gnutls_session session, opaque* data, size_t
len = 1;
if (data_size < len) {
gnutls_assert();
- return GNUTLS_E_INVALID_REQUEST;
+ return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
data[0] = _gnutls_cert_type2num( session->security_parameters.cert_type);
@@ -173,7 +172,7 @@ int _gnutls_num2cert_type( int num) {
case 1:
return GNUTLS_CRT_OPENPGP;
default:
- return GNUTLS_E_ILLEGAL_PARAMETER;
+ return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
}
}
@@ -187,7 +186,7 @@ int _gnutls_cert_type2num( int cert_type) {
case GNUTLS_CRT_OPENPGP:
return 1;
default:
- return GNUTLS_E_ILLEGAL_PARAMETER;
+ return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
}
}
diff --git a/lib/ext_max_record.c b/lib/ext_max_record.c
index 09a230e238..0b00f4b0af 100644
--- a/lib/ext_max_record.c
+++ b/lib/ext_max_record.c
@@ -70,7 +70,7 @@ int _gnutls_max_record_recv_params( gnutls_session session, const opaque* data,
if (new_size < 0 || new_size != session->internals.proposed_record_size) {
gnutls_assert();
- return GNUTLS_E_ILLEGAL_PARAMETER;
+ return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
} else {
session->security_parameters.max_record_recv_size = session->internals.proposed_record_size;
}
@@ -84,7 +84,6 @@ int _gnutls_max_record_recv_params( gnutls_session session, const opaque* data,
}
/* returns data_size or a negative number on failure
- * data is allocated localy
*/
int _gnutls_max_record_send_params( gnutls_session session, opaque* data,
size_t data_size)
@@ -99,7 +98,7 @@ int _gnutls_max_record_send_params( gnutls_session session, opaque* data,
len = 1;
if (data_size < len) {
gnutls_assert();
- return GNUTLS_E_INVALID_REQUEST;
+ return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
data[0] = (uint8) _gnutls_mre_record2num( session->internals.proposed_record_size);
@@ -112,7 +111,7 @@ int _gnutls_max_record_send_params( gnutls_session session, opaque* data,
len = 1;
if (data_size < len) {
gnutls_assert();
- return GNUTLS_E_INVALID_REQUEST;
+ return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
data[0] = (uint8) _gnutls_mre_record2num( session->security_parameters.max_record_recv_size);
@@ -139,7 +138,7 @@ int _gnutls_mre_num2record( int num) {
case 4:
return 4096;
default:
- return GNUTLS_E_ILLEGAL_PARAMETER;
+ return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
}
}
@@ -157,7 +156,7 @@ int _gnutls_mre_record2num( uint16 record_size) {
case 4096:
return 4;
default:
- return GNUTLS_E_ILLEGAL_PARAMETER;
+ return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER;
}
}
diff --git a/lib/ext_server_name.c b/lib/ext_server_name.c
index c94a68d67c..de0185ab50 100644
--- a/lib/ext_server_name.c
+++ b/lib/ext_server_name.c
@@ -111,7 +111,6 @@ int _gnutls_server_name_recv_params(gnutls_session session,
}
/* returns data_size or a negative number on failure
- * data is allocated localy
*/
int _gnutls_server_name_send_params(gnutls_session session, opaque * data,
size_t _data_size)
@@ -141,7 +140,7 @@ int _gnutls_server_name_send_params(gnutls_session session, opaque * data,
/* UINT16: write total size of all names
*/
- DECR_LENGTH_RET( data_size, 2, GNUTLS_E_INVALID_REQUEST);
+ DECR_LENGTH_RET( data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER);
_gnutls_write_uint16(total_size, p);
p += 2;
@@ -161,7 +160,7 @@ int _gnutls_server_name_send_params(gnutls_session session, opaque * data,
* UINT16: size of the first name
* LEN: the actual server name.
*/
- DECR_LENGTH_RET( data_size, len + 3, GNUTLS_E_INVALID_REQUEST);
+ DECR_LENGTH_RET( data_size, len + 3, GNUTLS_E_SHORT_MEMORY_BUFFER);
*p = 0; /* NAME_DNS type */
p++;
@@ -200,7 +199,7 @@ int _gnutls_server_name_send_params(gnutls_session session, opaque * data,
* that support virtual hosting, and the data will be null terminated.
* The client may give the server the dnsname they connected to.
*
- * If data has not enough size to hold the server name GNUTLS_E_INVALID_REQUEST
+ * If data has not enough size to hold the server name GNUTLS_E_SHORT_MEMORY_BUFFER
* is returned, and data_length will hold the required size.
*
* 'index' is used to retrieve more than one server names (if sent by the client).
@@ -241,7 +240,7 @@ int gnutls_get_server_name(gnutls_session session, void *data,
*data_length =
session->security_parameters.extensions.server_names[index].
name_length;
- return GNUTLS_E_INVALID_REQUEST;
+ return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
return 0;
@@ -273,7 +272,7 @@ int gnutls_set_server_name(gnutls_session session,
return GNUTLS_E_INVALID_REQUEST;
if (name_length > MAX_SERVER_NAME_SIZE)
- return GNUTLS_E_INVALID_REQUEST;
+ return GNUTLS_E_SHORT_MEMORY_BUFFER;
server_names =
session->security_parameters.extensions.server_names_size + 1;
diff --git a/lib/gnutls_alert.c b/lib/gnutls_alert.c
index 10e6eafa6b..f5d251ab4f 100644
--- a/lib/gnutls_alert.c
+++ b/lib/gnutls_alert.c
@@ -141,7 +141,7 @@ int _level = -1;
ret = GNUTLS_A_DECOMPRESSION_FAILURE;
_level = GNUTLS_AL_FATAL;
break;
- case GNUTLS_E_ILLEGAL_PARAMETER:
+ case GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER:
ret = GNUTLS_A_ILLEGAL_PARAMETER;
_level = GNUTLS_AL_FATAL;
break;
diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c
index 3e9ad574fd..a5f2d20b7d 100644
--- a/lib/gnutls_buffers.c
+++ b/lib/gnutls_buffers.c
@@ -98,7 +98,7 @@ int _gnutls_record_buffer_put(ContentType type, gnutls_session session, char *da
default:
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
return 0;
@@ -115,7 +115,7 @@ int _gnutls_record_buffer_get_size(ContentType type, gnutls_session session)
return session->internals.handshake_data_buffer.length;
default:
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
return 0;
}
@@ -139,7 +139,7 @@ int _gnutls_record_buffer_get(ContentType type, gnutls_session session, char *da
{
if (length==0 || data==NULL) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
switch(type) {
@@ -183,7 +183,7 @@ int _gnutls_record_buffer_get(ContentType type, gnutls_session session, char *da
break;
default:
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
@@ -334,7 +334,7 @@ ssize_t _gnutls_io_read_buffered( gnutls_session session, opaque **iptr, size_t
|| (session->internals.record_recv_buffer.length+sizeOfPtr) > MAX_RECV_SIZE)
{
gnutls_assert(); /* internal error */
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
/* leave peeked data to the kernel space only if application data
@@ -535,7 +535,7 @@ ssize_t _gnutls_io_write_buffered( gnutls_session session, const void *iptr, siz
*/
if (session->internals.record_send_buffer.length > 0 && iptr != NULL) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
/* If data in the buffer exist
@@ -804,7 +804,7 @@ ssize_t _gnutls_handshake_io_recv_int( gnutls_session session, ContentType type,
if (sizeOfPtr == 0 || iptr == NULL) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
if (session->internals.handshake_recv_buffer.length > 0) {
diff --git a/lib/gnutls_cert.c b/lib/gnutls_cert.c
index 9a46c61bee..308b775405 100644
--- a/lib/gnutls_cert.c
+++ b/lib/gnutls_cert.c
@@ -195,7 +195,7 @@ int _gnutls_cert_supported_kx(const gnutls_cert * cert, gnutls_kx_algorithm ** a
if (i==0) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
*alg = gnutls_calloc(1, sizeof(gnutls_kx_algorithm) * i);
diff --git a/lib/gnutls_dh_primes.c b/lib/gnutls_dh_primes.c
index 2dea0cd3c8..e89a224998 100644
--- a/lib/gnutls_dh_primes.c
+++ b/lib/gnutls_dh_primes.c
@@ -513,7 +513,7 @@ static int check_bits(int bits)
} while (supported_bits[i] != 0);
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
/* Replaces the prime in the static DH parameters, with a randomly
@@ -543,7 +543,7 @@ int gnutls_dh_params_set(gnutls_dh_params dh_params, gnutls_datum prime,
if (check_bits(bits) < 0) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
i = 0;
@@ -681,7 +681,7 @@ int gnutls_dh_params_generate(gnutls_datum * prime,
if (check_bits(bits) < 0) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
if (_gnutls_dh_generate_prime(&tmp_g, &tmp_prime, bits) < 0) {
diff --git a/lib/gnutls_errors.c b/lib/gnutls_errors.c
index c2e6078e6f..087b580eb2 100644
--- a/lib/gnutls_errors.c
+++ b/lib/gnutls_errors.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000 Nikos Mavroyanopoulos
+ * Copyright (C) 2000,2001,2002 Nikos Mavroyanopoulos
*
* This file is part of GNUTLS.
*
@@ -96,9 +96,9 @@ static gnutls_error_entry error_algorithms[] = {
ERROR_ENTRY("TLS Application data were received, while expected handshake data.", GNUTLS_E_GOT_APPLICATION_DATA, 1 ),
ERROR_ENTRY("Error in Database backend.", GNUTLS_E_DB_ERROR, 1 ),
ERROR_ENTRY("The certificate type is not supported.", GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE, 1 ),
- ERROR_ENTRY("Invalid parameters given in request.", GNUTLS_E_INVALID_PARAMETERS, 1 ),
+ ERROR_ENTRY("The memory buffer given, is too short to hold parameters.", GNUTLS_E_SHORT_MEMORY_BUFFER, 1 ),
ERROR_ENTRY("The request is invalid.", GNUTLS_E_INVALID_REQUEST, 1 ),
- ERROR_ENTRY("An illegal parameter has been received.", GNUTLS_E_ILLEGAL_PARAMETER, 1 ),
+ ERROR_ENTRY("An illegal parameter has been received.", GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER, 1 ),
ERROR_ENTRY("Error while reading file.", GNUTLS_E_FILE_ERROR, 1 ),
ERROR_ENTRY("Error in ASCII armoring.", GNUTLS_E_ASCII_ARMOR_ERROR, 1 ),
diff --git a/lib/gnutls_errors_int.h b/lib/gnutls_errors_int.h
index 224129b5c9..ddd7a4df5d 100644
--- a/lib/gnutls_errors_int.h
+++ b/lib/gnutls_errors_int.h
@@ -42,12 +42,12 @@
#define GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION -47
#define GNUTLS_E_X509_KEY_USAGE_VIOLATION -48
#define GNUTLS_E_NO_CERTIFICATE_FOUND -49 /* GNUTLS_A_BAD_CERTIFICATE */
-#define GNUTLS_E_INVALID_PARAMETERS -50
-#define GNUTLS_E_INVALID_REQUEST -51
+#define GNUTLS_E_INVALID_REQUEST -50
+#define GNUTLS_E_SHORT_MEMORY_BUFFER -51
#define GNUTLS_E_INTERRUPTED -52
#define GNUTLS_E_PUSH_ERROR -53
#define GNUTLS_E_PULL_ERROR -54
-#define GNUTLS_E_ILLEGAL_PARAMETER -55 /* GNUTLS_A_ILLEGAL_PARAMETER */
+#define GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER -55 /* GNUTLS_A_ILLEGAL_PARAMETER */
#define GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE -56
#define GNUTLS_E_PKCS1_WRONG_PAD -57
#define GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION -58
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c
index 06bfb421b3..ddc5e65184 100644
--- a/lib/gnutls_handshake.c
+++ b/lib/gnutls_handshake.c
@@ -736,7 +736,7 @@ int _gnutls_send_handshake(gnutls_session session, void *i_data,
if (i_data == NULL && i_datasize > 0) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
/* first run */
diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c
index cefcb0d896..1aca855a77 100644
--- a/lib/gnutls_record.c
+++ b/lib/gnutls_record.c
@@ -305,7 +305,7 @@ ssize_t gnutls_send_int( gnutls_session session, ContentType type, HandshakeType
if (session->internals.record_send_buffer.length == 0 &&
(sizeofdata == 0 || _data==NULL)) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
if (type!=GNUTLS_ALERT) /* alert messages are sent anyway */
@@ -694,7 +694,7 @@ ssize_t gnutls_recv_int( gnutls_session session, ContentType type, HandshakeType
ret = 0;
if (sizeofdata == 0 || data == NULL) {
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
if ( _gnutls_session_is_valid(session)!=0 || session->internals.may_read!=0) {
diff --git a/lib/gnutls_rsa_export.c b/lib/gnutls_rsa_export.c
index 5150c37465..5a26aa9acc 100644
--- a/lib/gnutls_rsa_export.c
+++ b/lib/gnutls_rsa_export.c
@@ -162,7 +162,7 @@ static int check_bits(int bits)
} while (supported_bits[i] != 0);
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
#define FREE_PRIVATE_PARAMS for (i=0;i<RSA_PRIVATE_PARAMS;i++) \
@@ -198,7 +198,7 @@ int gnutls_rsa_params_set(gnutls_rsa_params rsa_params,
if (check_bits(bits) < 0) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
for (i=0;i<RSA_PRIVATE_PARAMS;i++) {
@@ -330,7 +330,7 @@ int gnutls_rsa_params_generate(gnutls_datum * m, gnutls_datum *e,
if (check_bits(bits) < 0) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
ret = _gnutls_rsa_generate_params( rsa_params, bits);
diff --git a/lib/gnutls_session_pack.c b/lib/gnutls_session_pack.c
index 1c1ade4c20..f86ba8111c 100644
--- a/lib/gnutls_session_pack.c
+++ b/lib/gnutls_session_pack.c
@@ -65,7 +65,7 @@ int _gnutls_session_pack(gnutls_session session, gnutls_datum * packed_session)
if (info == NULL && session->gnutls_key->auth_info_size!=0) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
pack_size = session->gnutls_key->auth_info_size;
@@ -91,7 +91,7 @@ int _gnutls_session_pack(gnutls_session session, gnutls_datum * packed_session)
_gnutls_get_auth_info(session);
if (info == NULL && session->gnutls_key->auth_info_size!=0) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
packed_session->size =
@@ -114,7 +114,7 @@ int _gnutls_session_pack(gnutls_session session, gnutls_datum * packed_session)
_gnutls_get_auth_info(session);
if (info == NULL && session->gnutls_key->auth_info_size!=0) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
ret =
diff --git a/lib/gnutls_ui.c b/lib/gnutls_ui.c
index 4d6d284111..defaad9476 100644
--- a/lib/gnutls_ui.c
+++ b/lib/gnutls_ui.c
@@ -282,7 +282,7 @@ int gnutls_x509_fingerprint(GNUTLS_DigestAlgorithm algo, const gnutls_datum* dat
if (hash_len < 0 || (size_t)hash_len > *result_size) {
*result_size = hash_len;
- return GNUTLS_E_INVALID_REQUEST;
+ return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
*result_size = hash_len;
diff --git a/lib/x509_b64.c b/lib/x509_b64.c
index 3144ae3dda..6ba8db8bf1 100644
--- a/lib/x509_b64.c
+++ b/lib/x509_b64.c
@@ -259,7 +259,7 @@ int _gnutls_fbase64_encode(const char *msg, const uint8 * data, int data_size,
*
* This function will convert the given data to printable data, using the base64
* encoding. This is the encoding used in PEM messages. If the provided
- * buffer is not long enough GNUTLS_E_INVALID_REQUEST is returned.
+ * buffer is not long enough GNUTLS_E_SHORT_MEMORY_BUFFER is returned.
*
**/
int gnutls_pem_base64_encode( const char* msg, const gnutls_datum *data, char* result, int* result_size) {
@@ -273,7 +273,7 @@ int size;
if (result==NULL || *result_size < size) {
gnutls_free(ret);
*result_size = size;
- return GNUTLS_E_INVALID_REQUEST;
+ return GNUTLS_E_SHORT_MEMORY_BUFFER;
} else {
memcpy( result, ret, size);
gnutls_free(ret);
@@ -476,6 +476,8 @@ int _gnutls_fbase64_decode( const opaque* header, const opaque * data, size_t da
*
* Note that b64_data should be null terminated.
*
+ * Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not long enough,
+ * or 0 on success.
**/
int gnutls_pem_base64_decode( const char* header, const gnutls_datum *b64_data, char* result, int* result_size)
{
@@ -489,7 +491,7 @@ int size;
if (result==NULL || *result_size < size) {
gnutls_free(ret);
*result_size = size;
- return GNUTLS_E_INVALID_REQUEST;
+ return GNUTLS_E_SHORT_MEMORY_BUFFER;
} else {
memcpy( result, ret, size);
gnutls_free(ret);
diff --git a/libextra/gnutls_openpgp.c b/libextra/gnutls_openpgp.c
index 57f84761e0..bba33c8e80 100644
--- a/libextra/gnutls_openpgp.c
+++ b/libextra/gnutls_openpgp.c
@@ -80,7 +80,7 @@ map_cdk_rc( int rc )
case CDK_Error_No_Key: return GNUTLS_E_GETKEY_FAILED;
case CDK_Wrong_Format: return GNUTLS_E_OPENPGP_TRUSTDB_VERSION_UNSUPPORTED;
case CDK_Armor_Error: return GNUTLS_E_ASCII_ARMOR_ERROR;
- case CDK_Inv_Value: return GNUTLS_E_INVALID_PARAMETERS;
+ case CDK_Inv_Value: return GNUTLS_E_INVALID_REQUEST;
}
return rc;
}
@@ -104,7 +104,7 @@ kbx_blob_new( keybox_blob **r_ctx )
keybox_blob *c;
if( !r_ctx )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
c = cdk_calloc( 1, sizeof * c );
if( !c ) {
@@ -234,7 +234,7 @@ kbnode_to_datum( CDK_KBNODE knode, gnutls_datum *raw )
int rc = 0, nread;
if( !knode || !raw )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
while( (node = cdk_kbnode_walk( knode, &ctx, 0 )) ) {
pkt = cdk_kbnode_get_packet( node );
@@ -277,7 +277,7 @@ datum_to_kbnode( const gnutls_datum *raw, CDK_KBNODE *r_knode )
int rc;
if( !raw || !r_knode )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
s = cdk_stream_tmp( );
if( !s ) {
@@ -325,7 +325,7 @@ stream_to_datum( CDK_STREAM inp, gnutls_datum *raw )
int rc = 0, nread, nbytes = 0;
if( !buf || !raw )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
cdk_stream_seek( inp, 0 );
while( !cdk_stream_eof( inp ) ) {
@@ -352,7 +352,7 @@ openpgp_pk_to_gnutls_cert( gnutls_cert *cert, cdkPKT_public_key *pk )
int rc = 0;
if( !cert || !pk )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
/* GnuTLS OpenPGP doesn't support ELG keys */
if( is_ELG(pk->pubkey_algo) )
@@ -401,7 +401,7 @@ openpgp_sig_to_gnutls_cert( gnutls_cert *cert, cdkPKT_signature *sig )
int rc, nread;
if( !cert || !sig )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
tmp = cdk_stream_tmp( );
if( !tmp ) {
@@ -455,7 +455,7 @@ _gnutls_openpgp_key2gnutls_key( gnutls_private_key *pkey,
if( !pkey || raw_key->size <= 0 ) {
printf( "%s:%d: failed.\n", __FILE__, __LINE__ );
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
out = cdk_stream_tmp( );
@@ -544,7 +544,7 @@ _gnutls_openpgp_cert2gnutls_cert( gnutls_cert *cert, gnutls_datum raw )
int rc;
if( !cert )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
memset( cert, 0, sizeof *cert );
@@ -586,7 +586,7 @@ gnutls_openpgp_get_key( gnutls_datum *key, const gnutls_datum *keyring,
int rc = 0;
if( !key || !keyring || by == KEY_ATTR_NONE )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
memset( key, 0, sizeof *key );
blob = kbx_read_blob( keyring, 0 );
@@ -644,7 +644,7 @@ gnutls_certificate_set_openpgp_key_mem( gnutls_certificate_credentials res,
int rc = 0;
if ( !res || !key || !cert )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
rc = datum_to_kbnode( cert, &knode );
if ( rc )
@@ -736,7 +736,7 @@ gnutls_certificate_set_openpgp_key_file( gnutls_certificate_credentials res,
if( !res || !KEYFILE || !CERTFILE ) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
if( stat( CERTFILE, &statbuf ) || stat( KEYFILE, &statbuf ) ) {
@@ -876,7 +876,7 @@ gnutls_openpgp_extract_key_name( const gnutls_datum *cert,
int rc = 0;
if( !cert || !dn )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
if( idx < 0 || idx > gnutls_openpgp_count_key_names( cert ) )
return GNUTLS_E_INTERNAL_ERROR;
@@ -1155,7 +1155,7 @@ gnutls_openpgp_verify_key( const char *trustdb,
return GNUTLS_E_NO_CERTIFICATE_FOUND;
if( !keyring->size && !trustdb )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
blob = kbx_read_blob( keyring, 0 );
if( !blob )
@@ -1294,7 +1294,7 @@ gnutls_openpgp_add_keyring_file(gnutls_datum *keyring, const char *name)
int rc = 0;
if( !keyring || !name )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
rc = cdk_stream_open( name, &inp );
if( rc )
@@ -1332,7 +1332,7 @@ gnutls_openpgp_add_keyring_mem(gnutls_datum *keyring,
size_t nbytes = 0;
if( !keyring || !data || !len )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
blob = kbx_data_to_keyring( KBX_BLOB_DATA, 0, data, len, &nbytes );
if( blob && nbytes ) {
@@ -1364,7 +1364,7 @@ gnutls_certificate_set_openpgp_keyring_file(gnutls_certificate_credentials c,
struct stat statbuf;
if( !c || !file )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
if( stat( file, &statbuf ) )
return GNUTLS_E_FILE_ERROR;
@@ -1383,7 +1383,7 @@ gnutls_certificate_set_openpgp_keyring_mem( gnutls_certificate_credentials c,
int rc = 0;
if( !c || !data || !dlen )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
inp = cdk_stream_tmp_from_mem( data, dlen );
if( !inp )
@@ -1436,7 +1436,7 @@ gnutls_openpgp_recv_key(const char *host, short port, uint32 keyid,
size_t nbytes = 0, n = 0;
if ( !host || !key )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
if( !port )
port = 11371; /* standard service port */
@@ -1534,7 +1534,7 @@ _gnutls_openpgp_request_key( gnutls_datum* ret,
int rc = 0;
if( !ret || !cred || !key_fpr )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
if( key_fpr_size != 16 && key_fpr_size != 20 )
return GNUTLS_E_HASH_FAILED; /* only MD5 and SHA1 are supported */
@@ -1590,7 +1590,7 @@ static int
xml_add_tag( gnutls_string *xmlkey, const char *tag, const char *val )
{
if( !xmlkey || !tag || !val )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
_gnutls_string_append_str( xmlkey, " <" );
_gnutls_string_append_str( xmlkey, tag );
@@ -1613,7 +1613,7 @@ xml_add_mpi2( gnutls_string *xmlkey, const uint8 *data, size_t count,
int rc = 0;
if( !xmlkey || !data || !tag )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
p = gnutls_calloc( 1, 2 * ( count + 3 ) );
if( !p ) {
@@ -1652,7 +1652,7 @@ xml_add_key_mpi( gnutls_string *xmlkey, cdkPKT_public_key *pk )
int rc = 0;
if( !xmlkey || !pk )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
_gnutls_string_append_str( xmlkey, s );
@@ -1694,7 +1694,7 @@ xml_add_key( gnutls_string *xmlkey, int ext, cdkPKT_public_key *pk, int sub )
int i = 0, rc = 0;
if( !xmlkey || !pk )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
s = sub? " <SUBKEY>\n" : " <MAINKEY>\n";
_gnutls_string_append_str( xmlkey, s );
@@ -1768,7 +1768,7 @@ xml_add_userid( gnutls_string *xmlkey, int ext,
int rc = 0;
if ( !xmlkey || !dn || !id )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
s = " <USERID>\n";
_gnutls_string_append_str( xmlkey, s );
@@ -1824,7 +1824,7 @@ xml_add_sig( gnutls_string *xmlkey, int ext, cdkPKT_signature *sig )
int rc = 0;
if( !xmlkey || !sig )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
s = " <SIGNATURE>\n";
_gnutls_string_append_str( xmlkey, s );
@@ -1910,7 +1910,7 @@ gnutls_openpgp_key_to_xml( const gnutls_datum *cert,
gnutls_string string_xml_key;
if( !cert || !xmlkey )
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
rc = datum_to_kbnode( cert, &knode );
if( rc )
diff --git a/libextra/gnutls_srp.c b/libextra/gnutls_srp.c
index b6d3439635..04df935cde 100644
--- a/libextra/gnutls_srp.c
+++ b/libextra/gnutls_srp.c
@@ -347,7 +347,7 @@ int gnutls_srp_set_client_credentials( gnutls_srp_client_credentials res, char *
if (username==NULL || password == NULL) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
res->username = gnutls_strdup( username);
@@ -421,7 +421,7 @@ int i;
if (password_file==NULL || password_conf_file==NULL) {
gnutls_assert();
- return GNUTLS_E_INVALID_PARAMETERS;
+ return GNUTLS_E_INVALID_REQUEST;
}
/* Check if the files can be opened */