Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
3505d557
Commit
3505d557
authored
Jul 05, 2012
by
Samuel Pitoiset
Committed by
Martin Storsjö
Jul 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtmp: Rename rtmp_calc_digest to ff_rtmp_calc_digest and make it global
Signed-off-by:
Martin Storsjö
<
martin@martin.st
>
parent
3b175384
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
33 deletions
+36
-33
rtmp.h
libavformat/rtmp.h
+17
-0
rtmpproto.c
libavformat/rtmpproto.c
+19
-33
No files found.
libavformat/rtmp.h
View file @
3505d557
...
...
@@ -29,6 +29,9 @@
#define RTMP_HANDSHAKE_PACKET_SIZE 1536
#define HMAC_IPAD_VAL 0x36
#define HMAC_OPAD_VAL 0x5C
/**
* emulated Flash client version - 9.0.124.2 on Linux
* @{
...
...
@@ -40,4 +43,18 @@
#define RTMP_CLIENT_VER4 2
/** @} */
//version defines
/**
* Calculate HMAC-SHA2 digest for RTMP handshake packets.
*
* @param src input buffer
* @param len input buffer length (should be 1536)
* @param gap offset in buffer where 32 bytes should not be taken into account
* when calculating digest (since it will be used to store that digest)
* @param key digest key
* @param keylen digest key length
* @param dst buffer where calculated digest will be stored (32 bytes)
*/
int
ff_rtmp_calc_digest
(
const
uint8_t
*
src
,
int
len
,
int
gap
,
const
uint8_t
*
key
,
int
keylen
,
uint8_t
*
dst
);
#endif
/* AVFORMAT_RTMP_H */
libavformat/rtmpproto.c
View file @
3505d557
...
...
@@ -590,23 +590,8 @@ static int gen_bytes_read(URLContext *s, RTMPContext *rt, uint32_t ts)
return
ret
;
}
//TODO: Move HMAC code somewhere. Eventually.
#define HMAC_IPAD_VAL 0x36
#define HMAC_OPAD_VAL 0x5C
/**
* Calculate HMAC-SHA2 digest for RTMP handshake packets.
*
* @param src input buffer
* @param len input buffer length (should be 1536)
* @param gap offset in buffer where 32 bytes should not be taken into account
* when calculating digest (since it will be used to store that digest)
* @param key digest key
* @param keylen digest key length
* @param dst buffer where calculated digest will be stored (32 bytes)
*/
static
int
rtmp_calc_digest
(
const
uint8_t
*
src
,
int
len
,
int
gap
,
const
uint8_t
*
key
,
int
keylen
,
uint8_t
*
dst
)
int
ff_rtmp_calc_digest
(
const
uint8_t
*
src
,
int
len
,
int
gap
,
const
uint8_t
*
key
,
int
keylen
,
uint8_t
*
dst
)
{
struct
AVSHA
*
sha
;
uint8_t
hmac_buf
[
64
+
32
]
=
{
0
};
...
...
@@ -663,9 +648,9 @@ static int rtmp_handshake_imprint_with_digest(uint8_t *buf)
digest_pos
+=
buf
[
i
];
digest_pos
=
(
digest_pos
%
728
)
+
12
;
ret
=
rtmp_calc_digest
(
buf
,
RTMP_HANDSHAKE_PACKET_SIZE
,
digest_pos
,
rtmp_player_key
,
PLAYER_KEY_OPEN_PART_LEN
,
buf
+
digest_pos
);
ret
=
ff_
rtmp_calc_digest
(
buf
,
RTMP_HANDSHAKE_PACKET_SIZE
,
digest_pos
,
rtmp_player_key
,
PLAYER_KEY_OPEN_PART_LEN
,
buf
+
digest_pos
);
if
(
ret
<
0
)
return
ret
;
...
...
@@ -689,9 +674,9 @@ static int rtmp_validate_digest(uint8_t *buf, int off)
digest_pos
+=
buf
[
i
+
off
];
digest_pos
=
(
digest_pos
%
728
)
+
off
+
4
;
ret
=
rtmp_calc_digest
(
buf
,
RTMP_HANDSHAKE_PACKET_SIZE
,
digest_pos
,
rtmp_server_key
,
SERVER_KEY_OPEN_PART_LEN
,
digest
);
ret
=
ff_
rtmp_calc_digest
(
buf
,
RTMP_HANDSHAKE_PACKET_SIZE
,
digest_pos
,
rtmp_server_key
,
SERVER_KEY_OPEN_PART_LEN
,
digest
);
if
(
ret
<
0
)
return
ret
;
...
...
@@ -771,13 +756,14 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
}
}
ret
=
rtmp_calc_digest
(
tosend
+
1
+
client_pos
,
32
,
0
,
rtmp_server_key
,
sizeof
(
rtmp_server_key
),
digest
);
ret
=
ff_rtmp_calc_digest
(
tosend
+
1
+
client_pos
,
32
,
0
,
rtmp_server_key
,
sizeof
(
rtmp_server_key
),
digest
);
if
(
ret
<
0
)
return
ret
;
ret
=
rtmp_calc_digest
(
clientdata
,
RTMP_HANDSHAKE_PACKET_SIZE
-
32
,
0
,
digest
,
32
,
digest
);
ret
=
ff_rtmp_calc_digest
(
clientdata
,
RTMP_HANDSHAKE_PACKET_SIZE
-
32
,
0
,
digest
,
32
,
digest
);
if
(
ret
<
0
)
return
ret
;
...
...
@@ -788,15 +774,15 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
for
(
i
=
0
;
i
<
RTMP_HANDSHAKE_PACKET_SIZE
;
i
++
)
tosend
[
i
]
=
av_lfg_get
(
&
rnd
)
>>
24
;
ret
=
rtmp_calc_digest
(
serverdata
+
1
+
server_pos
,
32
,
0
,
rtmp_player_key
,
sizeof
(
rtmp_player_key
),
digest
);
ret
=
ff_
rtmp_calc_digest
(
serverdata
+
1
+
server_pos
,
32
,
0
,
rtmp_player_key
,
sizeof
(
rtmp_player_key
),
digest
);
if
(
ret
<
0
)
return
ret
;
ret
=
rtmp_calc_digest
(
tosend
,
RTMP_HANDSHAKE_PACKET_SIZE
-
32
,
0
,
digest
,
32
,
tosend
+
RTMP_HANDSHAKE_PACKET_SIZE
-
32
);
ret
=
ff_
rtmp_calc_digest
(
tosend
,
RTMP_HANDSHAKE_PACKET_SIZE
-
32
,
0
,
digest
,
32
,
tosend
+
RTMP_HANDSHAKE_PACKET_SIZE
-
32
);
if
(
ret
<
0
)
return
ret
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment