Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
red5-server-GL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amine Chbari
red5-server-GL
Commits
e3a1764d
Commit
e3a1764d
authored
1 year ago
by
amine.chbari.etu
Browse files
Options
Downloads
Patches
Plain Diff
declarer une fonction encrypt_rtmpe() pour regrouper le code dupliqué
parent
cb7f8f67
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/src/main/java/org/red5/server/net/rtmp/InboundHandshake.java
+34
-39
34 additions, 39 deletions
.../main/java/org/red5/server/net/rtmp/InboundHandshake.java
with
34 additions
and
39 deletions
server/src/main/java/org/red5/server/net/rtmp/InboundHandshake.java
+
34
−
39
View file @
e3a1764d
...
...
@@ -63,6 +63,35 @@ public class InboundHandshake extends RTMPHandshake {
return
decodeClientRequest1
(
in
);
}
/**
* encrypts the response to the client request C1
* this was duplicated code 176 - 195 and 241 - 259 from original file
* regroup it in one method
*/
public
void
encrypt_rtmpe
(
byte
handshaketype
,
int
DIGEST_LENGTH
,
byte
[]
signatureResp
,
byte
[]
digestresp
){
switch
(
handshakeType
)
{
case
RTMPConnection
.
RTMP_ENCRYPTED_XTEA
:
log
.
debug
(
"RTMPE type 8 XTEA"
);
// encrypt signatureResp
for
(
int
i
=
0
;
i
<
DIGEST_LENGTH
;
i
+=
8
)
{
encryptXtea
(
signatureResp
,
i
,
digestresp
[
i
]
%
15
);
}
break
;
case
RTMPConnection
.
RTMP_ENCRYPTED_BLOWFISH
:
log
.
debug
(
"RTMPE type 9 Blowfish"
);
// encrypt signatureResp
for
(
int
i
=
0
;
i
<
DIGEST_LENGTH
;
i
+=
8
)
{
encryptBlowfish
(
signatureResp
,
i
,
digestresp
[
i
]
%
15
);
}
break
;
}
}
/**
* Decodes the first client request (C1) and returns a server response (S0S1).
*
...
...
@@ -173,26 +202,8 @@ public class InboundHandshake extends RTMPHandshake {
calculateHMAC_SHA256
(
c1
,
0
,
(
Constants
.
HANDSHAKE_SIZE
-
DIGEST_LENGTH
),
digestResp
,
DIGEST_LENGTH
,
signatureResponse
,
0
);
log
.
debug
(
"Signature response: {}"
,
Hex
.
encodeHexString
(
signatureResponse
));
if
(
useEncryption
())
{
switch
(
handshakeType
)
{
case
RTMPConnection
.
RTMP_ENCRYPTED
:
log
.
debug
(
"RTMPE type 6"
);
// we dont encrypt signatureResp for type 6
break
;
case
RTMPConnection
.
RTMP_ENCRYPTED_XTEA
:
log
.
debug
(
"RTMPE type 8 XTEA"
);
// encrypt signatureResp
for
(
int
i
=
0
;
i
<
DIGEST_LENGTH
;
i
+=
8
)
{
encryptXtea
(
signatureResponse
,
i
,
digestResp
[
i
]
%
15
);
}
break
;
case
RTMPConnection
.
RTMP_ENCRYPTED_BLOWFISH
:
log
.
debug
(
"RTMPE type 9 Blowfish"
);
// encrypt signatureResp
for
(
int
i
=
0
;
i
<
DIGEST_LENGTH
;
i
+=
8
)
{
encryptBlowfish
(
signatureResponse
,
i
,
digestResp
[
i
]
%
15
);
}
break
;
}
// replace the switch block with called function
encrypt_rtmpe
(
handshakeType
,
DIGEST_LENGTH
,
signatureResponse
,
digestResp
);
}
// copy signature into C1 as S2
System
.
arraycopy
(
signatureResponse
,
0
,
c1
,
(
Constants
.
HANDSHAKE_SIZE
-
DIGEST_LENGTH
),
DIGEST_LENGTH
);
...
...
@@ -238,25 +249,9 @@ public class InboundHandshake extends RTMPHandshake {
calculateHMAC_SHA256
(
s1
,
digestPosServer
,
DIGEST_LENGTH
,
GENUINE_FP_KEY
,
GENUINE_FP_KEY
.
length
,
digest
,
0
);
calculateHMAC_SHA256
(
c2
,
0
,
Constants
.
HANDSHAKE_SIZE
-
DIGEST_LENGTH
,
digest
,
DIGEST_LENGTH
,
signature
,
0
);
if
(
useEncryption
())
{
switch
(
handshakeType
)
{
case
RTMPConnection
.
RTMP_ENCRYPTED
:
log
.
debug
(
"RTMPE type 6"
);
break
;
case
RTMPConnection
.
RTMP_ENCRYPTED_XTEA
:
log
.
debug
(
"RTMPE type 8 XTEA"
);
// encrypt signature
for
(
int
i
=
0
;
i
<
DIGEST_LENGTH
;
i
+=
8
)
{
encryptXtea
(
signature
,
i
,
digest
[
i
]
%
15
);
}
break
;
case
RTMPConnection
.
RTMP_ENCRYPTED_BLOWFISH
:
log
.
debug
(
"RTMPE type 9 Blowfish"
);
// encrypt signature
for
(
int
i
=
0
;
i
<
DIGEST_LENGTH
;
i
+=
8
)
{
encryptBlowfish
(
signature
,
i
,
digest
[
i
]
%
15
);
}
break
;
}
// replace the switch block with called function
encrypt_rtmpe
(
handshakeType
,
DIGEST_LENGTH
,
signature
,
digest
);
// update 'encoder / decoder state' for the RC4 keys both parties *pretend* as if handshake part 2 (1536 bytes) was encrypted
// effectively this hides / discards the first few bytes of encrypted session which is known to increase the secure-ness of RC4
// RC4 state is just a function of number of bytes processed so far that's why we just run 1536 arbitrary bytes through the keys below
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment