1 --- librtmp/dh.h.orig 2016-02-29 01:15:13 UTC
3 @@ -194,7 +194,7 @@ typedef BIGNUM * MP_t;
5 /* RFC 2631, Section 2.1.5, http://www.ietf.org/rfc/rfc2631.txt */
7 -isValidPublicKey(MP_t y, MP_t p, MP_t q)
8 +isValidPublicKey(const MP_t y, const MP_t p, const MP_t q)
12 @@ -253,20 +253,43 @@ DHInit(int nKeyBits)
16 +#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
29 +#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
30 MP_gethex(dh->p, P1024, res); /* prime P1024, see dhgroups.h */
32 + const BIGNUM *p = DH_get0_p(dh);
34 + MP_gethex(p, P1024, res); /* prime P1024, see dhgroups.h */
41 +#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
42 MP_set_w(dh->g, 2); /* base 2 */
44 + MP_set_w(g, 2); /* base 2 */
45 + DH_set0_pqg(dh, p, NULL, g);
48 +#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
49 dh->length = nKeyBits;
51 + DH_set_length(dh, nKeyBits);
56 @@ -293,12 +316,20 @@ DHGenerateKey(MDH *dh)
57 MP_gethex(q1, Q1024, res);
60 +#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
61 res = isValidPublicKey(dh->pub_key, dh->p, q1);
63 + res = isValidPublicKey(DH_get0_pub_key(dh), DH_get0_p(dh), q1);
67 +#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
69 MP_free(dh->priv_key);
70 dh->pub_key = dh->priv_key = 0;
72 + DH_set0_key(dh, NULL, NULL);
77 @@ -314,15 +345,27 @@ static int
78 DHGetPublicKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen)
81 +#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
82 if (!dh || !dh->pub_key)
84 + if (!dh || !DH_get0_pub_key(dh))
88 +#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
89 len = MP_bytes(dh->pub_key);
91 + len = MP_bytes(DH_get0_pub_key(dh));
93 if (len <= 0 || len > (int) nPubkeyLen)
96 memset(pubkey, 0, nPubkeyLen);
97 +#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
98 MP_setbin(dh->pub_key, pubkey + (nPubkeyLen - len), len);
100 + MP_setbin(DH_get0_pub_key(dh), pubkey + (nPubkeyLen - len), len);
105 @@ -364,7 +407,11 @@ DHComputeSharedSecretKey(MDH *dh, uint8_
106 MP_gethex(q1, Q1024, len);
109 +#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L
110 if (isValidPublicKey(pubkeyBn, dh->p, q1))
112 + if (isValidPublicKey(pubkeyBn, DH_get0_p(dh), q1))
114 res = MDH_compute_key(secret, nPubkeyLen, pubkeyBn, dh);