Coverage Report

Created: 2024-02-25 07:20

/src/libfcrypto/ossfuzz/crypt_rc4_fuzzer.cc
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * OSS-Fuzz target for libfcrypto RC4 crypt function
3
 *
4
 * Copyright (C) 2011-2024, Joachim Metz <joachim.metz@gmail.com>
5
 *
6
 * Refer to AUTHORS for acknowledgements.
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Lesser General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
#include <stddef.h>
23
#include <stdint.h>
24
25
/* Note that some of the OSS-Fuzz engines use C++
26
 */
27
extern "C" {
28
29
#include "ossfuzz_libfcrypto.h"
30
31
int LLVMFuzzerTestOneInput(
32
     const uint8_t *data,
33
     size_t size )
34
622
{
35
622
  uint8_t encrypted_data[ 64 ];
36
622
  uint8_t key[ 16 ]  = {
37
622
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
38
39
622
  libfcrypto_rc4_context_t *context = NULL;
40
41
622
  if( libfcrypto_rc4_context_initialize(
42
622
       &context,
43
622
       NULL ) != 1 )
44
0
  {
45
0
    return( 0 );
46
0
  }
47
622
  if( libfcrypto_rc4_context_set_key(
48
622
       context,
49
622
       key,
50
622
       128,
51
622
       NULL ) != 1 )
52
0
  {
53
0
    goto on_error_libfcrypto;
54
0
  }
55
622
  libfcrypto_rc4_crypt(
56
622
   context,
57
622
   data,
58
622
   size,
59
622
   encrypted_data,
60
622
   64,
61
622
   NULL );
62
63
622
on_error_libfcrypto:
64
622
  libfcrypto_rc4_context_free(
65
622
   &context,
66
622
   NULL );
67
68
622
  return( 0 );
69
622
}
70
71
} /* extern "C" */
72