LCOV - code coverage report
Current view: top level - ballet/ed25519 - fuzz_ed25519_verify.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 7 7 100.0 %
Date: 2025-01-08 12:08:44 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #if !FD_HAS_HOSTED
       2             : #error "This target requires FD_HAS_HOSTED"
       3             : #endif
       4             : 
       5             : #include <assert.h>
       6             : #include <stdio.h>
       7             : #include <stdlib.h>
       8             : 
       9             : #include "../../util/fd_util.h"
      10             : #include "../../util/sanitize/fd_fuzz.h"
      11             : #include "fd_ed25519.h"
      12             : 
      13             : int
      14             : LLVMFuzzerInitialize( int  *   argc,
      15          18 :                       char *** argv ) {
      16             :   /* Set up shell without signal handlers */
      17          18 :   putenv( "FD_LOG_BACKTRACE=0" );
      18          18 :   fd_boot( argc, argv );
      19          18 :   atexit( fd_halt );
      20          18 :   fd_log_level_core_set(3); /* crash on warning log */
      21          18 :   return 0;
      22          18 : }
      23             : 
      24             : struct verification_test {
      25             :   uchar sig[ 64 ];
      26             :   uchar pub[ 32 ];
      27             :   uchar msg[ ];
      28             : };
      29             : typedef struct verification_test verification_test_t;
      30             : 
      31             : /* This fuzzer tries to verify random data */
      32             : 
      33             : int
      34             : LLVMFuzzerTestOneInput( uchar const * data,
      35             :                         ulong         size ) {
      36             :   if( FD_UNLIKELY( size<96UL ) ) return -1;
      37             : 
      38             :   verification_test_t * const test = ( verification_test_t * const ) data;
      39             :   ulong sz = size-96UL;
      40             : 
      41             :   fd_sha512_t _sha[1];
      42             :   fd_sha512_t *sha = fd_sha512_join( fd_sha512_new( _sha ) );
      43             : 
      44             :   int result = fd_ed25519_verify( test->msg, sz, test->sig, test->pub, sha );
      45             :   assert( result != FD_ED25519_SUCCESS );
      46             : 
      47             :   FD_FUZZ_MUST_BE_COVERED;
      48             :   return 0;
      49             : }

Generated by: LCOV version 1.14