| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ | 5 #ifndef NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ |
| 6 #define NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ | 6 #define NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <stdarg.h> | 8 #include <stdarg.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 QuicCryptoStream* server, | 137 QuicCryptoStream* server, |
| 138 size_t server_i); | 138 size_t server_i); |
| 139 | 139 |
| 140 // Returns the value for the tag |tag| in the tag value map of |message|. | 140 // Returns the value for the tag |tag| in the tag value map of |message|. |
| 141 static std::string GetValueForTag(const CryptoHandshakeMessage& message, | 141 static std::string GetValueForTag(const CryptoHandshakeMessage& message, |
| 142 QuicTag tag); | 142 QuicTag tag); |
| 143 | 143 |
| 144 // Returns a new |ProofSource| that serves up test certificates. | 144 // Returns a new |ProofSource| that serves up test certificates. |
| 145 static std::unique_ptr<ProofSource> ProofSourceForTesting(); | 145 static std::unique_ptr<ProofSource> ProofSourceForTesting(); |
| 146 | 146 |
| 147 // Returns a |ProofVerifier| that uses the QUIC testing root CA. | 147 // Identical to |ProofSourceForTesting|, with the addition of setting |
| 148 // the |emit_expect_ct_header| field on the test certificates |
| 149 // to be the value of |send_expect_ct_header|. |
| 150 static std::unique_ptr<ProofSource> ProofSourceForTesting( |
| 151 bool send_expect_ct_header); |
| 152 |
| 153 // Returns a new |ProofVerifier| that uses the QUIC testing root CA. |
| 148 static std::unique_ptr<ProofVerifier> ProofVerifierForTesting(); | 154 static std::unique_ptr<ProofVerifier> ProofVerifierForTesting(); |
| 149 | 155 |
| 150 // Returns a real ProofVerifier (not a fake proof verifier) for testing. | 156 // Returns a real ProofVerifier (not a fake proof verifier) for testing. |
| 151 static std::unique_ptr<ProofVerifier> RealProofVerifierForTesting(); | 157 static std::unique_ptr<ProofVerifier> RealProofVerifierForTesting(); |
| 152 | 158 |
| 153 // Returns a hash of the leaf test certificate. | 159 // Returns a hash of the leaf test certificate. |
| 154 static uint64_t LeafCertHashForTesting(); | 160 static uint64_t LeafCertHashForTesting(); |
| 155 | 161 |
| 156 // Returns a |ProofVerifyContext| that must be used with the verifier | 162 // Returns a |ProofVerifyContext| that must be used with the verifier |
| 157 // returned by |ProofVerifierForTesting|. | 163 // returned by |ProofVerifierForTesting|. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 Perspective dest_perspective); | 211 Perspective dest_perspective); |
| 206 | 212 |
| 207 // Return an inchoate CHLO with some basic tag value std:pairs. | 213 // Return an inchoate CHLO with some basic tag value std:pairs. |
| 208 static CryptoHandshakeMessage GenerateDefaultInchoateCHLO( | 214 static CryptoHandshakeMessage GenerateDefaultInchoateCHLO( |
| 209 const QuicClock* clock, | 215 const QuicClock* clock, |
| 210 QuicVersion version, | 216 QuicVersion version, |
| 211 QuicCryptoServerConfig* crypto_config); | 217 QuicCryptoServerConfig* crypto_config); |
| 212 | 218 |
| 213 // Takes a inchoate CHLO, returns a full CHLO in |out| which can pass | 219 // Takes a inchoate CHLO, returns a full CHLO in |out| which can pass |
| 214 // |crypto_config|'s validation. | 220 // |crypto_config|'s validation. |
| 215 static void GenerateFullCHLO(const CryptoHandshakeMessage& inchoate_chlo, | 221 static void GenerateFullCHLO( |
| 216 QuicCryptoServerConfig* crypto_config, | 222 const CryptoHandshakeMessage& inchoate_chlo, |
| 217 IPAddress server_ip, | 223 QuicCryptoServerConfig* crypto_config, |
| 218 IPEndPoint client_addr, | 224 IPAddress server_ip, |
| 219 QuicVersion version, | 225 IPEndPoint client_addr, |
| 220 const QuicClock* clock, | 226 QuicVersion version, |
| 221 scoped_refptr<QuicCryptoProof> proof, | 227 const QuicClock* clock, |
| 222 QuicCompressedCertsCache* compressed_certs_cache, | 228 scoped_refptr<QuicSignedServerConfig> signed_config, |
| 223 CryptoHandshakeMessage* out); | 229 QuicCompressedCertsCache* compressed_certs_cache, |
| 230 CryptoHandshakeMessage* out); |
| 224 | 231 |
| 225 private: | 232 private: |
| 226 static void CompareClientAndServerKeys(QuicCryptoClientStream* client, | 233 static void CompareClientAndServerKeys(QuicCryptoClientStream* client, |
| 227 QuicCryptoServerStream* server); | 234 QuicCryptoServerStream* server); |
| 228 | 235 |
| 229 // Return a CHLO nonce in hexadecimal. | 236 // Return a CHLO nonce in hexadecimal. |
| 230 static std::string GenerateClientNonceHex( | 237 static std::string GenerateClientNonceHex( |
| 231 const QuicClock* clock, | 238 const QuicClock* clock, |
| 232 QuicCryptoServerConfig* crypto_config); | 239 QuicCryptoServerConfig* crypto_config); |
| 233 | 240 |
| 234 // Return a CHLO PUBS in hexadecimal. | 241 // Return a CHLO PUBS in hexadecimal. |
| 235 static std::string GenerateClientPublicValuesHex(); | 242 static std::string GenerateClientPublicValuesHex(); |
| 236 | 243 |
| 237 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils); | 244 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils); |
| 238 }; | 245 }; |
| 239 | 246 |
| 240 } // namespace test | 247 } // namespace test |
| 241 | 248 |
| 242 } // namespace net | 249 } // namespace net |
| 243 | 250 |
| 244 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ | 251 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ |
| OLD | NEW |