QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // Copyright (c) 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 5 | #include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" |
| 6 | #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" |
| 7 | #include "net/third_party/quiche/src/quic/core/quic_framer.h" |
| 8 | #include "net/third_party/quiche/src/quic/core/quic_packets.h" |
| 9 | #include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" |
| 10 | #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" |
| 11 | |
| 12 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 13 | quic::QuicFramer framer(quic::AllSupportedVersions(), quic::QuicTime::Zero(), |
| 14 | quic::Perspective::IS_SERVER, |
| 15 | quic::kQuicDefaultConnectionIdLength); |
| 16 | const char* const packet_bytes = reinterpret_cast<const char*>(data); |
| 17 | |
| 18 | // Test the CryptoFramer. |
| 19 | quic::QuicStringPiece crypto_input(packet_bytes, size); |
| 20 | std::unique_ptr<quic::CryptoHandshakeMessage> handshake_message( |
| 21 | quic::CryptoFramer::ParseMessage(crypto_input)); |
| 22 | |
| 23 | // Test the regular QuicFramer with the same input. |
| 24 | quic::test::NoOpFramerVisitor visitor; |
| 25 | framer.set_visitor(&visitor); |
| 26 | quic::QuicEncryptedPacket packet(packet_bytes, size); |
| 27 | framer.ProcessPacket(packet); |
| 28 | |
| 29 | return 0; |
| 30 | } |