OpenSSL 1.1.1-pre2
This commit is contained in:
+71
-6
@@ -27,7 +27,7 @@ https://github.com/llvm-mirror/llvm/tree/master/lib/Fuzzer if you prefer):
|
||||
$ sudo apt-get install subversion
|
||||
$ mkdir svn-work
|
||||
$ cd svn-work
|
||||
$ svn co http://llvm.org/svn/llvm-project/llvm/trunk/lib/Fuzzer
|
||||
$ svn co https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/fuzzer Fuzzer
|
||||
$ cd Fuzzer
|
||||
$ clang++ -c -g -O2 -std=c++11 *.cpp
|
||||
$ ar r libFuzzer.a *.o
|
||||
@@ -38,7 +38,13 @@ Configure for fuzzing:
|
||||
$ CC=clang ./config enable-fuzz-libfuzzer \
|
||||
--with-fuzzer-include=../../svn-work/Fuzzer \
|
||||
--with-fuzzer-lib=../../svn-work/Fuzzer/libFuzzer \
|
||||
-DPEDANTIC enable-asan enable-ubsan no-shared
|
||||
-DPEDANTIC enable-asan enable-ubsan no-shared \
|
||||
-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION \
|
||||
-fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp \
|
||||
enable-ec_nistp_64_gcc_128 -fno-sanitize=alignment enable-tls1_3 \
|
||||
enable-weak-ssl-ciphers enable-rc5 enable-md2 \
|
||||
enable-ssl3 enable-ssl3-method enable-nextprotoneg \
|
||||
--debug
|
||||
$ sudo apt-get install make
|
||||
$ LDCMD=clang++ make -j
|
||||
$ fuzz/helper.py $FUZZER
|
||||
@@ -46,9 +52,7 @@ Configure for fuzzing:
|
||||
Where $FUZZER is one of the executables in `fuzz/`.
|
||||
|
||||
If you get a crash, you should find a corresponding input file in
|
||||
`fuzz/corpora/$FUZZER-crash/`. You can reproduce the crash with
|
||||
|
||||
$ fuzz/$FUZZER <crashfile>
|
||||
`fuzz/corpora/$FUZZER-crash/`.
|
||||
|
||||
AFL
|
||||
===
|
||||
@@ -56,11 +60,72 @@ AFL
|
||||
Configure for fuzzing:
|
||||
|
||||
$ sudo apt-get install afl-clang
|
||||
$ CC=afl-clang-fast ./config enable-fuzz-afl no-shared
|
||||
$ CC=afl-clang-fast ./config enable-fuzz-afl no-shared -DPEDANTIC \
|
||||
enable-tls1_3 enable-weak-ssl-ciphers enable-rc5 enable-md2 \
|
||||
enable-ssl3 enable-ssl3-method enable-nextprotoneg \
|
||||
enable-ec_nistp_64_gcc_128 -fno-sanitize=alignment \
|
||||
--debug
|
||||
$ make
|
||||
|
||||
The following options can also be enabled: enable-asan, enable-ubsan, enable-msan
|
||||
|
||||
Run one of the fuzzers:
|
||||
|
||||
$ afl-fuzz -i fuzz/corpora/$FUZZER -o fuzz/corpora/$FUZZER/out fuzz/$FUZZER
|
||||
|
||||
Where $FUZZER is one of the executables in `fuzz/`.
|
||||
|
||||
Reproducing issues
|
||||
==================
|
||||
|
||||
If a fuzzer generates a reproducible error, you can reproduce the problem using
|
||||
the fuzz/*-test binaries and the file generated by the fuzzer. They binaries
|
||||
don't need to be build for fuzzing, there is no need to set CC or the call
|
||||
config with enable-fuzz-* or -fsanitize-coverage, but some of the other options
|
||||
above might be needed. For instance the enable-asan or enable-ubsan option might
|
||||
be useful to show you when the problem happens. For the client and server fuzzer
|
||||
it might be needed to use -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION to
|
||||
reproduce the generated random numbers.
|
||||
|
||||
To reproduce the crash you can run:
|
||||
|
||||
$ fuzz/$FUZZER-test $file
|
||||
|
||||
Random numbers
|
||||
==============
|
||||
|
||||
The client and server fuzzer normally generate random numbers as part of the TLS
|
||||
connection setup. This results in the coverage of the fuzzing corpus changing
|
||||
depending on the random numbers. This also has an effect for coverage of the
|
||||
rest of the test suite and you see the coverage change for each commit even when
|
||||
no code has been modified.
|
||||
|
||||
Since we want to maximize the coverage of the fuzzing corpus, the client and
|
||||
server fuzzer will use predictable numbers instead of the random numbers. This
|
||||
is controlled by the FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION define.
|
||||
|
||||
The coverage depends on the way the numbers are generated. We don't disable any
|
||||
check of hashes, but the corpus has the correct hash in it for the random
|
||||
numbers that were generated. For instance the client fuzzer will always generate
|
||||
the same client hello with the same random number in it, and so the server, as
|
||||
emulated by the file, can be generated for that client hello.
|
||||
|
||||
Coverage changes
|
||||
================
|
||||
|
||||
Since the corpus depends on the default behaviour of the client and the server,
|
||||
changes in what they send by default will have an impact on the coverage. The
|
||||
corpus will need to be updated in that case.
|
||||
|
||||
Updating the corpus
|
||||
===================
|
||||
|
||||
The client and server corpus is generated with multiple config options:
|
||||
- The options as documented above
|
||||
- Without enable-ec_nistp_64_gcc_128 and without --debug
|
||||
- With no-asm
|
||||
- Using 32 bit
|
||||
- A default config, plus options needed to generate the fuzzer.
|
||||
|
||||
The libfuzzer merge option is used to add the additional coverage
|
||||
from each config to the minimal set.
|
||||
+139
-9
@@ -27,8 +27,15 @@
|
||||
#include <openssl/ts.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/cms.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include "fuzzer.h"
|
||||
|
||||
#include "rand.inc"
|
||||
|
||||
static ASN1_ITEM_EXP *item_type[] = {
|
||||
ASN1_ITEM_ref(ACCESS_DESCRIPTION),
|
||||
#ifndef OPENSSL_NO_RFC3779
|
||||
@@ -99,7 +106,9 @@ static ASN1_ITEM_EXP *item_type[] = {
|
||||
ASN1_ITEM_ref(IPAddressRange),
|
||||
#endif
|
||||
ASN1_ITEM_ref(ISSUING_DIST_POINT),
|
||||
#if OPENSSL_API_COMPAT < 0x10200000L
|
||||
ASN1_ITEM_ref(LONG),
|
||||
#endif
|
||||
ASN1_ITEM_ref(NAME_CONSTRAINTS),
|
||||
ASN1_ITEM_ref(NETSCAPE_CERT_SEQUENCE),
|
||||
ASN1_ITEM_ref(NETSCAPE_SPKAC),
|
||||
@@ -159,7 +168,6 @@ static ASN1_ITEM_EXP *item_type[] = {
|
||||
ASN1_ITEM_ref(RSAPublicKey),
|
||||
ASN1_ITEM_ref(SXNET),
|
||||
ASN1_ITEM_ref(SXNETID),
|
||||
/*ASN1_ITEM_ref(TS_RESP), want to do this, but type is hidden, however d2i exists... */
|
||||
ASN1_ITEM_ref(USERNOTICE),
|
||||
ASN1_ITEM_ref(X509),
|
||||
ASN1_ITEM_ref(X509_ALGOR),
|
||||
@@ -179,25 +187,112 @@ static ASN1_ITEM_EXP *item_type[] = {
|
||||
ASN1_ITEM_ref(X509_REVOKED),
|
||||
ASN1_ITEM_ref(X509_SIG),
|
||||
ASN1_ITEM_ref(X509_VAL),
|
||||
#if OPENSSL_API_COMPAT < 0x10200000L
|
||||
ASN1_ITEM_ref(ZLONG),
|
||||
#endif
|
||||
ASN1_ITEM_ref(INT32),
|
||||
ASN1_ITEM_ref(ZINT32),
|
||||
ASN1_ITEM_ref(UINT32),
|
||||
ASN1_ITEM_ref(ZUINT32),
|
||||
ASN1_ITEM_ref(INT64),
|
||||
ASN1_ITEM_ref(ZINT64),
|
||||
ASN1_ITEM_ref(UINT64),
|
||||
ASN1_ITEM_ref(ZUINT64),
|
||||
NULL
|
||||
};
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv) {
|
||||
return 1;
|
||||
static ASN1_PCTX *pctx;
|
||||
|
||||
#define DO_TEST(TYPE, D2I, I2D, PRINT) { \
|
||||
const unsigned char *p = buf; \
|
||||
unsigned char *der = NULL; \
|
||||
TYPE *type = D2I(NULL, &p, len); \
|
||||
\
|
||||
if (type != NULL) { \
|
||||
int len2; \
|
||||
BIO *bio = BIO_new(BIO_s_null()); \
|
||||
\
|
||||
PRINT(bio, type); \
|
||||
BIO_free(bio); \
|
||||
len2 = I2D(type, &der); \
|
||||
if (len2 != 0) {} \
|
||||
OPENSSL_free(der); \
|
||||
TYPE ## _free(type); \
|
||||
} \
|
||||
}
|
||||
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
int n;
|
||||
#define DO_TEST_PRINT_OFFSET(TYPE, D2I, I2D, PRINT) { \
|
||||
const unsigned char *p = buf; \
|
||||
unsigned char *der = NULL; \
|
||||
TYPE *type = D2I(NULL, &p, len); \
|
||||
\
|
||||
if (type != NULL) { \
|
||||
BIO *bio = BIO_new(BIO_s_null()); \
|
||||
\
|
||||
PRINT(bio, type, 0); \
|
||||
BIO_free(bio); \
|
||||
I2D(type, &der); \
|
||||
OPENSSL_free(der); \
|
||||
TYPE ## _free(type); \
|
||||
} \
|
||||
}
|
||||
|
||||
ASN1_PCTX *pctx = ASN1_PCTX_new();
|
||||
#define DO_TEST_PRINT_PCTX(TYPE, D2I, I2D, PRINT) { \
|
||||
const unsigned char *p = buf; \
|
||||
unsigned char *der = NULL; \
|
||||
TYPE *type = D2I(NULL, &p, len); \
|
||||
\
|
||||
if (type != NULL) { \
|
||||
BIO *bio = BIO_new(BIO_s_null()); \
|
||||
\
|
||||
PRINT(bio, type, 0, pctx); \
|
||||
BIO_free(bio); \
|
||||
I2D(type, &der); \
|
||||
OPENSSL_free(der); \
|
||||
TYPE ## _free(type); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define DO_TEST_NO_PRINT(TYPE, D2I, I2D) { \
|
||||
const unsigned char *p = buf; \
|
||||
unsigned char *der = NULL; \
|
||||
TYPE *type = D2I(NULL, &p, len); \
|
||||
\
|
||||
if (type != NULL) { \
|
||||
BIO *bio = BIO_new(BIO_s_null()); \
|
||||
\
|
||||
BIO_free(bio); \
|
||||
I2D(type, &der); \
|
||||
OPENSSL_free(der); \
|
||||
TYPE ## _free(type); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
pctx = ASN1_PCTX_new();
|
||||
ASN1_PCTX_set_flags(pctx, ASN1_PCTX_FLAGS_SHOW_ABSENT |
|
||||
ASN1_PCTX_FLAGS_SHOW_SEQUENCE | ASN1_PCTX_FLAGS_SHOW_SSOF |
|
||||
ASN1_PCTX_FLAGS_SHOW_TYPE | ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME);
|
||||
ASN1_PCTX_set_str_flags(pctx, ASN1_STRFLGS_UTF8_CONVERT |
|
||||
ASN1_STRFLGS_SHOW_TYPE | ASN1_STRFLGS_DUMP_ALL);
|
||||
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
||||
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
|
||||
ERR_get_state();
|
||||
CRYPTO_free_ex_index(0, -1);
|
||||
FuzzerSetRand();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
int n;
|
||||
|
||||
|
||||
for (n = 0; item_type[n] != NULL; ++n) {
|
||||
const uint8_t *b = buf;
|
||||
unsigned char *der = NULL;
|
||||
@@ -206,17 +301,52 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
|
||||
if (o != NULL) {
|
||||
BIO *bio = BIO_new(BIO_s_null());
|
||||
|
||||
ASN1_item_print(bio, o, 4, i, pctx);
|
||||
BIO_free(bio);
|
||||
|
||||
ASN1_item_i2d(o, &der, i);
|
||||
OPENSSL_free(der);
|
||||
|
||||
ASN1_item_free(o, i);
|
||||
}
|
||||
}
|
||||
|
||||
ASN1_PCTX_free(pctx);
|
||||
#ifndef OPENSSL_NO_TS
|
||||
DO_TEST(TS_REQ, d2i_TS_REQ, i2d_TS_REQ, TS_REQ_print_bio);
|
||||
DO_TEST(TS_MSG_IMPRINT, d2i_TS_MSG_IMPRINT, i2d_TS_MSG_IMPRINT, TS_MSG_IMPRINT_print_bio);
|
||||
DO_TEST(TS_RESP, d2i_TS_RESP, i2d_TS_RESP, TS_RESP_print_bio);
|
||||
DO_TEST(TS_STATUS_INFO, d2i_TS_STATUS_INFO, i2d_TS_STATUS_INFO, TS_STATUS_INFO_print_bio);
|
||||
DO_TEST(TS_TST_INFO, d2i_TS_TST_INFO, i2d_TS_TST_INFO, TS_TST_INFO_print_bio);
|
||||
DO_TEST_NO_PRINT(TS_ACCURACY, d2i_TS_ACCURACY, i2d_TS_ACCURACY);
|
||||
DO_TEST_NO_PRINT(ESS_ISSUER_SERIAL, d2i_ESS_ISSUER_SERIAL, i2d_ESS_ISSUER_SERIAL);
|
||||
DO_TEST_NO_PRINT(ESS_CERT_ID, d2i_ESS_CERT_ID, i2d_ESS_CERT_ID);
|
||||
DO_TEST_NO_PRINT(ESS_SIGNING_CERT, d2i_ESS_SIGNING_CERT, i2d_ESS_SIGNING_CERT);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
DO_TEST(DH, d2i_DHparams, i2d_DHparams, DHparams_print);
|
||||
DO_TEST(DH, d2i_DHxparams, i2d_DHxparams, DHparams_print);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
DO_TEST_NO_PRINT(DSA_SIG, d2i_DSA_SIG, i2d_DSA_SIG);
|
||||
DO_TEST_PRINT_OFFSET(DSA, d2i_DSAPrivateKey, i2d_DSAPrivateKey, DSA_print);
|
||||
DO_TEST_PRINT_OFFSET(DSA, d2i_DSAPublicKey, i2d_DSAPublicKey, DSA_print);
|
||||
DO_TEST(DSA, d2i_DSAparams, i2d_DSAparams, DSAparams_print);
|
||||
#endif
|
||||
DO_TEST_PRINT_OFFSET(RSA, d2i_RSAPublicKey, i2d_RSAPublicKey, RSA_print);
|
||||
#ifndef OPENSSL_NO_EC
|
||||
DO_TEST_PRINT_OFFSET(EC_GROUP, d2i_ECPKParameters, i2d_ECPKParameters, ECPKParameters_print);
|
||||
DO_TEST_PRINT_OFFSET(EC_KEY, d2i_ECPrivateKey, i2d_ECPrivateKey, EC_KEY_print);
|
||||
DO_TEST(EC_KEY, d2i_ECParameters, i2d_ECParameters, ECParameters_print);
|
||||
DO_TEST_NO_PRINT(ECDSA_SIG, d2i_ECDSA_SIG, i2d_ECDSA_SIG);
|
||||
#endif
|
||||
DO_TEST_PRINT_PCTX(EVP_PKEY, d2i_AutoPrivateKey, i2d_PrivateKey, EVP_PKEY_print_private);
|
||||
DO_TEST(SSL_SESSION, d2i_SSL_SESSION, i2d_SSL_SESSION, SSL_SESSION_print);
|
||||
|
||||
ERR_clear_error();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FuzzerCleanup(void)
|
||||
{
|
||||
ASN1_PCTX_free(pctx);
|
||||
}
|
||||
+17
-7
@@ -16,18 +16,28 @@
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/err.h>
|
||||
#include "fuzzer.h"
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv) {
|
||||
static BIO *bio_out;
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
bio_out = BIO_new_file("/dev/null", "w");
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
||||
ERR_get_state();
|
||||
CRYPTO_free_ex_index(0, -1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
static BIO *bio_out;
|
||||
|
||||
if (bio_out == NULL)
|
||||
bio_out = BIO_new_file("/dev/null", "w");
|
||||
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
(void)ASN1_parse_dump(bio_out, buf, len, 0, 0);
|
||||
ERR_clear_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FuzzerCleanup(void)
|
||||
{
|
||||
BIO_free(bio_out);
|
||||
}
|
||||
+34
-19
@@ -15,31 +15,37 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/err.h>
|
||||
#include "fuzzer.h"
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv) {
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
||||
ERR_get_state();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
static BN_CTX *ctx;
|
||||
static BIGNUM *b1;
|
||||
static BIGNUM *b2;
|
||||
static BIGNUM *b3;
|
||||
static BIGNUM *b4;
|
||||
static BIGNUM *b5;
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
int success = 0;
|
||||
size_t l1 = 0, l2 = 0, l3 = 0;
|
||||
int s1 = 0, s2 = 0, s3 = 0;
|
||||
int s1 = 0, s3 = 0;
|
||||
BN_CTX *ctx;
|
||||
BIGNUM *b1;
|
||||
BIGNUM *b2;
|
||||
BIGNUM *b3;
|
||||
BIGNUM *b4;
|
||||
BIGNUM *b5;
|
||||
|
||||
b1 = BN_new();
|
||||
b2 = BN_new();
|
||||
b3 = BN_new();
|
||||
b4 = BN_new();
|
||||
b5 = BN_new();
|
||||
ctx = BN_CTX_new();
|
||||
|
||||
if (ctx == NULL) {
|
||||
b1 = BN_new();
|
||||
b2 = BN_new();
|
||||
b3 = BN_new();
|
||||
b4 = BN_new();
|
||||
b5 = BN_new();
|
||||
ctx = BN_CTX_new();
|
||||
}
|
||||
/* Divide the input into three parts, using the values of the first two
|
||||
* bytes to choose lengths, which generate b1, b2 and b3. Use three bits
|
||||
* of the third byte to choose signs for the three numbers.
|
||||
@@ -53,14 +59,12 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
l3 = len - l1 - l2;
|
||||
|
||||
s1 = buf[0] & 1;
|
||||
s2 = buf[0] & 2;
|
||||
s3 = buf[0] & 4;
|
||||
++buf;
|
||||
}
|
||||
OPENSSL_assert(BN_bin2bn(buf, l1, b1) == b1);
|
||||
BN_set_negative(b1, s1);
|
||||
OPENSSL_assert(BN_bin2bn(buf + l1, l2, b2) == b2);
|
||||
BN_set_negative(b2, s2);
|
||||
OPENSSL_assert(BN_bin2bn(buf + l1 + l2, l3, b3) == b3);
|
||||
BN_set_negative(b3, s3);
|
||||
|
||||
@@ -89,6 +93,17 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
|
||||
done:
|
||||
OPENSSL_assert(success);
|
||||
BN_free(b1);
|
||||
BN_free(b2);
|
||||
BN_free(b3);
|
||||
BN_free(b4);
|
||||
BN_free(b5);
|
||||
BN_CTX_free(ctx);
|
||||
ERR_clear_error();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FuzzerCleanup(void)
|
||||
{
|
||||
}
|
||||
+40
-16
@@ -15,32 +15,45 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/err.h>
|
||||
#include "fuzzer.h"
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv) {
|
||||
/* 256 kB */
|
||||
#define MAX_LEN (256 * 1000)
|
||||
|
||||
static BN_CTX *ctx;
|
||||
static BIGNUM *b1;
|
||||
static BIGNUM *b2;
|
||||
static BIGNUM *b3;
|
||||
static BIGNUM *b4;
|
||||
static BIGNUM *b5;
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
b1 = BN_new();
|
||||
b2 = BN_new();
|
||||
b3 = BN_new();
|
||||
b4 = BN_new();
|
||||
b5 = BN_new();
|
||||
ctx = BN_CTX_new();
|
||||
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
||||
ERR_get_state();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
static BN_CTX *ctx;
|
||||
static BIGNUM *b1;
|
||||
static BIGNUM *b2;
|
||||
static BIGNUM *b3;
|
||||
static BIGNUM *b4;
|
||||
static BIGNUM *b5;
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
int success = 0;
|
||||
size_t l1 = 0, l2 = 0;
|
||||
/* s1 and s2 will be the signs for b1 and b2. */
|
||||
int s1 = 0, s2 = 0;
|
||||
|
||||
if (ctx == NULL) {
|
||||
b1 = BN_new();
|
||||
b2 = BN_new();
|
||||
b3 = BN_new();
|
||||
b4 = BN_new();
|
||||
b5 = BN_new();
|
||||
ctx = BN_CTX_new();
|
||||
}
|
||||
/* limit the size of the input to avoid timeout */
|
||||
if (len > MAX_LEN)
|
||||
len = MAX_LEN;
|
||||
|
||||
/* We are going to split the buffer in two, sizes l1 and l2, giving b1 and
|
||||
* b2.
|
||||
*/
|
||||
@@ -102,6 +115,17 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
|
||||
done:
|
||||
OPENSSL_assert(success);
|
||||
ERR_clear_error();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FuzzerCleanup(void)
|
||||
{
|
||||
BN_free(b1);
|
||||
BN_free(b2);
|
||||
BN_free(b3);
|
||||
BN_free(b4);
|
||||
BN_free(b5);
|
||||
BN_CTX_free(ctx);
|
||||
}
|
||||
+12
-4
@@ -9,7 +9,7 @@
|
||||
-}
|
||||
|
||||
IF[{- !$disabled{"fuzz-afl"} || !$disabled{"fuzz-libfuzzer"} -}]
|
||||
PROGRAMS_NO_INST=asn1 asn1parse bignum bndiv conf crl server x509
|
||||
PROGRAMS_NO_INST=asn1 asn1parse bignum bndiv client conf crl server x509
|
||||
|
||||
IF[{- !$disabled{"cms"} -}]
|
||||
PROGRAMS_NO_INST=cms
|
||||
@@ -21,7 +21,7 @@ IF[{- !$disabled{"fuzz-afl"} || !$disabled{"fuzz-libfuzzer"} -}]
|
||||
|
||||
SOURCE[asn1]=asn1.c driver.c
|
||||
INCLUDE[asn1]=../include {- $ex_inc -}
|
||||
DEPEND[asn1]=../libcrypto {- $ex_lib -}
|
||||
DEPEND[asn1]=../libcrypto ../libssl {- $ex_lib -}
|
||||
|
||||
SOURCE[asn1parse]=asn1parse.c driver.c
|
||||
INCLUDE[asn1parse]=../include {- $ex_inc -}
|
||||
@@ -35,6 +35,10 @@ IF[{- !$disabled{"fuzz-afl"} || !$disabled{"fuzz-libfuzzer"} -}]
|
||||
INCLUDE[bndiv]=../include {- $ex_inc -}
|
||||
DEPEND[bndiv]=../libcrypto {- $ex_lib -}
|
||||
|
||||
SOURCE[client]=client.c driver.c
|
||||
INCLUDE[client]=../include {- $ex_inc -}
|
||||
DEPEND[client]=../libcrypto ../libssl {- $ex_lib -}
|
||||
|
||||
SOURCE[cms]=cms.c driver.c
|
||||
INCLUDE[cms]=../include {- $ex_inc -}
|
||||
DEPEND[cms]=../libcrypto {- $ex_lib -}
|
||||
@@ -61,7 +65,7 @@ IF[{- !$disabled{"fuzz-afl"} || !$disabled{"fuzz-libfuzzer"} -}]
|
||||
ENDIF
|
||||
|
||||
IF[{- !$disabled{tests} -}]
|
||||
PROGRAMS_NO_INST=asn1-test asn1parse-test bignum-test bndiv-test conf-test crl-test server-test x509-test
|
||||
PROGRAMS_NO_INST=asn1-test asn1parse-test bignum-test bndiv-test client-test conf-test crl-test server-test x509-test
|
||||
|
||||
IF[{- !$disabled{"cms"} -}]
|
||||
PROGRAMS_NO_INST=cms-test
|
||||
@@ -73,7 +77,7 @@ IF[{- !$disabled{tests} -}]
|
||||
|
||||
SOURCE[asn1-test]=asn1.c test-corpus.c
|
||||
INCLUDE[asn1-test]=../include
|
||||
DEPEND[asn1-test]=../libcrypto
|
||||
DEPEND[asn1-test]=../libcrypto ../libssl
|
||||
|
||||
SOURCE[asn1parse-test]=asn1parse.c test-corpus.c
|
||||
INCLUDE[asn1parse-test]=../include
|
||||
@@ -87,6 +91,10 @@ IF[{- !$disabled{tests} -}]
|
||||
INCLUDE[bndiv-test]=../include
|
||||
DEPEND[bndiv-test]=../libcrypto
|
||||
|
||||
SOURCE[client-test]=client.c test-corpus.c
|
||||
INCLUDE[client-test]=../include
|
||||
DEPEND[client-test]=../libcrypto ../libssl
|
||||
|
||||
SOURCE[cms-test]=cms.c test-corpus.c
|
||||
INCLUDE[cms-test]=../include
|
||||
DEPEND[cms-test]=../libcrypto
|
||||
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL licenses, (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* https://www.openssl.org/source/license.html
|
||||
* or in the file LICENSE in the source distribution.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/dsa.h>
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/dh.h>
|
||||
#include <openssl/err.h>
|
||||
#include "fuzzer.h"
|
||||
|
||||
#include "rand.inc"
|
||||
|
||||
/* unused, to avoid warning. */
|
||||
static int idx;
|
||||
|
||||
#define FUZZTIME 1485898104
|
||||
|
||||
#define TIME_IMPL(t) { if (t != NULL) *t = FUZZTIME; return FUZZTIME; }
|
||||
|
||||
/*
|
||||
* This might not work in all cases (and definitely not on Windows
|
||||
* because of the way linkers are) and callees can still get the
|
||||
* current time instead of the fixed time. This will just result
|
||||
* in things not being fully reproducible and have a slightly
|
||||
* different coverage.
|
||||
*/
|
||||
#if !defined(_WIN32)
|
||||
time_t time(time_t *t) TIME_IMPL(t)
|
||||
#endif
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
STACK_OF(SSL_COMP) *comp_methods;
|
||||
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS | OPENSSL_INIT_ASYNC, NULL);
|
||||
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
|
||||
ERR_get_state();
|
||||
CRYPTO_free_ex_index(0, -1);
|
||||
idx = SSL_get_ex_data_X509_STORE_CTX_idx();
|
||||
FuzzerSetRand();
|
||||
comp_methods = SSL_COMP_get_compression_methods();
|
||||
sk_SSL_COMP_sort(comp_methods);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
SSL *client;
|
||||
BIO *in;
|
||||
BIO *out;
|
||||
SSL_CTX *ctx;
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* TODO: use the ossltest engine (optionally?) to disable crypto checks.
|
||||
*/
|
||||
|
||||
/* This only fuzzes the initial flow from the client so far. */
|
||||
ctx = SSL_CTX_new(SSLv23_method());
|
||||
|
||||
client = SSL_new(ctx);
|
||||
OPENSSL_assert(SSL_set_cipher_list(client, "ALL:eNULL:@SECLEVEL=0") == 1);
|
||||
SSL_set_tlsext_host_name(client, "localhost");
|
||||
in = BIO_new(BIO_s_mem());
|
||||
out = BIO_new(BIO_s_mem());
|
||||
SSL_set_bio(client, in, out);
|
||||
SSL_set_connect_state(client);
|
||||
OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
|
||||
if (SSL_do_handshake(client) == 1) {
|
||||
/* Keep reading application data until error or EOF. */
|
||||
uint8_t tmp[1024];
|
||||
for (;;) {
|
||||
if (SSL_read(client, tmp, sizeof(tmp)) <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SSL_free(client);
|
||||
ERR_clear_error();
|
||||
SSL_CTX_free(ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FuzzerCleanup(void)
|
||||
{
|
||||
}
|
||||
+26
-7
@@ -14,23 +14,42 @@
|
||||
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/cms.h>
|
||||
#include <openssl/err.h>
|
||||
#include "fuzzer.h"
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv) {
|
||||
int FuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
||||
ERR_get_state();
|
||||
CRYPTO_free_ex_index(0, -1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
CMS_ContentInfo *i;
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
CMS_ContentInfo *cms;
|
||||
BIO *in;
|
||||
if (!len) {
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
in = BIO_new(BIO_s_mem());
|
||||
OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
|
||||
i = d2i_CMS_bio(in, NULL);
|
||||
CMS_ContentInfo_free(i);
|
||||
cms = d2i_CMS_bio(in, NULL);
|
||||
if (cms != NULL) {
|
||||
BIO *out = BIO_new(BIO_s_null());
|
||||
|
||||
i2d_CMS_bio(out, cms);
|
||||
BIO_free(out);
|
||||
CMS_ContentInfo_free(cms);
|
||||
}
|
||||
|
||||
BIO_free(in);
|
||||
ERR_clear_error();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FuzzerCleanup(void)
|
||||
{
|
||||
}
|
||||
+12
-2
@@ -13,13 +13,18 @@
|
||||
*/
|
||||
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/err.h>
|
||||
#include "fuzzer.h"
|
||||
|
||||
int FuzzerInitialize(int *argc, char ***argv) {
|
||||
int FuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
||||
ERR_get_state();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
int FuzzerTestOneInput(const uint8_t *buf, size_t len)
|
||||
{
|
||||
CONF *conf;
|
||||
BIO *in;
|
||||
long eline;
|
||||
@@ -33,6 +38,11 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
|
||||
NCONF_load_bio(conf, in, &eline);
|
||||
NCONF_free(conf);
|
||||
BIO_free(in);
|
||||
ERR_clear_error();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FuzzerCleanup(void)
|
||||
{
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
6�0��00000000
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
0€爛焵
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
2602061620Z0
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
��0��00000000
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
*�ホ=
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
1*
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
0��
|
||||
@@ -0,0 +1 @@
|
||||
1111311111゚
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user