X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fssl.h;h=ab02a2d6e407c4f54f1d9773162607f41fdbd34f;hb=402424de9b4c7c8e0f42433061c1a1e88013218f;hp=4efa24beb586caccb17a01e2a43086f7e835bc29;hpb=4b247cf9b38099d033bc4c887ac1901d16235bd6;p=umurmur.git diff --git a/src/ssl.h b/src/ssl.h index 4efa24b..ab02a2d 100644 --- a/src/ssl.h +++ b/src/ssl.h @@ -88,6 +88,40 @@ int urandom_bytes(void *ctx, unsigned char *dest, size_t len); typedef ssl_context SSL_handle_t; +#elif defined(USE_MBEDTLS) +#include + +#if !defined(MBEDTLS_VERSION_MAJOR) || (MBEDTLS_VERSION_MAJOR < 2) +#error mbedTLS version 2.0.0 or greater is required! +#endif + +#include +#if (MBEDTLS_VERSION_MINOR > 3) +#include +#else +#include +#endif + +#if defined(USE_MBEDTLS_HAVEGE) +#include + #define HAVEGE_RAND (havege_random) + #define RAND_bytes(_dst_, _size_) do { \ + mbedtls_havege_random(&hs, _dst_, _size_); \ + } while (0) +#else +#define RAND_bytes(_dst_, _size_) do { urandom_bytes(NULL, _dst_, _size_); } while (0) +int urandom_bytes(void *ctx, unsigned char *dest, size_t len); +#endif + +#define SSLI_ERROR_WANT_READ -0x0F300 /* mbedTLS v0.x.x uses -0x0f00 -> --0x0f90, v1.x.x uses -0x7080 -> -0x7e80 */ +#define SSLI_ERROR_WANT_WRITE -0x0F310 + +#define SSLI_ERROR_ZERO_RETURN 0 +#define SSLI_ERROR_CONNRESET MBEDTLS_ERR_NET_CONN_RESET +#define SSLI_ERROR_SYSCALL MBEDTLS_ERR_NET_RECV_FAILED + +typedef mbedtls_ssl_context SSL_handle_t; + #elif defined(USE_GNUTLS) #include