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
7200f5d0
Commit
7200f5d0
authored
Jan 14, 2007
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify multiply table init
Originally committed as revision 7503 to
svn://svn.ffmpeg.org/ffmpeg/trunk
parent
86074ce3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
aes.c
libavutil/aes.c
+11
-11
No files found.
libavutil/aes.c
View file @
7200f5d0
...
...
@@ -99,15 +99,25 @@ void av_aes_encrypt(AVAES *a){
crypt
(
a
,
2
,
sbox
,
enc_multbl
);
}
static
void
init_multbl3
(
uint8_t
tbl
[
4
][
256
][
4
]){
int
i
,
j
,
k
;
for
(
k
=
1
;
k
<
4
;
k
++
)
for
(
j
=
0
;
j
<
256
;
j
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
tbl
[
k
][
j
][
i
]
=
tbl
[
k
-
1
][
j
][(
i
-
1
)
&
3
];
}
static
void
init_multbl2
(
uint8_t
tbl
[
1024
],
int
c
[
4
],
uint8_t
*
log8
,
uint8_t
*
alog8
,
uint8_t
*
sbox
){
int
i
;
for
(
i
=
0
;
i
<
1024
;
i
++
){
int
x
=
sbox
[
i
/
4
];
if
(
x
)
tbl
[
i
]
=
alog8
[
log8
[
x
]
+
log8
[
c
[
i
&
3
]]
];
}
#ifndef CONFIG_SMALL
init_multbl3
(
tbl
);
#endif
}
// this is based on the reference AES code by Paulo Barreto and Vincent Rijmen
AVAES
*
av_aes_init
(
uint8_t
*
key
,
int
key_bits
,
int
decrypt
)
{
AVAES
*
a
;
...
...
@@ -136,17 +146,7 @@ AVAES *av_aes_init(uint8_t *key, int key_bits, int decrypt) {
// av_log(NULL, AV_LOG_ERROR, "%d, ", log8[i]);
}
init_multbl2
(
dec_multbl
[
0
],
(
int
[
4
]){
0xe
,
0x9
,
0xd
,
0xb
},
log8
,
alog8
,
inv_sbox
);
#ifndef CONFIG_SMALL
init_multbl2
(
dec_multbl
[
1
],
(
int
[
4
]){
0xb
,
0xe
,
0x9
,
0xd
},
log8
,
alog8
,
inv_sbox
);
init_multbl2
(
dec_multbl
[
2
],
(
int
[
4
]){
0xd
,
0xb
,
0xe
,
0x9
},
log8
,
alog8
,
inv_sbox
);
init_multbl2
(
dec_multbl
[
3
],
(
int
[
4
]){
0x9
,
0xd
,
0xb
,
0xe
},
log8
,
alog8
,
inv_sbox
);
#endif
init_multbl2
(
enc_multbl
[
0
],
(
int
[
4
]){
0x2
,
0x1
,
0x1
,
0x3
},
log8
,
alog8
,
sbox
);
#ifndef CONFIG_SMALL
init_multbl2
(
enc_multbl
[
1
],
(
int
[
4
]){
0x3
,
0x2
,
0x1
,
0x1
},
log8
,
alog8
,
sbox
);
init_multbl2
(
enc_multbl
[
2
],
(
int
[
4
]){
0x1
,
0x3
,
0x2
,
0x1
},
log8
,
alog8
,
sbox
);
init_multbl2
(
enc_multbl
[
3
],
(
int
[
4
]){
0x1
,
0x1
,
0x3
,
0x2
},
log8
,
alog8
,
sbox
);
#endif
}
if
(
key_bits
!=
128
&&
key_bits
!=
192
&&
key_bits
!=
256
)
...
...
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