summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2014-03-14 14:20:59 +0100
committerFelix Fietkau <nbd@openwrt.org>2014-03-14 14:23:05 +0100
commit2263994fef00cd53642c0337e893fb2d1b35c081 (patch)
treedde2ba3ad7fca9c2734190d1bf7e50d46748ae87
parent1dc753d6438121ef4cc57b185ea340c082d362c6 (diff)
downloadustream-ssl-2263994fef00cd53642c0337e893fb2d1b35c081.tar.gz
polarssl: add support for version 1.3
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-rw-r--r--ustream-polarssl.c25
-rw-r--r--ustream-polarssl.h13
2 files changed, 35 insertions, 3 deletions
diff --git a/ustream-polarssl.c b/ustream-polarssl.c
index 2117189..10221d3 100644
--- a/ustream-polarssl.c
+++ b/ustream-polarssl.c
@@ -94,7 +94,11 @@ __hidden void * __ustream_ssl_context_new(bool server)
return NULL;
uctx->server = server;
+#ifdef USE_VERSION_1_3
+ pk_init(&uctx->key);
+#else
rsa_init(&uctx->key, RSA_PKCS_V15, 0);
+#endif
return uctx;
}
@@ -102,8 +106,14 @@ __hidden void * __ustream_ssl_context_new(bool server)
__hidden int __ustream_ssl_set_crt_file(void *ctx, const char *file)
{
struct ustream_polarssl_ctx *uctx = ctx;
+ int ret;
- if (x509parse_crtfile(&uctx->cert, file))
+#ifdef USE_VERSION_1_3
+ ret = x509_crt_parse_file(&uctx->cert, file);
+#else
+ ret = x509parse_crtfile(&uctx->cert, file);
+#endif
+ if (ret)
return -1;
return 0;
@@ -112,8 +122,14 @@ __hidden int __ustream_ssl_set_crt_file(void *ctx, const char *file)
__hidden int __ustream_ssl_set_key_file(void *ctx, const char *file)
{
struct ustream_polarssl_ctx *uctx = ctx;
+ int ret;
- if (x509parse_keyfile(&uctx->key, file, NULL))
+#ifdef USE_VERSION_1_3
+ ret = pk_parse_keyfile(&uctx->key, file, NULL);
+#else
+ ret = x509parse_keyfile(&uctx->key, file, NULL);
+#endif
+ if (ret)
return -1;
return 0;
@@ -123,8 +139,13 @@ __hidden void __ustream_ssl_context_free(void *ctx)
{
struct ustream_polarssl_ctx *uctx = ctx;
+#ifdef USE_VERSION_1_3
+ pk_free(&uctx->key);
+ x509_crt_free(&uctx->cert);
+#else
rsa_free(&uctx->key);
x509_free(&uctx->cert);
+#endif
free(ctx);
}
diff --git a/ustream-polarssl.h b/ustream-polarssl.h
index 86bdc36..e7445f7 100644
--- a/ustream-polarssl.h
+++ b/ustream-polarssl.h
@@ -25,10 +25,21 @@
#include <polarssl/x509.h>
#include <polarssl/rsa.h>
#include <polarssl/error.h>
+#include <polarssl/version.h>
+
+#if POLARSSL_VERSION_MAJOR > 1 || POLARSSL_VERSION_MINOR >= 3
+#define USE_VERSION_1_3
+#else
+#define x509_crt x509_cert
+#endif
struct ustream_polarssl_ctx {
- x509_cert cert;
+#ifdef USE_VERSION_1_3
+ pk_context key;
+#else
rsa_context key;
+#endif
+ x509_crt cert;
bool server;
};