diff options
Diffstat (limited to 'thirdparty')
-rw-r--r-- | thirdparty/README.md | 26 | ||||
-rw-r--r-- | thirdparty/assimp/include/assimp/types.h | 9 | ||||
-rw-r--r-- | thirdparty/mbedtls/include/godot_core_mbedtls_config.h | 13 | ||||
-rw-r--r-- | thirdparty/mbedtls/library/godot_core_mbedtls_platform.c | 18 | ||||
-rw-r--r-- | thirdparty/miniupnpc/LICENSE | 4 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc.def | 45 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc.h | 153 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/codelength.h (renamed from thirdparty/miniupnpc/codelength.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/connecthostport.c (renamed from thirdparty/miniupnpc/connecthostport.c) | 62 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/connecthostport.h (renamed from thirdparty/miniupnpc/connecthostport.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/igd_desc_parse.c (renamed from thirdparty/miniupnpc/igd_desc_parse.c) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/igd_desc_parse.h (renamed from thirdparty/miniupnpc/igd_desc_parse.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/listdevices.c (renamed from thirdparty/miniupnpc/listdevices.c) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/minisoap.c (renamed from thirdparty/miniupnpc/minisoap.c) | 9 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/minisoap.h (renamed from thirdparty/miniupnpc/minisoap.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/minissdpc.c (renamed from thirdparty/miniupnpc/minissdpc.c) | 101 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/minissdpc.h (renamed from thirdparty/miniupnpc/minissdpc.h) | 6 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/miniupnpc.c (renamed from thirdparty/miniupnpc/miniupnpc.c) | 37 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/miniupnpc_declspec.h (renamed from thirdparty/miniupnpc/miniupnpc_declspec.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/miniupnpc_socketdef.h (renamed from thirdparty/miniupnpc/miniupnpc_socketdef.h) | 7 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/miniupnpcmodule.c (renamed from thirdparty/miniupnpc/miniupnpcmodule.c) | 34 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/miniupnpcstrings.h (renamed from thirdparty/miniupnpc/miniupnpcstrings.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/miniupnpctypes.h (renamed from thirdparty/miniupnpc/miniupnpctypes.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/miniwget.c (renamed from thirdparty/miniupnpc/miniwget.c) | 9 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/miniwget_private.h (renamed from thirdparty/miniupnpc/miniwget_private.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/minixml.c (renamed from thirdparty/miniupnpc/minixml.c) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/minixml.h (renamed from thirdparty/miniupnpc/minixml.h) | 2 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/minixmlvalid.c (renamed from thirdparty/miniupnpc/minixmlvalid.c) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/portlistingparse.c (renamed from thirdparty/miniupnpc/portlistingparse.c) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/portlistingparse.h (renamed from thirdparty/miniupnpc/portlistingparse.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/receivedata.c (renamed from thirdparty/miniupnpc/receivedata.c) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/receivedata.h (renamed from thirdparty/miniupnpc/receivedata.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/upnpc.c (renamed from thirdparty/miniupnpc/upnpc.c) | 4 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/upnpcommands.c (renamed from thirdparty/miniupnpc/upnpcommands.c) | 63 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/upnpcommands.h | 6 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/upnpdev.c (renamed from thirdparty/miniupnpc/upnpdev.c) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/upnpdev.h (renamed from thirdparty/miniupnpc/upnpdev.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/upnperrors.c (renamed from thirdparty/miniupnpc/upnperrors.c) | 8 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/upnperrors.h (renamed from thirdparty/miniupnpc/upnperrors.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/upnpreplyparse.c (renamed from thirdparty/miniupnpc/upnpreplyparse.c) | 5 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/upnpreplyparse.h (renamed from thirdparty/miniupnpc/upnpreplyparse.h) | 0 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniwget.h | 27 | ||||
-rw-r--r-- | thirdparty/miniupnpc/upnpcommands.h | 348 | ||||
-rw-r--r-- | thirdparty/misc/aes256.cpp | 397 | ||||
-rw-r--r-- | thirdparty/misc/aes256.h | 46 | ||||
-rw-r--r-- | thirdparty/misc/base64.c | 118 | ||||
-rw-r--r-- | thirdparty/misc/base64.h | 18 | ||||
-rw-r--r-- | thirdparty/misc/md5.cpp | 267 | ||||
-rw-r--r-- | thirdparty/misc/md5.h | 61 | ||||
-rw-r--r-- | thirdparty/misc/sha256.c | 245 | ||||
-rw-r--r-- | thirdparty/misc/sha256.h | 50 |
51 files changed, 236 insertions, 1962 deletions
diff --git a/thirdparty/README.md b/thirdparty/README.md index 3e1e8f9734..9738716221 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -303,14 +303,20 @@ File extracted from upstream release tarball `mbedtls-2.16.0-apache.tgz`: - Applied the patch in `thirdparty/mbedtls/padlock.diff`. This disables VIA padlock support which defines a symbol `unsupported` which clashes with a symbol in libwebsockets. +- Added 2 files `godot_core_mbedtls_platform.{c,h}` providing configuration + for light bundling with core. ## miniupnpc - Upstream: https://github.com/miniupnp/miniupnp/tree/master/miniupnpc -- Version: git (25615e0, 2018) +- Version: git (3cf6efa, 2019) - License: BSD-3-Clause +Extract only the `miniupnpc` folder inside `thirdparty/miniupnpc`. +Exclude all non `.c` and `.h` files, plus all files beginning with `test` +`minihttptestserver.c` and `wingenminiupnpcstrings.c`. + The only modified file is miniupnpcstrings.h, which was created for Godot (it is usually autogenerated by cmake). @@ -336,15 +342,7 @@ Collection of single-file libraries used in Godot components. ### core -- `aes256.{cpp,h}` - * Upstream: http://www.literatecode.com/aes256 - * Version: latest, as of April 2017 - * License: ISC -- `base64.{c,h}` - * Upstream: http://episec.com/people/edelkind/c.html - * Version: latest, as of April 2017 - * License: Public Domain - - `clipper.{cpp,hpp}` +- `clipper.{cpp,hpp}` * Upstream: https://sourceforge.net/projects/polyclipping * Version: 6.4.2 + Godot changes (added optional exceptions handling) * License: BSL-1.0 @@ -356,10 +354,6 @@ Collection of single-file libraries used in Godot components. * Upstream: https://github.com/brunexgeek/hqx * Version: TBD, file structure differs * License: Apache 2.0 -- `md5.{cpp,h}` - * Upstream: http://www.efgh.com/software/md5.htm - * Version: TBD, might not be latest from above URL - * License: RSA Message-Digest License - `open-simplex-noise.{c,h}` * Upstream: https://github.com/smcameron/open-simplex-noise-in-c * Version: git (0d555e7, 2015) @@ -368,10 +362,6 @@ Collection of single-file libraries used in Godot components. * Upstream: http://www.pcg-random.org * Version: minimal C implementation, http://www.pcg-random.org/download.html * License: Apache 2.0 -- `sha256.{c,h}` - * Upstream: https://github.com/ilvn/SHA256 - * Version: git (35ff823, 2015) - * License: ISC - `smaz.{c,h}` * Upstream: https://github.com/antirez/smaz * Version: git (150e125, 2009) diff --git a/thirdparty/assimp/include/assimp/types.h b/thirdparty/assimp/include/assimp/types.h index 748e4851f3..331b8cd03f 100644 --- a/thirdparty/assimp/include/assimp/types.h +++ b/thirdparty/assimp/include/assimp/types.h @@ -161,7 +161,14 @@ struct aiColor3D explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {} aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {} - /** Component-wise comparison */ + aiColor3D &operator=(const aiColor3D &o) { + r = o.r; + g = o.g; + b = o.b; + return *this; + } + + /** Component-wise comparison */ // TODO: add epsilon? bool operator == (const aiColor3D& other) const {return r == other.r && g == other.g && b == other.b;} diff --git a/thirdparty/mbedtls/include/godot_core_mbedtls_config.h b/thirdparty/mbedtls/include/godot_core_mbedtls_config.h new file mode 100644 index 0000000000..0e90a98886 --- /dev/null +++ b/thirdparty/mbedtls/include/godot_core_mbedtls_config.h @@ -0,0 +1,13 @@ +// For AES +#define MBEDTLS_CIPHER_MODE_CBC +#define MBEDTLS_CIPHER_MODE_CFB +#define MBEDTLS_CIPHER_MODE_CTR +#define MBEDTLS_CIPHER_MODE_OFB +#define MBEDTLS_CIPHER_MODE_XTS + +#define MBEDTLS_AES_C +#define MBEDTLS_BASE64_C +#define MBEDTLS_MD5_C +#define MBEDTLS_SHA1_C +#define MBEDTLS_SHA256_C +#define MBEDTLS_PLATFORM_ZEROIZE_ALT diff --git a/thirdparty/mbedtls/library/godot_core_mbedtls_platform.c b/thirdparty/mbedtls/library/godot_core_mbedtls_platform.c new file mode 100644 index 0000000000..9018726072 --- /dev/null +++ b/thirdparty/mbedtls/library/godot_core_mbedtls_platform.c @@ -0,0 +1,18 @@ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include <stdio.h> +#include <string.h> +#include <stddef.h> + +#ifdef MBEDTLS_PLATFORM_ZEROIZE_ALT +static void *(*const volatile memset_func)(void *, int, size_t) = memset; + +void mbedtls_platform_zeroize(void *buf, size_t len) { + memset_func( buf, 0, len ); +} +#endif + diff --git a/thirdparty/miniupnpc/LICENSE b/thirdparty/miniupnpc/LICENSE index 0816733704..39e0345f8a 100644 --- a/thirdparty/miniupnpc/LICENSE +++ b/thirdparty/miniupnpc/LICENSE @@ -1,5 +1,5 @@ -MiniUPnPc -Copyright (c) 2005-2016, Thomas BERNARD +MiniUPnP Project +Copyright (c) 2005-2019, Thomas BERNARD All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/thirdparty/miniupnpc/miniupnpc.def b/thirdparty/miniupnpc/miniupnpc.def deleted file mode 100644 index 60e0bbe423..0000000000 --- a/thirdparty/miniupnpc/miniupnpc.def +++ /dev/null @@ -1,45 +0,0 @@ -LIBRARY -; miniupnpc library - miniupnpc - -EXPORTS -; miniupnpc - upnpDiscover - freeUPNPDevlist - parserootdesc - UPNP_GetValidIGD - UPNP_GetIGDFromUrl - GetUPNPUrls - FreeUPNPUrls -; miniwget - miniwget - miniwget_getaddr -; upnpcommands - UPNP_GetTotalBytesSent - UPNP_GetTotalBytesReceived - UPNP_GetTotalPacketsSent - UPNP_GetTotalPacketsReceived - UPNP_GetStatusInfo - UPNP_GetConnectionTypeInfo - UPNP_GetExternalIPAddress - UPNP_GetLinkLayerMaxBitRates - UPNP_AddPortMapping - UPNP_AddAnyPortMapping - UPNP_DeletePortMapping - UPNP_DeletePortMappingRange - UPNP_GetPortMappingNumberOfEntries - UPNP_GetSpecificPortMappingEntry - UPNP_GetGenericPortMappingEntry - UPNP_GetListOfPortMappings - UPNP_AddPinhole - UPNP_CheckPinholeWorking - UPNP_UpdatePinhole - UPNP_GetPinholePackets - UPNP_DeletePinhole - UPNP_GetFirewallStatus - UPNP_GetOutboundPinholeTimeout -; upnperrors - strupnperror -; portlistingparse - ParsePortListing - FreePortListing diff --git a/thirdparty/miniupnpc/miniupnpc.h b/thirdparty/miniupnpc/miniupnpc.h deleted file mode 100644 index 8ddc282bd1..0000000000 --- a/thirdparty/miniupnpc/miniupnpc.h +++ /dev/null @@ -1,153 +0,0 @@ -/* $Id: miniupnpc.h,v 1.53 2018/05/07 11:05:16 nanard Exp $ */ -/* vim: tabstop=4 shiftwidth=4 noexpandtab - * Project: miniupnp - * http://miniupnp.free.fr/ - * Author: Thomas Bernard - * Copyright (c) 2005-2018 Thomas Bernard - * This software is subjects to the conditions detailed - * in the LICENCE file provided within this distribution */ -#ifndef MINIUPNPC_H_INCLUDED -#define MINIUPNPC_H_INCLUDED - -#include "miniupnpc_declspec.h" -#include "igd_desc_parse.h" -#include "upnpdev.h" - -/* error codes : */ -#define UPNPDISCOVER_SUCCESS (0) -#define UPNPDISCOVER_UNKNOWN_ERROR (-1) -#define UPNPDISCOVER_SOCKET_ERROR (-101) -#define UPNPDISCOVER_MEMORY_ERROR (-102) - -/* versions : */ -#define MINIUPNPC_VERSION "2.1" -#define MINIUPNPC_API_VERSION 17 - -/* Source port: - Using "1" as an alias for 1900 for backwards compatibility - (presuming one would have used that for the "sameport" parameter) */ -#define UPNP_LOCAL_PORT_ANY 0 -#define UPNP_LOCAL_PORT_SAME 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* Structures definitions : */ -struct UPNParg { const char * elt; const char * val; }; - -char * -simpleUPnPcommand(int, const char *, const char *, - const char *, struct UPNParg *, - int *); - -/* upnpDiscover() - * discover UPnP devices on the network. - * The discovered devices are returned as a chained list. - * It is up to the caller to free the list with freeUPNPDevlist(). - * delay (in millisecond) is the maximum time for waiting any device - * response. - * If available, device list will be obtained from MiniSSDPd. - * Default path for minissdpd socket will be used if minissdpdsock argument - * is NULL. - * If multicastif is not NULL, it will be used instead of the default - * multicast interface for sending SSDP discover packets. - * If localport is set to UPNP_LOCAL_PORT_SAME(1) SSDP packets will be sent - * from the source port 1900 (same as destination port), if set to - * UPNP_LOCAL_PORT_ANY(0) system assign a source port, any other value will - * be attempted as the source port. - * "searchalltypes" parameter is useful when searching several types, - * if 0, the discovery will stop with the first type returning results. - * TTL should default to 2. */ -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscover(int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error); - -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscoverAll(int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error); - -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscoverDevice(const char * device, int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error); - -MINIUPNP_LIBSPEC struct UPNPDev * -upnpDiscoverDevices(const char * const deviceTypes[], - int delay, const char * multicastif, - const char * minissdpdsock, int localport, - int ipv6, unsigned char ttl, - int * error, - int searchalltypes); - -/* parserootdesc() : - * parse root XML description of a UPnP device and fill the IGDdatas - * structure. */ -MINIUPNP_LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *); - -/* structure used to get fast access to urls - * controlURL: controlURL of the WANIPConnection - * ipcondescURL: url of the description of the WANIPConnection - * controlURL_CIF: controlURL of the WANCommonInterfaceConfig - * controlURL_6FC: controlURL of the WANIPv6FirewallControl - */ -struct UPNPUrls { - char * controlURL; - char * ipcondescURL; - char * controlURL_CIF; - char * controlURL_6FC; - char * rootdescURL; -}; - -/* UPNP_GetValidIGD() : - * return values : - * 0 = NO IGD found - * 1 = A valid connected IGD has been found - * 2 = A valid IGD has been found but it reported as - * not connected - * 3 = an UPnP device has been found but was not recognized as an IGD - * - * In any non zero return case, the urls and data structures - * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to - * free allocated memory. - */ -MINIUPNP_LIBSPEC int -UPNP_GetValidIGD(struct UPNPDev * devlist, - struct UPNPUrls * urls, - struct IGDdatas * data, - char * lanaddr, int lanaddrlen); - -/* UPNP_GetIGDFromUrl() - * Used when skipping the discovery process. - * When succeding, urls, data, and lanaddr arguments are set. - * return value : - * 0 - Not ok - * 1 - OK */ -MINIUPNP_LIBSPEC int -UPNP_GetIGDFromUrl(const char * rootdescurl, - struct UPNPUrls * urls, - struct IGDdatas * data, - char * lanaddr, int lanaddrlen); - -MINIUPNP_LIBSPEC void -GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, - const char *, unsigned int); - -MINIUPNP_LIBSPEC void -FreeUPNPUrls(struct UPNPUrls *); - -/* return 0 or 1 */ -MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/thirdparty/miniupnpc/codelength.h b/thirdparty/miniupnpc/miniupnpc/codelength.h index ea0b005ffe..ea0b005ffe 100644 --- a/thirdparty/miniupnpc/codelength.h +++ b/thirdparty/miniupnpc/miniupnpc/codelength.h diff --git a/thirdparty/miniupnpc/connecthostport.c b/thirdparty/miniupnpc/miniupnpc/connecthostport.c index ea6e4e5943..a59dc82437 100644 --- a/thirdparty/miniupnpc/connecthostport.c +++ b/thirdparty/miniupnpc/miniupnpc/connecthostport.c @@ -1,8 +1,8 @@ -/* $Id: connecthostport.c,v 1.15 2015/10/09 16:26:19 nanard Exp $ */ +/* $Id: connecthostport.c,v 1.21 2019/04/23 12:11:08 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * Project : miniupnp * Author : Thomas Bernard - * Copyright (c) 2010-2018 Thomas Bernard + * Copyright (c) 2010-2019 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. */ @@ -41,13 +41,6 @@ #include <sys/select.h> #endif /* #else _WIN32 */ -/* definition of PRINT_SOCKET_ERROR */ -#ifdef _WIN32 -#define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError()); -#else -#define PRINT_SOCKET_ERROR(x) perror(x) -#endif - #if defined(__amigaos__) || defined(__amigaos4__) #define herror(A) printf("%s\n", A) #endif @@ -123,8 +116,22 @@ SOCKET connecthostport(const char * host, unsigned short port, int err; FD_ZERO(&wset); FD_SET(s, &wset); - if((n = select(s + 1, NULL, &wset, NULL, NULL)) == -1 && errno == EINTR) +#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT + timeout.tv_sec = 3; + timeout.tv_usec = 0; + n = select(s + 1, NULL, &wset, NULL, &timeout); +#else + n = select(s + 1, NULL, &wset, NULL, NULL); +#endif + if(n == -1 && errno == EINTR) continue; +#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT + if(n == 0) { + errno = ETIMEDOUT; + n = -1; + break; + } +#endif /*len = 0;*/ /*n = getpeername(s, NULL, &len);*/ len = sizeof(err); @@ -163,7 +170,7 @@ SOCKET connecthostport(const char * host, unsigned short port, for(i = 0, j = 1; host[j] && (host[j] != ']') && i < MAXHOSTNAMELEN; i++, j++) { tmp_host[i] = host[j]; - if(0 == memcmp(host+j, "%25", 3)) /* %25 is just url encoding for '%' */ + if(0 == strncmp(host+j, "%25", 3)) /* %25 is just url encoding for '%' */ j+=2; /* skip "25" */ } tmp_host[i] = '\0'; @@ -183,9 +190,11 @@ SOCKET connecthostport(const char * host, unsigned short port, #endif return INVALID_SOCKET; } - s = -1; + s = INVALID_SOCKET; for(p = ai; p; p = p->ai_next) { + if(!ISINVALID(s)) + closesocket(s); s = socket(p->ai_family, p->ai_socktype, p->ai_protocol); if(ISINVALID(s)) continue; @@ -208,7 +217,7 @@ SOCKET connecthostport(const char * host, unsigned short port, PRINT_SOCKET_ERROR("setsockopt"); } #endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ - n = connect(s, p->ai_addr, p->ai_addrlen); + n = connect(s, p->ai_addr, MSC_CAST_INT p->ai_addrlen); #ifdef MINIUPNPC_IGNORE_EINTR /* EINTR The system call was interrupted by a signal that was caught * EINPROGRESS The socket is nonblocking and the connection cannot @@ -220,8 +229,22 @@ SOCKET connecthostport(const char * host, unsigned short port, int err; FD_ZERO(&wset); FD_SET(s, &wset); - if((n = select(s + 1, NULL, &wset, NULL, NULL)) == -1 && errno == EINTR) +#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT + timeout.tv_sec = 3; + timeout.tv_usec = 0; + n = select(s + 1, NULL, &wset, NULL, &timeout); +#else + n = select(s + 1, NULL, &wset, NULL, NULL); +#endif + if(n == -1 && errno == EINTR) continue; +#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT + if(n == 0) { + errno = ETIMEDOUT; + n = -1; + break; + } +#endif /*len = 0;*/ /*n = getpeername(s, NULL, &len);*/ len = sizeof(err); @@ -237,15 +260,8 @@ SOCKET connecthostport(const char * host, unsigned short port, } } #endif /* #ifdef MINIUPNPC_IGNORE_EINTR */ - if(n < 0) - { - closesocket(s); - continue; - } - else - { + if(n >= 0) /* connect() was successful */ break; - } } freeaddrinfo(ai); if(ISINVALID(s)) @@ -256,9 +272,9 @@ SOCKET connecthostport(const char * host, unsigned short port, if(n < 0) { PRINT_SOCKET_ERROR("connect"); + closesocket(s); return INVALID_SOCKET; } #endif /* #ifdef USE_GETHOSTBYNAME */ return s; } - diff --git a/thirdparty/miniupnpc/connecthostport.h b/thirdparty/miniupnpc/miniupnpc/connecthostport.h index 701816b5b6..701816b5b6 100644 --- a/thirdparty/miniupnpc/connecthostport.h +++ b/thirdparty/miniupnpc/miniupnpc/connecthostport.h diff --git a/thirdparty/miniupnpc/igd_desc_parse.c b/thirdparty/miniupnpc/miniupnpc/igd_desc_parse.c index d2999ad011..d2999ad011 100644 --- a/thirdparty/miniupnpc/igd_desc_parse.c +++ b/thirdparty/miniupnpc/miniupnpc/igd_desc_parse.c diff --git a/thirdparty/miniupnpc/igd_desc_parse.h b/thirdparty/miniupnpc/miniupnpc/igd_desc_parse.h index 0de546b697..0de546b697 100644 --- a/thirdparty/miniupnpc/igd_desc_parse.h +++ b/thirdparty/miniupnpc/miniupnpc/igd_desc_parse.h diff --git a/thirdparty/miniupnpc/listdevices.c b/thirdparty/miniupnpc/miniupnpc/listdevices.c index bd9ba57efc..bd9ba57efc 100644 --- a/thirdparty/miniupnpc/listdevices.c +++ b/thirdparty/miniupnpc/miniupnpc/listdevices.c diff --git a/thirdparty/miniupnpc/minisoap.c b/thirdparty/miniupnpc/miniupnpc/minisoap.c index 520c9302e8..f92b36ce89 100644 --- a/thirdparty/miniupnpc/minisoap.c +++ b/thirdparty/miniupnpc/miniupnpc/minisoap.c @@ -25,12 +25,6 @@ /* only for malloc */ #include <stdlib.h> -#ifdef _WIN32 -#define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError()); -#else -#define PRINT_SOCKET_ERROR(x) perror(x) -#endif - /* httpWrite sends the headers and the body to the socket * and returns the number of bytes sent */ static int @@ -79,11 +73,10 @@ int soapPostSubmit(SOCKET fd, const char * body, const char * httpversion) { - int bodysize; char headerbuf[512]; int headerssize; char portstr[8]; - bodysize = (int)strlen(body); + int bodysize = (int)strlen(body); /* We are not using keep-alive HTTP connections. * HTTP/1.1 needs the header Connection: close to do that. * This is the default with HTTP/1.0 diff --git a/thirdparty/miniupnpc/minisoap.h b/thirdparty/miniupnpc/miniupnpc/minisoap.h index d6a45d03ba..d6a45d03ba 100644 --- a/thirdparty/miniupnpc/minisoap.h +++ b/thirdparty/miniupnpc/miniupnpc/minisoap.h diff --git a/thirdparty/miniupnpc/minissdpc.c b/thirdparty/miniupnpc/miniupnpc/minissdpc.c index 1d29b4ba5b..29f8110155 100644 --- a/thirdparty/miniupnpc/minissdpc.c +++ b/thirdparty/miniupnpc/miniupnpc/minissdpc.c @@ -1,9 +1,9 @@ -/* $Id: minissdpc.c,v 1.32 2016/10/07 09:04:36 nanard Exp $ */ +/* $Id: minissdpc.c,v 1.40 2019/04/23 12:12:55 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * Project : miniupnp * Web : http://miniupnp.free.fr/ * Author : Thomas BERNARD - * copyright (c) 2005-2018 Thomas Bernard + * copyright (c) 2005-2019 Thomas Bernard * This software is subjet to the conditions detailed in the * provided LICENCE file. */ /*#include <syslog.h>*/ @@ -381,6 +381,7 @@ free_tmp_and_return: * the last 4 arguments are filled during the parsing : * - location/locationsize : "location:" field of the SSDP reply packet * - st/stsize : "st:" field of the SSDP reply packet. + * - usn/usnsize : "usn:" filed of the SSDP reply packet * The strings are NOT null terminated */ static void parseMSEARCHReply(const char * reply, int size, @@ -418,17 +419,17 @@ parseMSEARCHReply(const char * reply, int size, putchar('\n');*/ /* skip the colon and white spaces */ do { b++; } while(reply[b]==' '); - if(0==strncasecmp(reply+a, "location", 8)) + if(0==strncasecmp(reply+a, "location:", 9)) { *location = reply+b; *locationsize = i-b; } - else if(0==strncasecmp(reply+a, "st", 2)) + else if(0==strncasecmp(reply+a, "st:", 3)) { *st = reply+b; *stsize = i-b; } - else if(0==strncasecmp(reply+a, "usn", 3)) + else if(0==strncasecmp(reply+a, "usn:", 4)) { *usn = reply+b; *usnsize = i-b; @@ -471,7 +472,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[], int searchalltypes) { struct UPNPDev * tmp; - struct UPNPDev * devlist = 0; + struct UPNPDev * devlist = NULL; unsigned int scope_id = 0; int opt = 1; static const char MSearchMsgFmt[] = @@ -491,7 +492,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[], struct sockaddr_storage sockudp_w; #else int rv; - struct addrinfo hints, *servinfo, *p; + struct addrinfo hints, *servinfo; #endif #ifdef _WIN32 unsigned long _ttl = (unsigned long)ttl; @@ -545,51 +546,42 @@ ssdpDiscoverDevices(const char * const deviceTypes[], destAddr.sin_addr.s_addr = inet_addr("223.255.255.255"); destAddr.sin_port = 0; if (GetBestInterfaceEx((struct sockaddr *)&destAddr, &ifbestidx) == NO_ERROR) { - DWORD dwSize = 0; - DWORD dwRetVal = 0; - unsigned int i = 0; - ULONG flags = GAA_FLAG_INCLUDE_PREFIX; - ULONG family = AF_INET; - LPVOID lpMsgBuf = NULL; + DWORD dwRetVal = NO_ERROR; PIP_ADAPTER_ADDRESSES pAddresses = NULL; - ULONG outBufLen = 0; - ULONG Iterations = 0; + ULONG outBufLen = 15360; + int Iterations; PIP_ADAPTER_ADDRESSES pCurrAddresses = NULL; PIP_ADAPTER_UNICAST_ADDRESS pUnicast = NULL; - PIP_ADAPTER_ANYCAST_ADDRESS pAnycast = NULL; - PIP_ADAPTER_MULTICAST_ADDRESS pMulticast = NULL; - IP_ADAPTER_DNS_SERVER_ADDRESS *pDnServer = NULL; - IP_ADAPTER_PREFIX *pPrefix = NULL; - outBufLen = 15360; - do { + for (Iterations = 0; Iterations < 3; Iterations++) { pAddresses = (IP_ADAPTER_ADDRESSES *) HeapAlloc(GetProcessHeap(), 0, outBufLen); if (pAddresses == NULL) { break; } - dwRetVal = GetAdaptersAddresses(family, flags, NULL, pAddresses, &outBufLen); + dwRetVal = GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX, NULL, pAddresses, &outBufLen); - if (dwRetVal == ERROR_BUFFER_OVERFLOW) { - HeapFree(GetProcessHeap(), 0, pAddresses); - pAddresses = NULL; - } else { + if (dwRetVal != ERROR_BUFFER_OVERFLOW) { break; } - Iterations++; - } while ((dwRetVal == ERROR_BUFFER_OVERFLOW) && (Iterations < 3)); + HeapFree(GetProcessHeap(), 0, pAddresses); + pAddresses = NULL; + } if (dwRetVal == NO_ERROR) { pCurrAddresses = pAddresses; while (pCurrAddresses) { #ifdef DEBUG + int i; + PIP_ADAPTER_MULTICAST_ADDRESS pMulticast = NULL; + PIP_ADAPTER_ANYCAST_ADDRESS pAnycast = NULL; + printf("\tIfIndex (IPv4 interface): %u\n", pCurrAddresses->IfIndex); printf("\tAdapter name: %s\n", pCurrAddresses->AdapterName); pUnicast = pCurrAddresses->FirstUnicastAddress; if (pUnicast != NULL) { for (i = 0; pUnicast != NULL; i++) { - IPAddr.S_un.S_addr = (u_long) pUnicast->Address; - printf("\tIP Address[%d]: \t%s\n", i, inet_ntoa(IPAddr) ); + printf("\tIP Address[%d]: \t%s\n", i, inet_ntoa(((PSOCKADDR_IN)pUnicast->Address.lpSockaddr)->sin_addr) ); pUnicast = pUnicast->Next; } printf("\tNumber of Unicast Addresses: %d\n", i); @@ -597,8 +589,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[], pAnycast = pCurrAddresses->FirstAnycastAddress; if (pAnycast) { for (i = 0; pAnycast != NULL; i++) { - IPAddr.S_un.S_addr = (u_long) pAnyCast->Address; - printf("\tAnycast Address[%d]: \t%s\n", i, inet_ntoa(IPAddr) ); + printf("\tAnycast Address[%d]: \t%s\n", i, inet_ntoa(((PSOCKADDR_IN)pAnycast->Address.lpSockaddr)->sin_addr) ); pAnycast = pAnycast->Next; } printf("\tNumber of Anycast Addresses: %d\n", i); @@ -606,8 +597,8 @@ ssdpDiscoverDevices(const char * const deviceTypes[], pMulticast = pCurrAddresses->FirstMulticastAddress; if (pMulticast) { for (i = 0; pMulticast != NULL; i++) { - IPAddr.S_un.S_addr = (u_long) pMultiCast->Address; - printf("\tMulticast Address[%d]: \t%s\n", i, inet_ntoa(IPAddr) ); + printf("\tMulticast Address[%d]: \t%s\n", i, inet_ntoa(((PSOCKADDR_IN)pMulticast->Address.lpSockaddr)->sin_addr) ); + pMulticast = pMulticast->Next; } } printf("\n"); @@ -647,7 +638,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[], if(error) *error = MINISSDPC_SOCKET_ERROR; PRINT_SOCKET_ERROR("setsockopt(SO_REUSEADDR,...)"); - return NULL; + goto error; } if(ipv6) { @@ -692,7 +683,11 @@ ssdpDiscoverDevices(const char * const deviceTypes[], #endif } else { struct in_addr mc_if; +#if defined(_WIN32) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + InetPtonA(AF_INET, multicastif, &mc_if); +#else mc_if.s_addr = inet_addr(multicastif); /* ex: 192.168.x.x */ +#endif if(mc_if.s_addr != INADDR_NONE) { ((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr; @@ -819,24 +814,26 @@ ssdpDiscoverDevices(const char * const deviceTypes[], fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); #endif break; - } - for(p = servinfo; p; p = p->ai_next) { - n = sendto(sudp, bufr, n, 0, p->ai_addr, p->ai_addrlen); - if (n < 0) { + } else { + struct addrinfo *p; + for(p = servinfo; p; p = p->ai_next) { + n = sendto(sudp, bufr, n, 0, p->ai_addr, MSC_CAST_INT p->ai_addrlen); + if (n < 0) { #ifdef DEBUG - char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; - if (getnameinfo(p->ai_addr, p->ai_addrlen, hbuf, sizeof(hbuf), sbuf, - sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0) { - fprintf(stderr, "host:%s port:%s\n", hbuf, sbuf); - } + char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; + if (getnameinfo(p->ai_addr, (socklen_t)p->ai_addrlen, hbuf, sizeof(hbuf), sbuf, + sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0) { + fprintf(stderr, "host:%s port:%s\n", hbuf, sbuf); + } #endif - PRINT_SOCKET_ERROR("sendto"); - continue; - } else { - sentok = 1; + PRINT_SOCKET_ERROR("sendto"); + continue; + } else { + sentok = 1; + } } + freeaddrinfo(servinfo); } - freeaddrinfo(servinfo); if(!sentok) { if(error) *error = MINISSDPC_SOCKET_ERROR; @@ -877,11 +874,11 @@ ssdpDiscoverDevices(const char * const deviceTypes[], stsize, st, usnsize, (usn?usn:""), urlsize, descURL); #endif /* DEBUG */ for(tmp=devlist; tmp; tmp = tmp->pNext) { - if(memcmp(tmp->descURL, descURL, urlsize) == 0 && + if(strncmp(tmp->descURL, descURL, urlsize) == 0 && tmp->descURL[urlsize] == '\0' && - memcmp(tmp->st, st, stsize) == 0 && + strncmp(tmp->st, st, stsize) == 0 && tmp->st[stsize] == '\0' && - (usnsize == 0 || memcmp(tmp->usn, usn, usnsize) == 0) && + (usnsize == 0 || strncmp(tmp->usn, usn, usnsize) == 0) && tmp->usn[usnsize] == '\0') break; } diff --git a/thirdparty/miniupnpc/minissdpc.h b/thirdparty/miniupnpc/miniupnpc/minissdpc.h index 167d897cb6..c99f929b9e 100644 --- a/thirdparty/miniupnpc/minissdpc.h +++ b/thirdparty/miniupnpc/miniupnpc/minissdpc.h @@ -32,13 +32,13 @@ MINIUPNP_LIBSPEC int connectToMiniSSDPD(const char * socketpath); MINIUPNP_LIBSPEC int -disconnectFromMiniSSDPD(int fd); +disconnectFromMiniSSDPD(int s); MINIUPNP_LIBSPEC int -requestDevicesFromMiniSSDPD(int fd, const char * devtype); +requestDevicesFromMiniSSDPD(int s, const char * devtype); MINIUPNP_LIBSPEC struct UPNPDev * -receiveDevicesFromMiniSSDPD(int fd, int * error); +receiveDevicesFromMiniSSDPD(int s, int * error); #endif /* !(defined(_WIN32) || defined(__amigaos__) || defined(__amigaos4__)) */ diff --git a/thirdparty/miniupnpc/miniupnpc.c b/thirdparty/miniupnpc/miniupnpc/miniupnpc.c index 5d93ef9933..3181d10eb6 100644 --- a/thirdparty/miniupnpc/miniupnpc.c +++ b/thirdparty/miniupnpc/miniupnpc/miniupnpc.c @@ -1,9 +1,9 @@ -/* $Id: miniupnpc.c,v 1.149 2016/02/09 09:50:46 nanard Exp $ */ +/* $Id: miniupnpc.c,v 1.154 2019/04/23 12:12:13 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * Project : miniupnp * Web : http://miniupnp.free.fr/ * Author : Thomas BERNARD - * copyright (c) 2005-2018 Thomas Bernard + * copyright (c) 2005-2019 Thomas Bernard * This software is subjet to the conditions detailed in the * provided LICENSE file. */ #include <stdlib.h> @@ -63,7 +63,7 @@ #include "connecthostport.h" /* compare the beginning of a string with a constant string */ -#define COMPARE(str, cstr) (0==memcmp(str, cstr, sizeof(cstr) - 1)) +#define COMPARE(str, cstr) (0==strncmp(str, cstr, sizeof(cstr) - 1)) #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 64 @@ -85,8 +85,7 @@ static int is_rfc1918addr(const char * addr) return 1; /* 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) */ if(COMPARE(addr, "172.")) { - int i = atoi(addr + 4); - if((16 <= i) && (i <= 31)) + if((atoi(addr + 4) | 0x0f) == 0x1f) return 1; } return 0; @@ -416,7 +415,7 @@ static char * build_absolute_url(const char * baseurl, const char * descURL, const char * url, unsigned int scope_id) { - int l, n; + size_t l, n; char * s; const char * base; char * p; @@ -459,7 +458,7 @@ build_absolute_url(const char * baseurl, const char * descURL, memcpy(s, base, n); if(scope_id != 0) { s[n] = '\0'; - if(0 == memcmp(s, "http://[fe80:", 13)) { + if(n > 13 && 0 == memcmp(s, "http://[fe80:", 13)) { /* this is a linklocal IPv6 address */ p = strchr(s, ']'); if(p) { @@ -573,7 +572,6 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, int ndev = 0; int i; int state = -1; /* state 1 : IGD connected. State 2 : IGD. State 3 : anything */ - int n_igd = 0; char extIpAddr[16]; char myLanAddr[40]; int status_code = -1; @@ -588,12 +586,10 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, /* counting total number of devices in the list */ for(dev = devlist; dev; dev = dev->pNext) ndev++; - if(ndev > 0) - { - desc = calloc(ndev, sizeof(struct xml_desc)); - if(!desc) - return -1; /* memory allocation error */ - } + /* ndev is always > 0 */ + desc = calloc(ndev, sizeof(struct xml_desc)); + if(!desc) + return -1; /* memory allocation error */ /* Step 1 : downloading descriptions and testing type */ for(dev = devlist, i = 0; dev; dev = dev->pNext, i++) { @@ -617,7 +613,6 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:")) { desc[i].is_igd = 1; - n_igd++; if(lanaddr) strncpy(lanaddr, myLanAddr, lanaddrlen); } @@ -685,14 +680,9 @@ UPNP_GetValidIGD(struct UPNPDev * devlist, } state = 0; free_and_return: - if(desc) { - for(i = 0; i < ndev; i++) { - if(desc[i].xml) { - free(desc[i].xml); - } - } - free(desc); - } + for(i = 0; i < ndev; i++) + free(desc[i].xml); + free(desc); return state; } @@ -717,7 +707,6 @@ UPNP_GetIGDFromUrl(const char * rootdescurl, memset(urls, 0, sizeof(struct UPNPUrls)); parserootdesc(descXML, descXMLsize, data); free(descXML); - descXML = NULL; GetUPNPUrls(urls, data, rootdescurl, 0); return 1; } else { diff --git a/thirdparty/miniupnpc/miniupnpc_declspec.h b/thirdparty/miniupnpc/miniupnpc/miniupnpc_declspec.h index 40adb922ec..40adb922ec 100644 --- a/thirdparty/miniupnpc/miniupnpc_declspec.h +++ b/thirdparty/miniupnpc/miniupnpc/miniupnpc_declspec.h diff --git a/thirdparty/miniupnpc/miniupnpc_socketdef.h b/thirdparty/miniupnpc/miniupnpc/miniupnpc_socketdef.h index 965d9151b9..d4f79a7bd6 100644 --- a/thirdparty/miniupnpc/miniupnpc_socketdef.h +++ b/thirdparty/miniupnpc/miniupnpc/miniupnpc_socketdef.h @@ -28,6 +28,13 @@ #endif +#ifdef _MSC_VER +#define MSC_CAST_INT (int) +#else +#define MSC_CAST_INT +#endif + +/* definition of PRINT_SOCKET_ERROR */ #ifdef _WIN32 #define PRINT_SOCKET_ERROR(x) fprintf(stderr, "Socket error: %s, %d\n", x, WSAGetLastError()); #else diff --git a/thirdparty/miniupnpc/miniupnpcmodule.c b/thirdparty/miniupnpc/miniupnpc/miniupnpcmodule.c index 8657a0e002..d9341ab5bf 100644 --- a/thirdparty/miniupnpc/miniupnpcmodule.c +++ b/thirdparty/miniupnpc/miniupnpc/miniupnpcmodule.c @@ -1,8 +1,9 @@ -/* $Id: miniupnpcmodule.c,v 1.24 2014/06/10 09:48:11 nanard Exp $*/ -/* Project : miniupnp +/* $Id: miniupnpcmodule.c,v 1.34 2019/05/20 19:07:16 nanard Exp $*/ +/* vim: tabstop=4 shiftwidth=4 noexpandtab + * Project : miniupnp * Author : Thomas BERNARD * website : https://miniupnp.tuxfamily.org/ - * copyright (c) 2007-2018 Thomas Bernard + * copyright (c) 2007-2019 Thomas Bernard * This software is subjet to the conditions detailed in the * provided LICENCE file. */ #include <Python.h> @@ -292,7 +293,7 @@ Py_END_ALLOW_THREADS } /* AddPortMapping(externalPort, protocol, internalHost, internalPort, desc, - * remoteHost) + * remoteHost, leaseDuration) * protocol is 'UDP' or 'TCP' */ static PyObject * UPnP_addportmapping(UPnPObject *self, PyObject *args) @@ -305,17 +306,24 @@ UPnP_addportmapping(UPnPObject *self, PyObject *args) const char * host; const char * desc; const char * remoteHost; - const char * leaseDuration = "0"; + unsigned int intLeaseDuration = 0; + char strLeaseDuration[12]; int r; - if (!PyArg_ParseTuple(args, "HssHzz", &ePort, &proto, - &host, &iPort, &desc, &remoteHost)) +#if (PY_MAJOR_VERSION >= 3) || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 3) + if (!PyArg_ParseTuple(args, "HssHzz|I", &ePort, &proto, + &host, &iPort, &desc, &remoteHost, &intLeaseDuration)) +#else + if (!PyArg_ParseTuple(args, "HssHzz|i", &ePort, &proto, + &host, &iPort, &desc, &remoteHost, (int *)&intLeaseDuration)) +#endif return NULL; Py_BEGIN_ALLOW_THREADS sprintf(extPort, "%hu", ePort); sprintf(inPort, "%hu", iPort); + sprintf(strLeaseDuration, "%u", intLeaseDuration); r = UPNP_AddPortMapping(self->urls.controlURL, self->data.first.servicetype, extPort, inPort, host, desc, proto, - remoteHost, leaseDuration); + remoteHost, strLeaseDuration); Py_END_ALLOW_THREADS if(r==UPNPCOMMAND_SUCCESS) { @@ -676,6 +684,16 @@ initminiupnpc(void) /* initialize Winsock. */ WSADATA wsaData; int nResult = WSAStartup(MAKEWORD(2,2), &wsaData); + if (nResult != 0) + { + /* error code could be WSASYSNOTREADY WSASYSNOTREADY + * WSASYSNOTREADY WSASYSNOTREADY WSASYSNOTREADY */ +#if PY_MAJOR_VERSION >= 3 + return 0; +#else + return; +#endif + } UPnPType.tp_new = PyType_GenericNew; #endif diff --git a/thirdparty/miniupnpc/miniupnpcstrings.h b/thirdparty/miniupnpc/miniupnpc/miniupnpcstrings.h index a718cc7bbf..a718cc7bbf 100644 --- a/thirdparty/miniupnpc/miniupnpcstrings.h +++ b/thirdparty/miniupnpc/miniupnpc/miniupnpcstrings.h diff --git a/thirdparty/miniupnpc/miniupnpctypes.h b/thirdparty/miniupnpc/miniupnpc/miniupnpctypes.h index 307ce39699..307ce39699 100644 --- a/thirdparty/miniupnpc/miniupnpctypes.h +++ b/thirdparty/miniupnpc/miniupnpc/miniupnpctypes.h diff --git a/thirdparty/miniupnpc/miniwget.c b/thirdparty/miniupnpc/miniupnpc/miniwget.c index a46ba76022..5c135f4efd 100644 --- a/thirdparty/miniupnpc/miniwget.c +++ b/thirdparty/miniupnpc/miniupnpc/miniwget.c @@ -243,7 +243,7 @@ getHTTPResponse(SOCKET s, int * size, int * status_code) /* reading chunk size */ if(chunksize_buf_index == 0) { /* skipping any leading CR LF */ - if(i<n && buf[i] == '\r') i++; + if(buf[i] == '\r') i++; if(i<n && buf[i] == '\n') i++; } while(i<n && isxdigit(buf[i]) @@ -350,7 +350,7 @@ getHTTPResponse(SOCKET s, int * size, int * status_code) } } end_of_stream: - free(header_buf); header_buf = NULL; + free(header_buf); *size = content_buf_used; if(content_buf_used == 0) { @@ -371,7 +371,7 @@ miniwget3(const char * host, int * status_code) { char buf[2048]; - SOCKET s; + SOCKET s; int n; int len; int sent; @@ -559,7 +559,7 @@ parseURL(const char * url, #else /* under windows, scope is numerical */ char tmp[8]; - int l; + size_t l; scope++; /* "%25" is just '%' in URL encoding */ if(scope[0] == '2' && scope[1] == '5') @@ -659,4 +659,3 @@ miniwget_getaddr(const char * url, int * size, #endif return miniwget2(hostname, port, path, size, addr, addrlen, scope_id, status_code); } - diff --git a/thirdparty/miniupnpc/miniwget_private.h b/thirdparty/miniupnpc/miniupnpc/miniwget_private.h index e4eaac8085..e4eaac8085 100644 --- a/thirdparty/miniupnpc/miniwget_private.h +++ b/thirdparty/miniupnpc/miniupnpc/miniwget_private.h diff --git a/thirdparty/miniupnpc/minixml.c b/thirdparty/miniupnpc/miniupnpc/minixml.c index ed2d3c759c..ed2d3c759c 100644 --- a/thirdparty/miniupnpc/minixml.c +++ b/thirdparty/miniupnpc/miniupnpc/minixml.c diff --git a/thirdparty/miniupnpc/minixml.h b/thirdparty/miniupnpc/miniupnpc/minixml.h index 19e6f513bf..2e60397388 100644 --- a/thirdparty/miniupnpc/minixml.h +++ b/thirdparty/miniupnpc/miniupnpc/minixml.h @@ -10,7 +10,7 @@ * */ #ifndef MINIXML_H_INCLUDED #define MINIXML_H_INCLUDED -#define IS_WHITE_SPACE(c) ((c==' ') || (c=='\t') || (c=='\r') || (c=='\n')) +#define IS_WHITE_SPACE(c) ((c)==' ' || (c)=='\t' || (c)=='\r' || (c)=='\n') /* if a callback function pointer is set to NULL, * the function is not called */ diff --git a/thirdparty/miniupnpc/minixmlvalid.c b/thirdparty/miniupnpc/miniupnpc/minixmlvalid.c index dad1488122..dad1488122 100644 --- a/thirdparty/miniupnpc/minixmlvalid.c +++ b/thirdparty/miniupnpc/miniupnpc/minixmlvalid.c diff --git a/thirdparty/miniupnpc/portlistingparse.c b/thirdparty/miniupnpc/miniupnpc/portlistingparse.c index 55859f2714..55859f2714 100644 --- a/thirdparty/miniupnpc/portlistingparse.c +++ b/thirdparty/miniupnpc/miniupnpc/portlistingparse.c diff --git a/thirdparty/miniupnpc/portlistingparse.h b/thirdparty/miniupnpc/miniupnpc/portlistingparse.h index e3957a3f4c..e3957a3f4c 100644 --- a/thirdparty/miniupnpc/portlistingparse.h +++ b/thirdparty/miniupnpc/miniupnpc/portlistingparse.h diff --git a/thirdparty/miniupnpc/receivedata.c b/thirdparty/miniupnpc/miniupnpc/receivedata.c index 7b9cc5b778..7b9cc5b778 100644 --- a/thirdparty/miniupnpc/receivedata.c +++ b/thirdparty/miniupnpc/miniupnpc/receivedata.c diff --git a/thirdparty/miniupnpc/receivedata.h b/thirdparty/miniupnpc/miniupnpc/receivedata.h index c9fdc561f8..c9fdc561f8 100644 --- a/thirdparty/miniupnpc/receivedata.h +++ b/thirdparty/miniupnpc/miniupnpc/receivedata.h diff --git a/thirdparty/miniupnpc/upnpc.c b/thirdparty/miniupnpc/miniupnpc/upnpc.c index 0c65cbe8c0..674c89beb0 100644 --- a/thirdparty/miniupnpc/upnpc.c +++ b/thirdparty/miniupnpc/miniupnpc/upnpc.c @@ -1,7 +1,7 @@ /* $Id: upnpc.c,v 1.119 2018/03/13 23:34:46 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard - * Copyright (c) 2005-2018 Thomas Bernard + * Copyright (c) 2005-2019 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. */ @@ -579,7 +579,7 @@ int main(int argc, char ** argv) } #endif printf("upnpc : miniupnpc library test client, version %s.\n", MINIUPNPC_VERSION_STRING); - printf(" (c) 2005-2018 Thomas Bernard.\n"); + printf(" (c) 2005-2019 Thomas Bernard.\n"); printf("Go to http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/\n" "for more information.\n"); /* command line processing */ diff --git a/thirdparty/miniupnpc/upnpcommands.c b/thirdparty/miniupnpc/miniupnpc/upnpcommands.c index b6a693a93a..1e1ee6786f 100644 --- a/thirdparty/miniupnpc/upnpcommands.c +++ b/thirdparty/miniupnpc/miniupnpc/upnpcommands.c @@ -1,4 +1,4 @@ -/* $Id: upnpcommands.c,v 1.49 2018/03/13 23:34:47 nanard Exp $ */ +/* $Id: upnpcommands.c,v 1.51 2019/04/23 11:45:15 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * Project : miniupnp * Author : Thomas Bernard @@ -33,11 +33,11 @@ UPNP_GetTotalBytesSent(const char * controlURL, char * p; if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalBytesSent", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; + return (UNSIGNED_INTEGER)UPNPCOMMAND_HTTP_ERROR; } ParseNameValue(buffer, bufsize, &pdata); /*DisplayNameValueList(buffer, bufsize);*/ - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "NewTotalBytesSent"); r = my_atoui(p); ClearNameValueList(&pdata); @@ -57,11 +57,11 @@ UPNP_GetTotalBytesReceived(const char * controlURL, char * p; if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalBytesReceived", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; + return (UNSIGNED_INTEGER)UPNPCOMMAND_HTTP_ERROR; } ParseNameValue(buffer, bufsize, &pdata); /*DisplayNameValueList(buffer, bufsize);*/ - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "NewTotalBytesReceived"); r = my_atoui(p); ClearNameValueList(&pdata); @@ -81,11 +81,11 @@ UPNP_GetTotalPacketsSent(const char * controlURL, char * p; if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalPacketsSent", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; + return (UNSIGNED_INTEGER)UPNPCOMMAND_HTTP_ERROR; } ParseNameValue(buffer, bufsize, &pdata); /*DisplayNameValueList(buffer, bufsize);*/ - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "NewTotalPacketsSent"); r = my_atoui(p); ClearNameValueList(&pdata); @@ -105,11 +105,11 @@ UPNP_GetTotalPacketsReceived(const char * controlURL, char * p; if(!(buffer = simpleUPnPcommand(-1, controlURL, servicetype, "GetTotalPacketsReceived", 0, &bufsize))) { - return UPNPCOMMAND_HTTP_ERROR; + return (UNSIGNED_INTEGER)UPNPCOMMAND_HTTP_ERROR; } ParseNameValue(buffer, bufsize, &pdata); /*DisplayNameValueList(buffer, bufsize);*/ - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "NewTotalPacketsReceived"); r = my_atoui(p); ClearNameValueList(&pdata); @@ -142,7 +142,7 @@ UPNP_GetStatusInfo(const char * controlURL, } ParseNameValue(buffer, bufsize, &pdata); /*DisplayNameValueList(buffer, bufsize);*/ - free(buffer); buffer = NULL; + free(buffer); up = GetValueFromNameValueList(&pdata, "NewUptime"); p = GetValueFromNameValueList(&pdata, "NewConnectionStatus"); err = GetValueFromNameValueList(&pdata, "NewLastConnectionError"); @@ -202,7 +202,7 @@ UPNP_GetConnectionTypeInfo(const char * controlURL, return UPNPCOMMAND_HTTP_ERROR; } ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "NewConnectionType"); /*p = GetValueFromNameValueList(&pdata, "NewPossibleConnectionTypes");*/ /* PossibleConnectionTypes will have several values.... */ @@ -251,7 +251,7 @@ UPNP_GetLinkLayerMaxBitRates(const char * controlURL, } /*DisplayNameValueList(buffer, bufsize);*/ ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); /*down = GetValueFromNameValueList(&pdata, "NewDownstreamMaxBitRate");*/ /*up = GetValueFromNameValueList(&pdata, "NewUpstreamMaxBitRate");*/ down = GetValueFromNameValueList(&pdata, "NewLayer1DownstreamMaxBitRate"); @@ -315,7 +315,7 @@ UPNP_GetExternalIPAddress(const char * controlURL, } /*DisplayNameValueList(buffer, bufsize);*/ ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); /*printf("external ip = %s\n", GetValueFromNameValueList(&pdata, "NewExternalIPAddress") );*/ p = GetValueFromNameValueList(&pdata, "NewExternalIPAddress"); if(p) { @@ -385,7 +385,7 @@ UPNP_AddPortMapping(const char * controlURL, const char * servicetype, /*buffer[bufsize] = '\0';*/ /*puts(buffer);*/ ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); resVal = GetValueFromNameValueList(&pdata, "errorCode"); if(resVal) { /*printf("AddPortMapping errorCode = '%s'\n", resVal); */ @@ -446,7 +446,7 @@ UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype, return UPNPCOMMAND_HTTP_ERROR; } ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); resVal = GetValueFromNameValueList(&pdata, "errorCode"); if(resVal) { ret = UPNPCOMMAND_UNKNOWN_ERROR; @@ -501,7 +501,7 @@ UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, } /*DisplayNameValueList(buffer, bufsize);*/ ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); resVal = GetValueFromNameValueList(&pdata, "errorCode"); if(resVal) { ret = UPNPCOMMAND_UNKNOWN_ERROR; @@ -549,7 +549,7 @@ UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype, return UPNPCOMMAND_HTTP_ERROR; } ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); resVal = GetValueFromNameValueList(&pdata, "errorCode"); if(resVal) { ret = UPNPCOMMAND_UNKNOWN_ERROR; @@ -597,7 +597,7 @@ UPNP_GetGenericPortMappingEntry(const char * controlURL, return UPNPCOMMAND_HTTP_ERROR; } ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "NewRemoteHost"); if(p && rHost) @@ -677,7 +677,7 @@ UPNP_GetPortMappingNumberOfEntries(const char * controlURL, DisplayNameValueList(buffer, bufsize); #endif ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "NewPortMappingNumberOfEntries"); if(numEntries && p) { @@ -739,7 +739,7 @@ UPNP_GetSpecificPortMappingEntry(const char * controlURL, } /*DisplayNameValueList(buffer, bufsize);*/ ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "NewInternalClient"); if(p) { @@ -836,7 +836,7 @@ UPNP_GetListOfPortMappings(const char * controlURL, /*DisplayNameValueList(buffer, bufsize);*/ ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); /*p = GetValueFromNameValueList(&pdata, "NewPortListing");*/ /*if(p) { @@ -898,7 +898,7 @@ UPNP_GetFirewallStatus(const char * controlURL, return UPNPCOMMAND_HTTP_ERROR; } ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); fe = GetValueFromNameValueList(&pdata, "FirewallEnabled"); ipa = GetValueFromNameValueList(&pdata, "InboundPinholeAllowed"); if(ipa && fe) @@ -935,7 +935,6 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype int bufsize; struct NameValueParserData pdata; const char * resVal; - char * p; int ret; if(!intPort || !intClient || !proto || !remotePort || !remoteHost) @@ -960,7 +959,7 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype if(!buffer) return UPNPCOMMAND_HTTP_ERROR; ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); resVal = GetValueFromNameValueList(&pdata, "errorCode"); if(resVal) { @@ -969,10 +968,10 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype } else { - ret = UPNPCOMMAND_SUCCESS; - p = GetValueFromNameValueList(&pdata, "OutboundPinholeTimeout"); + const char * p = GetValueFromNameValueList(&pdata, "OutboundPinholeTimeout"); if(p) *opTimeout = my_atoui(p); + ret = UPNPCOMMAND_SUCCESS; } ClearNameValueList(&pdata); return ret; @@ -1037,7 +1036,7 @@ UPNP_AddPinhole(const char * controlURL, const char * servicetype, if(!buffer) return UPNPCOMMAND_HTTP_ERROR; ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "UniqueID"); if(p) { @@ -1087,7 +1086,7 @@ UPNP_UpdatePinhole(const char * controlURL, const char * servicetype, if(!buffer) return UPNPCOMMAND_HTTP_ERROR; ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); resVal = GetValueFromNameValueList(&pdata, "errorCode"); if(resVal) { @@ -1129,7 +1128,7 @@ UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char return UPNPCOMMAND_HTTP_ERROR; /*DisplayNameValueList(buffer, bufsize);*/ ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); resVal = GetValueFromNameValueList(&pdata, "errorCode"); if(resVal) { @@ -1171,7 +1170,7 @@ UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, return UPNPCOMMAND_HTTP_ERROR; } ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "IsWorking"); if(p) @@ -1218,7 +1217,7 @@ UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, if(!buffer) return UPNPCOMMAND_HTTP_ERROR; ParseNameValue(buffer, bufsize, &pdata); - free(buffer); buffer = NULL; + free(buffer); p = GetValueFromNameValueList(&pdata, "PinholePackets"); if(p) @@ -1237,5 +1236,3 @@ UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, ClearNameValueList(&pdata); return ret; } - - diff --git a/thirdparty/miniupnpc/miniupnpc/upnpcommands.h b/thirdparty/miniupnpc/miniupnpc/upnpcommands.h index 0c6d501666..1b6d447732 100644 --- a/thirdparty/miniupnpc/miniupnpc/upnpcommands.h +++ b/thirdparty/miniupnpc/miniupnpc/upnpcommands.h @@ -206,9 +206,9 @@ UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype, /* UPNP_GetPortMappingNumberOfEntries() * not supported by all routers */ MINIUPNP_LIBSPEC int -UPNP_GetPortMappingNumberOfEntries(const char* controlURL, - const char* servicetype, - unsigned int * num); +UPNP_GetPortMappingNumberOfEntries(const char * controlURL, + const char * servicetype, + unsigned int * numEntries); /* UPNP_GetSpecificPortMappingEntry() * retrieves an existing port mapping diff --git a/thirdparty/miniupnpc/upnpdev.c b/thirdparty/miniupnpc/miniupnpc/upnpdev.c index d89a9934c3..d89a9934c3 100644 --- a/thirdparty/miniupnpc/upnpdev.c +++ b/thirdparty/miniupnpc/miniupnpc/upnpdev.c diff --git a/thirdparty/miniupnpc/upnpdev.h b/thirdparty/miniupnpc/miniupnpc/upnpdev.h index f4ae174426..f4ae174426 100644 --- a/thirdparty/miniupnpc/upnpdev.h +++ b/thirdparty/miniupnpc/miniupnpc/upnpdev.h diff --git a/thirdparty/miniupnpc/upnperrors.c b/thirdparty/miniupnpc/miniupnpc/upnperrors.c index 40a2e7857f..650af42557 100644 --- a/thirdparty/miniupnpc/upnperrors.c +++ b/thirdparty/miniupnpc/miniupnpc/upnperrors.c @@ -1,7 +1,7 @@ -/* $Id: upnperrors.c,v 1.5 2011/04/10 11:19:36 nanard Exp $ */ +/* $Id: upnperrors.c,v 1.9 2019/06/25 21:15:46 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD - * copyright (c) 2007 Thomas Bernard + * copyright (c) 2007-2019 Thomas Bernard * All Right reserved. * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * This software is subjet to the conditions detailed in the @@ -27,10 +27,14 @@ const char * strupnperror(int err) case UPNPCOMMAND_INVALID_RESPONSE: s = "Miniupnpc Invalid response"; break; + case UPNPCOMMAND_HTTP_ERROR: + s = "Miniupnpc HTTP error"; + break; case UPNPDISCOVER_SOCKET_ERROR: s = "Miniupnpc Socket error"; break; case UPNPDISCOVER_MEMORY_ERROR: + case UPNPCOMMAND_MEM_ALLOC_ERROR: s = "Miniupnpc Memory allocation error"; break; case 401: diff --git a/thirdparty/miniupnpc/upnperrors.h b/thirdparty/miniupnpc/miniupnpc/upnperrors.h index 8499d9a1c9..8499d9a1c9 100644 --- a/thirdparty/miniupnpc/upnperrors.h +++ b/thirdparty/miniupnpc/miniupnpc/upnperrors.h diff --git a/thirdparty/miniupnpc/upnpreplyparse.c b/thirdparty/miniupnpc/miniupnpc/upnpreplyparse.c index 68a47c0278..4d06f0585d 100644 --- a/thirdparty/miniupnpc/upnpreplyparse.c +++ b/thirdparty/miniupnpc/miniupnpc/upnpreplyparse.c @@ -1,8 +1,8 @@ -/* $Id: upnpreplyparse.c,v 1.19 2015/07/15 10:29:11 nanard Exp $ */ +/* $Id: upnpreplyparse.c,v 1.20 2017/12/12 11:26:25 nanard Exp $ */ /* vim: tabstop=4 shiftwidth=4 noexpandtab * MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006-2017 Thomas Bernard + * (c) 2006-2019 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ @@ -78,6 +78,7 @@ NameValueParserGetData(void * d, const char * datas, int l) if(strcmp(data->curelt, "NewPortListing") == 0) { /* specific case for NewPortListing which is a XML Document */ + free(data->portListing); data->portListing = malloc(l + 1); if(!data->portListing) { diff --git a/thirdparty/miniupnpc/upnpreplyparse.h b/thirdparty/miniupnpc/miniupnpc/upnpreplyparse.h index 6badd15b26..6badd15b26 100644 --- a/thirdparty/miniupnpc/upnpreplyparse.h +++ b/thirdparty/miniupnpc/miniupnpc/upnpreplyparse.h diff --git a/thirdparty/miniupnpc/miniwget.h b/thirdparty/miniupnpc/miniwget.h deleted file mode 100644 index f5572c2544..0000000000 --- a/thirdparty/miniupnpc/miniwget.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $Id: miniwget.h,v 1.12 2016/01/24 17:24:36 nanard Exp $ */ -/* Project : miniupnp - * Author : Thomas Bernard - * Copyright (c) 2005-2016 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. - * */ -#ifndef MINIWGET_H_INCLUDED -#define MINIWGET_H_INCLUDED - -#include "miniupnpc_declspec.h" - -#ifdef __cplusplus -extern "C" { -#endif - -MINIUPNP_LIBSPEC void * miniwget(const char *, int *, unsigned int, int *); - -MINIUPNP_LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int, unsigned int, int *); - -int parseURL(const char *, char *, unsigned short *, char * *, unsigned int *); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/thirdparty/miniupnpc/upnpcommands.h b/thirdparty/miniupnpc/upnpcommands.h deleted file mode 100644 index 0c6d501666..0000000000 --- a/thirdparty/miniupnpc/upnpcommands.h +++ /dev/null @@ -1,348 +0,0 @@ -/* $Id: upnpcommands.h,v 1.32 2018/03/13 23:34:47 nanard Exp $ */ -/* Miniupnp project : http://miniupnp.free.fr/ - * Author : Thomas Bernard - * Copyright (c) 2005-2018 Thomas Bernard - * This software is subject to the conditions detailed in the - * LICENCE file provided within this distribution */ -#ifndef UPNPCOMMANDS_H_INCLUDED -#define UPNPCOMMANDS_H_INCLUDED - -#include "miniupnpc_declspec.h" -#include "miniupnpctypes.h" - -/* MiniUPnPc return codes : */ -#define UPNPCOMMAND_SUCCESS (0) -#define UPNPCOMMAND_UNKNOWN_ERROR (-1) -#define UPNPCOMMAND_INVALID_ARGS (-2) -#define UPNPCOMMAND_HTTP_ERROR (-3) -#define UPNPCOMMAND_INVALID_RESPONSE (-4) -#define UPNPCOMMAND_MEM_ALLOC_ERROR (-5) - -#ifdef __cplusplus -extern "C" { -#endif - -struct PortMappingParserData; - -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalBytesSent(const char * controlURL, - const char * servicetype); - -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalBytesReceived(const char * controlURL, - const char * servicetype); - -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalPacketsSent(const char * controlURL, - const char * servicetype); - -MINIUPNP_LIBSPEC UNSIGNED_INTEGER -UPNP_GetTotalPacketsReceived(const char * controlURL, - const char * servicetype); - -/* UPNP_GetStatusInfo() - * status and lastconnerror are 64 byte buffers - * Return values : - * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR - * or a UPnP Error code */ -MINIUPNP_LIBSPEC int -UPNP_GetStatusInfo(const char * controlURL, - const char * servicetype, - char * status, - unsigned int * uptime, - char * lastconnerror); - -/* UPNP_GetConnectionTypeInfo() - * argument connectionType is a 64 character buffer - * Return Values : - * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR - * or a UPnP Error code */ -MINIUPNP_LIBSPEC int -UPNP_GetConnectionTypeInfo(const char * controlURL, - const char * servicetype, - char * connectionType); - -/* UPNP_GetExternalIPAddress() call the corresponding UPNP method. - * if the third arg is not null the value is copied to it. - * at least 16 bytes must be available - * - * Return values : - * 0 : SUCCESS - * NON ZERO : ERROR Either an UPnP error code or an unknown error. - * - * possible UPnP Errors : - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 501 Action Failed - See UPnP Device Architecture section on Control. */ -MINIUPNP_LIBSPEC int -UPNP_GetExternalIPAddress(const char * controlURL, - const char * servicetype, - char * extIpAdd); - -/* UPNP_GetLinkLayerMaxBitRates() - * call WANCommonInterfaceConfig:1#GetCommonLinkProperties - * - * return values : - * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR - * or a UPnP Error Code. */ -MINIUPNP_LIBSPEC int -UPNP_GetLinkLayerMaxBitRates(const char* controlURL, - const char* servicetype, - unsigned int * bitrateDown, - unsigned int * bitrateUp); - -/* UPNP_AddPortMapping() - * if desc is NULL, it will be defaulted to "libminiupnpc" - * remoteHost is usually NULL because IGD don't support it. - * - * Return values : - * 0 : SUCCESS - * NON ZERO : ERROR. Either an UPnP error code or an unknown error. - * - * List of possible UPnP errors for AddPortMapping : - * errorCode errorDescription (short) - Description (long) - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 501 Action Failed - See UPnP Device Architecture section on Control. - * 606 Action not authorized - The action requested REQUIRES authorization and - * the sender was not authorized. - * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be - * wild-carded - * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded - * 718 ConflictInMappingEntry - The port mapping entry specified conflicts - * with a mapping assigned previously to another client - * 724 SamePortValuesRequired - Internal and External port values - * must be the same - * 725 OnlyPermanentLeasesSupported - The NAT implementation only supports - * permanent lease times on port mappings - * 726 RemoteHostOnlySupportsWildcard - RemoteHost must be a wildcard - * and cannot be a specific IP address or DNS name - * 727 ExternalPortOnlySupportsWildcard - ExternalPort must be a wildcard and - * cannot be a specific port value - * 728 NoPortMapsAvailable - There are not enough free ports available to - * complete port mapping. - * 729 ConflictWithOtherMechanisms - Attempted port mapping is not allowed - * due to conflict with other mechanisms. - * 732 WildCardNotPermittedInIntPort - The internal port cannot be wild-carded - */ -MINIUPNP_LIBSPEC int -UPNP_AddPortMapping(const char * controlURL, const char * servicetype, - const char * extPort, - const char * inPort, - const char * inClient, - const char * desc, - const char * proto, - const char * remoteHost, - const char * leaseDuration); - -/* UPNP_AddAnyPortMapping() - * if desc is NULL, it will be defaulted to "libminiupnpc" - * remoteHost is usually NULL because IGD don't support it. - * - * Return values : - * 0 : SUCCESS - * NON ZERO : ERROR. Either an UPnP error code or an unknown error. - * - * List of possible UPnP errors for AddPortMapping : - * errorCode errorDescription (short) - Description (long) - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 501 Action Failed - See UPnP Device Architecture section on Control. - * 606 Action not authorized - The action requested REQUIRES authorization and - * the sender was not authorized. - * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be - * wild-carded - * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded - * 728 NoPortMapsAvailable - There are not enough free ports available to - * complete port mapping. - * 729 ConflictWithOtherMechanisms - Attempted port mapping is not allowed - * due to conflict with other mechanisms. - * 732 WildCardNotPermittedInIntPort - The internal port cannot be wild-carded - */ -MINIUPNP_LIBSPEC int -UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype, - const char * extPort, - const char * inPort, - const char * inClient, - const char * desc, - const char * proto, - const char * remoteHost, - const char * leaseDuration, - char * reservedPort); - -/* UPNP_DeletePortMapping() - * Use same argument values as what was used for AddPortMapping(). - * remoteHost is usually NULL because IGD don't support it. - * Return Values : - * 0 : SUCCESS - * NON ZERO : error. Either an UPnP error code or an undefined error. - * - * List of possible UPnP errors for DeletePortMapping : - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 606 Action not authorized - The action requested REQUIRES authorization - * and the sender was not authorized. - * 714 NoSuchEntryInArray - The specified value does not exist in the array */ -MINIUPNP_LIBSPEC int -UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, - const char * extPort, const char * proto, - const char * remoteHost); - -/* UPNP_DeletePortRangeMapping() - * Use same argument values as what was used for AddPortMapping(). - * remoteHost is usually NULL because IGD don't support it. - * Return Values : - * 0 : SUCCESS - * NON ZERO : error. Either an UPnP error code or an undefined error. - * - * List of possible UPnP errors for DeletePortMapping : - * 606 Action not authorized - The action requested REQUIRES authorization - * and the sender was not authorized. - * 730 PortMappingNotFound - This error message is returned if no port - * mapping is found in the specified range. - * 733 InconsistentParameters - NewStartPort and NewEndPort values are not consistent. */ -MINIUPNP_LIBSPEC int -UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype, - const char * extPortStart, const char * extPortEnd, - const char * proto, - const char * manage); - -/* UPNP_GetPortMappingNumberOfEntries() - * not supported by all routers */ -MINIUPNP_LIBSPEC int -UPNP_GetPortMappingNumberOfEntries(const char* controlURL, - const char* servicetype, - unsigned int * num); - -/* UPNP_GetSpecificPortMappingEntry() - * retrieves an existing port mapping - * params : - * in extPort - * in proto - * in remoteHost - * out intClient (16 bytes) - * out intPort (6 bytes) - * out desc (80 bytes) - * out enabled (4 bytes) - * out leaseDuration (16 bytes) - * - * return value : - * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR - * or a UPnP Error Code. - * - * List of possible UPnP errors for _GetSpecificPortMappingEntry : - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 501 Action Failed - See UPnP Device Architecture section on Control. - * 606 Action not authorized - The action requested REQUIRES authorization - * and the sender was not authorized. - * 714 NoSuchEntryInArray - The specified value does not exist in the array. - */ -MINIUPNP_LIBSPEC int -UPNP_GetSpecificPortMappingEntry(const char * controlURL, - const char * servicetype, - const char * extPort, - const char * proto, - const char * remoteHost, - char * intClient, - char * intPort, - char * desc, - char * enabled, - char * leaseDuration); - -/* UPNP_GetGenericPortMappingEntry() - * params : - * in index - * out extPort (6 bytes) - * out intClient (16 bytes) - * out intPort (6 bytes) - * out protocol (4 bytes) - * out desc (80 bytes) - * out enabled (4 bytes) - * out rHost (64 bytes) - * out duration (16 bytes) - * - * return value : - * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR - * or a UPnP Error Code. - * - * Possible UPNP Error codes : - * 402 Invalid Args - See UPnP Device Architecture section on Control. - * 606 Action not authorized - The action requested REQUIRES authorization - * and the sender was not authorized. - * 713 SpecifiedArrayIndexInvalid - The specified array index is out of bounds - */ -MINIUPNP_LIBSPEC int -UPNP_GetGenericPortMappingEntry(const char * controlURL, - const char * servicetype, - const char * index, - char * extPort, - char * intClient, - char * intPort, - char * protocol, - char * desc, - char * enabled, - char * rHost, - char * duration); - -/* UPNP_GetListOfPortMappings() Available in IGD v2 - * - * - * Possible UPNP Error codes : - * 606 Action not Authorized - * 730 PortMappingNotFound - no port mapping is found in the specified range. - * 733 InconsistantParameters - NewStartPort and NewEndPort values are not - * consistent. - */ -MINIUPNP_LIBSPEC int -UPNP_GetListOfPortMappings(const char * controlURL, - const char * servicetype, - const char * startPort, - const char * endPort, - const char * protocol, - const char * numberOfPorts, - struct PortMappingParserData * data); - -/* IGD:2, functions for service WANIPv6FirewallControl:1 */ -MINIUPNP_LIBSPEC int -UPNP_GetFirewallStatus(const char * controlURL, - const char * servicetype, - int * firewallEnabled, - int * inboundPinholeAllowed); - -MINIUPNP_LIBSPEC int -UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype, - const char * remoteHost, - const char * remotePort, - const char * intClient, - const char * intPort, - const char * proto, - int * opTimeout); - -MINIUPNP_LIBSPEC int -UPNP_AddPinhole(const char * controlURL, const char * servicetype, - const char * remoteHost, - const char * remotePort, - const char * intClient, - const char * intPort, - const char * proto, - const char * leaseTime, - char * uniqueID); - -MINIUPNP_LIBSPEC int -UPNP_UpdatePinhole(const char * controlURL, const char * servicetype, - const char * uniqueID, - const char * leaseTime); - -MINIUPNP_LIBSPEC int -UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char * uniqueID); - -MINIUPNP_LIBSPEC int -UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, - const char * uniqueID, int * isWorking); - -MINIUPNP_LIBSPEC int -UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, - const char * uniqueID, int * packets); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/thirdparty/misc/aes256.cpp b/thirdparty/misc/aes256.cpp deleted file mode 100644 index dc271928b4..0000000000 --- a/thirdparty/misc/aes256.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* -* Byte-oriented AES-256 implementation. -* All lookup tables replaced with 'on the fly' calculations. -* -* Copyright (c) 2007-2011 Ilya O. Levin, http://www.literatecode.com -* Other contributors: Hal Finney -* -* Permission to use, copy, modify, and 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 "aes256.h" - -#define FD(x) (((x) >> 1) ^ (((x) & 1) ? 0x8d : 0)) - -#define BACK_TO_TABLES - -static uint8_t rj_xtime(uint8_t); -static void aes_subBytes(uint8_t *); -static void aes_subBytes_inv(uint8_t *); -static void aes_addRoundKey(uint8_t *, uint8_t *); -static void aes_addRoundKey_cpy(uint8_t *, uint8_t *, uint8_t *); -static void aes_shiftRows(uint8_t *); -static void aes_shiftRows_inv(uint8_t *); -static void aes_mixColumns(uint8_t *); -static void aes_mixColumns_inv(uint8_t *); -static void aes_expandEncKey(uint8_t *, uint8_t *); -static void aes_expandDecKey(uint8_t *, uint8_t *); -#ifndef BACK_TO_TABLES -static uint8_t gf_alog(uint8_t); -static uint8_t gf_log(uint8_t); -static uint8_t gf_mulinv(uint8_t); -static uint8_t rj_sbox(uint8_t); -static uint8_t rj_sbox_inv(uint8_t); -#endif - -#ifdef BACK_TO_TABLES - -static const uint8_t sbox[256] = { - 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, - 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, - 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, - 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, - 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, - 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, - 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, - 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, - 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, - 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, - 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, - 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, - 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, - 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, - 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, - 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, - 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, - 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, - 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, - 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, - 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, - 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, - 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, - 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, - 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, - 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, - 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, - 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, - 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, - 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, - 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, - 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 -}; -static const uint8_t sboxinv[256] = { - 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, - 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, - 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, - 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, - 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, - 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, - 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, - 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, - 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, - 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, - 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, - 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, - 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, - 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, - 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, - 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, - 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, - 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, - 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, - 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, - 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, - 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, - 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, - 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, - 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, - 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, - 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, - 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, - 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, - 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, - 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, - 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d -}; - -#define rj_sbox(x) sbox[(x)] -#define rj_sbox_inv(x) sboxinv[(x)] - -#else /* tableless subroutines */ - -/* -------------------------------------------------------------------------- */ -static uint8_t gf_alog(uint8_t x) // calculate anti-logarithm gen 3 -{ - uint8_t y = 1, i; - - for (i = 0; i < x; i++) y ^= rj_xtime(y); - - return y; -} /* gf_alog */ - -/* -------------------------------------------------------------------------- */ -static uint8_t gf_log(uint8_t x) // calculate logarithm gen 3 -{ - uint8_t y, i = 0; - - if (x) - for (i = 1, y = 1; i > 0; i++ ) - { - y ^= rj_xtime(y); - if (y == x) break; - } - - return i; -} /* gf_log */ - - -/* -------------------------------------------------------------------------- */ -static uint8_t gf_mulinv(uint8_t x) // calculate multiplicative inverse -{ - return (x) ? gf_alog(255 - gf_log(x)) : 0; -} /* gf_mulinv */ - -/* -------------------------------------------------------------------------- */ -static uint8_t rj_sbox(uint8_t x) -{ - uint8_t y, sb; - - sb = y = gf_mulinv(x); - y = (uint8_t)(y << 1) | (y >> 7), sb ^= y; - y = (uint8_t)(y << 1) | (y >> 7), sb ^= y; - y = (uint8_t)(y << 1) | (y >> 7), sb ^= y; - y = (uint8_t)(y << 1) | (y >> 7), sb ^= y; - - return (sb ^ 0x63); -} /* rj_sbox */ - -/* -------------------------------------------------------------------------- */ -static uint8_t rj_sbox_inv(uint8_t x) -{ - uint8_t y, sb; - - y = x ^ 0x63; - sb = y = (uint8_t)(y << 1) | (y >> 7); - y = (uint8_t)(y << 2) | (y >> 6); - sb ^= y; - y = (uint8_t)(y << 3) | (y >> 5); - sb ^= y; - - return gf_mulinv(sb); -} /* rj_sbox_inv */ - -#endif - -/* -------------------------------------------------------------------------- */ -static uint8_t rj_xtime(uint8_t x) -{ - uint8_t y = (uint8_t)(x << 1); - return (x & 0x80) ? (y ^ 0x1b) : y; -} /* rj_xtime */ - -/* -------------------------------------------------------------------------- */ -static void aes_subBytes(uint8_t *buf) -{ - register uint8_t i = 16; - - while (i--) buf[i] = rj_sbox(buf[i]); -} /* aes_subBytes */ - -/* -------------------------------------------------------------------------- */ -static void aes_subBytes_inv(uint8_t *buf) -{ - register uint8_t i = 16; - - while (i--) buf[i] = rj_sbox_inv(buf[i]); -} /* aes_subBytes_inv */ - -/* -------------------------------------------------------------------------- */ -static void aes_addRoundKey(uint8_t *buf, uint8_t *key) -{ - register uint8_t i = 16; - - while (i--) buf[i] ^= key[i]; -} /* aes_addRoundKey */ - -/* -------------------------------------------------------------------------- */ -static void aes_addRoundKey_cpy(uint8_t *buf, uint8_t *key, uint8_t *cpk) -{ - register uint8_t i = 16; - - while (i--) buf[i] ^= (cpk[i] = key[i]), cpk[16 + i] = key[16 + i]; -} /* aes_addRoundKey_cpy */ - - -/* -------------------------------------------------------------------------- */ -static void aes_shiftRows(uint8_t *buf) -{ - register uint8_t i, j; /* to make it potentially parallelable :) */ - - i = buf[1], buf[1] = buf[5], buf[5] = buf[9], buf[9] = buf[13], buf[13] = i; - i = buf[10], buf[10] = buf[2], buf[2] = i; - j = buf[3], buf[3] = buf[15], buf[15] = buf[11], buf[11] = buf[7], buf[7] = j; - j = buf[14], buf[14] = buf[6], buf[6] = j; - -} /* aes_shiftRows */ - -/* -------------------------------------------------------------------------- */ -static void aes_shiftRows_inv(uint8_t *buf) -{ - register uint8_t i, j; /* same as above :) */ - - i = buf[1], buf[1] = buf[13], buf[13] = buf[9], buf[9] = buf[5], buf[5] = i; - i = buf[2], buf[2] = buf[10], buf[10] = i; - j = buf[3], buf[3] = buf[7], buf[7] = buf[11], buf[11] = buf[15], buf[15] = j; - j = buf[6], buf[6] = buf[14], buf[14] = j; - -} /* aes_shiftRows_inv */ - -/* -------------------------------------------------------------------------- */ -static void aes_mixColumns(uint8_t *buf) -{ - register uint8_t i, a, b, c, d, e; - - for (i = 0; i < 16; i += 4) - { - a = buf[i]; - b = buf[i + 1]; - c = buf[i + 2]; - d = buf[i + 3]; - e = a ^ b ^ c ^ d; - buf[i] ^= e ^ rj_xtime(a ^ b); - buf[i + 1] ^= e ^ rj_xtime(b ^ c); - buf[i + 2] ^= e ^ rj_xtime(c ^ d); - buf[i + 3] ^= e ^ rj_xtime(d ^ a); - } -} /* aes_mixColumns */ - -/* -------------------------------------------------------------------------- */ -void aes_mixColumns_inv(uint8_t *buf) -{ - register uint8_t i, a, b, c, d, e, x, y, z; - - for (i = 0; i < 16; i += 4) - { - a = buf[i]; - b = buf[i + 1]; - c = buf[i + 2]; - d = buf[i + 3]; - e = a ^ b ^ c ^ d; - z = rj_xtime(e); - x = e ^ rj_xtime(rj_xtime(z ^ a ^ c)); - y = e ^ rj_xtime(rj_xtime(z ^ b ^ d)); - buf[i] ^= x ^ rj_xtime(a ^ b); - buf[i + 1] ^= y ^ rj_xtime(b ^ c); - buf[i + 2] ^= x ^ rj_xtime(c ^ d); - buf[i + 3] ^= y ^ rj_xtime(d ^ a); - } -} /* aes_mixColumns_inv */ - -/* -------------------------------------------------------------------------- */ -static void aes_expandEncKey(uint8_t *k, uint8_t *rc) -{ - register uint8_t i; - - k[0] ^= rj_sbox(k[29]) ^ (*rc); - k[1] ^= rj_sbox(k[30]); - k[2] ^= rj_sbox(k[31]); - k[3] ^= rj_sbox(k[28]); - *rc = rj_xtime( *rc); - - for(i = 4; i < 16; i += 4) k[i] ^= k[i - 4], k[i + 1] ^= k[i - 3], - k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1]; - k[16] ^= rj_sbox(k[12]); - k[17] ^= rj_sbox(k[13]); - k[18] ^= rj_sbox(k[14]); - k[19] ^= rj_sbox(k[15]); - - for(i = 20; i < 32; i += 4) k[i] ^= k[i - 4], k[i + 1] ^= k[i - 3], - k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1]; - -} /* aes_expandEncKey */ - -/* -------------------------------------------------------------------------- */ -void aes_expandDecKey(uint8_t *k, uint8_t *rc) -{ - uint8_t i; - - for(i = 28; i > 16; i -= 4) k[i + 0] ^= k[i - 4], k[i + 1] ^= k[i - 3], - k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1]; - - k[16] ^= rj_sbox(k[12]); - k[17] ^= rj_sbox(k[13]); - k[18] ^= rj_sbox(k[14]); - k[19] ^= rj_sbox(k[15]); - - for(i = 12; i > 0; i -= 4) k[i + 0] ^= k[i - 4], k[i + 1] ^= k[i - 3], - k[i + 2] ^= k[i - 2], k[i + 3] ^= k[i - 1]; - - *rc = FD(*rc); - k[0] ^= rj_sbox(k[29]) ^ (*rc); - k[1] ^= rj_sbox(k[30]); - k[2] ^= rj_sbox(k[31]); - k[3] ^= rj_sbox(k[28]); -} /* aes_expandDecKey */ - - -/* -------------------------------------------------------------------------- */ -void aes256_init(aes256_context *ctx, uint8_t *k) -{ - uint8_t rcon = 1; - register uint8_t i; - - for (i = 0; i < sizeof(ctx->key); i++) ctx->enckey[i] = ctx->deckey[i] = k[i]; - for (i = 8; --i;) aes_expandEncKey(ctx->deckey, &rcon); -} /* aes256_init */ - -/* -------------------------------------------------------------------------- */ -void aes256_done(aes256_context *ctx) -{ - register uint8_t i; - - for (i = 0; i < sizeof(ctx->key); i++) - ctx->key[i] = ctx->enckey[i] = ctx->deckey[i] = 0; -} /* aes256_done */ - -/* -------------------------------------------------------------------------- */ -void aes256_encrypt_ecb(aes256_context *ctx, uint8_t *buf) -{ - uint8_t i, rcon; - - aes_addRoundKey_cpy(buf, ctx->enckey, ctx->key); - for(i = 1, rcon = 1; i < 14; ++i) - { - aes_subBytes(buf); - aes_shiftRows(buf); - aes_mixColumns(buf); - if( i & 1 ) aes_addRoundKey( buf, &ctx->key[16]); - else aes_expandEncKey(ctx->key, &rcon), aes_addRoundKey(buf, ctx->key); - } - aes_subBytes(buf); - aes_shiftRows(buf); - aes_expandEncKey(ctx->key, &rcon); - aes_addRoundKey(buf, ctx->key); -} /* aes256_encrypt */ - -/* -------------------------------------------------------------------------- */ -void aes256_decrypt_ecb(aes256_context *ctx, uint8_t *buf) -{ - uint8_t i, rcon; - - aes_addRoundKey_cpy(buf, ctx->deckey, ctx->key); - aes_shiftRows_inv(buf); - aes_subBytes_inv(buf); - - for (i = 14, rcon = 0x80; --i;) - { - if( ( i & 1 ) ) - { - aes_expandDecKey(ctx->key, &rcon); - aes_addRoundKey(buf, &ctx->key[16]); - } - else aes_addRoundKey(buf, ctx->key); - aes_mixColumns_inv(buf); - aes_shiftRows_inv(buf); - aes_subBytes_inv(buf); - } - aes_addRoundKey( buf, ctx->key); -} /* aes256_decrypt */ diff --git a/thirdparty/misc/aes256.h b/thirdparty/misc/aes256.h deleted file mode 100644 index 150a0670f5..0000000000 --- a/thirdparty/misc/aes256.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Byte-oriented AES-256 implementation. -* All lookup tables replaced with 'on the fly' calculations. -* -* Copyright (c) 2007-2009 Ilya O. Levin, http://www.literatecode.com -* Other contributors: Hal Finney -* -* Permission to use, copy, modify, and 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. -*/ - -#ifndef AES_256_H -#define AES_256_H - -#include "core/typedefs.h" - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct { - uint8_t key[32]; - uint8_t enckey[32]; - uint8_t deckey[32]; - } aes256_context; - - - void aes256_init(aes256_context *, uint8_t * /* key */); - void aes256_done(aes256_context *); - void aes256_encrypt_ecb(aes256_context *, uint8_t * /* plaintext */); - void aes256_decrypt_ecb(aes256_context *, uint8_t * /* cipertext */); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/thirdparty/misc/base64.c b/thirdparty/misc/base64.c deleted file mode 100644 index 0929ae5db5..0000000000 --- a/thirdparty/misc/base64.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * File: base64.c - * Description: Simple BASE64 conversion methods - * Author: Ari Edelkind - * License: Public Domain - * Website: http://episec.com/people/edelkind/c.html - */ - -#include <string.h> - -char b64string[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -long base64_encode (to, from, len) - char *to, *from; - unsigned int len; -{ - char *fromp = from; - char *top = to; - unsigned char cbyte; - unsigned char obyte; - char end[3]; - - for (; len >= 3; len -= 3) { - cbyte = *fromp++; - *top++ = b64string[(int)(cbyte >> 2)]; - obyte = (cbyte << 4) & 0x30; /* 0011 0000 */ - - cbyte = *fromp++; - obyte |= (cbyte >> 4); /* 0000 1111 */ - *top++ = b64string[(int)obyte]; - obyte = (cbyte << 2) & 0x3C; /* 0011 1100 */ - - cbyte = *fromp++; - obyte |= (cbyte >> 6); /* 0000 0011 */ - *top++ = b64string[(int)obyte]; - *top++ = b64string[(int)(cbyte & 0x3F)];/* 0011 1111 */ - } - - if (len) { - end[0] = *fromp++; - if (--len) end[1] = *fromp++; else end[1] = 0; - end[2] = 0; - - cbyte = end[0]; - *top++ = b64string[(int)(cbyte >> 2)]; - obyte = (cbyte << 4) & 0x30; /* 0011 0000 */ - - cbyte = end[1]; - obyte |= (cbyte >> 4); - *top++ = b64string[(int)obyte]; - obyte = (cbyte << 2) & 0x3C; /* 0011 1100 */ - - if (len) *top++ = b64string[(int)obyte]; - else *top++ = '='; - *top++ = '='; - } - *top = 0; - return top - to; -} - -/* badchar(): check if c is decent; puts either the */ -/* location of c or null into p. */ -#define badchar(c,p) (!(p = memchr(b64string, c, 64))) - -long base64_decode (to, from, len) - char *to, *from; - unsigned int len; -{ - char *fromp = from; - char *top = to; - char *p; - unsigned char cbyte; - unsigned char obyte; - int padding = 0; - - for (; len >= 4; len -= 4) { - if ((cbyte = *fromp++) == '=') cbyte = 0; - else { - if (badchar(cbyte, p)) return -1; - cbyte = (p - b64string); - } - obyte = cbyte << 2; /* 1111 1100 */ - - if ((cbyte = *fromp++) == '=') cbyte = 0; - else { - if (badchar(cbyte, p)) return -1; - cbyte = p - b64string; - } - obyte |= cbyte >> 4; /* 0000 0011 */ - *top++ = obyte; - - obyte = cbyte << 4; /* 1111 0000 */ - if ((cbyte = *fromp++) == '=') { cbyte = 0; padding++; } - else { - padding = 0; - if (badchar (cbyte, p)) return -1; - cbyte = p - b64string; - } - obyte |= cbyte >> 2; /* 0000 1111 */ - *top++ = obyte; - - obyte = cbyte << 6; /* 1100 0000 */ - if ((cbyte = *fromp++) == '=') { cbyte = 0; padding++; } - else { - padding = 0; - if (badchar (cbyte, p)) return -1; - cbyte = p - b64string; - } - obyte |= cbyte; /* 0011 1111 */ - *top++ = obyte; - } - - *top = 0; - if (len) return -1; - return (top - to) - padding; -} - diff --git a/thirdparty/misc/base64.h b/thirdparty/misc/base64.h deleted file mode 100644 index ffcd0af973..0000000000 --- a/thirdparty/misc/base64.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * File: base64.h - * Description: Simple BASE64 conversion methods - * Author: Ari Edelkind - * License: Public Domain - * Website: http://episec.com/people/edelkind/c.html - */ - -#ifndef BASE64_H -#define BASE64_H - -extern "C" { - -long base64_encode(char *to, char *from, unsigned int len); -long base64_decode(char *to, char *from, unsigned int len); -}; - -#endif /* BASE64_H */ diff --git a/thirdparty/misc/md5.cpp b/thirdparty/misc/md5.cpp deleted file mode 100644 index 1653ab0be5..0000000000 --- a/thirdparty/misc/md5.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* - ********************************************************************** - ** md5.c ** - ** RSA Data Security, Inc. MD5 Message Digest Algorithm ** - ** Created: 2/17/90 RLR ** - ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version ** - ********************************************************************** - */ - -/* - ********************************************************************** - ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** - ** ** - ** License to copy and use this software is granted provided that ** - ** it is identified as the "RSA Data Security, Inc. MD5 Message ** - ** Digest Algorithm" in all material mentioning or referencing this ** - ** software or this function. ** - ** ** - ** License is also granted to make and use derivative works ** - ** provided that such works are identified as "derived from the RSA ** - ** Data Security, Inc. MD5 Message Digest Algorithm" in all ** - ** material mentioning or referencing the derived work. ** - ** ** - ** RSA Data Security, Inc. makes no representations concerning ** - ** either the merchantability of this software or the suitability ** - ** of this software for any particular purpose. It is provided "as ** - ** is" without express or implied warranty of any kind. ** - ** ** - ** These notices must be retained in any copies of any part of this ** - ** documentation and/or software. ** - ********************************************************************** - */ - -/* -- include the following line if the md5.h header file is separate -- */ -#include "md5.h" - -/* forward declaration */ -static void Transform (uint32_t *buf, uint32_t *in); - - -static unsigned char PADDING[64] = { - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -/* F, G and H are basic MD5 functions: selection, majority, parity */ -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -/* ROTATE_LEFT rotates x left n bits */ -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */ -/* Rotation is separate from addition to prevent recomputation */ -#define FF(a, b, c, d, x, s, ac) \ - {(a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) \ - {(a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) \ - {(a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) \ - {(a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -void MD5Init (MD5_CTX *mdContext) -{ - mdContext->i[0] = mdContext->i[1] = (uint32_t)0; - - /* Load magic initialization constants. - */ - mdContext->buf[0] = (uint32_t)0x67452301; - mdContext->buf[1] = (uint32_t)0xefcdab89; - mdContext->buf[2] = (uint32_t)0x98badcfe; - mdContext->buf[3] = (uint32_t)0x10325476; -} - -void MD5Update (MD5_CTX *mdContext,unsigned char *inBuf,unsigned int inLen) { - uint32_t in[16]; - int mdi; - unsigned int i, ii; - - /* compute number of bytes mod 64 */ - mdi = (int)((mdContext->i[0] >> 3) & 0x3F); - - /* update number of bits */ - if ((mdContext->i[0] + ((uint32_t)inLen << 3)) < mdContext->i[0]) - mdContext->i[1]++; - mdContext->i[0] += ((uint32_t)inLen << 3); - mdContext->i[1] += ((uint32_t)inLen >> 29); - - while (inLen--) { - /* add new character to buffer, increment mdi */ - mdContext->in[mdi++] = *inBuf++; - - /* transform if necessary */ - if (mdi == 0x40) { - for (i = 0, ii = 0; i < 16; i++, ii += 4) - in[i] = (((uint32_t)mdContext->in[ii+3]) << 24) | - (((uint32_t)mdContext->in[ii+2]) << 16) | - (((uint32_t)mdContext->in[ii+1]) << 8) | - ((uint32_t)mdContext->in[ii]); - Transform (mdContext->buf, in); - mdi = 0; - } - } -} - -void MD5Final (MD5_CTX *mdContext) { - uint32_t in[16]; - int mdi; - unsigned int i, ii; - unsigned int padLen; - - /* save number of bits */ - in[14] = mdContext->i[0]; - in[15] = mdContext->i[1]; - - /* compute number of bytes mod 64 */ - mdi = (int)((mdContext->i[0] >> 3) & 0x3F); - - /* pad out to 56 mod 64 */ - padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); - MD5Update (mdContext, PADDING, padLen); - - /* append length in bits and transform */ - for (i = 0, ii = 0; i < 14; i++, ii += 4) - in[i] = (((uint32_t)mdContext->in[ii+3]) << 24) | - (((uint32_t)mdContext->in[ii+2]) << 16) | - (((uint32_t)mdContext->in[ii+1]) << 8) | - ((uint32_t)mdContext->in[ii]); - Transform (mdContext->buf, in); - - /* store buffer in digest */ - for (i = 0, ii = 0; i < 4; i++, ii += 4) { - mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF); - mdContext->digest[ii+1] = - (unsigned char)((mdContext->buf[i] >> 8) & 0xFF); - mdContext->digest[ii+2] = - (unsigned char)((mdContext->buf[i] >> 16) & 0xFF); - mdContext->digest[ii+3] = - (unsigned char)((mdContext->buf[i] >> 24) & 0xFF); - } -} - -/* Basic MD5 step. Transform buf based on in. - */ -static void Transform (uint32_t *buf, uint32_t *in) { - uint32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3]; - - /* Round 1 */ -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 - FF ( a, b, c, d, in[ 0], S11, 3614090360); /* 1 */ - FF ( d, a, b, c, in[ 1], S12, 3905402710); /* 2 */ - FF ( c, d, a, b, in[ 2], S13, 606105819); /* 3 */ - FF ( b, c, d, a, in[ 3], S14, 3250441966); /* 4 */ - FF ( a, b, c, d, in[ 4], S11, 4118548399); /* 5 */ - FF ( d, a, b, c, in[ 5], S12, 1200080426); /* 6 */ - FF ( c, d, a, b, in[ 6], S13, 2821735955); /* 7 */ - FF ( b, c, d, a, in[ 7], S14, 4249261313); /* 8 */ - FF ( a, b, c, d, in[ 8], S11, 1770035416); /* 9 */ - FF ( d, a, b, c, in[ 9], S12, 2336552879); /* 10 */ - FF ( c, d, a, b, in[10], S13, 4294925233); /* 11 */ - FF ( b, c, d, a, in[11], S14, 2304563134); /* 12 */ - FF ( a, b, c, d, in[12], S11, 1804603682); /* 13 */ - FF ( d, a, b, c, in[13], S12, 4254626195); /* 14 */ - FF ( c, d, a, b, in[14], S13, 2792965006); /* 15 */ - FF ( b, c, d, a, in[15], S14, 1236535329); /* 16 */ - - /* Round 2 */ -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 - GG ( a, b, c, d, in[ 1], S21, 4129170786); /* 17 */ - GG ( d, a, b, c, in[ 6], S22, 3225465664); /* 18 */ - GG ( c, d, a, b, in[11], S23, 643717713); /* 19 */ - GG ( b, c, d, a, in[ 0], S24, 3921069994); /* 20 */ - GG ( a, b, c, d, in[ 5], S21, 3593408605); /* 21 */ - GG ( d, a, b, c, in[10], S22, 38016083); /* 22 */ - GG ( c, d, a, b, in[15], S23, 3634488961); /* 23 */ - GG ( b, c, d, a, in[ 4], S24, 3889429448); /* 24 */ - GG ( a, b, c, d, in[ 9], S21, 568446438); /* 25 */ - GG ( d, a, b, c, in[14], S22, 3275163606); /* 26 */ - GG ( c, d, a, b, in[ 3], S23, 4107603335); /* 27 */ - GG ( b, c, d, a, in[ 8], S24, 1163531501); /* 28 */ - GG ( a, b, c, d, in[13], S21, 2850285829); /* 29 */ - GG ( d, a, b, c, in[ 2], S22, 4243563512); /* 30 */ - GG ( c, d, a, b, in[ 7], S23, 1735328473); /* 31 */ - GG ( b, c, d, a, in[12], S24, 2368359562); /* 32 */ - - /* Round 3 */ -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 - HH ( a, b, c, d, in[ 5], S31, 4294588738); /* 33 */ - HH ( d, a, b, c, in[ 8], S32, 2272392833); /* 34 */ - HH ( c, d, a, b, in[11], S33, 1839030562); /* 35 */ - HH ( b, c, d, a, in[14], S34, 4259657740); /* 36 */ - HH ( a, b, c, d, in[ 1], S31, 2763975236); /* 37 */ - HH ( d, a, b, c, in[ 4], S32, 1272893353); /* 38 */ - HH ( c, d, a, b, in[ 7], S33, 4139469664); /* 39 */ - HH ( b, c, d, a, in[10], S34, 3200236656); /* 40 */ - HH ( a, b, c, d, in[13], S31, 681279174); /* 41 */ - HH ( d, a, b, c, in[ 0], S32, 3936430074); /* 42 */ - HH ( c, d, a, b, in[ 3], S33, 3572445317); /* 43 */ - HH ( b, c, d, a, in[ 6], S34, 76029189); /* 44 */ - HH ( a, b, c, d, in[ 9], S31, 3654602809); /* 45 */ - HH ( d, a, b, c, in[12], S32, 3873151461); /* 46 */ - HH ( c, d, a, b, in[15], S33, 530742520); /* 47 */ - HH ( b, c, d, a, in[ 2], S34, 3299628645); /* 48 */ - - /* Round 4 */ -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - II ( a, b, c, d, in[ 0], S41, 4096336452); /* 49 */ - II ( d, a, b, c, in[ 7], S42, 1126891415); /* 50 */ - II ( c, d, a, b, in[14], S43, 2878612391); /* 51 */ - II ( b, c, d, a, in[ 5], S44, 4237533241); /* 52 */ - II ( a, b, c, d, in[12], S41, 1700485571); /* 53 */ - II ( d, a, b, c, in[ 3], S42, 2399980690); /* 54 */ - II ( c, d, a, b, in[10], S43, 4293915773); /* 55 */ - II ( b, c, d, a, in[ 1], S44, 2240044497); /* 56 */ - II ( a, b, c, d, in[ 8], S41, 1873313359); /* 57 */ - II ( d, a, b, c, in[15], S42, 4264355552); /* 58 */ - II ( c, d, a, b, in[ 6], S43, 2734768916); /* 59 */ - II ( b, c, d, a, in[13], S44, 1309151649); /* 60 */ - II ( a, b, c, d, in[ 4], S41, 4149444226); /* 61 */ - II ( d, a, b, c, in[11], S42, 3174756917); /* 62 */ - II ( c, d, a, b, in[ 2], S43, 718787259); /* 63 */ - II ( b, c, d, a, in[ 9], S44, 3951481745); /* 64 */ - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; -} - -/* - ********************************************************************** - ** End of md5.c ** - ******************************* (cut) ******************************** - */ diff --git a/thirdparty/misc/md5.h b/thirdparty/misc/md5.h deleted file mode 100644 index 14b3cd3ddf..0000000000 --- a/thirdparty/misc/md5.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef MD5_H -#define MD5_H - -/* - ********************************************************************** - ** md5.h -- Header file for implementation of MD5 ** - ** RSA Data Security, Inc. MD5 Message Digest Algorithm ** - ** Created: 2/17/90 RLR ** - ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** - ** Revised (for MD5): RLR 4/27/91 ** - ** -- G modified to have y&~z instead of y&z ** - ** -- FF, GG, HH modified to add in last register done ** - ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** - ** -- distinct additive constant for each step ** - ** -- round 4 added, working mod 7 ** - ********************************************************************** - */ - -/* - ********************************************************************** - ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** - ** ** - ** License to copy and use this software is granted provided that ** - ** it is identified as the "RSA Data Security, Inc. MD5 Message ** - ** Digest Algorithm" in all material mentioning or referencing this ** - ** software or this function. ** - ** ** - ** License is also granted to make and use derivative works ** - ** provided that such works are identified as "derived from the RSA ** - ** Data Security, Inc. MD5 Message Digest Algorithm" in all ** - ** material mentioning or referencing the derived work. ** - ** ** - ** RSA Data Security, Inc. makes no representations concerning ** - ** either the merchantability of this software or the suitability ** - ** of this software for any particular purpose. It is provided "as ** - ** is" without express or implied warranty of any kind. ** - ** ** - ** These notices must be retained in any copies of any part of this ** - ** documentation and/or software. ** - ********************************************************************** - */ - -/* NOT typedef a 32 bit type */ - -#include "core/typedefs.h" - -/* Data structure for MD5 (Message Digest) computation */ -typedef struct { - uint32_t i[2]; /* number of _bits_ handled mod 2^64 */ - uint32_t buf[4]; /* scratch buffer */ - unsigned char in[64]; /* input buffer */ - unsigned char digest[16]; /* actual digest after MD5Final call */ -} MD5_CTX; - -void MD5Init (MD5_CTX *mdContext); -void MD5Update (MD5_CTX *mdContext,unsigned char *inBuf,unsigned int inLen); -void MD5Final (MD5_CTX *mdContext); - - - -#endif // MD5_H diff --git a/thirdparty/misc/sha256.c b/thirdparty/misc/sha256.c deleted file mode 100644 index 68a4339af9..0000000000 --- a/thirdparty/misc/sha256.c +++ /dev/null @@ -1,245 +0,0 @@ -/* -* SHA-256 implementation. -* -* Copyright (c) 2010 Ilya O. Levin, http://www.literatecode.com -* -* Permission to use, copy, modify, and 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. -*/ -#define SWAP_BYTES -// #define USE_STD_MEMCPY -// #define SELF_TEST - -#ifdef USE_STD_MEMCPY -#include <string.h> -#endif -#include "sha256.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define RL(x,n) (((x) << n) | ((x) >> (32 - n))) -#define RR(x,n) (((x) >> n) | ((x) << (32 - n))) - -#define S0(x) (RR((x), 2) ^ RR((x),13) ^ RR((x),22)) -#define S1(x) (RR((x), 6) ^ RR((x),11) ^ RR((x),25)) -#define G0(x) (RR((x), 7) ^ RR((x),18) ^ ((x) >> 3)) -#define G1(x) (RR((x),17) ^ RR((x),19) ^ ((x) >> 10)) - -#ifdef SWAP_BYTES -#define BSWP(x,y) _bswapw((uint32_t *)(x), (uint32_t)(y)) -#else -#define BSWP(p,n) -#endif -#ifdef USE_STD_MEMCPY -#define MEMCP(x,y,z) memcpy((x),(y),(z)) -#else -#define MEMCP(x,y,z) _memcp((x),(y),(z)) -#endif - -#ifndef __cdecl -#define __cdecl -#endif - -static const uint32_t K[64] = { - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, - 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, - 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, - 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, - 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, - 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 -}; - -/* -------------------------------------------------------------------------- */ -static void _bswapw(uint32_t *p, uint32_t i) -{ - while (i--) p[i] = (RR(p[i],24) & 0x00ff00ff) | (RR(p[i],8) & 0xff00ff00); - -} /* _bswapw */ - -/* -------------------------------------------------------------------------- */ -#ifndef USE_STD_MEMCPY -void * __cdecl _memcp (void *d, const void *s, uint32_t sz) -{ - void *rv = d; - - while (sz--) *(char *)d = *(char *)s, d = (char *)d + 1, s = (char *)s + 1; - - return(rv); -} /* _memcp */ -#endif - -/* -------------------------------------------------------------------------- */ -static void _rtrf(uint32_t *b, uint32_t *p, uint32_t i, uint32_t j) -{ - #define B(x, y) b[(x-y) & 7] - #define P(x, y) p[(x+y) & 15] - - B(7,i) += (j ? (p[i & 15] += G1(P(i,14)) + P(i,9) + G0(P(i,1))) : p[i & 15]) - + K[i+j] + S1(B(4,i)) - + (B(6,i) ^ (B(4,i) & (B(5,i) ^ B(6,i)))); - B(3,i) += B(7,i); - B(7,i) += S0(B(0,i)) + ( (B(0,i) & B(1,i)) | (B(2,i) & (B(0,i) ^ B(1,i))) ); - - #undef P - #undef B -} /* _rtrf */ - -/* -------------------------------------------------------------------------- */ -static void _hash(sha256_context *ctx) -{ - uint32_t b[8], *p, j; - - b[0] = ctx->hash[0]; b[1] = ctx->hash[1]; b[2] = ctx->hash[2]; - b[3] = ctx->hash[3]; b[4] = ctx->hash[4]; b[5] = ctx->hash[5]; - b[6] = ctx->hash[6]; b[7] = ctx->hash[7]; - - for (p = ctx->buf, j = 0; j < 64; j += 16) - _rtrf(b, p, 0, j), _rtrf(b, p, 1, j), _rtrf(b, p, 2, j), - _rtrf(b, p, 3, j), _rtrf(b, p, 4, j), _rtrf(b, p, 5, j), - _rtrf(b, p, 6, j), _rtrf(b, p, 7, j), _rtrf(b, p, 8, j), - _rtrf(b, p, 9, j), _rtrf(b, p, 10, j), _rtrf(b, p, 11, j), - _rtrf(b, p, 12, j), _rtrf(b, p, 13, j), _rtrf(b, p, 14, j), - _rtrf(b, p, 15, j); - - ctx->hash[0] += b[0]; ctx->hash[1] += b[1]; ctx->hash[2] += b[2]; - ctx->hash[3] += b[3]; ctx->hash[4] += b[4]; ctx->hash[5] += b[5]; - ctx->hash[6] += b[6]; ctx->hash[7] += b[7]; - -} /* _hash */ - -/* -------------------------------------------------------------------------- */ -void sha256_init(sha256_context ctx[1]) -{ - ctx->len[0] = ctx->len[1] = 0; - ctx->hash[0] = 0x6a09e667; ctx->hash[1] = 0xbb67ae85; - ctx->hash[2] = 0x3c6ef372; ctx->hash[3] = 0xa54ff53a; - ctx->hash[4] = 0x510e527f; ctx->hash[5] = 0x9b05688c; - ctx->hash[6] = 0x1f83d9ab; ctx->hash[7] = 0x5be0cd19; - -} /* sha256_init */ - -/* -------------------------------------------------------------------------- */ -void sha256_hash(sha256_context *ctx, uint8_t *dat, uint32_t sz) -{ - register uint32_t i = ctx->len[0] & 63, l, j; - - if ((ctx->len[0] += sz) < sz) ++(ctx->len[1]); - - for (j = 0, l = 64-i; sz >= l; j += l, sz -= l, l = 64, i = 0) - { - MEMCP(&ctx->buf[i], &dat[j], l); - BSWP(ctx->buf, 16 ); - _hash(ctx); - } - MEMCP(&ctx->buf[i], &dat[j], sz); - -} /* _hash */ - -/* -------------------------------------------------------------------------- */ -void sha256_done(sha256_context *ctx, uint8_t *buf) -{ - uint32_t i = (uint32_t)(ctx->len[0] & 63), j = ((~i) & 3) << 3; - - BSWP(ctx->buf, (i + 3) >> 2); - - ctx->buf[i >> 2] &= 0xffffff80 << j; /* add padding */ - ctx->buf[i >> 2] |= 0x00000080 << j; - - if (i < 56) i = (i >> 2) + 1; - else ctx->buf[15] ^= (i < 60) ? ctx->buf[15] : 0, _hash(ctx), i = 0; - - while (i < 14) ctx->buf[i++] = 0; - - ctx->buf[14] = (ctx->len[1] << 3)|(ctx->len[0] >> 29); /* add length */ - ctx->buf[15] = ctx->len[0] << 3; - - _hash(ctx); - - for (i = 0; i < 32; i++) - ctx->buf[i % 16] = 0, /* may remove this line in case of a DIY cleanup */ - buf[i] = (uint8_t)(ctx->hash[i >> 2] >> ((~i & 3) << 3)); - -} /* sha256_done */ - - -#ifdef SELF_TEST -#pragma warning (push, 0) -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#pragma warning(pop) - -char *buf[] = { - "", - "e3b0c442 98fc1c14 9afbf4c8 996fb924 27ae41e4 649b934c a495991b 7852b855", - - "abc", - "ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad", - - "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - "248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1", - - "The quick brown fox jumps over the lazy dog", - "d7a8fbb3 07d78094 69ca9abc b0082e4f 8d5651e4 6d3cdb76 2d02d0bf 37c9e592", - - "The quick brown fox jumps over the lazy cog", /* avalanche effect test */ - "e4c4d8f3 bf76b692 de791a17 3e053211 50f7a345 b46484fe 427f6acc 7ecc81be", - - "bhn5bjmoniertqea40wro2upyflkydsibsk8ylkmgbvwi420t44cq034eou1szc1k0mk46oeb7ktzmlxqkbte2sy", - "9085df2f 02e0cc45 5928d0f5 1b27b4bf 1d9cd260 a66ed1fd a11b0a3f f5756d99" -}; - -int main(int argc, char *argv[]) -{ - sha256_context ctx; - uint8_t hv[32]; - uint32_t i, j; - - for (j = 0; j < (sizeof(buf)/sizeof(buf[0])); j += 2) - { - sha256_init(&ctx); - sha256_hash(&ctx, (uint8_t *)buf[j], (uint32_t)strlen(buf[j])); - sha256_done(&ctx, hv); - printf("input = %s\ndigest: %s\nresult: ", buf[j], buf[j+1]); - for (i = 0; i < 32; i++) printf("%02x%s", hv[i], ((i%4)==3)?" ":""); - printf("\n\n"); - } - - for (j = 1; j < (uint32_t)argc; j++) - { - printf("argv[%d]: %s\nresult: ", (int)j, argv[j]); - sha256_init(&ctx); - sha256_hash(&ctx, (uint8_t *)argv[j], (uint32_t)strlen(argv[j])); - sha256_done(&ctx, hv); - for (i = 0; i < 32; i++) printf("%02x%s", hv[i], ((i%4)==3)?" ":""); - printf("\n\n"); - } - - return 0; -} /* main */ -#endif - -#ifdef __cplusplus -} -#endif diff --git a/thirdparty/misc/sha256.h b/thirdparty/misc/sha256.h deleted file mode 100644 index e19e56b4cc..0000000000 --- a/thirdparty/misc/sha256.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -* SHA-256 implementation. -* -* Copyright (c) 2010 Ilya O. Levin, http://www.literatecode.com -* -* Permission to use, copy, modify, and 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. -*/ -#ifdef _MSC_VER -#ifndef uint8_t -typedef unsigned __int8 uint8_t; -#endif -#ifndef uint32_t -typedef unsigned __int32 uint32_t; -#endif -#ifndef uint64_t -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#endif -#else -#include <stdint.h> -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - - typedef struct { - uint32_t buf[16]; - uint32_t hash[8]; - uint32_t len[2]; - } sha256_context; - - void sha256_init(sha256_context *); - void sha256_hash(sha256_context *, uint8_t * /* data */, uint32_t /* len */); - void sha256_done(sha256_context *, uint8_t * /* hash */); - -#ifdef __cplusplus -} -#endif |