Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(796)

Unified Diff: net/quic/crypto/proof_test.cc

Issue 14651009: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix integer constant is too large for 'unsigned long' type Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/crypto/null_encrypter.cc ('k') | net/quic/quic_bandwidth.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/crypto/proof_test.cc
diff --git a/net/quic/crypto/proof_test.cc b/net/quic/crypto/proof_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3423b50fcc293e411ff265ab42af3ff00e099fea
--- /dev/null
+++ b/net/quic/crypto/proof_test.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2013 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 "net/quic/crypto/proof_source.h"
+#include "net/quic/crypto/proof_verifier.h"
+#include "net/quic/test_tools/crypto_test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using std::string;
+using std::vector;
+
+namespace net {
+namespace test {
+
+TEST(Proof, Verify) {
+ // TODO(rtenneti): Enable testing of ProofVerifier.
+#if 0
+ scoped_ptr<ProofSource> source(CryptoTestUtils::ProofSourceForTesting());
+ scoped_ptr<ProofVerifier> verifier(
+ CryptoTestUtils::ProofVerifierForTesting());
+
+ const string server_config = "server config bytes";
+ const string hostname = "test.example.com";
+ const vector<string>* certs;
+ const vector<string>* first_certs;
+ string error_details, signature, first_signature;
+
+ ASSERT_TRUE(source->GetProof(hostname, server_config, &first_certs,
+ &first_signature));
+ ASSERT_TRUE(source->GetProof(hostname, server_config, &certs, &signature));
+
+ // Check that the proof source is caching correctly:
+ ASSERT_EQ(first_certs, certs);
+ ASSERT_EQ(signature, first_signature);
+
+ ASSERT_TRUE(verifier->VerifyProof(hostname, server_config, *certs, signature,
+ &error_details));
+ ASSERT_FALSE(verifier->VerifyProof("foo.com", server_config, *certs,
+ signature, &error_details));
+ ASSERT_FALSE(
+ verifier->VerifyProof(hostname, server_config.substr(1, string::npos),
+ *certs, signature, &error_details));
+ const string corrupt_signature = "1" + signature;
+ ASSERT_FALSE(verifier->VerifyProof(hostname, server_config, *certs,
+ corrupt_signature, &error_details));
+
+ vector<string> wrong_certs;
+ for (size_t i = 1; i < certs->size(); i++) {
+ wrong_certs.push_back((*certs)[i]);
+ }
+ ASSERT_FALSE(verifier->VerifyProof("foo.com", server_config, wrong_certs,
+ signature, &error_details));
+#endif // 0
+}
+
+} // namespace test
+} // namespace net
« no previous file with comments | « net/quic/crypto/null_encrypter.cc ('k') | net/quic/quic_bandwidth.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698