FFmpeg
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
Functions
Variables
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
c
d
g
i
o
q
r
s
v
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
Enumerator
a
d
e
f
i
j
l
m
n
p
r
s
v
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
l
m
o
p
q
r
s
t
u
v
w
x
y
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
libavutil
tests
aes_ctr.c
Go to the documentation of this file.
1
/*
2
* This file is part of FFmpeg.
3
*
4
* FFmpeg is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* FFmpeg is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with FFmpeg; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
19
#include "
libavutil/log.h
"
20
#include "
libavutil/mem.h
"
21
#include "
libavutil/mem_internal.h
"
22
#include "
libavutil/aes_ctr.h
"
23
24
static
const
DECLARE_ALIGNED
(8,
uint8_t
,
plain
)[] = {
25
0x6d, 0x6f, 0x73, 0x74, 0x20, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d
26
};
27
static
DECLARE_ALIGNED
(8,
uint8_t
,
tmp
)[11];
28
29
int
main
(
void
)
30
{
31
int
ret
= 1;
32
struct
AVAESCTR
*ae, *ad;
33
const
uint8_t
*iv;
34
35
ae =
av_aes_ctr_alloc
();
36
ad =
av_aes_ctr_alloc
();
37
38
if
(!ae || !ad)
39
goto
ERROR
;
40
41
if
(
av_aes_ctr_init
(ae, (
const
uint8_t
*)
"0123456789abcdef"
) < 0)
42
goto
ERROR
;
43
44
if
(
av_aes_ctr_init
(ad, (
const
uint8_t
*)
"0123456789abcdef"
) < 0)
45
goto
ERROR
;
46
47
av_aes_ctr_set_random_iv
(ae);
48
iv =
av_aes_ctr_get_iv
(ae);
49
av_aes_ctr_set_full_iv
(ad, iv);
50
51
av_aes_ctr_crypt
(ae,
tmp
,
plain
,
sizeof
(
tmp
));
52
av_aes_ctr_crypt
(ad,
tmp
,
tmp
,
sizeof
(
tmp
));
53
54
if
(memcmp(
tmp
,
plain
,
sizeof
(
tmp
)) != 0){
55
av_log
(
NULL
,
AV_LOG_ERROR
,
"test failed\n"
);
56
goto
ERROR
;
57
}
58
59
av_log
(
NULL
,
AV_LOG_INFO
,
"test passed\n"
);
60
ret
= 0;
61
62
ERROR
:
63
av_aes_ctr_free
(ae);
64
av_aes_ctr_free
(ad);
65
return
ret
;
66
}
mem_internal.h
av_aes_ctr_init
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key)
Initialize an AVAESCTR context.
Definition:
aes_ctr.c:69
tmp
static uint8_t tmp[11]
Definition:
aes_ctr.c:27
av_aes_ctr_get_iv
const uint8_t * av_aes_ctr_get_iv(struct AVAESCTR *a)
Get the current iv.
Definition:
aes_ctr.c:54
av_aes_ctr_alloc
struct AVAESCTR * av_aes_ctr_alloc(void)
Allocate an AVAESCTR context.
Definition:
aes_ctr.c:36
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition:
log.h:194
av_aes_ctr_crypt
void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int count)
Process a buffer using a previously initialized context.
Definition:
aes_ctr.c:111
av_aes_ctr_set_random_iv
void av_aes_ctr_set_random_iv(struct AVAESCTR *a)
Generate a random iv.
Definition:
aes_ctr.c:59
NULL
#define NULL
Definition:
coverity.c:32
ERROR
static void ERROR(const char *str)
Definition:
audio_fifo.c:57
av_aes_ctr_free
void av_aes_ctr_free(struct AVAESCTR *a)
Release an AVAESCTR context.
Definition:
aes_ctr.c:84
main
int main(void)
Definition:
aes_ctr.c:29
aes_ctr.h
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition:
log.h:205
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition:
mem.h:117
log.h
uint8_t
uint8_t
Definition:
audio_convert.c:194
plain
static const uint8_t plain[]
Definition:
aes_ctr.c:24
ret
ret
Definition:
filter_design.txt:187
av_aes_ctr_set_full_iv
void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t *iv)
Forcefully change the "full" 16-byte iv, including the counter.
Definition:
aes_ctr.c:48
mem.h
av_log
#define av_log(a,...)
Definition:
tableprint_vlc.h:28
AVAESCTR
Definition:
aes_ctr.c:29
Generated on Wed Aug 24 2022 21:34:48 for FFmpeg by
1.8.17