use libm with cyassl
[project/ustream-ssl.git] / ustream-ssl.c
index 471e29c..adc88b4 100644 (file)
@@ -1,3 +1,21 @@
+/*
+ * ustream-ssl - library for SSL over ustream
+ *
+ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
 #include <errno.h>
 
 #include <openssl/ssl.h>
@@ -182,12 +200,8 @@ static void ustream_ssl_stream_init(struct ustream_ssl *us)
 
 static void *_ustream_ssl_context_new(bool server)
 {
-#ifdef CYASSL_OPENSSL_H_
-       SSL_METHOD *m;
-#else
-       const SSL_METHOD *m;
-#endif
        SSL_CTX *c;
+       const void *m;
 
        ssl_init();
 
@@ -203,7 +217,7 @@ static void *_ustream_ssl_context_new(bool server)
                m = TLSv1_client_method();
 #endif
 
-       c = SSL_CTX_new(m);
+       c = SSL_CTX_new((void *) m);
        if (!c)
                return NULL;
 
@@ -221,7 +235,10 @@ static int _ustream_ssl_context_set_crt_file(void *ctx, const char *file)
        if (ret < 1)
                ret = SSL_CTX_use_certificate_file(ctx, file, SSL_FILETYPE_ASN1);
 
-       return ret;
+       if (ret < 1)
+               return -1;
+
+       return 0;
 }
 
 static int _ustream_ssl_context_set_key_file(void *ctx, const char *file)
@@ -232,7 +249,10 @@ static int _ustream_ssl_context_set_key_file(void *ctx, const char *file)
        if (ret < 1)
                ret = SSL_CTX_use_PrivateKey_file(ctx, file, SSL_FILETYPE_ASN1);
 
-       return ret;
+       if (ret < 1)
+               return -1;
+
+       return 0;
 }
 
 static void _ustream_ssl_context_free(void *ctx)