ssl_set_dbg(ssl, pssl_debug, NULL);
ssl_set_bio(ssl, net_recv, fd, net_send, fd);
-#ifdef POLARSSL_API_V1
ssl_set_ciphersuites(ssl, ciphers);
-#else
- ssl_set_ciphers(ssl, ciphers);
-#endif
#ifdef POLARSSL_API_V1_2
ssl_set_session(ssl, ssn);
rc = ssl_handshake(ssl);
if (rc != 0) {
-#ifdef POLARSSL_API_V1
if (rc == POLARSSL_ERR_NET_WANT_READ || rc == POLARSSL_ERR_NET_WANT_WRITE) {
-#else
- if (rc == POLARSSL_ERR_NET_TRY_AGAIN) {
-#endif
return 0;
} else if (POLARSSL_ERR_X509_CERT_VERIFY_FAILED) { /* Allow this (selfsigned etc) */
return 0;
int rc;
rc = ssl_read(ssl, buf, len);
-#ifdef POLARSSL_API_V1
if (rc == POLARSSL_ERR_NET_WANT_READ)
-#else
- if (rc == POLARSSL_ERR_NET_TRY_AGAIN)
-#endif
return SSLI_ERROR_WANT_READ;
return rc;
}
int rc;
rc = ssl_write(ssl, buf, len);
-#ifdef POLARSSL_API_V1
if (rc == POLARSSL_ERR_NET_WANT_WRITE)
-#else
- if (rc == POLARSSL_ERR_NET_TRY_AGAIN)
-#endif
return SSLI_ERROR_WANT_WRITE;
return rc;
}
#include <polarssl/ssl.h>
#include <polarssl/version.h>
-#define POLARSSL_API_V1
+#if (POLARSSL_VERSION_MAJOR < 1)
+#error PolarSSL version 1.0.0 or later is required!
+#endif
+
#ifdef USE_POLARSSL_HAVEGE
#if (POLARSSL_VERSION_MINOR >= 1)
#define HAVEGE_RAND (havege_random)
#define SSLI_ERROR_WANT_READ -0x0F300 /* PolarSSL v0.x.x uses -0x0f00 -> --0x0f90, v1.x.x uses -0x7080 -> -0x7e80 */
#define SSLI_ERROR_WANT_WRITE -0x0F310
-#ifdef POLARSSL_API_V1
#define SSLI_ERROR_ZERO_RETURN 0
-#else
-#define SSLI_ERROR_ZERO_RETURN POLARSSL_ERR_NET_CONN_RESET
-#endif
#define SSLI_ERROR_CONNRESET POLARSSL_ERR_NET_CONN_RESET
#define SSLI_ERROR_SYSCALL POLARSSL_ERR_NET_RECV_FAILED