Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
4619c0a5
Commit
4619c0a5
authored
Jun 04, 2008
by
Kaloyan Kovachev
Committed by
Rémi Denis-Courmont
Jun 07, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the CSA Key parsing inside csa_SetCW function
Signed-off-by:
Rémi Denis-Courmont
<
rdenis@simphalempin.com
>
parent
d9810ce0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
81 deletions
+80
-81
modules/demux/ts.c
modules/demux/ts.c
+18
-40
modules/mux/mpeg/csa.c
modules/mux/mpeg/csa.c
+45
-5
modules/mux/mpeg/csa.h
modules/mux/mpeg/csa.h
+1
-1
modules/mux/mpeg/ts.c
modules/mux/mpeg/ts.c
+16
-35
No files found.
modules/demux/ts.c
View file @
4619c0a5
...
@@ -777,52 +777,30 @@ static int Open( vlc_object_t *p_this )
...
@@ -777,52 +777,30 @@ static int Open( vlc_object_t *p_this )
var_Get
(
p_demux
,
"ts-csa-ck"
,
&
val
);
var_Get
(
p_demux
,
"ts-csa-ck"
,
&
val
);
if
(
val
.
psz_string
&&
*
val
.
psz_string
)
if
(
val
.
psz_string
&&
*
val
.
psz_string
)
{
{
char
*
psz
=
val
.
psz_string
;
int
i_res
;
if
(
psz
[
0
]
==
'0'
&&
(
psz
[
1
]
==
'x'
||
psz
[
1
]
==
'X'
)
)
{
p_sys
->
csa
=
csa_New
();
psz
+=
2
;
}
i_res
=
csa_SetCW
(
(
vlc_object_t
*
)
p_demux
,
p_sys
->
csa
,
val
.
psz_string
,
1
);
if
(
strlen
(
psz
)
!=
16
)
if
(
i_res
!=
VLC_SUCCESS
||
csa_SetCW
(
(
vlc_object_t
*
)
p_demux
,
p_sys
->
csa
,
val
.
psz_string
,
0
)
!=
VLC_SUCCESS
)
{
{
msg_Warn
(
p_demux
,
"invalid csa ck (it must be 16 chars long)"
);
csa_Delete
(
p_sys
->
csa
);
}
}
else
if
(
p_sys
->
csa
)
{
{
#ifndef UNDER_CE
vlc_value_t
pkt_val
;
uint64_t
i_ck
=
strtoull
(
psz
,
NULL
,
16
);
#else
uint64_t
i_ck
=
strtoll
(
psz
,
NULL
,
16
);
#endif
uint8_t
ck
[
8
];
int
i
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
ck
[
i
]
=
(
i_ck
>>
(
56
-
8
*
i
)
)
&
0xff
;
}
#ifndef TS_NO_CSA_CK_MSG
msg_Dbg
(
p_demux
,
"using CSA scrambling with "
"ck=%x:%x:%x:%x:%x:%x:%x:%x"
,
ck
[
0
],
ck
[
1
],
ck
[
2
],
ck
[
3
],
ck
[
4
],
ck
[
5
],
ck
[
6
],
ck
[
7
]
);
#endif
p_sys
->
csa
=
csa_New
();
if
(
p_sys
->
csa
)
var_Create
(
p_demux
,
"ts-csa-pkt"
,
VLC_VAR_INTEGER
|
VLC_VAR_DOINHERIT
);
var_Get
(
p_demux
,
"ts-csa-pkt"
,
&
pkt_val
);
if
(
pkt_val
.
i_int
<
4
||
pkt_val
.
i_int
>
188
)
{
{
vlc_value_t
pkt_val
;
msg_Err
(
p_demux
,
"wrong packet size %d specified."
,
pkt_val
.
i_int
);
msg_Warn
(
p_demux
,
"using default packet size of 188 bytes"
);
csa_SetCW
(
p_sys
->
csa
,
ck
,
ck
);
p_sys
->
i_csa_pkt_size
=
188
;
var_Create
(
p_demux
,
"ts-csa-pkt"
,
VLC_VAR_INTEGER
|
VLC_VAR_DOINHERIT
);
var_Get
(
p_demux
,
"ts-csa-pkt"
,
&
pkt_val
);
if
(
pkt_val
.
i_int
<
4
||
pkt_val
.
i_int
>
188
)
{
msg_Err
(
p_demux
,
"wrong packet size %d specified."
,
pkt_val
.
i_int
);
msg_Warn
(
p_demux
,
"using default packet size of 188 bytes"
);
p_sys
->
i_csa_pkt_size
=
188
;
}
else
p_sys
->
i_csa_pkt_size
=
pkt_val
.
i_int
;
msg_Dbg
(
p_demux
,
"decrypting %d bytes of packet"
,
p_sys
->
i_csa_pkt_size
);
}
}
else
p_sys
->
i_csa_pkt_size
=
pkt_val
.
i_int
;
msg_Dbg
(
p_demux
,
"decrypting %d bytes of packet"
,
p_sys
->
i_csa_pkt_size
);
}
}
}
}
free
(
val
.
psz_string
);
free
(
val
.
psz_string
);
...
...
modules/mux/mpeg/csa.c
View file @
4619c0a5
...
@@ -81,13 +81,53 @@ void csa_Delete( csa_t *c )
...
@@ -81,13 +81,53 @@ void csa_Delete( csa_t *c )
/*****************************************************************************
/*****************************************************************************
* csa_SetCW:
* csa_SetCW:
*****************************************************************************/
*****************************************************************************/
void
csa_SetCW
(
csa_t
*
c
,
uint8_t
o_ck
[
8
],
uint8_t
e_ck
[
8
]
)
int
csa_SetCW
(
vlc_object_t
*
p_caller
,
csa_t
*
c
,
char
*
psz_ck
,
int
set_odd
)
{
{
memcpy
(
c
->
o_ck
,
o_ck
,
8
);
if
(
!
c
)
csa_ComputeKey
(
c
->
o_kk
,
o_ck
);
{
msg_Dbg
(
p_caller
,
"no CSA found"
);
return
VLC_EGENERIC
;
}
/* skip 0x */
if
(
psz_ck
[
0
]
==
'0'
&&
(
psz_ck
[
1
]
==
'x'
||
psz_ck
[
1
]
==
'X'
)
)
{
psz_ck
+=
2
;
}
if
(
strlen
(
psz_ck
)
!=
16
)
{
msg_Warn
(
p_caller
,
"invalid csa ck (it must be 16 chars long)"
);
return
VLC_EGENERIC
;
}
else
{
#ifndef UNDER_CE
uint64_t
i_ck
=
strtoull
(
psz_ck
,
NULL
,
16
);
#else
uint64_t
i_ck
=
strtoll
(
psz_ck
,
NULL
,
16
);
#endif
uint8_t
ck
[
8
];
int
i
;
memcpy
(
c
->
e_ck
,
e_ck
,
8
);
for
(
i
=
0
;
i
<
8
;
i
++
)
csa_ComputeKey
(
c
->
e_kk
,
e_ck
);
{
ck
[
i
]
=
(
i_ck
>>
(
56
-
8
*
i
)
)
&
0xff
;
}
#ifndef TS_NO_CSA_CK_MSG
msg_Dbg
(
p_caller
,
"using CSA (de)scrambling with %s key=%x:%x:%x:%x:%x:%x:%x:%x"
,
((
set_odd
==
1
)
?
"odd"
:
"even"
),
ck
[
0
],
ck
[
1
],
ck
[
2
],
ck
[
3
],
ck
[
4
],
ck
[
5
],
ck
[
6
],
ck
[
7
]
);
#endif
if
(
set_odd
==
1
)
{
memcpy
(
c
->
o_ck
,
ck
,
8
);
csa_ComputeKey
(
c
->
o_kk
,
ck
);
}
else
{
memcpy
(
c
->
e_ck
,
ck
,
8
);
csa_ComputeKey
(
c
->
e_kk
,
ck
);
}
return
VLC_SUCCESS
;
}
}
}
/*****************************************************************************
/*****************************************************************************
...
...
modules/mux/mpeg/csa.h
View file @
4619c0a5
...
@@ -34,7 +34,7 @@ typedef struct csa_t csa_t;
...
@@ -34,7 +34,7 @@ typedef struct csa_t csa_t;
csa_t
*
csa_New
(
void
);
csa_t
*
csa_New
(
void
);
void
csa_Delete
(
csa_t
*
);
void
csa_Delete
(
csa_t
*
);
void
csa_SetCW
(
csa_t
*
,
uint8_t
o_ck
[
8
],
uint8_t
e_ck
[
8
]
);
int
csa_SetCW
(
vlc_object_t
*
p_caller
,
csa_t
*
c
,
char
*
psz_ck
,
int
set_odd
);
void
csa_Decrypt
(
csa_t
*
,
uint8_t
*
pkt
,
int
i_pkt_size
);
void
csa_Decrypt
(
csa_t
*
,
uint8_t
*
pkt
,
int
i_pkt_size
);
void
csa_Encrypt
(
csa_t
*
,
uint8_t
*
pkt
,
int
i_pkt_size
,
int
b_odd
);
void
csa_Encrypt
(
csa_t
*
,
uint8_t
*
pkt
,
int
i_pkt_size
,
int
b_odd
);
...
...
modules/mux/mpeg/ts.c
View file @
4619c0a5
...
@@ -771,48 +771,29 @@ static int Open( vlc_object_t *p_this )
...
@@ -771,48 +771,29 @@ static int Open( vlc_object_t *p_this )
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"csa-ck"
,
&
val
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"csa-ck"
,
&
val
);
if
(
val
.
psz_string
&&
*
val
.
psz_string
)
if
(
val
.
psz_string
&&
*
val
.
psz_string
)
{
{
char
*
psz
=
val
.
psz_string
;
int
i_res
;
/* skip 0x */
p_sys
->
csa
=
csa_New
();
if
(
psz
[
0
]
==
'0'
&&
(
psz
[
1
]
==
'x'
||
psz
[
1
]
==
'X'
)
)
{
i_res
=
csa_SetCW
(
(
vlc_object_t
*
)
p_mux
,
p_sys
->
csa
,
val
.
psz_string
,
1
);
psz
+=
2
;
if
(
i_res
!=
VLC_SUCCESS
||
csa_SetCW
(
(
vlc_object_t
*
)
p_mux
,
p_sys
->
csa
,
val
.
psz_string
,
0
)
!=
VLC_SUCCESS
)
}
if
(
strlen
(
psz
)
!=
16
)
{
{
msg_Dbg
(
p_mux
,
"invalid csa ck (it must be 16 chars long)"
);
csa_Delete
(
p_sys
->
csa
);
}
}
else
if
(
p_sys
->
csa
)
{
{
uint64_t
i_ck
=
strtoull
(
psz
,
NULL
,
16
);
vlc_value_t
pkt_val
;
uint8_t
ck
[
8
];
int
i
;
for
(
i
=
0
;
i
<
8
;
i
++
)
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"csa-pkt"
,
&
pkt_val
);
if
(
pkt_val
.
i_int
<
12
||
pkt_val
.
i_int
>
188
)
{
{
ck
[
i
]
=
(
i_ck
>>
(
56
-
8
*
i
)
)
&
0xff
;
msg_Err
(
p_mux
,
"wrong packet size %d specified."
,
pkt_val
.
i_int
);
}
msg_Warn
(
p_mux
,
"using default packet size of 188 bytes"
);
#ifndef TS_NO_CSA_CK_MSG
p_sys
->
i_csa_pkt_size
=
188
;
msg_Dbg
(
p_mux
,
"using CSA scrambling with ck=%x:%x:%x:%x:%x:%x:%x:%x"
,
ck
[
0
],
ck
[
1
],
ck
[
2
],
ck
[
3
],
ck
[
4
],
ck
[
5
],
ck
[
6
],
ck
[
7
]
);
#endif
p_sys
->
csa
=
csa_New
();
if
(
p_sys
->
csa
)
{
vlc_value_t
pkt_val
;
csa_SetCW
(
p_sys
->
csa
,
ck
,
ck
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"csa-pkt"
,
&
pkt_val
);
if
(
pkt_val
.
i_int
<
12
||
pkt_val
.
i_int
>
188
)
{
msg_Err
(
p_mux
,
"wrong packet size %d specified."
,
pkt_val
.
i_int
);
msg_Warn
(
p_mux
,
"using default packet size of 188 bytes"
);
p_sys
->
i_csa_pkt_size
=
188
;
}
else
p_sys
->
i_csa_pkt_size
=
pkt_val
.
i_int
;
msg_Dbg
(
p_mux
,
"encrypting %d bytes of packet"
,
p_sys
->
i_csa_pkt_size
);
}
}
else
p_sys
->
i_csa_pkt_size
=
pkt_val
.
i_int
;
msg_Dbg
(
p_mux
,
"encrypting %d bytes of packet"
,
p_sys
->
i_csa_pkt_size
);
}
}
}
}
free
(
val
.
psz_string
);
free
(
val
.
psz_string
);
...
...
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