- Changed behaviour of net_recv(), ssl_fetch_input() and ssl_read(). net_recv() now returns 0 on EOF instead of POLARSSL_ERR_NET_CONN_RESET. ssl_fetch_input() returns POLARSSL_ERR_SSL_CONN_EOF on an EOF from its f_recv() function. ssl_read() returns 0 if a POLARSSL_ERR_SSL_CONN_EOF is received after the handshake.
- Network functions now return POLARSSL_ERR_NET_WANT_READ or POLARSSL_ERR_NET_WANT_WRITE instead of the ambiguous POLARSSL_ERR_NET_TRY_AGAIN
diff --git a/include/polarssl/error.h b/include/polarssl/error.h
index b9a73af..8a3f304 100644
--- a/include/polarssl/error.h
+++ b/include/polarssl/error.h
@@ -56,7 +56,7 @@
* XTEA 1 0x0028-0x0028
* PADLOCK 1 0x0030-0x0030
* DES 1 0x0032-0x0032
- * NET 10 0x0040-0x0052
+ * NET 11 0x0040-0x0054
*
* High-level module nr (3 bits - 0x1...-0x8...)
* Name ID Nr of Errors
diff --git a/include/polarssl/net.h b/include/polarssl/net.h
index d828a3e..ee23180 100644
--- a/include/polarssl/net.h
+++ b/include/polarssl/net.h
@@ -38,7 +38,8 @@
#define POLARSSL_ERR_NET_RECV_FAILED -0x004C /**< Reading information from the socket failed. */
#define POLARSSL_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */
#define POLARSSL_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */
-#define POLARSSL_ERR_NET_TRY_AGAIN -0x0052 /**< Connection was busy, try again. */
+#define POLARSSL_ERR_NET_WANT_READ -0x0052 /**< Connection requires a read call. */
+#define POLARSSL_ERR_NET_WANT_WRITE -0x0054 /**< Connection requires a write call. */
#ifdef __cplusplus
extern "C" {
@@ -123,7 +124,7 @@
* \param len Maximum length of the buffer
*
* \return This function returns the number of bytes received,
- * or a non-zero error code; POLARSSL_ERR_NET_TRY_AGAIN
+ * or a non-zero error code; POLARSSL_ERR_NET_WANT_READ
* indicates read() is blocking.
*/
int net_recv( void *ctx, unsigned char *buf, size_t len );
@@ -137,7 +138,7 @@
* \param len The length of the buffer
*
* \return This function returns the number of bytes sent,
- * or a non-zero error code; POLARSSL_ERR_NET_TRY_AGAIN
+ * or a non-zero error code; POLARSSL_ERR_NET_WANT_WRITE
* indicates write() is blocking.
*/
int net_send( void *ctx, unsigned char *buf, size_t len );
diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h
index af9ec11..1108b8b 100644
--- a/include/polarssl/ssl.h
+++ b/include/polarssl/ssl.h
@@ -52,7 +52,7 @@
#define POLARSSL_ERR_SSL_BAD_INPUT_DATA -0x7100 /**< Bad input parameters to function. */
#define POLARSSL_ERR_SSL_INVALID_MAC -0x7180 /**< Verification of the message MAC failed. */
#define POLARSSL_ERR_SSL_INVALID_RECORD -0x7200 /**< An invalid SSL record was received. */
-#define POLARSSL_ERR_SSL_INVALID_MODULUS_SIZE -0x7280 /**< An invalid modulus size was received. */
+#define POLARSSL_ERR_SSL_CONN_EOF -0x7280 /**< The connection indicated an EOF. */
#define POLARSSL_ERR_SSL_UNKNOWN_CIPHER -0x7300 /**< An unknown cipher was received. */
#define POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN -0x7380 /**< The server has no ciphersuites in common with the client. */
#define POLARSSL_ERR_SSL_NO_SESSION_FOUND -0x7400 /**< No session to recover was found. */
@@ -596,8 +596,8 @@
*
* \param ssl SSL context
*
- * \return 0 if successful, POLARSSL_ERR_NET_TRY_AGAIN,
- * or a specific SSL error code.
+ * \return 0 if successful, POLARSSL_ERR_NET_WANT_READ,
+ * POLARSSL_ERR_NET_WANT_WRITE, or a specific SSL error code.
*/
int ssl_handshake( ssl_context *ssl );
@@ -608,7 +608,7 @@
* \param buf buffer that will hold the data
* \param len how many bytes must be read
*
- * \return This function returns the number of bytes read,
+ * \return This function returns the number of bytes read, 0 for EOF,
* or a negative error code.
*/
int ssl_read( ssl_context *ssl, unsigned char *buf, size_t len );
@@ -623,7 +623,7 @@
* \return This function returns the number of bytes written,
* or a negative error code.
*
- * \note When this function returns POLARSSL_ERR_NET_TRY_AGAIN,
+ * \note When this function returns POLARSSL_ERR_NET_WANT_WRITE,
* it must be called later with the *same* arguments,
* until it returns a positive value.
*/
@@ -653,6 +653,10 @@
void ssl_calc_verify( ssl_context *ssl, unsigned char hash[36] );
int ssl_read_record( ssl_context *ssl );
+/**
+ * \return 0 if successful, POLARSSL_ERR_SSL_CONN_EOF on EOF or
+ * another negative error code.
+ */
int ssl_fetch_input( ssl_context *ssl, size_t nb_want );
int ssl_write_record( ssl_context *ssl );