Support PEM input in CertificateView and CertificatePrivateKey.
Since most of the certificate files out there are encoded in PEM, we will need to eventually parse those. This implements PEM patching from scratch, since that appears to be less effort than using openssl/pem.h.
gfe-relnote: n/a (no functional change)
PiperOrigin-RevId: 307510249
Change-Id: Ieec30267af8a9ea8f5c476cc6eaa411c06599baf
diff --git a/quic/core/crypto/certificate_view_pem_fuzzer.cc b/quic/core/crypto/certificate_view_pem_fuzzer.cc
new file mode 100644
index 0000000..e1efd98
--- /dev/null
+++ b/quic/core/crypto/certificate_view_pem_fuzzer.cc
@@ -0,0 +1,18 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <sstream>
+#include <string>
+
+#include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h"
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ std::string input(reinterpret_cast<const char*>(data), size);
+ std::stringstream stream(input);
+
+ quic::CertificateView::LoadPemFromStream(&stream);
+ stream.seekg(0);
+ quic::CertificatePrivateKey::LoadPemFromStream(&stream);
+ return 0;
+}