LCOV - code coverage report
Current view: top level - ballet/ed25519 - fuzz_ed25519_verify.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 6 6 100.0 %
Date: 2024-11-13 11:58:15 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 :   return 0;
      21          18 : }
      22             : 
      23             : struct verification_test {
      24             :   uchar sig[ 64 ];
      25             :   uchar pub[ 32 ];
      26             :   uchar msg[ ];
      27             : };
      28             : typedef struct verification_test verification_test_t;
      29             : 
      30             : /* This fuzzer tries to verify random data */
      31             : 
      32             : int
      33             : LLVMFuzzerTestOneInput( uchar const * data,
      34             :                         ulong         size ) {
      35             :   if( FD_UNLIKELY( size<96UL ) ) return -1;
      36             : 
      37             :   verification_test_t * const test = ( verification_test_t * const ) data;
      38             :   ulong sz = size-96UL;
      39             : 
      40             :   fd_sha512_t _sha[1];
      41             :   fd_sha512_t *sha = fd_sha512_join( fd_sha512_new( _sha ) );
      42             : 
      43             :   int result = fd_ed25519_verify( test->msg, sz, test->sig, test->pub, sha );
      44             :   assert( result != FD_ED25519_SUCCESS );
      45             : 
      46             :   FD_FUZZ_MUST_BE_COVERED;
      47             :   return 0;
      48             : }

Generated by: LCOV version 1.14