summaryrefslogtreecommitdiff
path: root/drivers/builtin_openssl2/crypto/bio
diff options
context:
space:
mode:
authormrezai <mhd.rezai@gmail.com>2016-04-15 19:03:35 +0430
committermrezai <mhd.rezai@gmail.com>2016-04-15 19:03:35 +0430
commite97922f22038e9049ed4c2db5b3736dfaa0edde3 (patch)
tree37e036a343e7482a387b7acd0a88509af78a69eb /drivers/builtin_openssl2/crypto/bio
parent880f4abda44a42532abb6f15999a90bc85f6264a (diff)
Update OpenSSL to version 1.0.2g
Diffstat (limited to 'drivers/builtin_openssl2/crypto/bio')
-rw-r--r--drivers/builtin_openssl2/crypto/bio/b_dump.c25
-rw-r--r--drivers/builtin_openssl2/crypto/bio/b_sock.c8
-rw-r--r--drivers/builtin_openssl2/crypto/bio/bio_err.c2
-rw-r--r--drivers/builtin_openssl2/crypto/bio/bss_acpt.c2
-rw-r--r--drivers/builtin_openssl2/crypto/bio/bss_conn.c2
-rw-r--r--drivers/builtin_openssl2/crypto/bio/bss_dgram.c84
-rw-r--r--drivers/builtin_openssl2/crypto/bio/bss_fd.c22
-rw-r--r--drivers/builtin_openssl2/crypto/bio/bss_mem.c6
8 files changed, 135 insertions, 16 deletions
diff --git a/drivers/builtin_openssl2/crypto/bio/b_dump.c b/drivers/builtin_openssl2/crypto/bio/b_dump.c
index 87c8162c5e..ccf0e287c4 100644
--- a/drivers/builtin_openssl2/crypto/bio/b_dump.c
+++ b/drivers/builtin_openssl2/crypto/bio/b_dump.c
@@ -181,3 +181,28 @@ int BIO_dump_indent(BIO *bp, const char *s, int len, int indent)
{
return BIO_dump_indent_cb(write_bio, bp, s, len, indent);
}
+
+int BIO_hex_string(BIO *out, int indent, int width, unsigned char *data,
+ int datalen)
+{
+ int i, j = 0;
+
+ if (datalen < 1)
+ return 1;
+
+ for (i = 0; i < datalen - 1; i++) {
+ if (i && !j)
+ BIO_printf(out, "%*s", indent, "");
+
+ BIO_printf(out, "%02X:", data[i]);
+
+ j = (j + 1) % width;
+ if (!j)
+ BIO_printf(out, "\n");
+ }
+
+ if (i && !j)
+ BIO_printf(out, "%*s", indent, "");
+ BIO_printf(out, "%02X", data[datalen - 1]);
+ return 1;
+}
diff --git a/drivers/builtin_openssl2/crypto/bio/b_sock.c b/drivers/builtin_openssl2/crypto/bio/b_sock.c
index bda882c40b..5bad0a2bad 100644
--- a/drivers/builtin_openssl2/crypto/bio/b_sock.c
+++ b/drivers/builtin_openssl2/crypto/bio/b_sock.c
@@ -225,13 +225,17 @@ int BIO_get_port(const char *str, unsigned short *port_ptr)
int BIO_sock_error(int sock)
{
int j, i;
- int size;
+ union {
+ size_t s;
+ int i;
+ } size;
# if defined(OPENSSL_SYS_BEOS_R5)
return 0;
# endif
- size = sizeof(int);
+ /* heuristic way to adapt for platforms that expect 64-bit optlen */
+ size.s = 0, size.i = sizeof(j);
/*
* Note: under Windows the third parameter is of type (char *) whereas
* under other systems it is (void *) if you don't have a cast it will
diff --git a/drivers/builtin_openssl2/crypto/bio/bio_err.c b/drivers/builtin_openssl2/crypto/bio/bio_err.c
index 6dd6162fc9..d9007aa3d3 100644
--- a/drivers/builtin_openssl2/crypto/bio/bio_err.c
+++ b/drivers/builtin_openssl2/crypto/bio/bio_err.c
@@ -1,6 +1,6 @@
/* crypto/bio/bio_err.c */
/* ====================================================================
- * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved.
+ * Copyright (c) 1999-2015 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/drivers/builtin_openssl2/crypto/bio/bss_acpt.c b/drivers/builtin_openssl2/crypto/bio/bss_acpt.c
index d08292c3e9..4a5e39bd38 100644
--- a/drivers/builtin_openssl2/crypto/bio/bss_acpt.c
+++ b/drivers/builtin_openssl2/crypto/bio/bss_acpt.c
@@ -445,7 +445,7 @@ static int acpt_puts(BIO *bp, const char *str)
return (ret);
}
-BIO *BIO_new_accept(char *str)
+BIO *BIO_new_accept(const char *str)
{
BIO *ret;
diff --git a/drivers/builtin_openssl2/crypto/bio/bss_conn.c b/drivers/builtin_openssl2/crypto/bio/bss_conn.c
index ed214ca6f1..7d15ad29dc 100644
--- a/drivers/builtin_openssl2/crypto/bio/bss_conn.c
+++ b/drivers/builtin_openssl2/crypto/bio/bss_conn.c
@@ -594,7 +594,7 @@ static int conn_puts(BIO *bp, const char *str)
return (ret);
}
-BIO *BIO_new_connect(char *str)
+BIO *BIO_new_connect(const char *str)
{
BIO *ret;
diff --git a/drivers/builtin_openssl2/crypto/bio/bss_dgram.c b/drivers/builtin_openssl2/crypto/bio/bss_dgram.c
index d12b83a8dc..bdd7bf88ea 100644
--- a/drivers/builtin_openssl2/crypto/bio/bss_dgram.c
+++ b/drivers/builtin_openssl2/crypto/bio/bss_dgram.c
@@ -65,7 +65,7 @@
#include <openssl/bio.h>
#ifndef OPENSSL_NO_DGRAM
-# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS)
+# if defined(OPENSSL_SYS_VMS)
# include <sys/timeb.h>
# endif
@@ -80,6 +80,10 @@
# define IP_MTU 14 /* linux is lame */
# endif
+# if OPENSSL_USE_IPV6 && !defined(IPPROTO_IPV6)
+# define IPPROTO_IPV6 41 /* windows is lame */
+# endif
+
# if defined(__FreeBSD__) && defined(IN6_IS_ADDR_V4MAPPED)
/* Standard definition causes type-punning problems. */
# undef IN6_IS_ADDR_V4MAPPED
@@ -496,8 +500,8 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
int *ip;
struct sockaddr *to = NULL;
bio_dgram_data *data = NULL;
-# if defined(OPENSSL_SYS_LINUX) && (defined(IP_MTU_DISCOVER) || defined(IP_MTU))
int sockopt_val = 0;
+# if defined(OPENSSL_SYS_LINUX) && (defined(IP_MTU_DISCOVER) || defined(IP_MTU))
socklen_t sockopt_len; /* assume that system supporting IP_MTU is
* modern enough to define socklen_t */
socklen_t addr_len;
@@ -880,6 +884,61 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = 0;
break;
# endif
+ case BIO_CTRL_DGRAM_SET_DONT_FRAG:
+ sockopt_val = num ? 1 : 0;
+
+ switch (data->peer.sa.sa_family) {
+ case AF_INET:
+# if defined(IP_DONTFRAG)
+ if ((ret = setsockopt(b->num, IPPROTO_IP, IP_DONTFRAG,
+ &sockopt_val, sizeof(sockopt_val))) < 0) {
+ perror("setsockopt");
+ ret = -1;
+ }
+# elif defined(OPENSSL_SYS_LINUX) && defined(IP_MTU_DISCOVER) && defined (IP_PMTUDISC_PROBE)
+ if ((sockopt_val = num ? IP_PMTUDISC_PROBE : IP_PMTUDISC_DONT),
+ (ret = setsockopt(b->num, IPPROTO_IP, IP_MTU_DISCOVER,
+ &sockopt_val, sizeof(sockopt_val))) < 0) {
+ perror("setsockopt");
+ ret = -1;
+ }
+# elif defined(OPENSSL_SYS_WINDOWS) && defined(IP_DONTFRAGMENT)
+ if ((ret = setsockopt(b->num, IPPROTO_IP, IP_DONTFRAGMENT,
+ (const char *)&sockopt_val,
+ sizeof(sockopt_val))) < 0) {
+ perror("setsockopt");
+ ret = -1;
+ }
+# else
+ ret = -1;
+# endif
+ break;
+# if OPENSSL_USE_IPV6
+ case AF_INET6:
+# if defined(IPV6_DONTFRAG)
+ if ((ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_DONTFRAG,
+ (const void *)&sockopt_val,
+ sizeof(sockopt_val))) < 0) {
+ perror("setsockopt");
+ ret = -1;
+ }
+# elif defined(OPENSSL_SYS_LINUX) && defined(IPV6_MTUDISCOVER)
+ if ((sockopt_val = num ? IP_PMTUDISC_PROBE : IP_PMTUDISC_DONT),
+ (ret = setsockopt(b->num, IPPROTO_IPV6, IPV6_MTU_DISCOVER,
+ &sockopt_val, sizeof(sockopt_val))) < 0) {
+ perror("setsockopt");
+ ret = -1;
+ }
+# else
+ ret = -1;
+# endif
+ break;
+# endif
+ default:
+ ret = -1;
+ break;
+ }
+ break;
case BIO_CTRL_DGRAM_GET_MTU_OVERHEAD:
ret = dgram_get_mtu_overhead(data);
break;
@@ -1993,11 +2052,22 @@ int BIO_dgram_non_fatal_error(int err)
static void get_current_time(struct timeval *t)
{
-# ifdef OPENSSL_SYS_WIN32
- struct _timeb tb;
- _ftime(&tb);
- t->tv_sec = (long)tb.time;
- t->tv_usec = (long)tb.millitm * 1000;
+# if defined(_WIN32)
+ SYSTEMTIME st;
+ union {
+ unsigned __int64 ul;
+ FILETIME ft;
+ } now;
+
+ GetSystemTime(&st);
+ SystemTimeToFileTime(&st, &now.ft);
+# ifdef __MINGW32__
+ now.ul -= 116444736000000000ULL;
+# else
+ now.ul -= 116444736000000000UI64; /* re-bias to 1/1/1970 */
+# endif
+ t->tv_sec = (long)(now.ul / 10000000);
+ t->tv_usec = ((int)(now.ul % 10000000)) / 10;
# elif defined(OPENSSL_SYS_VMS)
struct timeb tb;
ftime(&tb);
diff --git a/drivers/builtin_openssl2/crypto/bio/bss_fd.c b/drivers/builtin_openssl2/crypto/bio/bss_fd.c
index ccef578154..5f4e34481b 100644
--- a/drivers/builtin_openssl2/crypto/bio/bss_fd.c
+++ b/drivers/builtin_openssl2/crypto/bio/bss_fd.c
@@ -63,9 +63,27 @@
#if defined(OPENSSL_NO_POSIX_IO)
/*
- * One can argue that one should implement dummy placeholder for
- * BIO_s_fd here...
+ * Dummy placeholder for BIO_s_fd...
*/
+BIO *BIO_new_fd(int fd, int close_flag)
+{
+ return NULL;
+}
+
+int BIO_fd_non_fatal_error(int err)
+{
+ return 0;
+}
+
+int BIO_fd_should_retry(int i)
+{
+ return 0;
+}
+
+BIO_METHOD *BIO_s_fd(void)
+{
+ return NULL;
+}
#else
/*
* As for unconditional usage of "UPLINK" interface in this module.
diff --git a/drivers/builtin_openssl2/crypto/bio/bss_mem.c b/drivers/builtin_openssl2/crypto/bio/bss_mem.c
index d190765dc2..b0394a960d 100644
--- a/drivers/builtin_openssl2/crypto/bio/bss_mem.c
+++ b/drivers/builtin_openssl2/crypto/bio/bss_mem.c
@@ -91,7 +91,8 @@ BIO_METHOD *BIO_s_mem(void)
return (&mem_method);
}
-BIO *BIO_new_mem_buf(void *buf, int len)
+
+BIO *BIO_new_mem_buf(const void *buf, int len)
{
BIO *ret;
BUF_MEM *b;
@@ -105,7 +106,8 @@ BIO *BIO_new_mem_buf(void *buf, int len)
if (!(ret = BIO_new(BIO_s_mem())))
return NULL;
b = (BUF_MEM *)ret->ptr;
- b->data = buf;
+ /* Cast away const and trust in the MEM_RDONLY flag. */
+ b->data = (void *)buf;
b->length = sz;
b->max = sz;
ret->flags |= BIO_FLAGS_MEM_RDONLY;