[rtmpdump] branch master updated. ee5456b Update OpenSSL support
rtmpdump at mplayerhq.hu
rtmpdump at mplayerhq.hu
Wed Feb 28 18:29:43 EET 2024
The branch, master has been updated
via ee5456b5374c12f66e47f56b4e83e9557c62ebfe (commit)
via b7c7976457b65e675f8fd006debc501a6f16548f (commit)
from b59c7926aff3271ff0fe85ac46c6ca390dc81000 (commit)
- Log -----------------------------------------------------------------
commit ee5456b5374c12f66e47f56b4e83e9557c62ebfe
Author: Howard Chu <hyc at highlandsun.com>
AuthorDate: Wed Feb 28 16:29:29 2024 +0000
Commit: Howard Chu <hyc at highlandsun.com>
CommitDate: Wed Feb 28 16:29:29 2024 +0000
Update OpenSSL support
diff --git a/librtmp/dh.h b/librtmp/dh.h
index 5fc3f32..59ab6a8 100644
--- a/librtmp/dh.h
+++ b/librtmp/dh.h
@@ -249,24 +249,26 @@ DHInit(int nKeyBits)
{
size_t res;
MDH *dh = MDH_new();
+ MP_t g, p;
if (!dh)
goto failed;
- MP_new(dh->g);
+ MP_new(g);
- if (!dh->g)
+ if (!g)
goto failed;
- MP_gethex(dh->p, P1024, res); /* prime P1024, see dhgroups.h */
+ MP_gethex(p, P1024, res); /* prime P1024, see dhgroups.h */
if (!res)
{
goto failed;
}
- MP_set_w(dh->g, 2); /* base 2 */
+ MP_set_w(g, 2); /* base 2 */
+ DH_set0_pqg(dh, p, NULL, g);
- dh->length = nKeyBits;
+ DH_set_length(dh, nKeyBits);
return dh;
failed:
@@ -279,31 +281,30 @@ failed:
static int
DHGenerateKey(MDH *dh)
{
- size_t res = 0;
+ MP_t q1;
+ size_t res;
if (!dh)
return 0;
- while (!res)
- {
- MP_t q1 = NULL;
-
- if (!MDH_generate_key(dh))
- return 0;
+ MP_gethex(q1, Q1024, res);
+ assert(res);
- MP_gethex(q1, Q1024, res);
- assert(res);
-
- res = isValidPublicKey(dh->pub_key, dh->p, q1);
- if (!res)
+ do
+ {
+ if (MDH_generate_key(dh))
+ {
+ MP_t key = (MP_t)DH_get0_pub_key(dh);
+ MP_t p = (MP_t)DH_get0_p(dh);
+ res = isValidPublicKey(key, p, q1);
+ }
+ else
{
- MP_free(dh->pub_key);
- MP_free(dh->priv_key);
- dh->pub_key = dh->priv_key = 0;
+ res = 0;
+ break;
}
-
- MP_free(q1);
- }
- return 1;
+ } while (!res);
+ MP_free(q1);
+ return res;
}
/* fill pubkey with the public key in BIG ENDIAN order
@@ -314,15 +315,16 @@ static int
DHGetPublicKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen)
{
int len;
- if (!dh || !dh->pub_key)
+ MP_t pub_key;
+ if (!dh || !(pub_key = (MP_t)DH_get0_pub_key(dh)))
return 0;
- len = MP_bytes(dh->pub_key);
+ len = MP_bytes(pub_key);
if (len <= 0 || len > (int) nPubkeyLen)
return 0;
memset(pubkey, 0, nPubkeyLen);
- MP_setbin(dh->pub_key, pubkey + (nPubkeyLen - len), len);
+ MP_setbin(pub_key, pubkey + (nPubkeyLen - len), len);
return 1;
}
@@ -364,7 +366,7 @@ DHComputeSharedSecretKey(MDH *dh, uint8_t *pubkey, size_t nPubkeyLen,
MP_gethex(q1, Q1024, len);
assert(len);
- if (isValidPublicKey(pubkeyBn, dh->p, q1))
+ if (isValidPublicKey(pubkeyBn, (MP_t)DH_get0_p(dh), q1))
res = MDH_compute_key(secret, nPubkeyLen, pubkeyBn, dh);
else
res = -1;
diff --git a/librtmp/handshake.h b/librtmp/handshake.h
index 0438486..ac38c88 100644
--- a/librtmp/handshake.h
+++ b/librtmp/handshake.h
@@ -69,9 +69,16 @@ typedef struct arcfour_ctx* RC4_handle;
#if OPENSSL_VERSION_NUMBER < 0x0090800 || !defined(SHA256_DIGEST_LENGTH)
#error Your OpenSSL is too old, need 0.9.8 or newer with SHA256
#endif
+#if OPENSSL_VERSION_NUMBER >= 0x10100000
+#define HMAC_CTX HMAC_CTX *
+#define HMAC_setup(ctx, key, len) ctx = HMAC_CTX_new(); 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_free(ctx)
+#else
#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)
+#endif
typedef RC4_KEY * RC4_handle;
#define RC4_alloc(h) *h = malloc(sizeof(RC4_KEY))
diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
index e3669e3..fc5f824 100644
--- a/librtmp/hashswf.c
+++ b/librtmp/hashswf.c
@@ -58,11 +58,19 @@
#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <openssl/rc4.h>
+#if OPENSSL_VERSION_NUMBER >= 0x10100000
+#define HMAC_CTX HMAC_CTX *
+#define HMAC_setup(ctx, key, len) ctx = HMAC_CTX_new(); 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)
+#define HMAC_close(ctx) HMAC_CTX_free(ctx)
+#else
#define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, (unsigned char *)key, len, EVP_sha256(), 0)
#define HMAC_crunch(ctx, buf, len) HMAC_Update(&ctx, (unsigned char *)buf, len)
#define HMAC_finish(ctx, dig, dlen) HMAC_Final(&ctx, (unsigned char *)dig, &dlen);
#define HMAC_close(ctx) HMAC_CTX_cleanup(&ctx)
#endif
+#endif
extern void RTMP_TLS_Init();
extern TLS_CTX RTMP_TLS_ctx;
commit b7c7976457b65e675f8fd006debc501a6f16548f
Author: Howard Chu <hyc at highlandsun.com>
AuthorDate: Wed Feb 28 16:29:01 2024 +0000
Commit: Howard Chu <hyc at highlandsun.com>
CommitDate: Wed Feb 28 16:29:01 2024 +0000
Delte unused didAlloc var
diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
index 0162c88..cf1de70 100644
--- a/librtmp/rtmp.c
+++ b/librtmp/rtmp.c
@@ -3553,7 +3553,6 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet)
uint8_t hbuf[RTMP_MAX_HEADER_SIZE] = { 0 };
char *header = (char *)hbuf;
int nSize, hSize, nToRead, nChunk;
- int didAlloc = FALSE;
int extendedTimestamp;
RTMP_Log(RTMP_LOGDEBUG2, "%s: fd=%d", __FUNCTION__, r->m_sb.sb_socket);
@@ -3683,7 +3682,6 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet)
RTMP_Log(RTMP_LOGDEBUG, "%s, failed to allocate packet", __FUNCTION__);
return FALSE;
}
- didAlloc = TRUE;
packet->m_headerType = (hbuf[0] & 0xc0) >> 6;
}
-----------------------------------------------------------------------
Summary of changes:
librtmp/dh.h | 58 +++++++++++++++++++++++++++--------------------------
librtmp/handshake.h | 7 +++++++
librtmp/hashswf.c | 8 ++++++++
librtmp/rtmp.c | 2 --
4 files changed, 45 insertions(+), 30 deletions(-)
hooks/post-receive
--
More information about the rtmpdump
mailing list