Coverage Report

Created: 2025-06-13 07:22

/src/libfcrypto/ossfuzz/crypt_des3_cbc_fuzzer.cc
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * OSS-Fuzz target for libfcrypto DES3-CBC 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
628
{
35
628
  uint8_t encrypted_data[ 64 ];
36
37
628
  uint8_t initialization_vector[ 8 ] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
38
628
  uint8_t key[ 8 ]                   = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
39
40
628
  libfcrypto_des3_context_t *context = NULL;
41
42
628
  if( libfcrypto_des3_context_initialize(
43
628
       &context,
44
628
       NULL ) != 1 )
45
0
  {
46
0
    return( 0 );
47
0
  }
48
628
  if( libfcrypto_des3_context_set_key(
49
628
       context,
50
628
       key,
51
628
       64,
52
628
       NULL ) != 1 )
53
0
  {
54
0
    goto on_error_libfcrypto;
55
0
  }
56
628
  libfcrypto_des3_crypt_cbc(
57
628
   context,
58
628
   LIBFCRYPTO_DES3_CRYPT_MODE_ENCRYPT,
59
628
   initialization_vector,
60
628
   8,
61
628
   data,
62
628
   size,
63
628
   encrypted_data,
64
628
   64,
65
628
   NULL );
66
67
628
on_error_libfcrypto:
68
628
  libfcrypto_des3_context_free(
69
628
   &context,
70
628
   NULL );
71
72
628
  return( 0 );
73
628
}
74
75
} /* extern "C" */
76