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
10de4087
Commit
10de4087
authored
Sep 10, 2015
by
Vittorio Giovara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf: Update to the new crypto API
parent
c0a49077
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
24 deletions
+59
-24
asfcrypt.c
libavformat/asfcrypt.c
+18
-8
omadec.c
libavformat/omadec.c
+41
-16
No files found.
libavformat/asfcrypt.c
View file @
10de4087
...
...
@@ -146,8 +146,8 @@ static uint64_t multiswap_dec(const uint32_t keys[12],
void
ff_asfcrypt_dec
(
const
uint8_t
key
[
20
],
uint8_t
*
data
,
int
len
)
{
struct
AVDES
des
;
struct
AVRC4
rc4
;
struct
AVDES
*
des
;
struct
AVRC4
*
rc4
;
int
num_qwords
=
len
>>
3
;
uint8_t
*
qwords
=
data
;
uint64_t
rc4buff
[
8
]
=
{
0
};
...
...
@@ -160,19 +160,26 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
data
[
i
]
^=
key
[
i
];
return
;
}
des
=
av_des_alloc
();
rc4
=
av_rc4_alloc
();
if
(
!
des
||
!
rc4
)
{
av_freep
(
&
des
);
av_freep
(
&
rc4
);
return
;
}
av_rc4_init
(
&
rc4
,
key
,
12
*
8
,
1
);
av_rc4_crypt
(
&
rc4
,
(
uint8_t
*
)
rc4buff
,
NULL
,
sizeof
(
rc4buff
),
NULL
,
1
);
av_rc4_init
(
rc4
,
key
,
12
*
8
,
1
);
av_rc4_crypt
(
rc4
,
(
uint8_t
*
)
rc4buff
,
NULL
,
sizeof
(
rc4buff
),
NULL
,
1
);
multiswap_init
((
uint8_t
*
)
rc4buff
,
ms_keys
);
packetkey
=
AV_RN64
(
&
qwords
[
num_qwords
*
8
-
8
]);
packetkey
^=
rc4buff
[
7
];
av_des_init
(
&
des
,
key
+
12
,
64
,
1
);
av_des_crypt
(
&
des
,
(
uint8_t
*
)
&
packetkey
,
(
uint8_t
*
)
&
packetkey
,
1
,
NULL
,
1
);
av_des_init
(
des
,
key
+
12
,
64
,
1
);
av_des_crypt
(
des
,
(
uint8_t
*
)
&
packetkey
,
(
uint8_t
*
)
&
packetkey
,
1
,
NULL
,
1
);
packetkey
^=
rc4buff
[
6
];
av_rc4_init
(
&
rc4
,
(
uint8_t
*
)
&
packetkey
,
64
,
1
);
av_rc4_crypt
(
&
rc4
,
data
,
data
,
len
,
NULL
,
1
);
av_rc4_init
(
rc4
,
(
uint8_t
*
)
&
packetkey
,
64
,
1
);
av_rc4_crypt
(
rc4
,
data
,
data
,
len
,
NULL
,
1
);
ms_state
=
0
;
for
(
i
=
0
;
i
<
num_qwords
-
1
;
i
++
,
qwords
+=
8
)
...
...
@@ -182,4 +189,7 @@ void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
packetkey
=
av_le2ne64
(
packetkey
);
packetkey
=
multiswap_dec
(
ms_keys
,
ms_state
,
packetkey
);
AV_WL64
(
qwords
,
packetkey
);
av_free
(
rc4
);
av_free
(
des
);
}
libavformat/omadec.c
View file @
10de4087
...
...
@@ -74,7 +74,7 @@ typedef struct OMAContext {
uint8_t
sm_val
[
8
];
uint8_t
e_val
[
8
];
uint8_t
iv
[
8
];
struct
AVDES
av_des
;
struct
AVDES
*
av_des
;
}
OMAContext
;
static
void
hex_log
(
AVFormatContext
*
s
,
int
level
,
...
...
@@ -125,28 +125,34 @@ static int rprobe(AVFormatContext *s, uint8_t *enc_header, unsigned size,
{
OMAContext
*
oc
=
s
->
priv_data
;
unsigned
int
pos
;
struct
AVDES
av_des
;
struct
AVDES
*
av_des
;
if
(
!
enc_header
||
!
r_val
||
size
<
OMA_ENC_HEADER_SIZE
+
oc
->
k_size
+
oc
->
e_size
+
oc
->
i_size
||
size
<
OMA_RPROBE_M_VAL
)
return
-
1
;
av_des
=
av_des_alloc
();
if
(
!
av_des
)
return
AVERROR
(
ENOMEM
);
/* m_val */
av_des_init
(
&
av_des
,
r_val
,
192
,
1
);
av_des_crypt
(
&
av_des
,
oc
->
m_val
,
&
enc_header
[
48
],
1
,
NULL
,
1
);
av_des_init
(
av_des
,
r_val
,
192
,
1
);
av_des_crypt
(
av_des
,
oc
->
m_val
,
&
enc_header
[
48
],
1
,
NULL
,
1
);
/* s_val */
av_des_init
(
&
av_des
,
oc
->
m_val
,
64
,
0
);
av_des_crypt
(
&
av_des
,
oc
->
s_val
,
NULL
,
1
,
NULL
,
0
);
av_des_init
(
av_des
,
oc
->
m_val
,
64
,
0
);
av_des_crypt
(
av_des
,
oc
->
s_val
,
NULL
,
1
,
NULL
,
0
);
/* sm_val */
pos
=
OMA_ENC_HEADER_SIZE
+
oc
->
k_size
+
oc
->
e_size
;
av_des_init
(
&
av_des
,
oc
->
s_val
,
64
,
0
);
av_des_mac
(
&
av_des
,
oc
->
sm_val
,
&
enc_header
[
pos
],
(
oc
->
i_size
>>
3
));
av_des_init
(
av_des
,
oc
->
s_val
,
64
,
0
);
av_des_mac
(
av_des
,
oc
->
sm_val
,
&
enc_header
[
pos
],
(
oc
->
i_size
>>
3
));
pos
+=
oc
->
i_size
;
av_free
(
av_des
);
return
memcmp
(
&
enc_header
[
pos
],
oc
->
sm_val
,
8
)
?
-
1
:
0
;
}
...
...
@@ -156,7 +162,7 @@ static int nprobe(AVFormatContext *s, uint8_t *enc_header, unsigned size,
OMAContext
*
oc
=
s
->
priv_data
;
uint64_t
pos
;
uint32_t
taglen
,
datalen
;
struct
AVDES
av_des
;
struct
AVDES
*
av_des
;
if
(
!
enc_header
||
!
n_val
||
size
<
OMA_ENC_HEADER_SIZE
+
oc
->
k_size
+
4
)
...
...
@@ -184,15 +190,22 @@ static int nprobe(AVFormatContext *s, uint8_t *enc_header, unsigned size,
if
(
datalen
<<
4
>
size
-
pos
)
return
-
1
;
av_des_init
(
&
av_des
,
n_val
,
192
,
1
);
av_des
=
av_des_alloc
();
if
(
!
av_des
)
return
AVERROR
(
ENOMEM
);
av_des_init
(
av_des
,
n_val
,
192
,
1
);
while
(
datalen
--
>
0
)
{
av_des_crypt
(
&
av_des
,
oc
->
r_val
,
&
enc_header
[
pos
],
2
,
NULL
,
1
);
kset
(
s
,
oc
->
r_val
,
NULL
,
16
);
av_des_crypt
(
av_des
,
oc
->
r_val
,
&
enc_header
[
pos
],
2
,
NULL
,
1
);
kset
(
s
,
oc
->
r_val
,
NULL
,
16
);
{
if
(
!
rprobe
(
s
,
enc_header
,
size
,
oc
->
r_val
))
av_free
(
av_des
);
return
0
;
}
pos
+=
16
;
}
av_free
(
av_des
);
return
-
1
;
}
...
...
@@ -277,14 +290,18 @@ static int decrypt_init(AVFormatContext *s, ID3v2ExtraMeta *em, uint8_t *header)
}
}
oc
->
av_des
=
av_des_alloc
();
if
(
!
oc
->
av_des
)
return
AVERROR
(
ENOMEM
);
/* e_val */
av_des_init
(
&
oc
->
av_des
,
oc
->
m_val
,
64
,
0
);
av_des_crypt
(
&
oc
->
av_des
,
oc
->
e_val
,
av_des_init
(
oc
->
av_des
,
oc
->
m_val
,
64
,
0
);
av_des_crypt
(
oc
->
av_des
,
oc
->
e_val
,
&
gdata
[
OMA_ENC_HEADER_SIZE
+
40
],
1
,
NULL
,
0
);
hex_log
(
s
,
AV_LOG_DEBUG
,
"EK"
,
oc
->
e_val
,
8
);
/* init e_val */
av_des_init
(
&
oc
->
av_des
,
oc
->
e_val
,
64
,
1
);
av_des_init
(
oc
->
av_des
,
oc
->
e_val
,
64
,
1
);
return
0
;
}
...
...
@@ -446,7 +463,7 @@ static int oma_read_packet(AVFormatContext *s, AVPacket *pkt)
/* previous unencrypted block saved in IV for
* the next packet (CBC mode) */
if
(
ret
==
packet_size
)
av_des_crypt
(
&
oc
->
av_des
,
pkt
->
data
,
pkt
->
data
,
av_des_crypt
(
oc
->
av_des
,
pkt
->
data
,
pkt
->
data
,
(
packet_size
>>
3
),
oc
->
iv
,
1
);
else
memset
(
oc
->
iv
,
0
,
8
);
...
...
@@ -502,6 +519,13 @@ wipe:
return
err
;
}
static
int
oma_read_close
(
AVFormatContext
*
s
)
{
OMAContext
*
oc
=
s
->
priv_data
;
av_free
(
oc
->
av_des
);
return
0
;
}
AVInputFormat
ff_oma_demuxer
=
{
.
name
=
"oma"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"Sony OpenMG audio"
),
...
...
@@ -510,6 +534,7 @@ AVInputFormat ff_oma_demuxer = {
.
read_header
=
oma_read_header
,
.
read_packet
=
oma_read_packet
,
.
read_seek
=
oma_read_seek
,
.
read_close
=
oma_read_close
,
.
flags
=
AVFMT_GENERIC_INDEX
,
.
extensions
=
"oma,omg,aa3"
,
.
codec_tag
=
(
const
AVCodecTag
*
const
[]){
ff_oma_codec_tags
,
0
},
...
...
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