]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
fuzz: add simple x509 certificate requests and revocation lists fuzzers
authorDmitry Baryshkov <dbaryshkov@gmail.com>
Fri, 6 Mar 2020 22:05:45 +0000 (01:05 +0300)
committerDmitry Baryshkov <dbaryshkov@gmail.com>
Mon, 9 Mar 2020 17:18:16 +0000 (20:18 +0300)
Add x509 certificate requests and certificate revocation lists fuzzers.
Use data from tests/cert-tests as a starting seed for the corpora.

Fixes #903

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
20 files changed:
fuzz/Makefile.am
fuzz/gnutls_x509_crl_parser_fuzzer.c [new file with mode: 0644]
fuzz/gnutls_x509_crl_parser_fuzzer.in/027756c2bcbe9c7e40d84f1d95a1096869d2b88a [new file with mode: 0644]
fuzz/gnutls_x509_crl_parser_fuzzer.in/29ad4c879cc2d31eaf145c7a9dc8e1dfb2510b14 [new file with mode: 0644]
fuzz/gnutls_x509_crl_parser_fuzzer.in/444a5c0edcfed360801be0cb99e1898e12c218d7 [new file with mode: 0644]
fuzz/gnutls_x509_crl_parser_fuzzer.in/48e9607eb3f073f7845690be49b6acd2547d7362 [new file with mode: 0644]
fuzz/gnutls_x509_crl_parser_fuzzer.in/4903c7d58c4077490c7c63d884b9993087298594 [new file with mode: 0644]
fuzz/gnutls_x509_crl_parser_fuzzer.in/4f58aabf04b92b0a91c643a80fccf42a22beec50 [new file with mode: 0644]
fuzz/gnutls_x509_crl_parser_fuzzer.in/50dca39ea79c6e5d3911d8b44d7328c8bfcfad08 [new file with mode: 0644]
fuzz/gnutls_x509_crl_parser_fuzzer.in/606fe2f10c22d77172998298d331155c5841fab6 [new file with mode: 0644]
fuzz/gnutls_x509_crl_parser_fuzzer.in/7ebae215244b160658517bde057f4a3653cbb32c [new file with mode: 0644]
fuzz/gnutls_x509_crl_parser_fuzzer.in/c780cb0ee96a448f5af0e1bb09224674546c723a [new file with mode: 0644]
fuzz/gnutls_x509_crq_parser_fuzzer.c [new file with mode: 0644]
fuzz/gnutls_x509_crq_parser_fuzzer.in/00da5667fcf94c6753aff43d0e8cf7a2c0e28233 [new file with mode: 0644]
fuzz/gnutls_x509_crq_parser_fuzzer.in/2ac00bb62cce4c5a85ba7d59d167e8cecbfb468d [new file with mode: 0644]
fuzz/gnutls_x509_crq_parser_fuzzer.in/2e7defbf265715d2c2d5ea8bc464071ce19e667a [new file with mode: 0644]
fuzz/gnutls_x509_crq_parser_fuzzer.in/9a926fe3e62b45ba45705ef482a04289a942804f [new file with mode: 0644]
fuzz/gnutls_x509_crq_parser_fuzzer.in/b63e395f3b22408f4c03a9ef249afedb48b64609 [new file with mode: 0644]
fuzz/gnutls_x509_crq_parser_fuzzer.in/d1e497073008aa907e2c79e236234eff7a21e43e [new file with mode: 0644]
fuzz/gnutls_x509_crq_parser_fuzzer.in/d6cb1c75c08f4c6b76d4e37fefca392f403c7c4e [new file with mode: 0644]

index 295e30a9505c506bcfbb6e3c91b7a69b2a0e3f2d..61a3a6b997fbe5d8382634c2b4d8feebbc2f7b29 100644 (file)
@@ -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 (file)
index 0000000..b306501
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..ceb8b55
Binary files /dev/null and b/fuzz/gnutls_x509_crl_parser_fuzzer.in/027756c2bcbe9c7e40d84f1d95a1096869d2b88a differ
diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/29ad4c879cc2d31eaf145c7a9dc8e1dfb2510b14 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/29ad4c879cc2d31eaf145c7a9dc8e1dfb2510b14
new file mode 100644 (file)
index 0000000..5dea927
Binary files /dev/null and b/fuzz/gnutls_x509_crl_parser_fuzzer.in/29ad4c879cc2d31eaf145c7a9dc8e1dfb2510b14 differ
diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/444a5c0edcfed360801be0cb99e1898e12c218d7 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/444a5c0edcfed360801be0cb99e1898e12c218d7
new file mode 100644 (file)
index 0000000..56c880f
Binary files /dev/null and b/fuzz/gnutls_x509_crl_parser_fuzzer.in/444a5c0edcfed360801be0cb99e1898e12c218d7 differ
diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/48e9607eb3f073f7845690be49b6acd2547d7362 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/48e9607eb3f073f7845690be49b6acd2547d7362
new file mode 100644 (file)
index 0000000..287019c
Binary files /dev/null and b/fuzz/gnutls_x509_crl_parser_fuzzer.in/48e9607eb3f073f7845690be49b6acd2547d7362 differ
diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/4903c7d58c4077490c7c63d884b9993087298594 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/4903c7d58c4077490c7c63d884b9993087298594
new file mode 100644 (file)
index 0000000..cd46aa1
Binary files /dev/null and b/fuzz/gnutls_x509_crl_parser_fuzzer.in/4903c7d58c4077490c7c63d884b9993087298594 differ
diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/4f58aabf04b92b0a91c643a80fccf42a22beec50 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/4f58aabf04b92b0a91c643a80fccf42a22beec50
new file mode 100644 (file)
index 0000000..7ab7752
Binary files /dev/null and b/fuzz/gnutls_x509_crl_parser_fuzzer.in/4f58aabf04b92b0a91c643a80fccf42a22beec50 differ
diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/50dca39ea79c6e5d3911d8b44d7328c8bfcfad08 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/50dca39ea79c6e5d3911d8b44d7328c8bfcfad08
new file mode 100644 (file)
index 0000000..2aa75ad
Binary files /dev/null and b/fuzz/gnutls_x509_crl_parser_fuzzer.in/50dca39ea79c6e5d3911d8b44d7328c8bfcfad08 differ
diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/606fe2f10c22d77172998298d331155c5841fab6 b/fuzz/gnutls_x509_crl_parser_fuzzer.in/606fe2f10c22d77172998298d331155c5841fab6
new file mode 100644 (file)
index 0000000..148b478
Binary files /dev/null and b/fuzz/gnutls_x509_crl_parser_fuzzer.in/606fe2f10c22d77172998298d331155c5841fab6 differ
diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/7ebae215244b160658517bde057f4a3653cbb32c b/fuzz/gnutls_x509_crl_parser_fuzzer.in/7ebae215244b160658517bde057f4a3653cbb32c
new file mode 100644 (file)
index 0000000..92ae458
Binary files /dev/null and b/fuzz/gnutls_x509_crl_parser_fuzzer.in/7ebae215244b160658517bde057f4a3653cbb32c differ
diff --git a/fuzz/gnutls_x509_crl_parser_fuzzer.in/c780cb0ee96a448f5af0e1bb09224674546c723a b/fuzz/gnutls_x509_crl_parser_fuzzer.in/c780cb0ee96a448f5af0e1bb09224674546c723a
new file mode 100644 (file)
index 0000000..3823a45
Binary files /dev/null and b/fuzz/gnutls_x509_crl_parser_fuzzer.in/c780cb0ee96a448f5af0e1bb09224674546c723a differ
diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.c b/fuzz/gnutls_x509_crq_parser_fuzzer.c
new file mode 100644 (file)
index 0000000..4f7ebee
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..7631bd7
Binary files /dev/null and b/fuzz/gnutls_x509_crq_parser_fuzzer.in/00da5667fcf94c6753aff43d0e8cf7a2c0e28233 differ
diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/2ac00bb62cce4c5a85ba7d59d167e8cecbfb468d b/fuzz/gnutls_x509_crq_parser_fuzzer.in/2ac00bb62cce4c5a85ba7d59d167e8cecbfb468d
new file mode 100644 (file)
index 0000000..b728d2c
Binary files /dev/null and b/fuzz/gnutls_x509_crq_parser_fuzzer.in/2ac00bb62cce4c5a85ba7d59d167e8cecbfb468d differ
diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/2e7defbf265715d2c2d5ea8bc464071ce19e667a b/fuzz/gnutls_x509_crq_parser_fuzzer.in/2e7defbf265715d2c2d5ea8bc464071ce19e667a
new file mode 100644 (file)
index 0000000..2e9e772
Binary files /dev/null and b/fuzz/gnutls_x509_crq_parser_fuzzer.in/2e7defbf265715d2c2d5ea8bc464071ce19e667a differ
diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/9a926fe3e62b45ba45705ef482a04289a942804f b/fuzz/gnutls_x509_crq_parser_fuzzer.in/9a926fe3e62b45ba45705ef482a04289a942804f
new file mode 100644 (file)
index 0000000..c15f868
Binary files /dev/null and b/fuzz/gnutls_x509_crq_parser_fuzzer.in/9a926fe3e62b45ba45705ef482a04289a942804f differ
diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/b63e395f3b22408f4c03a9ef249afedb48b64609 b/fuzz/gnutls_x509_crq_parser_fuzzer.in/b63e395f3b22408f4c03a9ef249afedb48b64609
new file mode 100644 (file)
index 0000000..59694b8
Binary files /dev/null and b/fuzz/gnutls_x509_crq_parser_fuzzer.in/b63e395f3b22408f4c03a9ef249afedb48b64609 differ
diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/d1e497073008aa907e2c79e236234eff7a21e43e b/fuzz/gnutls_x509_crq_parser_fuzzer.in/d1e497073008aa907e2c79e236234eff7a21e43e
new file mode 100644 (file)
index 0000000..1bbee92
Binary files /dev/null and b/fuzz/gnutls_x509_crq_parser_fuzzer.in/d1e497073008aa907e2c79e236234eff7a21e43e differ
diff --git a/fuzz/gnutls_x509_crq_parser_fuzzer.in/d6cb1c75c08f4c6b76d4e37fefca392f403c7c4e b/fuzz/gnutls_x509_crq_parser_fuzzer.in/d6cb1c75c08f4c6b76d4e37fefca392f403c7c4e
new file mode 100644 (file)
index 0000000..b5fc84a
Binary files /dev/null and b/fuzz/gnutls_x509_crq_parser_fuzzer.in/d6cb1c75c08f4c6b76d4e37fefca392f403c7c4e differ