FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/tests/checkasm/aes.c
Date: 2026-08-20 12:56:29
Exec Total Coverage
Lines: 22 26 84.6%
Functions: 1 1 100.0%
Branches: 21 44 47.7%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2015 Rodger Combs <rodger.combs@gmail.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include <string.h>
22
23 #include "checkasm.h"
24 #include "libavutil/aes.h"
25 #include "libavutil/aes_internal.h"
26 #include "libavutil/internal.h"
27
28 #define MAX_COUNT 16
29
30 14 void checkasm_check_aes(void)
31 {
32 int i, j, d;
33 AVAES b;
34 uint8_t pt[MAX_COUNT * 16];
35 uint8_t temp[2][MAX_COUNT * 16];
36 uint8_t iv[2][16];
37
38
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 14 times.
42 for (d = 0; d <= 1; d++) {
39
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for (i = 128; i <= 256; i += 64) {
40 84 av_aes_init(&b, (const uint8_t*)"PI=3.1415926535897932384626433..", i, d);
41
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 42 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 72 times.
84 if (check_func(b.crypt, "aes_%scrypt_%i", d ? "de" : "en", i)) {
42 12 declare_func(void, AVAES *a, uint8_t *dst, const uint8_t *src,
43 int count, uint8_t *iv, int rounds);
44 12 int count = (rnd() & (MAX_COUNT - 1)) + 1;
45
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for (j = 0; j < 16 * MAX_COUNT; j++)
46 3072 pt[j] = rnd();
47
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 12 times.
204 for (j = 0; j < 16; j++)
48 192 iv[0][j] = iv[1][j] = rnd();
49
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 call_ref(&b, temp[0], pt, count, iv[0], b.rounds);
50 12 call_new(&b, temp[1], pt, count, iv[1], b.rounds);
51
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (memcmp(temp[0], temp[1], 16 * count))
52 fail();
53
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (memcmp(iv[0], iv[1], sizeof(iv[0])))
54 fail();
55
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 call_ref(&b, temp[0], pt, count, NULL, b.rounds);
56 12 call_new(&b, temp[1], pt, count, NULL, b.rounds);
57
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (memcmp(temp[0], temp[1], 16 * count))
58 fail();
59
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (memcmp(iv[0], iv[1], sizeof(iv[0])))
60 fail();
61
1/18
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 59 not taken.
✗ Branch 60 not taken.
12 bench_new(&b, temp[1], pt, MAX_COUNT, NULL, b.rounds);
62 }
63 }
64
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 report("%scrypt", d ? "de" : "en");
65 }
66 14 }
67