-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add fuzzing targets Signed-off-by: Bogdan Vaneev <[email protected]> * Add init to fuzz sign Signed-off-by: Bogdan Vaneev <[email protected]>
- Loading branch information
Showing
5 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function(ed25519_add_fuzz fuzz_name) | ||
add_executable(${fuzz_name} ${ARGN}) | ||
set_target_properties(${fuzz_name} PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/fuzz_bin | ||
ARCHIVE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/fuzz_lib | ||
LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/fuzz_lib | ||
) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright Soramitsu Co., Ltd. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set(compiler "clang-7") | ||
set(flags "-g -O1") | ||
set(options "-fsanitize=fuzzer,undefined") | ||
|
||
set(CMAKE_C_COMPILER ${compiler}) | ||
set(CMAKE_CXX_COMPILER ${compiler}) | ||
set(CMAKE_C_FLAGS ${flags}) | ||
set(CMAKE_CXX_FLAGS ${flags}) | ||
|
||
add_compile_options(${options}) | ||
add_link_options(${options}) | ||
|
||
|
||
set(_random ${RANDOM}) | ||
foreach(_edimpl ${ED25519_SUPPORTED_LIBRARIES_EDIMPL}) | ||
foreach(_hash ${ED25519_SUPPORTED_LIBRARIES_HASH}) | ||
foreach(_build STATIC SHARED) | ||
|
||
set(_target ${_edimpl}-${_hash}-${_random}-${_build}) | ||
|
||
if(NOT TARGET ${edtarget}) | ||
ed25519_merge_libraries(fuzz-ed25519-${_target} ${_build} | ||
LIBRARIES | ||
${_edimpl} | ||
${_hash} | ||
${_random} | ||
) | ||
endif() | ||
|
||
|
||
ed25519_add_fuzz(fuzz-sign-${_target} | ||
fuzz_sign.cc | ||
) | ||
ed25519_target_link_libraries(fuzz-sign-${_target} | ||
fuzz-ed25519-${_target} | ||
) | ||
|
||
endforeach() | ||
endforeach() | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright Soramitsu Co., Ltd. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <stdint.h> | ||
#include <ed25519/ed25519.h> | ||
|
||
static public_key_t pub; | ||
static private_key_t priv; | ||
static signature_t sig; | ||
|
||
extern "C" int LLVMFuzzerInitialize(int argc, char** argv){ | ||
ed25519_create_keypair(&priv, &pub); | ||
return 0; | ||
} | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { | ||
ed25519_sign(&sig, Data, Size, &pub, &priv); | ||
return 0; // Non-zero return values are reserved for future use. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters