1 --- dh.h.orig 2016-02-29 01:15:13 UTC
3 @@ -253,20 +253,44 @@ DHInit(int nKeyBits)
7 +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
18 + DH_set0_pqg(dh, NULL, g, NULL);
21 +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
22 MP_gethex(dh->p, P1024, res); /* prime P1024, see dhgroups.h */
25 + DH_get0_pqg(dh, (BIGNUM const**)&p, NULL, NULL);
26 + MP_gethex(p, P1024, res); /* prime P1024, see dhgroups.h */
33 +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
34 MP_set_w(dh->g, 2); /* base 2 */
36 + MP_set_w(g, 2); /* base 2 */
37 + DH_set0_pqg(dh, NULL, g, NULL);
40 +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
41 dh->length = nKeyBits;
43 + DH_set_length(dh, nKeyBits);
48 @@ -293,12 +317,24 @@ DHGenerateKey(MDH *dh)
49 MP_gethex(q1, Q1024, res);
52 +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
53 res = isValidPublicKey(dh->pub_key, dh->p, q1);
55 + BIGNUM const* pub_key = NULL;
56 + BIGNUM const* p = NULL;
57 + DH_get0_key(dh, &pub_key, NULL);
58 + DH_get0_pqg(dh, &p, NULL, NULL);
59 + res = isValidPublicKey((BIGNUM*)pub_key, (BIGNUM*)p, q1);
63 +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
65 MP_free(dh->priv_key);
66 dh->pub_key = dh->priv_key = 0;
73 @@ -314,15 +350,29 @@ static int
74 DHGetPublicKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen)
77 +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
78 if (!dh || !dh->pub_key)
80 + BIGNUM const* pub_key = NULL;
81 + DH_get0_key(dh, &pub_key, NULL);
82 + if (!dh || !pub_key)
86 +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
87 len = MP_bytes(dh->pub_key);
89 + len = MP_bytes(pub_key);
91 if (len <= 0 || len > (int) nPubkeyLen)
94 memset(pubkey, 0, nPubkeyLen);
95 +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
96 MP_setbin(dh->pub_key, pubkey + (nPubkeyLen - len), len);
98 + MP_setbin(pub_key, pubkey + (nPubkeyLen - len), len);
103 @@ -364,7 +414,13 @@ DHComputeSharedSecretKey(MDH *dh, uint8_t *pubkey, siz
104 MP_gethex(q1, Q1024, len);
107 +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
108 if (isValidPublicKey(pubkeyBn, dh->p, q1))
110 + BIGNUM const* p = NULL;
111 + DH_get0_pqg(dh, &p, NULL, NULL);
112 + if (isValidPublicKey(pubkeyBn, (BIGNUM*)p, q1))
114 res = MDH_compute_key(secret, nPubkeyLen, pubkeyBn, dh);
117 --- handshake.h.orig 2016-02-29 01:15:13 UTC
120 #define SHA256_DIGEST_LENGTH 32
122 #define HMAC_CTX sha2_context
123 -#define HMAC_setup(ctx, key, len) sha2_hmac_starts(&ctx, (unsigned char *)key, len, 0)
124 -#define HMAC_crunch(ctx, buf, len) sha2_hmac_update(&ctx, buf, len)
125 -#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(&ctx, dig)
126 +#define HMAC_setup(ctx, key, len) sha2_hmac_starts(ctx, (unsigned char *)key, len, 0)
127 +#define HMAC_crunch(ctx, buf, len) sha2_hmac_update(ctx, buf, len)
128 +#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(ctx, dig)
130 typedef arc4_context * RC4_handle;
131 #define RC4_alloc(h) *h = malloc(sizeof(arc4_context))
132 @@ -50,9 +50,9 @@ typedef arc4_context * RC4_handle;
135 #define HMAC_CTX struct hmac_sha256_ctx
136 -#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(&ctx, len, key)
137 -#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(&ctx, len, buf)
138 -#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig)
139 +#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(ctx, len, key)
140 +#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(ctx, len, buf)
141 +#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(ctx, SHA256_DIGEST_LENGTH, dig)
142 #define HMAC_close(ctx)
144 typedef struct arcfour_ctx* RC4_handle;
145 @@ -64,14 +64,23 @@ typedef struct arcfour_ctx* RC4_handle;
147 #else /* USE_OPENSSL */
148 #include <openssl/sha.h>
149 +#include <openssl/ossl_typ.h>
150 #include <openssl/hmac.h>
151 #include <openssl/rc4.h>
152 #if OPENSSL_VERSION_NUMBER < 0x0090800 || !defined(SHA256_DIGEST_LENGTH)
153 #error Your OpenSSL is too old, need 0.9.8 or newer with SHA256
155 -#define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, key, len, EVP_sha256(), 0)
156 -#define HMAC_crunch(ctx, buf, len) HMAC_Update(&ctx, buf, len)
157 -#define HMAC_finish(ctx, dig, dlen) HMAC_Final(&ctx, dig, &dlen); HMAC_CTX_cleanup(&ctx)
158 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
159 +#define HMAC_setup(ctx, key, len) HMAC_CTX_init(ctx); HMAC_Init_ex(ctx, key, len, EVP_sha256(), 0)
161 +#define HMAC_setup(ctx, key, len) HMAC_CTX_reset(ctx); HMAC_Init_ex(ctx, key, len, EVP_sha256(), 0)
163 +#define HMAC_crunch(ctx, buf, len) HMAC_Update(ctx, buf, len)
164 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
165 +#define HMAC_finish(ctx, dig, dlen) HMAC_Final(ctx, dig, &dlen); HMAC_CTX_cleanup(ctx)
167 +#define HMAC_finish(ctx, dig, dlen) HMAC_Final(ctx, dig, &dlen); HMAC_CTX_free(ctx)
170 typedef RC4_KEY * RC4_handle;
171 #define RC4_alloc(h) *h = malloc(sizeof(RC4_KEY))
172 @@ -117,7 +126,7 @@ static void InitRC4Encryption
174 uint8_t digest[SHA256_DIGEST_LENGTH];
175 unsigned int digestLen = 0;
177 + HMAC_CTX* ctx = NULL;
180 RC4_alloc(rc4keyOut);
181 @@ -266,7 +275,7 @@ HMACsha256(const uint8_t *message, size_t messageLen,
182 size_t keylen, uint8_t *digest)
184 unsigned int digestLen;
186 + HMAC_CTX* ctx = NULL;
188 HMAC_setup(ctx, key, keylen);
189 HMAC_crunch(ctx, message, messageLen);
190 --- hashswf.c.orig 2016-02-29 01:15:13 UTC
193 #define SHA256_DIGEST_LENGTH 32
195 #define HMAC_CTX sha2_context
196 -#define HMAC_setup(ctx, key, len) sha2_hmac_starts(&ctx, (unsigned char *)key, len, 0)
197 -#define HMAC_crunch(ctx, buf, len) sha2_hmac_update(&ctx, buf, len)
198 -#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(&ctx, dig)
199 +#define HMAC_setup(ctx, key, len) sha2_hmac_starts(ctx, (unsigned char *)key, len, 0)
200 +#define HMAC_crunch(ctx, buf, len) sha2_hmac_update(ctx, buf, len)
201 +#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(ctx, dig)
202 #define HMAC_close(ctx)
203 #elif defined(USE_GNUTLS)
204 #include <nettle/hmac.h>
208 #define HMAC_CTX struct hmac_sha256_ctx
209 -#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(&ctx, len, key)
210 -#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(&ctx, len, buf)
211 -#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig)
212 +#define HMAC_setup(ctx, key, len) hmac_sha256_set_key(ctx, len, key)
213 +#define HMAC_crunch(ctx, buf, len) hmac_sha256_update(ctx, len, buf)
214 +#define HMAC_finish(ctx, dig, dlen) dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(ctx, SHA256_DIGEST_LENGTH, dig)
215 #define HMAC_close(ctx)
216 #else /* USE_OPENSSL */
217 #include <openssl/ssl.h>
218 #include <openssl/sha.h>
219 #include <openssl/hmac.h>
220 #include <openssl/rc4.h>
221 -#define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, (unsigned char *)key, len, EVP_sha256(), 0)
222 -#define HMAC_crunch(ctx, buf, len) HMAC_Update(&ctx, (unsigned char *)buf, len)
223 -#define HMAC_finish(ctx, dig, dlen) HMAC_Final(&ctx, (unsigned char *)dig, &dlen);
224 -#define HMAC_close(ctx) HMAC_CTX_cleanup(&ctx)
225 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
226 +#define HMAC_setup(ctx, key, len) HMAC_CTX_init(ctx); HMAC_Init_ex(ctx, (unsigned char *)key, len, EVP_sha256(), 0)
228 +#define HMAC_setup(ctx, key, len) HMAC_CTX_reset(ctx); HMAC_Init_ex(ctx, (unsigned char *)key, len, EVP_sha256(), 0)
230 +#define HMAC_crunch(ctx, buf, len) HMAC_Update(ctx, (unsigned char *)buf, len)
231 +#define HMAC_finish(ctx, dig, dlen) HMAC_Final(ctx, (unsigned char *)dig, &dlen);
232 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
233 +#define HMAC_close(ctx) HMAC_CTX_cleanup(ctx)
235 +#define HMAC_close(ctx) HMAC_CTX_reset(ctx); HMAC_CTX_free(ctx)
239 extern void RTMP_TLS_Init();
240 extern TLS_CTX RTMP_TLS_ctx;
241 @@ -289,7 +297,7 @@ leave: