Coverage Report

Created: 2025-07-18 06:19

/src/rnp/src/fuzzing/keyring.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2020, [Ribose Inc](https://www.ribose.com).
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without modification,
6
 * are permitted provided that the following conditions are met:
7
 *
8
 * 1.  Redistributions of source code must retain the above copyright notice,
9
 *     this list of conditions and the following disclaimer.
10
 *
11
 * 2.  Redistributions in binary form must reproduce the above copyright notice,
12
 *     this list of conditions and the following disclaimer in the documentation
13
 *     and/or other materials provided with the distribution.
14
 *
15
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
19
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#include <rnp/rnp.h>
28
29
#ifdef RNP_RUN_TESTS
30
int keyring_LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
31
int
32
keyring_LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
33
#else
34
int
35
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
36
#endif
37
12.4k
{
38
12.4k
    rnp_input_t input = NULL;
39
12.4k
    rnp_ffi_t   ffi = NULL;
40
41
12.4k
    (void) rnp_input_from_memory(&input, data, size, false);
42
43
12.4k
    (void) rnp_ffi_create(&ffi, "GPG", "GPG");
44
12.4k
    (void) rnp_load_keys(
45
12.4k
      ffi, "GPG", input, RNP_LOAD_SAVE_PUBLIC_KEYS | RNP_LOAD_SAVE_SECRET_KEYS);
46
47
12.4k
    rnp_input_destroy(input);
48
12.4k
    rnp_ffi_destroy(ffi);
49
50
12.4k
    return 0;
51
12.4k
}