summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2001-07-28 10:36:46 +0000
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2001-07-28 10:36:46 +0000
commit4945ad1a3eb49c1321cda580c7ed8eddc769e511 (patch)
tree110632ba180bf666262578ccf3d043f306488afc /lib
parentf5eee1a355387fe8885f7b1e13f0f8260ddb8162 (diff)
downloadgnutls-4945ad1a3eb49c1321cda580c7ed8eddc769e511.tar.gz
added some documentation. Bug fixes in CHANGECIPHER_SPEC packet.
Diffstat (limited to 'lib')
-rw-r--r--lib/gnutls.h.in10
-rw-r--r--lib/gnutls_errors.c2
-rw-r--r--lib/gnutls_errors_int.h1
-rw-r--r--lib/gnutls_global.c20
-rw-r--r--lib/gnutls_handshake.c3
-rw-r--r--lib/gnutls_int.h3
-rw-r--r--lib/gnutls_record.c8
-rw-r--r--lib/gnutls_sig_check.c10
8 files changed, 34 insertions, 23 deletions
diff --git a/lib/gnutls.h.in b/lib/gnutls.h.in
index 471bfc9973..761cb8f34f 100644
--- a/lib/gnutls.h.in
+++ b/lib/gnutls.h.in
@@ -234,8 +234,14 @@ int gnutls_set_x509_trust( X509PKI_CREDENTIALS res, char* CAFILE, char* CRLFILE)
int gnutls_global_init();
void gnutls_global_deinit();
-void gnutls_set_recv_func( ssize_t (*recv_func)(SOCKET, void*, size_t, int));
-void gnutls_set_send_func( ssize_t (*send_func)(SOCKET, const void*, size_t, int));
+typedef ssize_t (*RECV_FUNC)(SOCKET, void*, size_t,int);
+typedef ssize_t (*SEND_FUNC)(SOCKET, const void*, size_t,int);
+
+RECV_FUNC _gnutls_recv_func;
+SEND_FUNC _gnutls_send_func;
+
+void gnutls_global_set_send_func( SEND_FUNC send_func);
+void gnutls_global_set_recv_func( RECV_FUNC recv_func);
/* error codes appended here */
diff --git a/lib/gnutls_errors.c b/lib/gnutls_errors.c
index b8fae8fd43..65b3ea8480 100644
--- a/lib/gnutls_errors.c
+++ b/lib/gnutls_errors.c
@@ -32,6 +32,7 @@ struct gnutls_error_entry {
typedef struct gnutls_error_entry gnutls_error_entry;
static gnutls_error_entry error_algorithms[] = {
+ GNUTLS_ERROR_ENTRY( GNUTLS_E_SUCCESS, 0),
GNUTLS_ERROR_ENTRY( GNUTLS_E_MAC_FAILED, 1),
GNUTLS_ERROR_ENTRY( GNUTLS_E_UNKNOWN_CIPHER, 1),
GNUTLS_ERROR_ENTRY( GNUTLS_E_UNKNOWN_CIPHER_SUITE, 1),
@@ -103,6 +104,7 @@ static gnutls_error_entry error_algorithms[] = {
int gnutls_is_fatal_error(int error)
{
int ret = 0;
+
GNUTLS_ERROR_ALG_LOOP(ret = p->fatal);
return ret;
}
diff --git a/lib/gnutls_errors_int.h b/lib/gnutls_errors_int.h
index 01ddd5ce52..d186b2db61 100644
--- a/lib/gnutls_errors_int.h
+++ b/lib/gnutls_errors_int.h
@@ -1,3 +1,4 @@
+#define GNUTLS_E_SUCCESS 0
#define GNUTLS_E_MAC_FAILED -1
#define GNUTLS_E_UNKNOWN_CIPHER -2
#define GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM -3
diff --git a/lib/gnutls_global.c b/lib/gnutls_global.c
index f21a199152..1f83b8f459 100644
--- a/lib/gnutls_global.c
+++ b/lib/gnutls_global.c
@@ -30,8 +30,12 @@ extern const static_asn pkcs1_asn1_tab[];
extern const static_asn pkix_asn1_tab[];
static void* old_sig_handler;
-ssize_t (*_gnutls_recv_func)( SOCKET, void*, size_t, int);
-ssize_t (*_gnutls_send_func)( SOCKET,const void*, size_t, int);
+
+typedef ssize_t (*RECV_FUNC)(SOCKET, void*, size_t,int);
+typedef ssize_t (*SEND_FUNC)(SOCKET, const void*, size_t,int);
+
+RECV_FUNC _gnutls_recv_func;
+SEND_FUNC _gnutls_send_func;
static node_asn *PKIX1_ASN;
static node_asn *PKCS1_ASN;
@@ -45,8 +49,8 @@ node_asn* _gnutls_get_pkcs() {
}
/**
- * gnutls_set_recv_func - This function sets the recv() function
- * @(*recv_func): it's a recv(2) like function
+ * gnutls_global_set_recv_func - This function sets the recv() function
+ * @recv_func: it's a recv(2) like function
*
* This is the function were you set the recv() function gnutls
* is going to use. Normaly you may not use this function since
@@ -56,13 +60,13 @@ node_asn* _gnutls_get_pkcs() {
* called once and after gnutls_global_init().
*
**/
-void gnutls_set_recv_func( ssize_t (*recv_func)(SOCKET,void*,size_t,int)) {
+void gnutls_global_set_recv_func( RECV_FUNC recv_func) {
_gnutls_recv_func = recv_func;
}
/**
- * gnutls_set_send_func - This function sets the send() function
- * @(*send_func): it's a send(2) like function
+ * gnutls_global_set_send_func - This function sets the send() function
+ * @send_func: it's a send(2) like function
*
* This is the function were you set the send() function gnutls
* is going to use. Normaly you may not use this function since
@@ -71,7 +75,7 @@ void gnutls_set_recv_func( ssize_t (*recv_func)(SOCKET,void*,size_t,int)) {
* a front end to this function. This function should be
* called once and after gnutls_global_init().
**/
-void gnutls_set_send_func( ssize_t (*send_func)(SOCKET, const void*,size_t,int)) {
+void gnutls_global_set_send_func( SEND_FUNC send_func) {
_gnutls_send_func = send_func;
}
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c
index e46b4958bc..433aa4248c 100644
--- a/lib/gnutls_handshake.c
+++ b/lib/gnutls_handshake.c
@@ -1421,10 +1421,11 @@ static int _gnutls_recv_handshake_final(SOCKET cd, GNUTLS_STATE state,
int init)
{
int ret = 0;
+ char ch;
ret =
gnutls_recv_int(cd, state, GNUTLS_CHANGE_CIPHER_SPEC, -1,
- NULL, 0, 0);
+ &ch, 1, 0);
if (ret < 0) {
ERR("recv ChangeCipherSpec", ret);
gnutls_assert();
diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h
index 0cbe811de3..19a8bf04e9 100644
--- a/lib/gnutls_int.h
+++ b/lib/gnutls_int.h
@@ -31,8 +31,9 @@
#define BUFFERS_DEBUG
#define RECORD_DEBUG
#define HANDSHAKE_DEBUG
-#define DEBUG
*/
+#define DEBUG
+
#define SOCKET int
#define LIST ...
diff --git a/lib/gnutls_record.c b/lib/gnutls_record.c
index 82491ba7c6..c9fa9f01e2 100644
--- a/lib/gnutls_record.c
+++ b/lib/gnutls_record.c
@@ -562,7 +562,6 @@ ssize_t gnutls_recv_int(SOCKET cd, GNUTLS_STATE state, ContentType type, Handsha
if (state->gnutls_internals.valid_connection == VALID_FALSE || sizeofdata==0) {
return 0; /* EOF */
-/* return GNUTLS_E_INVALID_SESSION; */
}
/* in order for GNUTLS_E_AGAIN to be returned the socket
@@ -729,11 +728,14 @@ ssize_t gnutls_recv_int(SOCKET cd, GNUTLS_STATE state, ContentType type, Handsha
#endif
gnutls_free(ciphertext);
gnutls_free(tmpdata);
- if (tmplen!=1) {
+
+ if (tmplen!=sizeofdata) { /* sizeofdata should be 1 */
gnutls_assert();
return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;
}
- return 0;
+ memcpy( data, tmpdata, sizeofdata);
+
+ return tmplen;
}
#ifdef RECORD_DEBUG
diff --git a/lib/gnutls_sig_check.c b/lib/gnutls_sig_check.c
index de1b89e6c3..ec249bdfef 100644
--- a/lib/gnutls_sig_check.c
+++ b/lib/gnutls_sig_check.c
@@ -168,10 +168,6 @@ _gnutls_pkcs1_rsa_verify_sig( gnutls_datum* signature, gnutls_datum* text, MPI e
return ret;
}
-#ifdef DEBUG
-fprintf(stderr, "digest_size: %s\n", _gnutls_bin2hex(digest,digest_size));
-#endif
-
gnutls_free_datum( &decrypted);
if (digest_size != gnutls_hash_get_algo_len(hash)) {
@@ -182,9 +178,7 @@ fprintf(stderr, "digest_size: %s\n", _gnutls_bin2hex(digest,digest_size));
hd = gnutls_hash_init( hash);
gnutls_hash( hd, text->data, text->size);
gnutls_hash_deinit( hd, md);
-#ifdef DEBUG
- fprintf(stderr, "cmd: %s\n", _gnutls_bin2hex(md, 16));
-#endif
+
if (memcmp( md, digest, digest_size)!=0) {
gnutls_assert();
return GNUTLS_E_PK_SIGNATURE_FAILED;
@@ -216,7 +210,7 @@ gnutls_datum* tbs;
return GNUTLS_CERT_TRUSTED;
}
#ifdef DEBUG
-fprintf(stderr, "PK: %d\n", issuer->subject_pk_algorithm);
+ fprintf(stderr, "PK: %d\n", issuer->subject_pk_algorithm);
#endif
gnutls_assert();