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
15ff5c72
Commit
15ff5c72
authored
Oct 12, 2015
by
Rodger Combs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavu/aes: add runtime dispatch for crypt function
parent
ec588db5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
17 deletions
+33
-17
aes.c
libavutil/aes.c
+32
-17
aes_internal.h
libavutil/aes_internal.h
+1
-0
No files found.
libavutil/aes.c
View file @
15ff5c72
...
@@ -126,31 +126,44 @@ static inline void aes_crypt(AVAES *a, int s, const uint8_t *sbox,
...
@@ -126,31 +126,44 @@ static inline void aes_crypt(AVAES *a, int s, const uint8_t *sbox,
subshift
(
&
a
->
state
[
0
],
s
,
sbox
);
subshift
(
&
a
->
state
[
0
],
s
,
sbox
);
}
}
void
av_aes_
crypt
(
AVAES
*
a
,
uint8_t
*
dst
,
const
uint8_t
*
src
,
static
void
aes_en
crypt
(
AVAES
*
a
,
uint8_t
*
dst
,
const
uint8_t
*
src
,
int
count
,
uint8_t
*
iv
,
int
decrypt
)
int
count
,
uint8_t
*
iv
,
int
rounds
)
{
{
while
(
count
--
)
{
while
(
count
--
)
{
addkey_s
(
&
a
->
state
[
1
],
src
,
&
a
->
round_key
[
a
->
rounds
]);
addkey_s
(
&
a
->
state
[
1
],
src
,
&
a
->
round_key
[
rounds
]);
if
(
decrypt
)
{
if
(
iv
)
aes_crypt
(
a
,
0
,
inv_sbox
,
dec_multbl
);
addkey_s
(
&
a
->
state
[
1
],
iv
,
&
a
->
state
[
1
]);
if
(
iv
)
{
aes_crypt
(
a
,
2
,
sbox
,
enc_multbl
);
addkey_s
(
&
a
->
state
[
0
],
iv
,
&
a
->
state
[
0
]);
addkey_d
(
dst
,
&
a
->
state
[
0
],
&
a
->
round_key
[
0
]);
memcpy
(
iv
,
src
,
16
);
if
(
iv
)
}
memcpy
(
iv
,
dst
,
16
);
addkey_d
(
dst
,
&
a
->
state
[
0
],
&
a
->
round_key
[
0
]);
src
+=
16
;
}
else
{
dst
+=
16
;
if
(
iv
)
}
addkey_s
(
&
a
->
state
[
1
],
iv
,
&
a
->
state
[
1
]);
}
aes_crypt
(
a
,
2
,
sbox
,
enc_multbl
);
addkey_d
(
dst
,
&
a
->
state
[
0
],
&
a
->
round_key
[
0
]);
static
void
aes_decrypt
(
AVAES
*
a
,
uint8_t
*
dst
,
const
uint8_t
*
src
,
if
(
iv
)
int
count
,
uint8_t
*
iv
,
int
rounds
)
memcpy
(
iv
,
dst
,
16
);
{
while
(
count
--
)
{
addkey_s
(
&
a
->
state
[
1
],
src
,
&
a
->
round_key
[
rounds
]);
aes_crypt
(
a
,
0
,
inv_sbox
,
dec_multbl
);
if
(
iv
)
{
addkey_s
(
&
a
->
state
[
0
],
iv
,
&
a
->
state
[
0
]);
memcpy
(
iv
,
src
,
16
);
}
}
addkey_d
(
dst
,
&
a
->
state
[
0
],
&
a
->
round_key
[
0
]);
src
+=
16
;
src
+=
16
;
dst
+=
16
;
dst
+=
16
;
}
}
}
}
void
av_aes_crypt
(
AVAES
*
a
,
uint8_t
*
dst
,
const
uint8_t
*
src
,
int
count
,
uint8_t
*
iv
,
int
decrypt
)
{
a
->
crypt
(
a
,
dst
,
src
,
count
,
iv
,
a
->
rounds
);
}
static
void
init_multbl2
(
uint32_t
tbl
[][
256
],
const
int
c
[
4
],
static
void
init_multbl2
(
uint32_t
tbl
[][
256
],
const
int
c
[
4
],
const
uint8_t
*
log8
,
const
uint8_t
*
alog8
,
const
uint8_t
*
log8
,
const
uint8_t
*
alog8
,
const
uint8_t
*
sbox
)
const
uint8_t
*
sbox
)
...
@@ -186,6 +199,8 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
...
@@ -186,6 +199,8 @@ int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
uint8_t
log8
[
256
];
uint8_t
log8
[
256
];
uint8_t
alog8
[
512
];
uint8_t
alog8
[
512
];
a
->
crypt
=
decrypt
?
aes_decrypt
:
aes_encrypt
;
if
(
!
enc_multbl
[
FF_ARRAY_ELEMS
(
enc_multbl
)
-
1
][
FF_ARRAY_ELEMS
(
enc_multbl
[
0
])
-
1
])
{
if
(
!
enc_multbl
[
FF_ARRAY_ELEMS
(
enc_multbl
)
-
1
][
FF_ARRAY_ELEMS
(
enc_multbl
[
0
])
-
1
])
{
j
=
1
;
j
=
1
;
for
(
i
=
0
;
i
<
255
;
i
++
)
{
for
(
i
=
0
;
i
<
255
;
i
++
)
{
...
...
libavutil/aes_internal.h
View file @
15ff5c72
...
@@ -36,6 +36,7 @@ typedef struct AVAES {
...
@@ -36,6 +36,7 @@ typedef struct AVAES {
av_aes_block
round_key
[
15
];
av_aes_block
round_key
[
15
];
av_aes_block
state
[
2
];
av_aes_block
state
[
2
];
int
rounds
;
int
rounds
;
void
(
*
crypt
)(
struct
AVAES
*
a
,
uint8_t
*
dst
,
const
uint8_t
*
src
,
int
count
,
uint8_t
*
iv
,
int
rounds
);
}
AVAES
;
}
AVAES
;
#endif
/* AVUTIL_AES_INTERNAL_H */
#endif
/* AVUTIL_AES_INTERNAL_H */
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