12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef NET_SPDY_TEST_UTILS_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define NET_SPDY_TEST_UTILS_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include <stdint.h>
903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <string>
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/spdy/spdy_protocol.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace net {
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class HashValue;
1703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class TransportSecurityState;
1803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace test {
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)std::string HexDumpWithMarks(const unsigned char* data, int length,
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                             const bool* marks, int mark_length);
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void CompareCharArraysWithHexError(
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const std::string& description,
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const unsigned char* actual,
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int actual_len,
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const unsigned char* expected,
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    const int expected_len);
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
315c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuvoid SetFrameFlags(SpdyFrame* frame,
325c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu                   uint8 flags,
335c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu                   SpdyMajorVersion spdy_version);
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
355c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuvoid SetFrameLength(SpdyFrame* frame,
365c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu                    size_t length,
375c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu                    SpdyMajorVersion spdy_version);
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
39cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)std::string a2b_hex(const char* hex_data);
40cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
4103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// Returns a SHA1 HashValue in which each byte has the value |label|.
4203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)HashValue GetTestHashValue(uint8_t label);
4303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
4403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// Returns SHA1 pinning header for the of the base64 encoding of
4503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// GetTestHashValue(|label|).
4603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)std::string GetTestPin(uint8_t label);
4703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
4803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// Adds a pin for |host| to |state|.
4903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)void AddPin(TransportSecurityState* state,
5003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)            const std::string& host,
5103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)            uint8_t primary_label,
5203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)            uint8_t backup_label);
5303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace test
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace net
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // NET_SPDY_TEST_UTILS_H_
59