Changeset View
Changeset View
Standalone View
Standalone View
multimedia/librtmp/files/patch-librtmp-dh.h
--- librtmp/dh.h.orig 2016-02-29 01:15:13 UTC | --- librtmp/dh.h.orig 2019-03-30 21:33:00 UTC | ||||
+++ librtmp/dh.h | +++ librtmp/dh.h | ||||
@@ -194,7 +194,7 @@ typedef BIGNUM * MP_t; | @@ -194,7 +194,7 @@ typedef BIGNUM * MP_t; | ||||
/* RFC 2631, Section 2.1.5, http://www.ietf.org/rfc/rfc2631.txt */ | /* RFC 2631, Section 2.1.5, http://www.ietf.org/rfc/rfc2631.txt */ | ||||
static int | static int | ||||
-isValidPublicKey(MP_t y, MP_t p, MP_t q) | -isValidPublicKey(MP_t y, MP_t p, MP_t q) | ||||
+isValidPublicKey(const MP_t y, const MP_t p, const MP_t q) | +isValidPublicKey(const MP_t y, const MP_t p, const MP_t q) | ||||
{ | { | ||||
int ret = TRUE; | int ret = TRUE; | ||||
MP_t bn; | MP_t bn; | ||||
@@ -253,20 +253,43 @@ DHInit(int nKeyBits) | @@ -253,20 +253,43 @@ DHInit(int nKeyBits) | ||||
if (!dh) | if (!dh) | ||||
goto failed; | goto failed; | ||||
+#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
MP_new(dh->g); | MP_new(dh->g); | ||||
if (!dh->g) | if (!dh->g) | ||||
goto failed; | goto failed; | ||||
+#else | +#else | ||||
+ BIGNUM *g; | + BIGNUM *g; | ||||
+ MP_new(g); | + MP_new(g); | ||||
+ if (g == NULL) | + if (g == NULL) | ||||
+ goto failed; | + goto failed; | ||||
+#endif | +#endif | ||||
+ | + | ||||
+#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
MP_gethex(dh->p, P1024, res); /* prime P1024, see dhgroups.h */ | MP_gethex(dh->p, P1024, res); /* prime P1024, see dhgroups.h */ | ||||
+#else | +#else | ||||
+ const BIGNUM *p = DH_get0_p(dh); | + const BIGNUM *p = DH_get0_p(dh); | ||||
+ | + | ||||
+ MP_gethex(p, P1024, res); /* prime P1024, see dhgroups.h */ | + MP_gethex(p, P1024, res); /* prime P1024, see dhgroups.h */ | ||||
+#endif | +#endif | ||||
if (!res) | if (!res) | ||||
{ | { | ||||
goto failed; | goto failed; | ||||
} | } | ||||
+#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
MP_set_w(dh->g, 2); /* base 2 */ | MP_set_w(dh->g, 2); /* base 2 */ | ||||
+#else | +#else | ||||
+ MP_set_w(g, 2); /* base 2 */ | + MP_set_w(g, 2); /* base 2 */ | ||||
+ DH_set0_pqg(dh, p, NULL, g); | + DH_set0_pqg(dh, p, NULL, g); | ||||
+#endif | +#endif | ||||
+#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
dh->length = nKeyBits; | dh->length = nKeyBits; | ||||
+#else | +#else | ||||
+ DH_set_length(dh, nKeyBits); | + DH_set_length(dh, nKeyBits); | ||||
+#endif | +#endif | ||||
return dh; | return dh; | ||||
failed: | failed: | ||||
@@ -293,12 +316,20 @@ DHGenerateKey(MDH *dh) | @@ -293,12 +316,20 @@ DHGenerateKey(MDH *dh) | ||||
MP_gethex(q1, Q1024, res); | MP_gethex(q1, Q1024, res); | ||||
assert(res); | assert(res); | ||||
+#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
res = isValidPublicKey(dh->pub_key, dh->p, q1); | res = isValidPublicKey(dh->pub_key, dh->p, q1); | ||||
+#else | +#else | ||||
+ res = isValidPublicKey(DH_get0_pub_key(dh), DH_get0_p(dh), q1); | + res = isValidPublicKey(DH_get0_pub_key(dh), DH_get0_p(dh), q1); | ||||
+#endif | +#endif | ||||
if (!res) | if (!res) | ||||
{ | { | ||||
+#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
MP_free(dh->pub_key); | MP_free(dh->pub_key); | ||||
MP_free(dh->priv_key); | MP_free(dh->priv_key); | ||||
dh->pub_key = dh->priv_key = 0; | dh->pub_key = dh->priv_key = 0; | ||||
+#else | +#else | ||||
+ DH_set0_key(dh, NULL, NULL); | + DH_set0_key(dh, NULL, NULL); | ||||
+#endif | +#endif | ||||
} | } | ||||
MP_free(q1); | MP_free(q1); | ||||
@@ -314,15 +345,27 @@ static int | @@ -314,15 +345,27 @@ static int | ||||
DHGetPublicKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen) | DHGetPublicKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen) | ||||
{ | { | ||||
int len; | int len; | ||||
+#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
if (!dh || !dh->pub_key) | if (!dh || !dh->pub_key) | ||||
+#else | +#else | ||||
+ if (!dh || !DH_get0_pub_key(dh)) | + if (!dh || !DH_get0_pub_key(dh)) | ||||
+#endif | +#endif | ||||
return 0; | return 0; | ||||
+#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
len = MP_bytes(dh->pub_key); | len = MP_bytes(dh->pub_key); | ||||
+#else | +#else | ||||
+ len = MP_bytes(DH_get0_pub_key(dh)); | + len = MP_bytes(DH_get0_pub_key(dh)); | ||||
+#endif | +#endif | ||||
if (len <= 0 || len > (int) nPubkeyLen) | if (len <= 0 || len > (int) nPubkeyLen) | ||||
return 0; | return 0; | ||||
memset(pubkey, 0, nPubkeyLen); | memset(pubkey, 0, nPubkeyLen); | ||||
+#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
MP_setbin(dh->pub_key, pubkey + (nPubkeyLen - len), len); | MP_setbin(dh->pub_key, pubkey + (nPubkeyLen - len), len); | ||||
+#else | +#else | ||||
+ MP_setbin(DH_get0_pub_key(dh), pubkey + (nPubkeyLen - len), len); | + MP_setbin(DH_get0_pub_key(dh), pubkey + (nPubkeyLen - len), len); | ||||
+#endif | +#endif | ||||
return 1; | return 1; | ||||
} | } | ||||
@@ -364,7 +407,11 @@ DHComputeSharedSecretKey(MDH *dh, uint8_ | @@ -364,7 +407,11 @@ DHComputeSharedSecretKey(MDH *dh, uint8_t *pubkey, siz | ||||
MP_gethex(q1, Q1024, len); | MP_gethex(q1, Q1024, len); | ||||
assert(len); | assert(len); | ||||
+#if !defined(USE_OPENSSL) || defined(LIBRESSL_VERSION_NUMBER) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | +#if !defined(USE_OPENSSL) || !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000L | ||||
if (isValidPublicKey(pubkeyBn, dh->p, q1)) | if (isValidPublicKey(pubkeyBn, dh->p, q1)) | ||||
+#else | +#else | ||||
+ if (isValidPublicKey(pubkeyBn, DH_get0_p(dh), q1)) | + if (isValidPublicKey(pubkeyBn, DH_get0_p(dh), q1)) | ||||
+#endif | +#endif | ||||
res = MDH_compute_key(secret, nPubkeyLen, pubkeyBn, dh); | res = MDH_compute_key(secret, nPubkeyLen, pubkeyBn, dh); | ||||
else | else | ||||
res = -1; | res = -1; |