Lagom/Fuzzers: Add fuzzers for all current hashing functions

Namely MD5, SHA1, SHA256, SHA384 and SHA512.
This commit is contained in:
Luke 2021-06-18 16:31:31 +01:00 committed by Linus Groh
parent 4dc63896de
commit f29036dc98
6 changed files with 85 additions and 0 deletions

View file

@ -26,6 +26,7 @@ add_simple_fuzzer(FuzzGzipCompression)
add_simple_fuzzer(FuzzGzipDecompression)
add_simple_fuzzer(FuzzICOLoader)
add_simple_fuzzer(FuzzJPGLoader)
add_simple_fuzzer(FuzzMD5)
add_simple_fuzzer(FuzzPNGLoader)
add_simple_fuzzer(FuzzPBMLoader)
add_simple_fuzzer(FuzzPGMLoader)
@ -39,6 +40,10 @@ add_simple_fuzzer(FuzzLatin2Decoder)
add_simple_fuzzer(FuzzMarkdown)
add_simple_fuzzer(FuzzRegexECMA262)
add_simple_fuzzer(FuzzRegexPosixExtended)
add_simple_fuzzer(FuzzSHA1)
add_simple_fuzzer(FuzzSHA256)
add_simple_fuzzer(FuzzSHA384)
add_simple_fuzzer(FuzzSHA512)
add_simple_fuzzer(FuzzShell)
add_simple_fuzzer(FuzzSQLParser)
add_simple_fuzzer(FuzzTTF)

View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCrypto/Hash/MD5.h>
#include <stddef.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto buffer = ByteBuffer::copy(data, size);
Crypto::Hash::MD5::hash(buffer);
return 0;
}

View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCrypto/Hash/SHA1.h>
#include <stddef.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto buffer = ByteBuffer::copy(data, size);
Crypto::Hash::SHA1::hash(buffer);
return 0;
}

View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCrypto/Hash/SHA2.h>
#include <stddef.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto buffer = ByteBuffer::copy(data, size);
Crypto::Hash::SHA256::hash(buffer);
return 0;
}

View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCrypto/Hash/SHA2.h>
#include <stddef.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto buffer = ByteBuffer::copy(data, size);
Crypto::Hash::SHA384::hash(buffer);
return 0;
}

View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCrypto/Hash/SHA2.h>
#include <stddef.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto buffer = ByteBuffer::copy(data, size);
Crypto::Hash::SHA512::hash(buffer);
return 0;
}