aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorwiso <wiso@svn>2010-06-29 19:56:55 +0000
committerwiso <wiso@svn>2010-06-29 19:56:55 +0000
commitf198eec42b1a55ee19389fd739f3b21ca2d44c71 (patch)
tree4c679545cd3934979106eabc7a1d3c1e95cad9eb /lib
parent575961a703d12c188b287d374e1420c79c9ac313 (diff)
[WIN32] reverted r31502-31503 by request
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31504 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'lib')
-rw-r--r--lib/librtmp_win32/Makefile_win3286
-rw-r--r--lib/librtmp_win32/librtmp/amf.h161
-rw-r--r--lib/librtmp_win32/librtmp/bytes.h91
-rw-r--r--lib/librtmp_win32/librtmp/dh.h334
-rw-r--r--lib/librtmp_win32/librtmp/dhgroups.h199
-rw-r--r--lib/librtmp_win32/librtmp/handshake.h1093
-rw-r--r--lib/librtmp_win32/librtmp/http.h47
-rw-r--r--lib/librtmp_win32/librtmp/log.h63
-rw-r--r--lib/librtmp_win32/librtmp/rtmp.h345
-rw-r--r--lib/librtmp_win32/librtmp/rtmp_sys.h112
-rw-r--r--lib/librtmp_win32/readme.txt5
11 files changed, 0 insertions, 2536 deletions
diff --git a/lib/librtmp_win32/Makefile_win32 b/lib/librtmp_win32/Makefile_win32
deleted file mode 100644
index a6a046d949..0000000000
--- a/lib/librtmp_win32/Makefile_win32
+++ /dev/null
@@ -1,86 +0,0 @@
-VERSION=v2.2f
-
-prefix=/usr/local
-
-CC=$(CROSS_COMPILE)gcc
-LD=$(CROSS_COMPILE)ld
-AR=$(CROSS_COMPILE)ar
-
-CRYPTO=OPENSSL
-#CRYPTO=GNUTLS
-DEF_POLARSSL=-DUSE_POLARSSL
-DEF_OPENSSL=-DUSE_OPENSSL
-DEF_GNUTLS=-DUSE_GNUTLS
-DEF_=-DNO_CRYPTO
-REQ_GNUTLS=gnutls
-REQ_OPENSSL=libssl,libcrypto
-LIB_GNUTLS=-lgnutls -lgcrypt
-LIB_OPENSSL=-lssl -lcrypto
-LIB_POLARSSL=-lpolarssl
-CRYPTO_LIB=$(LIB_$(CRYPTO))
-CRYPTO_REQ=$(REQ_$(CRYPTO))
-CRYPTO_DEF=$(DEF_$(CRYPTO))
-
-SHARED=SO
-SODEF_=
-SODEF_SO=-fPIC
-SOLIB_=
-SOLIB_SO=librtmp.so
-SOINST_=
-SOINST_SO=install_so
-SO_DEF=$(SODEF_$(SHARED))
-SO_LIB=$(SOLIB_$(SHARED))
-SO_INST=$(SOINST_$(SHARED))
-
-DEF=-DRTMPDUMP_VERSION=\"$(VERSION)\" $(CRYPTO_DEF) $(XDEF)
-OPT=-O2
-CFLAGS=-Wall $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
-
-incdir=$(prefix)/include/librtmp
-libdir=$(prefix)/lib
-mandir=$(prefix)/man
-INCDIR=$(DESTDIR)$(incdir)
-LIBDIR=$(DESTDIR)$(libdir)
-MANDIR=$(DESTDIR)$(mandir)
-
-OBJS=rtmp.o log.o amf.o hashswf.o parseurl.o
-
-all: librtmp.a $(SO_LIB)
-
-clean:
- rm -f *.o *.a *.dll
-
-librtmp.a: $(OBJS)
- $(AR) rs $@ $?
-
-librtmp.dll: $(OBJS)
- $(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB) -lws2_32 -lwinmm -lz
-
-librtmp.so.0: $(OBJS)
- $(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
-
-librtmp.so: librtmp.so.0
- ln -sf $? $@
-
-log.o: log.c log.h Makefile
-rtmp.o: rtmp.c rtmp.h rtmp_sys.h handshake.h dh.h log.h amf.h Makefile
-amf.o: amf.c amf.h bytes.h log.h Makefile
-hashswf.o: hashswf.c http.h rtmp.h rtmp_sys.h Makefile
-parseurl.o: parseurl.c rtmp.h rtmp_sys.h log.h Makefile
-
-librtmp.pc: librtmp.pc.in Makefile
- sed -e "s;@prefix@;$(prefix);" -e "s;@VERSION@;$(VERSION);" \
- -e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" librtmp.pc.in > $@
-
-install: install_base $(SO_INST)
-
-install_base: librtmp.a librtmp.pc
- -mkdir -p $(INCDIR) $(LIBDIR)/pkgconfig $(MANDIR)/man3
- cp amf.h http.h log.h rtmp.h $(INCDIR)
- cp librtmp.a $(LIBDIR)
- cp librtmp.pc $(LIBDIR)/pkgconfig
- cp librtmp.3 $(MANDIR)/man3
-
-install_so: librtmp.so.0
- cp librtmp.so.0 $(LIBDIR)
- cd $(LIBDIR); ln -sf librtmp.so.0 librtmp.so
diff --git a/lib/librtmp_win32/librtmp/amf.h b/lib/librtmp_win32/librtmp/amf.h
deleted file mode 100644
index b945beb5f8..0000000000
--- a/lib/librtmp_win32/librtmp/amf.h
+++ /dev/null
@@ -1,161 +0,0 @@
-#ifndef __AMF_H__
-#define __AMF_H__
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- * Copyright (C) 2008-2009 Andrej Stepanchuk
- * Copyright (C) 2009-2010 Howard Chu
- *
- * This file is part of librtmp.
- *
- * librtmp is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1,
- * or (at your option) any later version.
- *
- * librtmp is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with librtmp see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/lgpl.html
- */
-
-#include <stdint.h>
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- typedef enum
- { AMF_NUMBER = 0, AMF_BOOLEAN, AMF_STRING, AMF_OBJECT,
- AMF_MOVIECLIP, /* reserved, not used */
- AMF_NULL, AMF_UNDEFINED, AMF_REFERENCE, AMF_ECMA_ARRAY, AMF_OBJECT_END,
- AMF_STRICT_ARRAY, AMF_DATE, AMF_LONG_STRING, AMF_UNSUPPORTED,
- AMF_RECORDSET, /* reserved, not used */
- AMF_XML_DOC, AMF_TYPED_OBJECT,
- AMF_AVMPLUS, /* switch to AMF3 */
- AMF_INVALID = 0xff
- } AMFDataType;
-
- typedef enum
- { AMF3_UNDEFINED = 0, AMF3_NULL, AMF3_FALSE, AMF3_TRUE,
- AMF3_INTEGER, AMF3_DOUBLE, AMF3_STRING, AMF3_XML_DOC, AMF3_DATE,
- AMF3_ARRAY, AMF3_OBJECT, AMF3_XML, AMF3_BYTE_ARRAY
- } AMF3DataType;
-
- typedef struct AVal
- {
- char *av_val;
- int av_len;
- } AVal;
-#define AVC(str) {str,sizeof(str)-1}
-#define AVMATCH(a1,a2) ((a1)->av_len == (a2)->av_len && !memcmp((a1)->av_val,(a2)->av_val,(a1)->av_len))
-
- struct AMFObjectProperty;
-
- typedef struct AMFObject
- {
- int o_num;
- struct AMFObjectProperty *o_props;
- } AMFObject;
-
- typedef struct AMFObjectProperty
- {
- AVal p_name;
- AMFDataType p_type;
- union
- {
- double p_number;
- AVal p_aval;
- AMFObject p_object;
- } p_vu;
- int16_t p_UTCoffset;
- } AMFObjectProperty;
-
- char *AMF_EncodeString(char *output, char *outend, const AVal * str);
- char *AMF_EncodeNumber(char *output, char *outend, double dVal);
- char *AMF_EncodeInt16(char *output, char *outend, short nVal);
- char *AMF_EncodeInt24(char *output, char *outend, int nVal);
- char *AMF_EncodeInt32(char *output, char *outend, int nVal);
- char *AMF_EncodeBoolean(char *output, char *outend, int bVal);
-
- /* Shortcuts for AMFProp_Encode */
- char *AMF_EncodeNamedString(char *output, char *outend, const AVal * name, const AVal * value);
- char *AMF_EncodeNamedNumber(char *output, char *outend, const AVal * name, double dVal);
- char *AMF_EncodeNamedBoolean(char *output, char *outend, const AVal * name, int bVal);
-
- unsigned short AMF_DecodeInt16(const char *data);
- unsigned int AMF_DecodeInt24(const char *data);
- unsigned int AMF_DecodeInt32(const char *data);
- void AMF_DecodeString(const char *data, AVal * str);
- void AMF_DecodeLongString(const char *data, AVal * str);
- int AMF_DecodeBoolean(const char *data);
- double AMF_DecodeNumber(const char *data);
-
- char *AMF_Encode(AMFObject * obj, char *pBuffer, char *pBufEnd);
- int AMF_Decode(AMFObject * obj, const char *pBuffer, int nSize,
- int bDecodeName);
- int AMF_DecodeArray(AMFObject * obj, const char *pBuffer, int nSize,
- int nArrayLen, int bDecodeName);
- int AMF3_Decode(AMFObject * obj, const char *pBuffer, int nSize,
- int bDecodeName);
- void AMF_Dump(AMFObject * obj);
- void AMF_Reset(AMFObject * obj);
-
- void AMF_AddProp(AMFObject * obj, const AMFObjectProperty * prop);
- int AMF_CountProp(AMFObject * obj);
- AMFObjectProperty *AMF_GetProp(AMFObject * obj, const AVal * name,
- int nIndex);
-
- AMFDataType AMFProp_GetType(AMFObjectProperty * prop);
- void AMFProp_SetNumber(AMFObjectProperty * prop, double dval);
- void AMFProp_SetBoolean(AMFObjectProperty * prop, int bflag);
- void AMFProp_SetString(AMFObjectProperty * prop, AVal * str);
- void AMFProp_SetObject(AMFObjectProperty * prop, AMFObject * obj);
-
- void AMFProp_GetName(AMFObjectProperty * prop, AVal * name);
- void AMFProp_SetName(AMFObjectProperty * prop, AVal * name);
- double AMFProp_GetNumber(AMFObjectProperty * prop);
- int AMFProp_GetBoolean(AMFObjectProperty * prop);
- void AMFProp_GetString(AMFObjectProperty * prop, AVal * str);
- void AMFProp_GetObject(AMFObjectProperty * prop, AMFObject * obj);
-
- int AMFProp_IsValid(AMFObjectProperty * prop);
-
- char *AMFProp_Encode(AMFObjectProperty * prop, char *pBuffer, char *pBufEnd);
- int AMF3Prop_Decode(AMFObjectProperty * prop, const char *pBuffer,
- int nSize, int bDecodeName);
- int AMFProp_Decode(AMFObjectProperty * prop, const char *pBuffer,
- int nSize, int bDecodeName);
-
- void AMFProp_Dump(AMFObjectProperty * prop);
- void AMFProp_Reset(AMFObjectProperty * prop);
-
- typedef struct AMF3ClassDef
- {
- AVal cd_name;
- char cd_externalizable;
- char cd_dynamic;
- int cd_num;
- AVal *cd_props;
- } AMF3ClassDef;
-
- void AMF3CD_AddProp(AMF3ClassDef * cd, AVal * prop);
- AVal *AMF3CD_GetProp(AMF3ClassDef * cd, int idx);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __AMF_H__ */
diff --git a/lib/librtmp_win32/librtmp/bytes.h b/lib/librtmp_win32/librtmp/bytes.h
deleted file mode 100644
index 8c6e80d0e3..0000000000
--- a/lib/librtmp_win32/librtmp/bytes.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- * Copyright (C) 2008-2009 Andrej Stepanchuk
- * Copyright (C) 2009-2010 Howard Chu
- *
- * This file is part of librtmp.
- *
- * librtmp is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1,
- * or (at your option) any later version.
- *
- * librtmp is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with librtmp see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/lgpl.html
- */
-
-#ifndef __BYTES_H__
-#define __BYTES_H__
-
-#include <stdint.h>
-
-#ifdef _WIN32
-/* Windows is little endian only */
-#define __LITTLE_ENDIAN 1234
-#define __BIG_ENDIAN 4321
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#define __FLOAT_WORD_ORDER __BYTE_ORDER
-
-typedef unsigned char uint8_t;
-
-#else /* !_WIN32 */
-
-#include <sys/param.h>
-
-#if defined(BYTE_ORDER) && !defined(__BYTE_ORDER)
-#define __BYTE_ORDER BYTE_ORDER
-#endif
-
-#if defined(BIG_ENDIAN) && !defined(__BIG_ENDIAN)
-#define __BIG_ENDIAN BIG_ENDIAN
-#endif
-
-#if defined(LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN)
-#define __LITTLE_ENDIAN LITTLE_ENDIAN
-#endif
-
-#endif /* !_WIN32 */
-
-/* define default endianness */
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif
-
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif
-
-#ifndef __BYTE_ORDER
-#warning "Byte order not defined on your system, assuming little endian!"
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif
-
-/* ok, we assume to have the same float word order and byte order if float word order is not defined */
-#ifndef __FLOAT_WORD_ORDER
-#warning "Float word order not defined, assuming the same as byte order!"
-#define __FLOAT_WORD_ORDER __BYTE_ORDER
-#endif
-
-#if !defined(__BYTE_ORDER) || !defined(__FLOAT_WORD_ORDER)
-#error "Undefined byte or float word order!"
-#endif
-
-#if __FLOAT_WORD_ORDER != __BIG_ENDIAN && __FLOAT_WORD_ORDER != __LITTLE_ENDIAN
-#error "Unknown/unsupported float word order!"
-#endif
-
-#if __BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN
-#error "Unknown/unsupported byte order!"
-#endif
-
-#endif
-
diff --git a/lib/librtmp_win32/librtmp/dh.h b/lib/librtmp_win32/librtmp/dh.h
deleted file mode 100644
index 8e285a60cc..0000000000
--- a/lib/librtmp_win32/librtmp/dh.h
+++ /dev/null
@@ -1,334 +0,0 @@
-/* RTMPDump - Diffie-Hellmann Key Exchange
- * Copyright (C) 2009 Andrej Stepanchuk
- * Copyright (C) 2009-2010 Howard Chu
- *
- * This file is part of librtmp.
- *
- * librtmp is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1,
- * or (at your option) any later version.
- *
- * librtmp is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with librtmp see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/lgpl.html
- */
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <limits.h>
-
-#ifdef USE_POLARSSL
-#include <polarssl/dhm.h>
-typedef mpi * MP_t;
-#define MP_new(m) m = malloc(sizeof(mpi)); mpi_init(m, NULL)
-#define MP_set_w(mpi, w) mpi_lset(mpi, w)
-#define MP_cmp(u, v) mpi_cmp_mpi(u, v)
-#define MP_set(u, v) mpi_copy(u, v)
-#define MP_sub_w(mpi, w) mpi_sub_int(mpi, mpi, w)
-#define MP_cmp_1(mpi) mpi_cmp_int(mpi, 1)
-#define MP_modexp(r, y, q, p) mpi_exp_mod(r, y, q, p, NULL)
-#define MP_free(mpi) mpi_free(mpi, NULL); free(mpi)
-#define MP_gethex(u, hex, res) MP_new(u); res = mpi_read_string(u, 16, hex) == 0
-#define MP_bytes(u) mpi_size(u)
-#define MP_setbin(u,buf,len) mpi_write_binary(u,buf,len)
-#define MP_getbin(u,buf,len) MP_new(u); mpi_read_binary(u,buf,len)
-
-typedef struct MDH {
- MP_t p;
- MP_t g;
- MP_t pub_key;
- MP_t priv_key;
- long length;
- dhm_context ctx;
-} MDH;
-
-#define MDH_new() calloc(1,sizeof(MDH))
-#define MDH_free(vp) {MDH *dh = vp; dhm_free(&dh->ctx); MP_free(dh->p); MP_free(dh->g); MP_free(dh->pub_key); MP_free(dh->priv_key); free(dh);}
-
-static int MDH_generate_key(MDH *dh)
-{
- unsigned char out[2];
- MP_set(&dh->ctx.P, dh->p);
- MP_set(&dh->ctx.G, dh->g);
- dh->ctx.len = 128;
- dhm_make_public(&dh->ctx, 1024, out, 1, havege_rand, &RTMP_TLS_ctx->hs);
- MP_new(dh->pub_key);
- MP_new(dh->priv_key);
- MP_set(dh->pub_key, &dh->ctx.GX);
- MP_set(dh->priv_key, &dh->ctx.X);
- return 1;
-}
-
-static int MDH_compute_key(uint8_t *secret, size_t len, MP_t pub, MDH *dh)
-{
- int n = len;
- MP_set(&dh->ctx.GY, pub);
- dhm_calc_secret(&dh->ctx, secret, &n);
- return 0;
-}
-
-#elif defined(USE_GNUTLS)
-#include <gcrypt.h>
-typedef gcry_mpi_t MP_t;
-#define MP_new(m) m = gcry_mpi_new(1)
-#define MP_set_w(mpi, w) gcry_mpi_set_ui(mpi, w)
-#define MP_cmp(u, v) gcry_mpi_cmp(u, v)
-#define MP_set(u, v) gcry_mpi_set(u, v)
-#define MP_sub_w(mpi, w) gcry_mpi_sub_ui(mpi, mpi, w)
-#define MP_cmp_1(mpi) gcry_mpi_cmp_ui(mpi, 1)
-#define MP_modexp(r, y, q, p) gcry_mpi_powm(r, y, q, p)
-#define MP_free(mpi) gcry_mpi_release(mpi)
-#define MP_gethex(u, hex, res) res = (gcry_mpi_scan(&u, GCRYMPI_FMT_HEX, hex, 0, 0) == 0)
-#define MP_bytes(u) (gcry_mpi_get_nbits(u) + 7) / 8
-#define MP_setbin(u,buf,len) gcry_mpi_print(GCRYMPI_FMT_USG,buf,len,NULL,u)
-#define MP_getbin(u,buf,len) gcry_mpi_scan(&u,GCRYMPI_FMT_USG,buf,len,NULL)
-
-typedef struct MDH {
- MP_t p;
- MP_t g;
- MP_t pub_key;
- MP_t priv_key;
- long length;
-} MDH;
-
-#define MDH_new() calloc(1,sizeof(MDH))
-#define MDH_free(dh) do {MP_free(((MDH*)(dh))->p); MP_free(((MDH*)(dh))->g); MP_free(((MDH*)(dh))->pub_key); MP_free(((MDH*)(dh))->priv_key); free(dh);} while(0)
-
-extern MP_t gnutls_calc_dh_secret(MP_t *priv, MP_t g, MP_t p);
-extern MP_t gnutls_calc_dh_key(MP_t y, MP_t x, MP_t p);
-
-#define MDH_generate_key(dh) (dh->pub_key = gnutls_calc_dh_secret(&dh->priv_key, dh->g, dh->p))
-static int MDH_compute_key(uint8_t *secret, size_t len, MP_t pub, MDH *dh)
-{
- MP_t sec = gnutls_calc_dh_key(pub, dh->priv_key, dh->p);
- if (sec)
- {
- MP_setbin(sec, secret, len);
- MP_free(sec);
- return 0;
- }
- else
- return -1;
-}
-
-#else /* USE_OPENSSL */
-#include <openssl/bn.h>
-#include <openssl/dh.h>
-
-typedef BIGNUM * MP_t;
-#define MP_new(m) m = BN_new()
-#define MP_set_w(mpi, w) BN_set_word(mpi, w)
-#define MP_cmp(u, v) BN_cmp(u, v)
-#define MP_set(u, v) BN_copy(u, v)
-#define MP_sub_w(mpi, w) BN_sub_word(mpi, w)
-#define MP_cmp_1(mpi) BN_cmp(mpi, BN_value_one())
-#define MP_modexp(r, y, q, p) do {BN_CTX *ctx = BN_CTX_new(); BN_mod_exp(r, y, q, p, ctx); BN_CTX_free(ctx);} while(0)
-#define MP_free(mpi) BN_free(mpi)
-#define MP_gethex(u, hex, res) res = BN_hex2bn(&u, hex)
-#define MP_bytes(u) BN_num_bytes(u)
-#define MP_setbin(u,buf,len) BN_bn2bin(u,buf)
-#define MP_getbin(u,buf,len) u = BN_bin2bn(buf,len,0)
-
-#define MDH DH
-#define MDH_new() DH_new()
-#define MDH_free(dh) DH_free(dh)
-#define MDH_generate_key(dh) DH_generate_key(dh)
-#define MDH_compute_key(secret, seclen, pub, dh) DH_compute_key(secret, pub, dh)
-
-#endif
-
-#include "log.h"
-#include "dhgroups.h"
-
-/* RFC 2631, Section 2.1.5, http://www.ietf.org/rfc/rfc2631.txt */
-static int
-isValidPublicKey(MP_t y, MP_t p, MP_t q)
-{
- int ret = TRUE;
- MP_t bn;
- assert(y);
-
- MP_new(bn);
- assert(bn);
-
- /* y must lie in [2,p-1] */
- MP_set_w(bn, 1);
- if (MP_cmp(y, bn) < 0)
- {
- RTMP_Log(RTMP_LOGERROR, "DH public key must be at least 2");
- ret = FALSE;
- goto failed;
- }
-
- /* bn = p-2 */
- MP_set(bn, p);
- MP_sub_w(bn, 1);
- if (MP_cmp(y, bn) > 0)
- {
- RTMP_Log(RTMP_LOGERROR, "DH public key must be at most p-2");
- ret = FALSE;
- goto failed;
- }
-
- /* Verify with Sophie-Germain prime
- *
- * This is a nice test to make sure the public key position is calculated
- * correctly. This test will fail in about 50% of the cases if applied to
- * random data.
- */
- if (q)
- {
- /* y must fulfill y^q mod p = 1 */
- MP_modexp(bn, y, q, p);
-
- if (MP_cmp_1(bn) != 0)
- {
- RTMP_Log(RTMP_LOGWARNING, "DH public key does not fulfill y^q mod p = 1");
- }
- }
-
-failed:
- MP_free(bn);
- return ret;
-}
-
-static MDH *
-DHInit(int nKeyBits)
-{
- size_t res;
- MDH *dh = MDH_new();
-
- if (!dh)
- goto failed;
-
- MP_new(dh->g);
-
- if (!dh->g)
- goto failed;
-
- MP_gethex(dh->p, P1024, res); /* prime P1024, see dhgroups.h */
- if (!res)
- {
- goto failed;
- }
-
- MP_set_w(dh->g, 2); /* base 2 */
-
- dh->length = nKeyBits;
- return dh;
-
-failed:
- if (dh)
- MDH_free(dh);
-
- return 0;
-}
-
-static int
-DHGenerateKey(MDH *dh)
-{
- size_t res = 0;
- if (!dh)
- return 0;
-
- while (!res)
- {
- MP_t q1 = NULL;
-
- if (!MDH_generate_key(dh))
- return 0;
-
- MP_gethex(q1, Q1024, res);
- assert(res);
-
- res = isValidPublicKey(dh->pub_key, dh->p, q1);
- if (!res)
- {
- MP_free(dh->pub_key);
- MP_free(dh->priv_key);
- dh->pub_key = dh->priv_key = 0;
- }
-
- MP_free(q1);
- }
- return 1;
-}
-
-/* fill pubkey with the public key in BIG ENDIAN order
- * 00 00 00 00 00 x1 x2 x3 .....
- */
-
-static int
-DHGetPublicKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen)
-{
- int len;
- if (!dh || !dh->pub_key)
- return 0;
-
- len = MP_bytes(dh->pub_key);
- if (len <= 0 || len > (int) nPubkeyLen)
- return 0;
-
- memset(pubkey, 0, nPubkeyLen);
- MP_setbin(dh->pub_key, pubkey + (nPubkeyLen - len), len);
- return 1;
-}
-
-#if 0 /* unused */
-static int
-DHGetPrivateKey(MDH *dh, uint8_t *privkey, size_t nPrivkeyLen)
-{
- if (!dh || !dh->priv_key)
- return 0;
-
- int len = MP_bytes(dh->priv_key);
- if (len <= 0 || len > (int) nPrivkeyLen)
- return 0;
-
- memset(privkey, 0, nPrivkeyLen);
- MP_setbin(dh->priv_key, privkey + (nPrivkeyLen - len), len);
- return 1;
-}
-#endif
-
-/* computes the shared secret key from the private MDH value and the
- * other party's public key (pubkey)
- */
-static int
-DHComputeSharedSecretKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen,
- uint8_t *secret)
-{
- MP_t q1 = NULL, pubkeyBn = NULL;
- size_t len;
- int res;
-
- if (!dh || !secret || nPubkeyLen >= INT_MAX)
- return -1;
-
- MP_getbin(pubkeyBn, pubkey, nPubkeyLen);
- if (!pubkeyBn)
- return -1;
-
- MP_gethex(q1, Q1024, len);
- assert(len);
-
- if (isValidPublicKey(pubkeyBn, dh->p, q1))
- res = MDH_compute_key(secret, nPubkeyLen, pubkeyBn, dh);
- else
- res = -1;
-
- MP_free(q1);
- MP_free(pubkeyBn);
-
- return res;
-}
diff --git a/lib/librtmp_win32/librtmp/dhgroups.h b/lib/librtmp_win32/librtmp/dhgroups.h
deleted file mode 100644
index 2db3989ce1..0000000000
--- a/lib/librtmp_win32/librtmp/dhgroups.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/* librtmp - Diffie-Hellmann Key Exchange
- * Copyright (C) 2009 Andrej Stepanchuk
- *
- * This file is part of librtmp.
- *
- * librtmp is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1,
- * or (at your option) any later version.
- *
- * librtmp is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with librtmp see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/lgpl.html
- */
-
-/* from RFC 3526, see http://www.ietf.org/rfc/rfc3526.txt */
-
-/* 2^768 - 2 ^704 - 1 + 2^64 * { [2^638 pi] + 149686 } */
-#define P768 \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A63A3620FFFFFFFFFFFFFFFF"
-
-/* 2^1024 - 2^960 - 1 + 2^64 * { [2^894 pi] + 129093 } */
-#define P1024 \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381" \
- "FFFFFFFFFFFFFFFF"
-
-/* Group morder largest prime factor: */
-#define Q1024 \
- "7FFFFFFFFFFFFFFFE487ED5110B4611A62633145C06E0E68" \
- "948127044533E63A0105DF531D89CD9128A5043CC71A026E" \
- "F7CA8CD9E69D218D98158536F92F8A1BA7F09AB6B6A8E122" \
- "F242DABB312F3F637A262174D31BF6B585FFAE5B7A035BF6" \
- "F71C35FDAD44CFD2D74F9208BE258FF324943328F67329C0" \
- "FFFFFFFFFFFFFFFF"
-
-/* 2^1536 - 2^1472 - 1 + 2^64 * { [2^1406 pi] + 741804 } */
-#define P1536 \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
- "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
- "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
- "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF"
-
-/* 2^2048 - 2^1984 - 1 + 2^64 * { [2^1918 pi] + 124476 } */
-#define P2048 \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
- "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
- "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
- "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
- "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
- "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
- "15728E5A8AACAA68FFFFFFFFFFFFFFFF"
-
-/* 2^3072 - 2^3008 - 1 + 2^64 * { [2^2942 pi] + 1690314 } */
-#define P3072 \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
- "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
- "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
- "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
- "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
- "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
- "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
- "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
- "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
- "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
- "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
- "43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF"
-
-/* 2^4096 - 2^4032 - 1 + 2^64 * { [2^3966 pi] + 240904 } */
-#define P4096 \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
- "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
- "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
- "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
- "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
- "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
- "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
- "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
- "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
- "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
- "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
- "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" \
- "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" \
- "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" \
- "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" \
- "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" \
- "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199" \
- "FFFFFFFFFFFFFFFF"
-
-/* 2^6144 - 2^6080 - 1 + 2^64 * { [2^6014 pi] + 929484 } */
-#define P6144 \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
- "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
- "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
- "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
- "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
- "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
- "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
- "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
- "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
- "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
- "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
- "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" \
- "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" \
- "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" \
- "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" \
- "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" \
- "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934028492" \
- "36C3FAB4D27C7026C1D4DCB2602646DEC9751E763DBA37BD" \
- "F8FF9406AD9E530EE5DB382F413001AEB06A53ED9027D831" \
- "179727B0865A8918DA3EDBEBCF9B14ED44CE6CBACED4BB1B" \
- "DB7F1447E6CC254B332051512BD7AF426FB8F401378CD2BF" \
- "5983CA01C64B92ECF032EA15D1721D03F482D7CE6E74FEF6" \
- "D55E702F46980C82B5A84031900B1C9E59E7C97FBEC7E8F3" \
- "23A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AA" \
- "CC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE328" \
- "06A1D58BB7C5DA76F550AA3D8A1FBFF0EB19CCB1A313D55C" \
- "DA56C9EC2EF29632387FE8D76E3C0468043E8F663F4860EE" \
- "12BF2D5B0B7474D6E694F91E6DCC4024FFFFFFFFFFFFFFFF"
-
-/* 2^8192 - 2^8128 - 1 + 2^64 * { [2^8062 pi] + 4743158 } */
-#define P8192 \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
- "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
- "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
- "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
- "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
- "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
- "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
- "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
- "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
- "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
- "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
- "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" \
- "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" \
- "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" \
- "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" \
- "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" \
- "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934028492" \
- "36C3FAB4D27C7026C1D4DCB2602646DEC9751E763DBA37BD" \
- "F8FF9406AD9E530EE5DB382F413001AEB06A53ED9027D831" \
- "179727B0865A8918DA3EDBEBCF9B14ED44CE6CBACED4BB1B" \
- "DB7F1447E6CC254B332051512BD7AF426FB8F401378CD2BF" \
- "5983CA01C64B92ECF032EA15D1721D03F482D7CE6E74FEF6" \
- "D55E702F46980C82B5A84031900B1C9E59E7C97FBEC7E8F3" \
- "23A97A7E36CC88BE0F1D45B7FF585AC54BD407B22B4154AA" \
- "CC8F6D7EBF48E1D814CC5ED20F8037E0A79715EEF29BE328" \
- "06A1D58BB7C5DA76F550AA3D8A1FBFF0EB19CCB1A313D55C" \
- "DA56C9EC2EF29632387FE8D76E3C0468043E8F663F4860EE" \
- "12BF2D5B0B7474D6E694F91E6DBE115974A3926F12FEE5E4" \
- "38777CB6A932DF8CD8BEC4D073B931BA3BC832B68D9DD300" \
- "741FA7BF8AFC47ED2576F6936BA424663AAB639C5AE4F568" \
- "3423B4742BF1C978238F16CBE39D652DE3FDB8BEFC848AD9" \
- "22222E04A4037C0713EB57A81A23F0C73473FC646CEA306B" \
- "4BCBC8862F8385DDFA9D4B7FA2C087E879683303ED5BDD3A" \
- "062B3CF5B3A278A66D2A13F83F44F82DDF310EE074AB6A36" \
- "4597E899A0255DC164F31CC50846851DF9AB48195DED7EA1" \
- "B1D510BD7EE74D73FAF36BC31ECFA268359046F4EB879F92" \
- "4009438B481C6CD7889A002ED5EE382BC9190DA6FC026E47" \
- "9558E4475677E9AA9E3050E2765694DFC81F56E880B96E71" \
- "60C980DD98EDD3DFFFFFFFFFFFFFFFFF"
-
diff --git a/lib/librtmp_win32/librtmp/handshake.h b/lib/librtmp_win32/librtmp/handshake.h
deleted file mode 100644
index 958579a812..0000000000
--- a/lib/librtmp_win32/librtmp/handshake.h
+++ /dev/null
@@ -1,1093 +0,0 @@
-/*
- * Copyright (C) 2008-2009 Andrej Stepanchuk
- * Copyright (C) 2009-2010 Howard Chu
- * Copyright (C) 2010 2a665470ced7adb7156fcef47f8199a6371c117b8a79e399a2771e0b36384090
- *
- * This file is part of librtmp.
- *
- * librtmp is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1,
- * or (at your option) any later version.
- *
- * librtmp is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with librtmp see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/lgpl.html
- */
-
-/* This file is #included in rtmp.c, it is not meant to be compiled alone */
-
-#ifdef USE_POLARSSL
-#include <polarssl/sha2.h>
-#include <polarssl/arc4.h>
-#ifndef SHA256_DIGEST_LENGTH
-#define SHA256_DIGEST_LENGTH 32
-#endif
-#define HMAC_CTX sha2_context
-#define HMAC_setup(ctx, key, len) sha2_hmac_starts(&ctx, (unsigned char *)key, len, 0)
-#define HMAC_crunch(ctx, buf, len) sha2_hmac_update(&ctx, buf, len)
-#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(&ctx, dig)
-
-typedef arc4_context * RC4_handle;
-#define RC4_alloc(h) *h = malloc(sizeof(arc4_context))
-#define RC4_setkey(h,l,k) arc4_setup(h,k,l)
-#define RC4_encrypt(h,l,d) arc4_crypt(h,l,(unsigned char *)d,(unsigned char *)d)
-#define RC4_encrypt2(h,l,s,d) arc4_crypt(h,l,(unsigned char *)s,(unsigned char *)d)
-#define RC4_free(h) free(h)
-
-#elif defined(USE_GNUTLS)
-#include <gcrypt.h>
-#ifndef SHA256_DIGEST_LENGTH
-#define SHA256_DIGEST_LENGTH 32
-#endif
-#define HMAC_CTX gcry_md_hd_t
-#define HMAC_setup(ctx, key, len) gcry_md_open(&ctx, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC); gcry_md_setkey(ctx, key, len)
-#define HMAC_crunch(ctx, buf, len) gcry_md_write(ctx, buf, len)
-#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; memcpy(dig, gcry_md_read(ctx, 0), dlen); gcry_md_close(ctx)
-
-typedef gcry_cipher_hd_t RC4_handle;
-#define RC4_alloc(h) gcry_cipher_open(h, GCRY_CIPHER_ARCFOUR, GCRY_CIPHER_MODE_STREAM, 0)
-#define RC4_setkey(h,l,k) gcry_cipher_setkey(h,k,l)
-#define RC4_encrypt(h,l,d) gcry_cipher_encrypt(h,(void *)d,l,NULL,0)
-#define RC4_encrypt2(h,l,s,d) gcry_cipher_encrypt(h,(void *)d,l,(void *)s,l)
-#define RC4_free(h) gcry_cipher_close(h)
-
-#else /* USE_OPENSSL */
-#include <openssl/sha.h>
-#include <openssl/hmac.h>
-#include <openssl/rc4.h>
-#if OPENSSL_VERSION_NUMBER < 0x0090800 || !defined(SHA256_DIGEST_LENGTH)
-#error Your OpenSSL is too old, need 0.9.8 or newer with SHA256
-#endif
-#define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, key, len, EVP_sha256(), 0)
-#define HMAC_crunch(ctx, buf, len) HMAC_Update(&ctx, buf, len)
-#define HMAC_finish(ctx, dig, dlen) HMAC_Final(&ctx, dig, &dlen); HMAC_CTX_cleanup(&ctx)
-
-typedef RC4_KEY * RC4_handle;
-#define RC4_alloc(h) *h = malloc(sizeof(RC4_KEY))
-#define RC4_setkey(h,l,k) RC4_set_key(h,l,k)
-#define RC4_encrypt(h,l,d) RC4(h,l,(uint8_t *)d,(uint8_t *)d)
-#define RC4_encrypt2(h,l,s,d) RC4(h,l,(uint8_t *)s,(uint8_t *)d)
-#define RC4_free(h) free(h)
-#endif
-
-#define FP10
-
-#include "dh.h"
-
-static const uint8_t GenuineFMSKey[] = {
- 0x47, 0x65, 0x6e, 0x75, 0x69, 0x6e, 0x65, 0x20, 0x41, 0x64, 0x6f, 0x62,
- 0x65, 0x20, 0x46, 0x6c,
- 0x61, 0x73, 0x68, 0x20, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x20, 0x53, 0x65,
- 0x72, 0x76, 0x65, 0x72,
- 0x20, 0x30, 0x30, 0x31, /* Genuine Adobe Flash Media Server 001 */
-
- 0xf0, 0xee, 0xc2, 0x4a, 0x80, 0x68, 0xbe, 0xe8, 0x2e, 0x00, 0xd0, 0xd1,
- 0x02, 0x9e, 0x7e, 0x57, 0x6e, 0xec, 0x5d, 0x2d, 0x29, 0x80, 0x6f, 0xab,
- 0x93, 0xb8, 0xe6, 0x36,
- 0xcf, 0xeb, 0x31, 0xae
-}; /* 68 */
-
-static const uint8_t GenuineFPKey[] = {
- 0x47, 0x65, 0x6E, 0x75, 0x69, 0x6E, 0x65, 0x20, 0x41, 0x64, 0x6F, 0x62,
- 0x65, 0x20, 0x46, 0x6C,
- 0x61, 0x73, 0x68, 0x20, 0x50, 0x6C, 0x61, 0x79, 0x65, 0x72, 0x20, 0x30,
- 0x30, 0x31, /* Genuine Adobe Flash Player 001 */
- 0xF0, 0xEE,
- 0xC2, 0x4A, 0x80, 0x68, 0xBE, 0xE8, 0x2E, 0x00, 0xD0, 0xD1, 0x02, 0x9E,
- 0x7E, 0x57, 0x6E, 0xEC,
- 0x5D, 0x2D, 0x29, 0x80, 0x6F, 0xAB, 0x93, 0xB8, 0xE6, 0x36, 0xCF, 0xEB,
- 0x31, 0xAE
-}; /* 62 */
-
-static void InitRC4Encryption
- (uint8_t * secretKey,
- uint8_t * pubKeyIn,
- uint8_t * pubKeyOut, RC4_handle *rc4keyIn, RC4_handle *rc4keyOut)
-{
- uint8_t digest[SHA256_DIGEST_LENGTH];
- unsigned int digestLen = 0;
- HMAC_CTX ctx;
-
- RC4_alloc(rc4keyIn);
- RC4_alloc(rc4keyOut);
-
- HMAC_setup(ctx, secretKey, 128);
- HMAC_crunch(ctx, pubKeyIn, 128);
- HMAC_finish(ctx, digest, digestLen);
-
- RTMP_Log(RTMP_LOGDEBUG, "RC4 Out Key: ");
- RTMP_LogHex(RTMP_LOGDEBUG, digest, 16);
-
- RC4_setkey(*rc4keyOut, 16, digest);
-
- HMAC_setup(ctx, secretKey, 128);
- HMAC_crunch(ctx, pubKeyOut, 128);
- HMAC_finish(ctx, digest, digestLen);
-
- RTMP_Log(RTMP_LOGDEBUG, "RC4 In Key: ");
- RTMP_LogHex(RTMP_LOGDEBUG, digest, 16);
-
- RC4_setkey(*rc4keyIn, 16, digest);
-}
-
-typedef unsigned int (getoff)(uint8_t *buf, unsigned int len);
-
-static unsigned int
-GetDHOffset2(uint8_t *handshake, unsigned int len)
-{
- unsigned int offset = 0;
- uint8_t *ptr = handshake + 768;
- unsigned int res;
-
- assert(RTMP_SIG_SIZE <= len);
-
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
-
- res = (offset % 632) + 8;
-
- if (res + 128 > 767)
- {
- RTMP_Log(RTMP_LOGERROR,
- "%s: Couldn't calculate correct DH offset (got %d), exiting!",
- __FUNCTION__, res);
- exit(1);
- }
- return res;
-}
-
-static unsigned int
-GetDigestOffset2(uint8_t *handshake, unsigned int len)
-{
- unsigned int offset = 0;
- uint8_t *ptr = handshake + 772;
- unsigned int res;
-
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
-
- res = (offset % 728) + 776;
-
- if (res + 32 > 1535)
- {
- RTMP_Log(RTMP_LOGERROR,
- "%s: Couldn't calculate correct digest offset (got %d), exiting",
- __FUNCTION__, res);
- exit(1);
- }
- return res;
-}
-
-static unsigned int
-GetDHOffset1(uint8_t *handshake, unsigned int len)
-{
- unsigned int offset = 0;
- uint8_t *ptr = handshake + 1532;
- unsigned int res;
-
- assert(RTMP_SIG_SIZE <= len);
-
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
-
- res = (offset % 632) + 772;
-
- if (res + 128 > 1531)
- {
- RTMP_Log(RTMP_LOGERROR, "%s: Couldn't calculate DH offset (got %d), exiting!",
- __FUNCTION__, res);
- exit(1);
- }
-
- return res;
-}
-
-static unsigned int
-GetDigestOffset1(uint8_t *handshake, unsigned int len)
-{
- unsigned int offset = 0;
- uint8_t *ptr = handshake + 8;
- unsigned int res;
-
- assert(12 <= len);
-
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
- ptr++;
- offset += (*ptr);
-
- res = (offset % 728) + 12;
-
- if (res + 32 > 771)
- {
- RTMP_Log(RTMP_LOGERROR,
- "%s: Couldn't calculate digest offset (got %d), exiting!",
- __FUNCTION__, res);
- exit(1);
- }
-
- return res;
-}
-
-static getoff *digoff[] = {GetDigestOffset1, GetDigestOffset2};
-static getoff *dhoff[] = {GetDHOffset1, GetDHOffset2};
-
-static void
-HMACsha256(const uint8_t *message, size_t messageLen, const uint8_t *key,
- size_t keylen, uint8_t *digest)
-{
- unsigned int digestLen;
- HMAC_CTX ctx;
-
- HMAC_setup(ctx, key, keylen);
- HMAC_crunch(ctx, message, messageLen);
- HMAC_finish(ctx, digest, digestLen);
-
- assert(digestLen == 32);
-}
-
-static void
-CalculateDigest(unsigned int digestPos, uint8_t *handshakeMessage,
- const uint8_t *key, size_t keyLen, uint8_t *digest)
-{
- const int messageLen = RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH;
- uint8_t message[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH];
-
- memcpy(message, handshakeMessage, digestPos);
- memcpy(message + digestPos,
- &handshakeMessage[digestPos + SHA256_DIGEST_LENGTH],
- messageLen - digestPos);
-
- HMACsha256(message, messageLen, key, keyLen, digest);
-}
-
-static int
-VerifyDigest(unsigned int digestPos, uint8_t *handshakeMessage, const uint8_t *key,
- size_t keyLen)
-{
- uint8_t calcDigest[SHA256_DIGEST_LENGTH];
-
- CalculateDigest(digestPos, handshakeMessage, key, keyLen, calcDigest);
-
- return memcmp(&handshakeMessage[digestPos], calcDigest,
- SHA256_DIGEST_LENGTH) == 0;
-}
-
-/* handshake
- *
- * Type = [1 bytes] plain: 0x03, encrypted: 0x06, 0x08, 0x09
- * -------------------------------------------------------------------- [1536 bytes]
- * Uptime = [4 bytes] big endian unsigned number, uptime
- * Version = [4 bytes] each byte represents a version number, e.g. 9.0.124.0
- * ...
- *
- */
-
-static const uint32_t rtmpe8_keys[16][4] = {
- {0xbff034b2, 0x11d9081f, 0xccdfb795, 0x748de732},
- {0x086a5eb6, 0x1743090e, 0x6ef05ab8, 0xfe5a39e2},
- {0x7b10956f, 0x76ce0521, 0x2388a73a, 0x440149a1},
- {0xa943f317, 0xebf11bb2, 0xa691a5ee, 0x17f36339},
- {0x7a30e00a, 0xb529e22c, 0xa087aea5, 0xc0cb79ac},
- {0xbdce0c23, 0x2febdeff, 0x1cfaae16, 0x1123239d},
- {0x55dd3f7b, 0x77e7e62e, 0x9bb8c499, 0xc9481ee4},
- {0x407bb6b4, 0x71e89136, 0xa7aebf55, 0xca33b839},
- {0xfcf6bdc3, 0xb63c3697, 0x7ce4f825, 0x04d959b2},
- {0x28e091fd, 0x41954c4c, 0x7fb7db00, 0xe3a066f8},
- {0x57845b76, 0x4f251b03, 0x46d45bcd, 0xa2c30d29},
- {0x0acceef8, 0xda55b546, 0x03473452, 0x5863713b},
- {0xb82075dc, 0xa75f1fee, 0xd84268e8, 0xa72a44cc},
- {0x07cf6e9e, 0xa16d7b25, 0x9fa7ae6c, 0xd92f5629},
- {0xfeb1eae4, 0x8c8c3ce1, 0x4e0064a7, 0x6a387c2a},
- {0x893a9427, 0xcc3013a2, 0xf106385b, 0xa829f927}
-};
-
-/* RTMPE type 8 uses XTEA on the regular signature
- * http://en.wikipedia.org/wiki/XTEA
- */
-static void rtmpe8_sig(uint8_t *in, uint8_t *out, int keyid)
-{
- unsigned int i, num_rounds = 32;
- uint32_t v0, v1, sum=0, delta=0x9E3779B9;
- uint32_t const *k;
-
- v0 = in[0] | (in[1] << 8) | (in[2] << 16) | (in[3] << 24);
- v1 = in[4] | (in[5] << 8) | (in[6] << 16) | (in[7] << 24);
- k = rtmpe8_keys[keyid];
-
- for (i=0; i < num_rounds; i++) {
- v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]);
- sum += delta;
- v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]);
- }
-
- out[0] = v0; v0 >>= 8;
- out[1] = v0; v0 >>= 8;
- out[2] = v0; v0 >>= 8;
- out[3] = v0;
-
- out[4] = v1; v1 >>= 8;
- out[5] = v1; v1 >>= 8;
- out[6] = v1; v1 >>= 8;
- out[7] = v1;
-}
-
-static int
-HandShake(RTMP * r, int FP9HandShake)
-{
- int i, offalg = 0;
- int dhposClient = 0;
- int digestPosClient = 0;
- int encrypted = r->Link.protocol & RTMP_FEATURE_ENC;
-
- RC4_handle keyIn = 0;
- RC4_handle keyOut = 0;
-
- int32_t *ip;
- uint32_t uptime;
-
- uint8_t clientbuf[RTMP_SIG_SIZE + 4], *clientsig=clientbuf+4;
- uint8_t serversig[RTMP_SIG_SIZE], client2[RTMP_SIG_SIZE], *reply;
- uint8_t type;
- getoff *getdh = NULL, *getdig = NULL;
-
- if (encrypted || r->Link.SWFSize)
- FP9HandShake = TRUE;
- else
- FP9HandShake = FALSE;
-
- r->Link.rc4keyIn = r->Link.rc4keyOut = 0;
-
- if (encrypted)
- {
- clientsig[-1] = 0x06; /* 0x08 is RTMPE as well */
- offalg = 1;
- }
- else
- clientsig[-1] = 0x03;
-
- uptime = htonl(RTMP_GetTime());
- memcpy(clientsig, &uptime, 4);
-
- if (FP9HandShake)
- {
- /* set version to at least 9.0.115.0 */
- if (encrypted)
- {
- clientsig[4] = 128;
- clientsig[6] = 3;
- }
- else
- {
- clientsig[4] = 10;
- clientsig[6] = 45;
- }
- clientsig[5] = 0;
- clientsig[7] = 2;
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Client type: %02X", __FUNCTION__, clientsig[-1]);
- getdig = digoff[offalg];
- getdh = dhoff[offalg];
- }
- else
- {
- memset(&clientsig[4], 0, 4);
- }
-
- /* generate random data */
-#ifdef _DEBUG
- memset(clientsig+8, 0, RTMP_SIG_SIZE-8);
-#else
- ip = (int32_t *)(clientsig+8);
- for (i = 2; i < RTMP_SIG_SIZE/4; i++)
- *ip++ = rand();
-#endif
-
- /* set handshake digest */
- if (FP9HandShake)
- {
- if (encrypted)
- {
- /* generate Diffie-Hellmann parameters */
- r->Link.dh = DHInit(1024);
- if (!r->Link.dh)
- {
- RTMP_Log(RTMP_LOGERROR, "%s: Couldn't initialize Diffie-Hellmann!",
- __FUNCTION__);
- return FALSE;
- }
-
- dhposClient = getdh(clientsig, RTMP_SIG_SIZE);
- RTMP_Log(RTMP_LOGDEBUG, "%s: DH pubkey position: %d", __FUNCTION__, dhposClient);
-
- if (!DHGenerateKey(r->Link.dh))
- {
- RTMP_Log(RTMP_LOGERROR, "%s: Couldn't generate Diffie-Hellmann public key!",
- __FUNCTION__);
- return FALSE;
- }
-
- if (!DHGetPublicKey(r->Link.dh, &clientsig[dhposClient], 128))
- {
- RTMP_Log(RTMP_LOGERROR, "%s: Couldn't write public key!", __FUNCTION__);
- return FALSE;
- }
- }
-
- digestPosClient = getdig(clientsig, RTMP_SIG_SIZE); /* reuse this value in verification */
- RTMP_Log(RTMP_LOGDEBUG, "%s: Client digest offset: %d", __FUNCTION__,
- digestPosClient);
-
- CalculateDigest(digestPosClient, clientsig, GenuineFPKey, 30,
- &clientsig[digestPosClient]);
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Initial client digest: ", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, clientsig + digestPosClient,
- SHA256_DIGEST_LENGTH);
- }
-
-#ifdef _DEBUG
- RTMP_Log(RTMP_LOGDEBUG, "Clientsig: ");
- RTMP_LogHex(RTMP_LOGDEBUG, clientsig, RTMP_SIG_SIZE);
-#endif
-
- if (!WriteN(r, (char *)clientsig-1, RTMP_SIG_SIZE + 1))
- return FALSE;
-
- if (ReadN(r, (char *)&type, 1) != 1) /* 0x03 or 0x06 */
- return FALSE;
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Type Answer : %02X", __FUNCTION__, type);
-
- if (type != clientsig[-1])
- RTMP_Log(RTMP_LOGWARNING, "%s: Type mismatch: client sent %d, server answered %d",
- __FUNCTION__, clientsig[-1], type);
-
- if (ReadN(r, (char *)serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE)
- return FALSE;
-
- /* decode server response */
- memcpy(&uptime, serversig, 4);
- uptime = ntohl(uptime);
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Server Uptime : %d", __FUNCTION__, uptime);
- RTMP_Log(RTMP_LOGDEBUG, "%s: FMS Version : %d.%d.%d.%d", __FUNCTION__, serversig[4],
- serversig[5], serversig[6], serversig[7]);
-
- if (FP9HandShake && type == 3 && !serversig[4])
- FP9HandShake = FALSE;
-
-#ifdef _DEBUG
- RTMP_Log(RTMP_LOGDEBUG, "Server signature:");
- RTMP_LogHex(RTMP_LOGDEBUG, serversig, RTMP_SIG_SIZE);
-#endif
-
- if (FP9HandShake)
- {
- uint8_t digestResp[SHA256_DIGEST_LENGTH];
- uint8_t *signatureResp = NULL;
-
- /* we have to use this signature now to find the correct algorithms for getting the digest and DH positions */
- int digestPosServer = getdig(serversig, RTMP_SIG_SIZE);
-
- if (!VerifyDigest(digestPosServer, serversig, GenuineFMSKey, 36))
- {
- RTMP_Log(RTMP_LOGWARNING, "Trying different position for server digest!");
- offalg ^= 1;
- getdig = digoff[offalg];
- getdh = dhoff[offalg];
- digestPosServer = getdig(serversig, RTMP_SIG_SIZE);
-
- if (!VerifyDigest(digestPosServer, serversig, GenuineFMSKey, 36))
- {
- RTMP_Log(RTMP_LOGERROR, "Couldn't verify the server digest"); /* continuing anyway will probably fail */
- return FALSE;
- }
- }
-
- /* generate SWFVerification token (SHA256 HMAC hash of decompressed SWF, key are the last 32 bytes of the server handshake) */
- if (r->Link.SWFSize)
- {
- const char swfVerify[] = { 0x01, 0x01 };
- char *vend = r->Link.SWFVerificationResponse+sizeof(r->Link.SWFVerificationResponse);
-
- memcpy(r->Link.SWFVerificationResponse, swfVerify, 2);
- AMF_EncodeInt32(&r->Link.SWFVerificationResponse[2], vend, r->Link.SWFSize);
- AMF_EncodeInt32(&r->Link.SWFVerificationResponse[6], vend, r->Link.SWFSize);
- HMACsha256(r->Link.SWFHash, SHA256_DIGEST_LENGTH,
- &serversig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
- SHA256_DIGEST_LENGTH,
- (uint8_t *)&r->Link.SWFVerificationResponse[10]);
- }
-
- /* do Diffie-Hellmann Key exchange for encrypted RTMP */
- if (encrypted)
- {
- /* compute secret key */
- uint8_t secretKey[128] = { 0 };
- int len, dhposServer;
-
- dhposServer = getdh(serversig, RTMP_SIG_SIZE);
- RTMP_Log(RTMP_LOGDEBUG, "%s: Server DH public key offset: %d", __FUNCTION__,
- dhposServer);
- len = DHComputeSharedSecretKey(r->Link.dh, &serversig[dhposServer],
- 128, secretKey);
- if (len < 0)
- {
- RTMP_Log(RTMP_LOGDEBUG, "%s: Wrong secret key position!", __FUNCTION__);
- return FALSE;
- }
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Secret key: ", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, secretKey, 128);
-
- InitRC4Encryption(secretKey,
- (uint8_t *) & serversig[dhposServer],
- (uint8_t *) & clientsig[dhposClient],
- &keyIn, &keyOut);
- }
-
-
- reply = client2;
-#ifdef _DEBUG
- memset(reply, 0xff, RTMP_SIG_SIZE);
-#else
- ip = (int32_t *)reply;
- for (i = 0; i < RTMP_SIG_SIZE/4; i++)
- *ip++ = rand();
-#endif
- /* calculate response now */
- signatureResp = reply+RTMP_SIG_SIZE-SHA256_DIGEST_LENGTH;
-
- HMACsha256(&serversig[digestPosServer], SHA256_DIGEST_LENGTH,
- GenuineFPKey, sizeof(GenuineFPKey), digestResp);
- HMACsha256(reply, RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH, digestResp,
- SHA256_DIGEST_LENGTH, signatureResp);
-
- /* some info output */
- RTMP_Log(RTMP_LOGDEBUG,
- "%s: Calculated digest key from secure key and server digest: ",
- __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, digestResp, SHA256_DIGEST_LENGTH);
-
-#ifdef FP10
- if (type == 8 )
- {
- uint8_t *dptr = digestResp;
- uint8_t *sig = signatureResp;
- /* encrypt signatureResp */
- for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
- rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
- }
-#if 0
- else if (type == 9))
- {
- uint8_t *dptr = digestResp;
- uint8_t *sig = signatureResp;
- /* encrypt signatureResp */
- for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
- rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
- }
-#endif
-#endif
- RTMP_Log(RTMP_LOGDEBUG, "%s: Client signature calculated:", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, signatureResp, SHA256_DIGEST_LENGTH);
- }
- else
- {
- reply = serversig;
-#if 0
- uptime = htonl(RTMP_GetTime());
- memcpy(reply+4, &uptime, 4);
-#endif
- }
-
-#ifdef _DEBUG
- RTMP_Log(RTMP_LOGDEBUG, "%s: Sending handshake response: ",
- __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, reply, RTMP_SIG_SIZE);
-#endif
- if (!WriteN(r, (char *)reply, RTMP_SIG_SIZE))
- return FALSE;
-
- /* 2nd part of handshake */
- if (ReadN(r, (char *)serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE)
- return FALSE;
-
-#ifdef _DEBUG
- RTMP_Log(RTMP_LOGDEBUG, "%s: 2nd handshake: ", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, serversig, RTMP_SIG_SIZE);
-#endif
-
- if (FP9HandShake)
- {
- uint8_t signature[SHA256_DIGEST_LENGTH];
- uint8_t digest[SHA256_DIGEST_LENGTH];
-
- if (serversig[4] == 0 && serversig[5] == 0 && serversig[6] == 0
- && serversig[7] == 0)
- {
- RTMP_Log(RTMP_LOGDEBUG,
- "%s: Wait, did the server just refuse signed authentication?",
- __FUNCTION__);
- }
- RTMP_Log(RTMP_LOGDEBUG, "%s: Server sent signature:", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, &serversig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
- SHA256_DIGEST_LENGTH);
-
- /* verify server response */
- HMACsha256(&clientsig[digestPosClient], SHA256_DIGEST_LENGTH,
- GenuineFMSKey, sizeof(GenuineFMSKey), digest);
- HMACsha256(serversig, RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH, digest,
- SHA256_DIGEST_LENGTH, signature);
-
- /* show some information */
- RTMP_Log(RTMP_LOGDEBUG, "%s: Digest key: ", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, digest, SHA256_DIGEST_LENGTH);
-
-#ifdef FP10
- if (type == 8 )
- {
- uint8_t *dptr = digest;
- uint8_t *sig = signature;
- /* encrypt signature */
- for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
- rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
- }
-#if 0
- else if (type == 9)
- {
- uint8_t *dptr = digest;
- uint8_t *sig = signature;
- /* encrypt signatureResp */
- for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
- rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
- }
-#endif
-#endif
- RTMP_Log(RTMP_LOGDEBUG, "%s: Signature calculated:", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, signature, SHA256_DIGEST_LENGTH);
- if (memcmp
- (signature, &serversig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
- SHA256_DIGEST_LENGTH) != 0)
- {
- RTMP_Log(RTMP_LOGWARNING, "%s: Server not genuine Adobe!", __FUNCTION__);
- return FALSE;
- }
- else
- {
- RTMP_Log(RTMP_LOGDEBUG, "%s: Genuine Adobe Flash Media Server", __FUNCTION__);
- }
-
- if (encrypted)
- {
- char buff[RTMP_SIG_SIZE];
- /* set keys for encryption from now on */
- r->Link.rc4keyIn = keyIn;
- r->Link.rc4keyOut = keyOut;
-
-
- /* update the keystreams */
- if (r->Link.rc4keyIn)
- {
- RC4_encrypt(r->Link.rc4keyIn, RTMP_SIG_SIZE, (uint8_t *) buff);
- }
-
- if (r->Link.rc4keyOut)
- {
- RC4_encrypt(r->Link.rc4keyOut, RTMP_SIG_SIZE, (uint8_t *) buff);
- }
- }
- }
- else
- {
- if (memcmp(serversig, clientsig, RTMP_SIG_SIZE) != 0)
- {
- RTMP_Log(RTMP_LOGWARNING, "%s: client signature does not match!",
- __FUNCTION__);
- }
- }
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Handshaking finished....", __FUNCTION__);
- return TRUE;
-}
-
-static int
-SHandShake(RTMP * r)
-{
- int i, offalg = 0;
- int dhposServer = 0;
- int digestPosServer = 0;
- RC4_handle keyIn = 0;
- RC4_handle keyOut = 0;
- int FP9HandShake = FALSE;
- int encrypted;
- int32_t *ip;
-
- uint8_t clientsig[RTMP_SIG_SIZE];
- uint8_t serverbuf[RTMP_SIG_SIZE + 4], *serversig = serverbuf+4;
- uint8_t type;
- uint32_t uptime;
- getoff *getdh = NULL, *getdig = NULL;
-
- if (ReadN(r, (char *)&type, 1) != 1) /* 0x03 or 0x06 */
- return FALSE;
-
- if (ReadN(r, (char *)clientsig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE)
- return FALSE;
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Type Requested : %02X", __FUNCTION__, type);
- RTMP_LogHex(RTMP_LOGDEBUG2, clientsig, RTMP_SIG_SIZE);
-
- if (type == 3)
- {
- encrypted = FALSE;
- }
- else if (type == 6 || type == 8)
- {
- offalg = 1;
- encrypted = TRUE;
- FP9HandShake = TRUE;
- r->Link.protocol |= RTMP_FEATURE_ENC;
- /* use FP10 if client is capable */
- if (clientsig[4] == 128)
- type = 8;
- }
- else
- {
- RTMP_Log(RTMP_LOGERROR, "%s: Unknown version %02x",
- __FUNCTION__, type);
- return FALSE;
- }
-
- if (!FP9HandShake && clientsig[4])
- FP9HandShake = TRUE;
-
- serversig[-1] = type;
-
- r->Link.rc4keyIn = r->Link.rc4keyOut = 0;
-
- uptime = htonl(RTMP_GetTime());
- memcpy(serversig, &uptime, 4);
-
- if (FP9HandShake)
- {
- /* Server version */
- serversig[4] = 3;
- serversig[5] = 5;
- serversig[6] = 1;
- serversig[7] = 1;
-
- getdig = digoff[offalg];
- getdh = dhoff[offalg];
- }
- else
- {
- memset(&serversig[4], 0, 4);
- }
-
- /* generate random data */
-#ifdef _DEBUG
- memset(serversig+8, 0, RTMP_SIG_SIZE-8);
-#else
- ip = (int32_t *)(serversig+8);
- for (i = 2; i < RTMP_SIG_SIZE/4; i++)
- *ip++ = rand();
-#endif
-
- /* set handshake digest */
- if (FP9HandShake)
- {
- if (encrypted)
- {
- /* generate Diffie-Hellmann parameters */
- r->Link.dh = DHInit(1024);
- if (!r->Link.dh)
- {
- RTMP_Log(RTMP_LOGERROR, "%s: Couldn't initialize Diffie-Hellmann!",
- __FUNCTION__);
- return FALSE;
- }
-
- dhposServer = getdh(serversig, RTMP_SIG_SIZE);
- RTMP_Log(RTMP_LOGDEBUG, "%s: DH pubkey position: %d", __FUNCTION__, dhposServer);
-
- if (!DHGenerateKey(r->Link.dh))
- {
- RTMP_Log(RTMP_LOGERROR, "%s: Couldn't generate Diffie-Hellmann public key!",
- __FUNCTION__);
- return FALSE;
- }
-
- if (!DHGetPublicKey
- (r->Link.dh, (uint8_t *) &serversig[dhposServer], 128))
- {
- RTMP_Log(RTMP_LOGERROR, "%s: Couldn't write public key!", __FUNCTION__);
- return FALSE;
- }
- }
-
- digestPosServer = getdig(serversig, RTMP_SIG_SIZE); /* reuse this value in verification */
- RTMP_Log(RTMP_LOGDEBUG, "%s: Server digest offset: %d", __FUNCTION__,
- digestPosServer);
-
- CalculateDigest(digestPosServer, serversig, GenuineFMSKey, 36,
- &serversig[digestPosServer]);
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Initial server digest: ", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, serversig + digestPosServer,
- SHA256_DIGEST_LENGTH);
- }
-
- RTMP_Log(RTMP_LOGDEBUG2, "Serversig: ");
- RTMP_LogHex(RTMP_LOGDEBUG2, serversig, RTMP_SIG_SIZE);
-
- if (!WriteN(r, (char *)serversig-1, RTMP_SIG_SIZE + 1))
- return FALSE;
-
- /* decode client response */
- memcpy(&uptime, clientsig, 4);
- uptime = ntohl(uptime);
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Client Uptime : %d", __FUNCTION__, uptime);
- RTMP_Log(RTMP_LOGDEBUG, "%s: Player Version: %d.%d.%d.%d", __FUNCTION__, clientsig[4],
- clientsig[5], clientsig[6], clientsig[7]);
-
- if (FP9HandShake)
- {
- uint8_t digestResp[SHA256_DIGEST_LENGTH];
- uint8_t *signatureResp = NULL;
-
- /* we have to use this signature now to find the correct algorithms for getting the digest and DH positions */
- int digestPosClient = getdig(clientsig, RTMP_SIG_SIZE);
-
- if (!VerifyDigest(digestPosClient, clientsig, GenuineFPKey, 30))
- {
- RTMP_Log(RTMP_LOGWARNING, "Trying different position for client digest!");
- offalg ^= 1;
- getdig = digoff[offalg];
- getdh = dhoff[offalg];
-
- digestPosClient = getdig(clientsig, RTMP_SIG_SIZE);
-
- if (!VerifyDigest(digestPosClient, clientsig, GenuineFPKey, 30))
- {
- RTMP_Log(RTMP_LOGERROR, "Couldn't verify the client digest"); /* continuing anyway will probably fail */
- return FALSE;
- }
- }
-
- /* generate SWFVerification token (SHA256 HMAC hash of decompressed SWF, key are the last 32 bytes of the server handshake) */
- if (r->Link.SWFSize)
- {
- const char swfVerify[] = { 0x01, 0x01 };
- char *vend = r->Link.SWFVerificationResponse+sizeof(r->Link.SWFVerificationResponse);
-
- memcpy(r->Link.SWFVerificationResponse, swfVerify, 2);
- AMF_EncodeInt32(&r->Link.SWFVerificationResponse[2], vend, r->Link.SWFSize);
- AMF_EncodeInt32(&r->Link.SWFVerificationResponse[6], vend, r->Link.SWFSize);
- HMACsha256(r->Link.SWFHash, SHA256_DIGEST_LENGTH,
- &serversig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
- SHA256_DIGEST_LENGTH,
- (uint8_t *)&r->Link.SWFVerificationResponse[10]);
- }
-
- /* do Diffie-Hellmann Key exchange for encrypted RTMP */
- if (encrypted)
- {
- int dhposClient, len;
- /* compute secret key */
- uint8_t secretKey[128] = { 0 };
-
- dhposClient = getdh(clientsig, RTMP_SIG_SIZE);
- RTMP_Log(RTMP_LOGDEBUG, "%s: Client DH public key offset: %d", __FUNCTION__,
- dhposClient);
- len =
- DHComputeSharedSecretKey(r->Link.dh,
- (uint8_t *) &clientsig[dhposClient], 128,
- secretKey);
- if (len < 0)
- {
- RTMP_Log(RTMP_LOGDEBUG, "%s: Wrong secret key position!", __FUNCTION__);
- return FALSE;
- }
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Secret key: ", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, secretKey, 128);
-
- InitRC4Encryption(secretKey,
- (uint8_t *) &clientsig[dhposClient],
- (uint8_t *) &serversig[dhposServer],
- &keyIn, &keyOut);
- }
-
-
- /* calculate response now */
- signatureResp = clientsig+RTMP_SIG_SIZE-SHA256_DIGEST_LENGTH;
-
- HMACsha256(&clientsig[digestPosClient], SHA256_DIGEST_LENGTH,
- GenuineFMSKey, sizeof(GenuineFMSKey), digestResp);
- HMACsha256(clientsig, RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH, digestResp,
- SHA256_DIGEST_LENGTH, signatureResp);
-#ifdef FP10
- if (type == 8 )
- {
- uint8_t *dptr = digestResp;
- uint8_t *sig = signatureResp;
- /* encrypt signatureResp */
- for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
- rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
- }
-#if 0
- else if (type == 9))
- {
- uint8_t *dptr = digestResp;
- uint8_t *sig = signatureResp;
- /* encrypt signatureResp */
- for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
- rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
- }
-#endif
-#endif
-
- /* some info output */
- RTMP_Log(RTMP_LOGDEBUG,
- "%s: Calculated digest key from secure key and server digest: ",
- __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, digestResp, SHA256_DIGEST_LENGTH);
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Server signature calculated:", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, signatureResp, SHA256_DIGEST_LENGTH);
- }
-#if 0
- else
- {
- uptime = htonl(RTMP_GetTime());
- memcpy(clientsig+4, &uptime, 4);
- }
-#endif
-
- RTMP_Log(RTMP_LOGDEBUG2, "%s: Sending handshake response: ",
- __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG2, clientsig, RTMP_SIG_SIZE);
-
- if (!WriteN(r, (char *)clientsig, RTMP_SIG_SIZE))
- return FALSE;
-
- /* 2nd part of handshake */
- if (ReadN(r, (char *)clientsig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE)
- return FALSE;
-
- RTMP_Log(RTMP_LOGDEBUG2, "%s: 2nd handshake: ", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG2, clientsig, RTMP_SIG_SIZE);
-
- if (FP9HandShake)
- {
- uint8_t signature[SHA256_DIGEST_LENGTH];
- uint8_t digest[SHA256_DIGEST_LENGTH];
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Client sent signature:", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, &clientsig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
- SHA256_DIGEST_LENGTH);
-
- /* verify client response */
- HMACsha256(&serversig[digestPosServer], SHA256_DIGEST_LENGTH,
- GenuineFPKey, sizeof(GenuineFPKey), digest);
- HMACsha256(clientsig, RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH, digest,
- SHA256_DIGEST_LENGTH, signature);
-#ifdef FP10
- if (type == 8 )
- {
- uint8_t *dptr = digest;
- uint8_t *sig = signature;
- /* encrypt signatureResp */
- for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
- rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
- }
-#if 0
- else if (type == 9))
- {
- uint8_t *dptr = digestResp;
- uint8_t *sig = signatureResp;
- /* encrypt signatureResp */
- for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
- rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
- }
-#endif
-#endif
-
- /* show some information */
- RTMP_Log(RTMP_LOGDEBUG, "%s: Digest key: ", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, digest, SHA256_DIGEST_LENGTH);
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Signature calculated:", __FUNCTION__);
- RTMP_LogHex(RTMP_LOGDEBUG, signature, SHA256_DIGEST_LENGTH);
- if (memcmp
- (signature, &clientsig[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH],
- SHA256_DIGEST_LENGTH) != 0)
- {
- RTMP_Log(RTMP_LOGWARNING, "%s: Client not genuine Adobe!", __FUNCTION__);
- return FALSE;
- }
- else
- {
- RTMP_Log(RTMP_LOGDEBUG, "%s: Genuine Adobe Flash Player", __FUNCTION__);
- }
-
- if (encrypted)
- {
- char buff[RTMP_SIG_SIZE];
- /* set keys for encryption from now on */
- r->Link.rc4keyIn = keyIn;
- r->Link.rc4keyOut = keyOut;
-
- /* update the keystreams */
- if (r->Link.rc4keyIn)
- {
- RC4_encrypt(r->Link.rc4keyIn, RTMP_SIG_SIZE, (uint8_t *) buff);
- }
-
- if (r->Link.rc4keyOut)
- {
- RC4_encrypt(r->Link.rc4keyOut, RTMP_SIG_SIZE, (uint8_t *) buff);
- }
- }
- }
- else
- {
- if (memcmp(serversig, clientsig, RTMP_SIG_SIZE) != 0)
- {
- RTMP_Log(RTMP_LOGWARNING, "%s: client signature does not match!",
- __FUNCTION__);
- }
- }
-
- RTMP_Log(RTMP_LOGDEBUG, "%s: Handshaking finished....", __FUNCTION__);
- return TRUE;
-}
diff --git a/lib/librtmp_win32/librtmp/http.h b/lib/librtmp_win32/librtmp/http.h
deleted file mode 100644
index cf3d9039b0..0000000000
--- a/lib/librtmp_win32/librtmp/http.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef __RTMP_HTTP_H__
-#define __RTMP_HTTP_H__
-/*
- * Copyright (C) 2010 Howard Chu
- * Copyright (C) 2010 Antti Ajanki
- *
- * This file is part of librtmp.
- *
- * librtmp is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1,
- * or (at your option) any later version.
- *
- * librtmp is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with librtmp see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/lgpl.html
- */
-
-typedef enum {
- HTTPRES_OK, /* result OK */
- HTTPRES_OK_NOT_MODIFIED, /* not modified since last request */
- HTTPRES_NOT_FOUND, /* not found */
- HTTPRES_BAD_REQUEST, /* client error */
- HTTPRES_SERVER_ERROR, /* server reported an error */
- HTTPRES_REDIRECTED, /* resource has been moved */
- HTTPRES_LOST_CONNECTION /* connection lost while waiting for data */
-} HTTPResult;
-
-struct HTTP_ctx {
- char *date;
- int size;
- int status;
- void *data;
-};
-
-typedef size_t (HTTP_read_callback)(void *ptr, size_t size, size_t nmemb, void *stream);
-
-HTTPResult HTTP_get(struct HTTP_ctx *http, const char *url, HTTP_read_callback *cb);
-
-#endif
diff --git a/lib/librtmp_win32/librtmp/log.h b/lib/librtmp_win32/librtmp/log.h
deleted file mode 100644
index 97c9aac1a7..0000000000
--- a/lib/librtmp_win32/librtmp/log.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2008-2009 Andrej Stepanchuk
- * Copyright (C) 2009-2010 Howard Chu
- *
- * This file is part of librtmp.
- *
- * librtmp is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1,
- * or (at your option) any later version.
- *
- * librtmp is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with librtmp see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/lgpl.html
- */
-
-#ifndef __RTMP_LOG_H__
-#define __RTMP_LOG_H__
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-/* Enable this to get full debugging output */
-/* #define _DEBUG */
-
-#ifdef _DEBUG
-#undef NODEBUG
-#endif
-
-typedef enum
-{ RTMP_LOGCRIT=0, RTMP_LOGERROR, RTMP_LOGWARNING, RTMP_LOGINFO,
- RTMP_LOGDEBUG, RTMP_LOGDEBUG2, RTMP_LOGALL
-} RTMP_LogLevel;
-
-extern RTMP_LogLevel RTMP_debuglevel;
-
-typedef void (RTMP_LogCallback)(int level, const char *fmt, va_list);
-void RTMP_LogSetCallback(RTMP_LogCallback *cb);
-void RTMP_LogSetOutput(FILE *file);
-void RTMP_LogPrintf(const char *format, ...);
-void RTMP_LogStatus(const char *format, ...);
-void RTMP_Log(int level, const char *format, ...);
-void RTMP_LogHex(int level, const uint8_t *data, unsigned long len);
-void RTMP_LogHexString(int level, const uint8_t *data, unsigned long len);
-void RTMP_LogSetLevel(RTMP_LogLevel lvl);
-RTMP_LogLevel RTMP_LogGetLevel(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/lib/librtmp_win32/librtmp/rtmp.h b/lib/librtmp_win32/librtmp/rtmp.h
deleted file mode 100644
index f1da6a57ee..0000000000
--- a/lib/librtmp_win32/librtmp/rtmp.h
+++ /dev/null
@@ -1,345 +0,0 @@
-#ifndef __RTMP_H__
-#define __RTMP_H__
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- * Copyright (C) 2008-2009 Andrej Stepanchuk
- * Copyright (C) 2009-2010 Howard Chu
- *
- * This file is part of librtmp.
- *
- * librtmp is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1,
- * or (at your option) any later version.
- *
- * librtmp is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with librtmp see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/lgpl.html
- */
-
-#if !defined(NO_CRYPTO) && !defined(CRYPTO)
-#define CRYPTO
-#endif
-
-#include <errno.h>
-#include <stdint.h>
-#include <stddef.h>
-
-#include "amf.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define RTMP_LIB_VERSION 0x020206 /* 2.2f */
-
-#define RTMP_FEATURE_HTTP 0x01
-#define RTMP_FEATURE_ENC 0x02
-#define RTMP_FEATURE_SSL 0x04
-#define RTMP_FEATURE_MFP 0x08 /* not yet supported */
-#define RTMP_FEATURE_WRITE 0x10 /* publish, not play */
-#define RTMP_FEATURE_HTTP2 0x20 /* server-side rtmpt */
-
-#define RTMP_PROTOCOL_UNDEFINED -1
-#define RTMP_PROTOCOL_RTMP 0
-#define RTMP_PROTOCOL_RTMPE RTMP_FEATURE_ENC
-#define RTMP_PROTOCOL_RTMPT RTMP_FEATURE_HTTP
-#define RTMP_PROTOCOL_RTMPS RTMP_FEATURE_SSL
-#define RTMP_PROTOCOL_RTMPTE (RTMP_FEATURE_HTTP|RTMP_FEATURE_ENC)
-#define RTMP_PROTOCOL_RTMPTS (RTMP_FEATURE_HTTP|RTMP_FEATURE_SSL)
-#define RTMP_PROTOCOL_RTMFP RTMP_FEATURE_MFP
-
-#define RTMP_DEFAULT_CHUNKSIZE 128
-
-/* needs to fit largest number of bytes recv() may return */
-#define RTMP_BUFFER_CACHE_SIZE (16*1024)
-
-#define RTMP_CHANNELS 65600
-
- extern const char RTMPProtocolStringsLower[][7];
- extern const AVal RTMP_DefaultFlashVer;
- extern int RTMP_ctrlC;
-
- uint32_t RTMP_GetTime(void);
-
-#define RTMP_PACKET_TYPE_AUDIO 0x08
-#define RTMP_PACKET_TYPE_VIDEO 0x09
-#define RTMP_PACKET_TYPE_INFO 0x12
-
-#define RTMP_MAX_HEADER_SIZE 18
-
-#define RTMP_PACKET_SIZE_LARGE 0
-#define RTMP_PACKET_SIZE_MEDIUM 1
-#define RTMP_PACKET_SIZE_SMALL 2
-#define RTMP_PACKET_SIZE_MINIMUM 3
-
- typedef struct RTMPChunk
- {
- int c_headerSize;
- int c_chunkSize;
- char *c_chunk;
- char c_header[RTMP_MAX_HEADER_SIZE];
- } RTMPChunk;
-
- typedef struct RTMPPacket
- {
- uint8_t m_headerType;
- uint8_t m_packetType;
- uint8_t m_hasAbsTimestamp; /* timestamp absolute or relative? */
- int m_nChannel;
- uint32_t m_nTimeStamp; /* timestamp */
- int32_t m_nInfoField2; /* last 4 bytes in a long header */
- uint32_t m_nBodySize;
- uint32_t m_nBytesRead;
- RTMPChunk *m_chunk;
- char *m_body;
- } RTMPPacket;
-
- typedef struct RTMPSockBuf
- {
- int sb_socket;
- int sb_size; /* number of unprocessed bytes in buffer */
- char *sb_start; /* pointer into sb_pBuffer of next byte to process */
- char sb_buf[RTMP_BUFFER_CACHE_SIZE]; /* data read from socket */
- int sb_timedout;
- void *sb_ssl;
- } RTMPSockBuf;
-
- void RTMPPacket_Reset(RTMPPacket *p);
- void RTMPPacket_Dump(RTMPPacket *p);
- int RTMPPacket_Alloc(RTMPPacket *p, int nSize);
- void RTMPPacket_Free(RTMPPacket *p);
-
-#define RTMPPacket_IsReady(a) ((a)->m_nBytesRead == (a)->m_nBodySize)
-
- typedef struct RTMP_LNK
- {
- AVal hostname;
- AVal sockshost;
-
- AVal playpath0; /* parsed from URL */
- AVal playpath; /* passed in explicitly */
- AVal tcUrl;
- AVal swfUrl;
- AVal pageUrl;
- AVal app;
- AVal auth;
- AVal flashVer;
- AVal subscribepath;
- AVal token;
- AMFObject extras;
- int edepth;
-
- int seekTime;
- int stopTime;
-
-#define RTMP_LF_AUTH 0x0001 /* using auth param */
-#define RTMP_LF_LIVE 0x0002 /* stream is live */
-#define RTMP_LF_SWFV 0x0004 /* do SWF verification */
-#define RTMP_LF_PLST 0x0008 /* send playlist before play */
-#define RTMP_LF_BUFX 0x0010 /* toggle stream on BufferEmpty msg */
-#define RTMP_LF_FTCU 0x0020 /* free tcUrl on close */
- int lFlags;
-
- int swfAge;
-
- int protocol;
- int timeout; /* connection timeout in seconds */
-
- unsigned short socksport;
- unsigned short port;
-
-#ifdef CRYPTO
-#define RTMP_SWF_HASHLEN 32
- void *dh; /* for encryption */
- void *rc4keyIn;
- void *rc4keyOut;
-
- uint32_t SWFSize;
- uint8_t SWFHash[RTMP_SWF_HASHLEN];
- char SWFVerificationResponse[RTMP_SWF_HASHLEN+10];
-#endif
- } RTMP_LNK;
-
- /* state for read() wrapper */
- typedef struct RTMP_READ
- {
- char *buf;
- char *bufpos;
- unsigned int buflen;
- uint32_t timestamp;
- uint8_t dataType;
- uint8_t flags;
-#define RTMP_READ_HEADER 0x01
-#define RTMP_READ_RESUME 0x02
-#define RTMP_READ_NO_IGNORE 0x04
-#define RTMP_READ_GOTKF 0x08
-#define RTMP_READ_GOTFLVK 0x10
-#define RTMP_READ_SEEKING 0x20
- int8_t status;
-#define RTMP_READ_COMPLETE -3
-#define RTMP_READ_ERROR -2
-#define RTMP_READ_EOF -1
-#define RTMP_READ_IGNORE 0
-
- /* if bResume == TRUE */
- uint8_t initialFrameType;
- uint32_t nResumeTS;
- char *metaHeader;
- char *initialFrame;
- uint32_t nMetaHeaderSize;
- uint32_t nInitialFrameSize;
- uint32_t nIgnoredFrameCounter;
- uint32_t nIgnoredFlvFrameCounter;
- } RTMP_READ;
-
- typedef struct RTMP_METHOD
- {
- AVal name;
- int num;
- } RTMP_METHOD;
-
- typedef struct RTMP
- {
- int m_inChunkSize;
- int m_outChunkSize;
- int m_nBWCheckCounter;
- int m_nBytesIn;
- int m_nBytesInSent;
- int m_nBufferMS;
- int m_stream_id; /* returned in _result from createStream */
- int m_mediaChannel;
- uint32_t m_mediaStamp;
- uint32_t m_pauseStamp;
- int m_pausing;
- int m_nServerBW;
- int m_nClientBW;
- uint8_t m_nClientBW2;
- uint8_t m_bPlaying;
- uint8_t m_bSendEncoding;
- uint8_t m_bSendCounter;
-
- int m_numInvokes;
- int m_numCalls;
- RTMP_METHOD *m_methodCalls; /* remote method calls queue */
-
- RTMPPacket *m_vecChannelsIn[RTMP_CHANNELS];
- RTMPPacket *m_vecChannelsOut[RTMP_CHANNELS];
- int m_channelTimestamp[RTMP_CHANNELS]; /* abs timestamp of last packet */
-
- double m_fAudioCodecs; /* audioCodecs for the connect packet */
- double m_fVideoCodecs; /* videoCodecs for the connect packet */
- double m_fEncoding; /* AMF0 or AMF3 */
-
- double m_fDuration; /* duration of stream in seconds */
-
- int m_msgCounter; /* RTMPT stuff */
- int m_polling;
- int m_resplen;
- int m_unackd;
- AVal m_clientID;
-
- RTMP_READ m_read;
- RTMPPacket m_write;
- RTMPSockBuf m_sb;
- RTMP_LNK Link;
- } RTMP;
-
- int RTMP_ParseURL(const char *url, int *protocol, AVal *host,
- unsigned int *port, AVal *playpath, AVal *app);
-
- void RTMP_ParsePlaypath(AVal *in, AVal *out);
- void RTMP_SetBufferMS(RTMP *r, int size);
- void RTMP_UpdateBufferMS(RTMP *r);
-
- int RTMP_SetOpt(RTMP *r, const AVal *opt, AVal *arg);
- int RTMP_SetupURL(RTMP *r, char *url);
- void RTMP_SetupStream(RTMP *r, int protocol,
- AVal *hostname,
- unsigned int port,
- AVal *sockshost,
- AVal *playpath,
- AVal *tcUrl,
- AVal *swfUrl,
- AVal *pageUrl,
- AVal *app,
- AVal *auth,
- AVal *swfSHA256Hash,
- uint32_t swfSize,
- AVal *flashVer,
- AVal *subscribepath,
- int dStart,
- int dStop, int bLiveStream, long int timeout);
-
- int RTMP_Connect(RTMP *r, RTMPPacket *cp);
- struct sockaddr;
- int RTMP_Connect0(RTMP *r, struct sockaddr *svc);
- int RTMP_Connect1(RTMP *r, RTMPPacket *cp);
- int RTMP_Serve(RTMP *r);
-
- int RTMP_ReadPacket(RTMP *r, RTMPPacket *packet);
- int RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue);
- int RTMP_SendChunk(RTMP *r, RTMPChunk *chunk);
- int RTMP_IsConnected(RTMP *r);
- int RTMP_Socket(RTMP *r);
- int RTMP_IsTimedout(RTMP *r);
- double RTMP_GetDuration(RTMP *r);
- int RTMP_ToggleStream(RTMP *r);
-
- int RTMP_ConnectStream(RTMP *r, int seekTime);
- int RTMP_ReconnectStream(RTMP *r, int seekTime);
- void RTMP_DeleteStream(RTMP *r);
- int RTMP_GetNextMediaPacket(RTMP *r, RTMPPacket *packet);
- int RTMP_ClientPacket(RTMP *r, RTMPPacket *packet);
-
- void RTMP_Init(RTMP *r);
- void RTMP_Close(RTMP *r);
- RTMP *RTMP_Alloc(void);
- void RTMP_Free(RTMP *r);
- void RTMP_EnableWrite(RTMP *r);
-
- int RTMP_LibVersion(void);
- void RTMP_UserInterrupt(void); /* user typed Ctrl-C */
-
- int RTMP_SendCtrl(RTMP *r, short nType, unsigned int nObject,
- unsigned int nTime);
-
- /* caller probably doesn't know current timestamp, should
- * just use RTMP_Pause instead
- */
- int RTMP_SendPause(RTMP *r, int DoPause, int dTime);
- int RTMP_Pause(RTMP *r, int DoPause);
-
- int RTMP_FindFirstMatchingProperty(AMFObject *obj, const AVal *name,
- AMFObjectProperty * p);
-
- int RTMPSockBuf_Fill(RTMPSockBuf *sb);
- int RTMPSockBuf_Send(RTMPSockBuf *sb, const char *buf, int len);
- int RTMPSockBuf_Close(RTMPSockBuf *sb);
-
- int RTMP_SendCreateStream(RTMP *r);
- int RTMP_SendSeek(RTMP *r, int dTime);
- int RTMP_SendServerBW(RTMP *r);
- int RTMP_SendClientBW(RTMP *r);
- void RTMP_DropRequest(RTMP *r, int i, int freeit);
- int RTMP_Read(RTMP *r, char *buf, int size);
- int RTMP_Write(RTMP *r, const char *buf, int size);
-
-/* hashswf.c */
- int RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash,
- int age);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif
diff --git a/lib/librtmp_win32/librtmp/rtmp_sys.h b/lib/librtmp_win32/librtmp/rtmp_sys.h
deleted file mode 100644
index 0874cbe6ce..0000000000
--- a/lib/librtmp_win32/librtmp/rtmp_sys.h
+++ /dev/null
@@ -1,112 +0,0 @@
-#ifndef __RTMP_SYS_H__
-#define __RTMP_SYS_H__
-/*
- * Copyright (C) 2010 Howard Chu
- *
- * This file is part of librtmp.
- *
- * librtmp is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1,
- * or (at your option) any later version.
- *
- * librtmp is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with librtmp see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/lgpl.html
- */
-
-#ifdef _WIN32
-
-#ifdef _XBOX
-#include <xtl.h>
-#include <winsockx.h>
-#define snprintf _snprintf
-#define strcasecmp stricmp
-#define strncasecmp strnicmp
-#define vsnprintf _vsnprintf
-
-#else /* !_XBOX */
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#endif
-
-#define GetSockError() WSAGetLastError()
-#define SetSockError(e) WSASetLastError(e)
-#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
-#define EWOULDBLOCK WSAETIMEDOUT /* we don't use nonblocking, but we do use timeouts */
-#define sleep(n) Sleep(n*1000)
-#define msleep(n) Sleep(n)
-#define SET_RCVTIMEO(tv,s) int tv = s*1000
-#else /* !_WIN32 */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/times.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#define GetSockError() errno
-#define SetSockError(e) errno = e
-#undef closesocket
-#define closesocket(s) close(s)
-#define msleep(n) usleep(n*1000)
-#define SET_RCVTIMEO(tv,s) struct timeval tv = {s,0}
-#endif
-
-#include "rtmp.h"
-
-#ifdef USE_POLARSSL
-#include <polarssl/net.h>
-#include <polarssl/ssl.h>
-#include <polarssl/havege.h>
-typedef struct tls_ctx {
- havege_state hs;
- ssl_session ssn;
-} tls_ctx;
-#define TLS_CTX tls_ctx *
-#define TLS_client(ctx,s) s = malloc(sizeof(ssl_context)); ssl_init(s);\
- ssl_set_endpoint(s, SSL_IS_CLIENT); ssl_set_authmode(s, SSL_VERIFY_NONE);\
- ssl_set_rng(s, havege_rand, &ctx->hs); ssl_set_ciphers(s, ssl_default_ciphers);\
- ssl_set_session(s, 1, 600, &ctx->ssn)
-#define TLS_setfd(s,fd) ssl_set_bio(s, net_recv, &fd, net_send, &fd)
-#define TLS_connect(s) ssl_handshake(s)
-#define TLS_read(s,b,l) ssl_read(s,(unsigned char *)b,l)
-#define TLS_write(s,b,l) ssl_write(s,(unsigned char *)b,l)
-#define TLS_shutdown(s) ssl_close_notify(s)
-#define TLS_close(s) ssl_free(s); free(s)
-
-#elif defined(USE_GNUTLS)
-#include <gnutls/gnutls.h>
-typedef struct tls_ctx {
- gnutls_certificate_credentials_t cred;
- gnutls_priority_t prios;
-} tls_ctx;
-#define TLS_CTX tls_ctx *
-#define TLS_client(ctx,s) gnutls_init((gnutls_session_t *)(&s), GNUTLS_CLIENT); gnutls_priority_set(s, ctx->prios); gnutls_credentials_set(s, GNUTLS_CRD_CERTIFICATE, ctx->cred)
-#define TLS_setfd(s,fd) gnutls_transport_set_ptr(s, (gnutls_transport_ptr_t)(long)fd)
-#define TLS_connect(s) gnutls_handshake(s)
-#define TLS_read(s,b,l) gnutls_record_recv(s,b,l)
-#define TLS_write(s,b,l) gnutls_record_send(s,b,l)
-#define TLS_shutdown(s) gnutls_bye(s, GNUTLS_SHUT_RDWR)
-#define TLS_close(s) gnutls_deinit(s)
-
-#else /* USE_OPENSSL */
-#define TLS_CTX SSL_CTX *
-#define TLS_client(ctx,s) s = SSL_new(ctx)
-#define TLS_setfd(s,fd) SSL_set_fd(s,fd)
-#define TLS_connect(s) SSL_connect(s)
-#define TLS_read(s,b,l) SSL_read(s,b,l)
-#define TLS_write(s,b,l) SSL_write(s,b,l)
-#define TLS_shutdown(s) SSL_shutdown(s)
-#define TLS_close(s) SSL_free(s)
-
-#endif
-#endif
diff --git a/lib/librtmp_win32/readme.txt b/lib/librtmp_win32/readme.txt
deleted file mode 100644
index fe5a7affee..0000000000
--- a/lib/librtmp_win32/readme.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-- rtmpdump revision 523 (svn://svn.mplayerhq.hu/rtmpdump/trunk)
-- polarssl-0.13.1
-- zlib
-- use provided makefile
-- make SYS=MINGW CRYPTO=POLARSSL librtmp.dll