diff options
author | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2020-03-09 18:28:44 +0000 |
---|---|---|
committer | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2020-03-09 18:28:44 +0000 |
commit | 145ac5ff22db107b484454367f6dc037db2b9ac5 (patch) | |
tree | 509d953fd80b147f9e1748193ec7815bb51f390d | |
parent | 6e999754566f8dbf390d2657f0b5b197237e1e25 (diff) | |
parent | 1d147fd30546d026c46470047151b2b0e80f1068 (diff) | |
download | gnutls-145ac5ff22db107b484454367f6dc037db2b9ac5.tar.gz |
Merge branch 'crl-crq-fuzz' into 'master'
fuzz: add simple x509 certificate requests fuzzer
Closes #903
See merge request gnutls/gnutls!1204
20 files changed, 106 insertions, 0 deletions
diff --git a/fuzz/Makefile.am b/fuzz/Makefile.am index 295e30a950..61a3a6b997 100644 --- a/fuzz/Makefile.am +++ b/fuzz/Makefile.am @@ -30,6 +30,8 @@ FUZZERS = \ gnutls_srp_client_fuzzer$(EXEEXT) \ gnutls_srp_server_fuzzer$(EXEEXT) \ gnutls_set_trust_file_fuzzer$(EXEEXT) \ + gnutls_x509_crl_parser_fuzzer$(EXEEXT) \ + gnutls_x509_crq_parser_fuzzer$(EXEEXT) \ gnutls_x509_parser_fuzzer$(EXEEXT) \ gnutls_ext_raw_parse_fuzzer$(EXEEXT) @@ -57,6 +59,8 @@ gnutls_server_rawpk_fuzzer_SOURCES = gnutls_server_rawpk_fuzzer.c $(COMMON_SOURC gnutls_srp_client_fuzzer_SOURCES = gnutls_srp_client_fuzzer.c $(COMMON_SOURCES) mem.h srp.h gnutls_srp_server_fuzzer_SOURCES = gnutls_srp_server_fuzzer.c $(COMMON_SOURCES) mem.h srp.h gnutls_set_trust_file_fuzzer_SOURCES = gnutls_set_trust_file_fuzzer.c $(COMMON_SOURCES) +gnutls_x509_crl_parser_fuzzer_SOURCES = gnutls_x509_crq_parser_fuzzer.c $(COMMON_SOURCES) +gnutls_x509_crq_parser_fuzzer_SOURCES = gnutls_x509_crq_parser_fuzzer.c $(COMMON_SOURCES) gnutls_x509_parser_fuzzer_SOURCES = gnutls_x509_parser_fuzzer.c $(COMMON_SOURCES) gnutls_ext_raw_parse_fuzzer_SOURCES = gnutls_ext_raw_parse_fuzzer.c $(COMMON_SOURCES) diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.c b/fuzz/gnutls_x509_crl_parser_fuzzer.c new file mode 100644 index 0000000000..b306501df2 --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2020 Dmitry Baryshkov + * + * This file is part of GnuTLS. + * + * The GnuTLS is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/> + * + */ + +#include <assert.h> +#include <stdint.h> + +#include <gnutls/gnutls.h> +#include <gnutls/x509.h> + +#include "fuzzer.h" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + gnutls_datum_t raw; + gnutls_datum_t out; + gnutls_x509_crl_t crl; + int ret; + + raw.data = (unsigned char *)data; + raw.size = size; + + ret = gnutls_x509_crl_init(&crl); + assert(ret >= 0); + + ret = gnutls_x509_crl_import(crl, &raw, GNUTLS_X509_FMT_DER); + if (ret >= 0) { + ret = gnutls_x509_crl_print(crl, GNUTLS_CRT_PRINT_FULL, &out); + assert(ret >= 0); + gnutls_free(out.data); + } + gnutls_x509_crl_deinit(crl); + + return 0; +} diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/027756c2bcbe9c7e40d84f1d95a1096869d2b88a b/fuzz/gnutls_x509_crl_parser_fuzzer.in/027756c2bcbe9c7e40d84f1d95a1096869d2b88a Binary files differnew file mode 100644 index 0000000000..ceb8b555c6 --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.in/027756c2bcbe9c7e40d84f1d95a1096869d2b88a diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/29ad4c879cc2d31eaf145c7a9dc8e1dfb2510b14 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/29ad4c879cc2d31eaf145c7a9dc8e1dfb2510b14 Binary files differnew file mode 100644 index 0000000000..5dea927e7f --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.in/29ad4c879cc2d31eaf145c7a9dc8e1dfb2510b14 diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/444a5c0edcfed360801be0cb99e1898e12c218d7 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/444a5c0edcfed360801be0cb99e1898e12c218d7 Binary files differnew file mode 100644 index 0000000000..56c880f737 --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.in/444a5c0edcfed360801be0cb99e1898e12c218d7 diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/48e9607eb3f073f7845690be49b6acd2547d7362 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/48e9607eb3f073f7845690be49b6acd2547d7362 Binary files differnew file mode 100644 index 0000000000..287019cbbd --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.in/48e9607eb3f073f7845690be49b6acd2547d7362 diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/4903c7d58c4077490c7c63d884b9993087298594 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/4903c7d58c4077490c7c63d884b9993087298594 Binary files differnew file mode 100644 index 0000000000..cd46aa1d73 --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.in/4903c7d58c4077490c7c63d884b9993087298594 diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/4f58aabf04b92b0a91c643a80fccf42a22beec50 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/4f58aabf04b92b0a91c643a80fccf42a22beec50 Binary files differnew file mode 100644 index 0000000000..7ab7752000 --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.in/4f58aabf04b92b0a91c643a80fccf42a22beec50 diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/50dca39ea79c6e5d3911d8b44d7328c8bfcfad08 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/50dca39ea79c6e5d3911d8b44d7328c8bfcfad08 Binary files differnew file mode 100644 index 0000000000..2aa75adcb8 --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.in/50dca39ea79c6e5d3911d8b44d7328c8bfcfad08 diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/606fe2f10c22d77172998298d331155c5841fab6 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/606fe2f10c22d77172998298d331155c5841fab6 Binary files differnew file mode 100644 index 0000000000..148b47815d --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.in/606fe2f10c22d77172998298d331155c5841fab6 diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/7ebae215244b160658517bde057f4a3653cbb32c b/fuzz/gnutls_x509_crl_parser_fuzzer.in/7ebae215244b160658517bde057f4a3653cbb32c Binary files differnew file mode 100644 index 0000000000..92ae4584dd --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.in/7ebae215244b160658517bde057f4a3653cbb32c diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/c780cb0ee96a448f5af0e1bb09224674546c723a b/fuzz/gnutls_x509_crl_parser_fuzzer.in/c780cb0ee96a448f5af0e1bb09224674546c723a Binary files differnew file mode 100644 index 0000000000..3823a45aea --- /dev/null +++ b/fuzz/gnutls_x509_crl_parser_fuzzer.in/c780cb0ee96a448f5af0e1bb09224674546c723a diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.c b/fuzz/gnutls_x509_crq_parser_fuzzer.c new file mode 100644 index 0000000000..4f7ebee78d --- /dev/null +++ b/fuzz/gnutls_x509_crq_parser_fuzzer.c @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2020 Dmitry Baryshkov + * + * This file is part of GnuTLS. + * + * The GnuTLS is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/> + * + */ + +#include <assert.h> +#include <stdint.h> + +#include <gnutls/gnutls.h> +#include <gnutls/x509.h> + +#include "fuzzer.h" + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + gnutls_datum_t raw; + gnutls_datum_t out; + gnutls_x509_crq_t crq; + int ret; + + raw.data = (unsigned char *)data; + raw.size = size; + + ret = gnutls_x509_crq_init(&crq); + assert(ret >= 0); + + ret = gnutls_x509_crq_import(crq, &raw, GNUTLS_X509_FMT_DER); + if (ret >= 0) { + ret = gnutls_x509_crq_print(crq, GNUTLS_CRT_PRINT_FULL, &out); + assert(ret >= 0); + gnutls_free(out.data); + } + gnutls_x509_crq_deinit(crq); + + return 0; +} diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/00da5667fcf94c6753aff43d0e8cf7a2c0e28233 b/fuzz/gnutls_x509_crq_parser_fuzzer.in/00da5667fcf94c6753aff43d0e8cf7a2c0e28233 Binary files differnew file mode 100644 index 0000000000..7631bd7e56 --- /dev/null +++ b/fuzz/gnutls_x509_crq_parser_fuzzer.in/00da5667fcf94c6753aff43d0e8cf7a2c0e28233 diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/2ac00bb62cce4c5a85ba7d59d167e8cecbfb468d b/fuzz/gnutls_x509_crq_parser_fuzzer.in/2ac00bb62cce4c5a85ba7d59d167e8cecbfb468d Binary files differnew file mode 100644 index 0000000000..b728d2c5ed --- /dev/null +++ b/fuzz/gnutls_x509_crq_parser_fuzzer.in/2ac00bb62cce4c5a85ba7d59d167e8cecbfb468d diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/2e7defbf265715d2c2d5ea8bc464071ce19e667a b/fuzz/gnutls_x509_crq_parser_fuzzer.in/2e7defbf265715d2c2d5ea8bc464071ce19e667a Binary files differnew file mode 100644 index 0000000000..2e9e772027 --- /dev/null +++ b/fuzz/gnutls_x509_crq_parser_fuzzer.in/2e7defbf265715d2c2d5ea8bc464071ce19e667a diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/9a926fe3e62b45ba45705ef482a04289a942804f b/fuzz/gnutls_x509_crq_parser_fuzzer.in/9a926fe3e62b45ba45705ef482a04289a942804f Binary files differnew file mode 100644 index 0000000000..c15f868bab --- /dev/null +++ b/fuzz/gnutls_x509_crq_parser_fuzzer.in/9a926fe3e62b45ba45705ef482a04289a942804f diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/b63e395f3b22408f4c03a9ef249afedb48b64609 b/fuzz/gnutls_x509_crq_parser_fuzzer.in/b63e395f3b22408f4c03a9ef249afedb48b64609 Binary files differnew file mode 100644 index 0000000000..59694b83c4 --- /dev/null +++ b/fuzz/gnutls_x509_crq_parser_fuzzer.in/b63e395f3b22408f4c03a9ef249afedb48b64609 diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/d1e497073008aa907e2c79e236234eff7a21e43e b/fuzz/gnutls_x509_crq_parser_fuzzer.in/d1e497073008aa907e2c79e236234eff7a21e43e Binary files differnew file mode 100644 index 0000000000..1bbee926a8 --- /dev/null +++ b/fuzz/gnutls_x509_crq_parser_fuzzer.in/d1e497073008aa907e2c79e236234eff7a21e43e diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/d6cb1c75c08f4c6b76d4e37fefca392f403c7c4e b/fuzz/gnutls_x509_crq_parser_fuzzer.in/d6cb1c75c08f4c6b76d4e37fefca392f403c7c4e Binary files differnew file mode 100644 index 0000000000..b5fc84abe7 --- /dev/null +++ b/fuzz/gnutls_x509_crq_parser_fuzzer.in/d6cb1c75c08f4c6b76d4e37fefca392f403c7c4e |