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

Unified Diff: net/quic/test_tools/crypto_test_utils_nss.cc

Issue 15937012: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small bug fixes 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
Index: net/quic/test_tools/crypto_test_utils_nss.cc
diff --git a/net/quic/test_tools/crypto_test_utils_nss.cc b/net/quic/test_tools/crypto_test_utils_nss.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d21da6950b5c4f37366a35d344aecb1ac2913a4f
--- /dev/null
+++ b/net/quic/test_tools/crypto_test_utils_nss.cc
@@ -0,0 +1,69 @@
+// 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/test_tools/crypto_test_utils.h"
+
+#include "net/quic/crypto/channel_id.h"
+
+using base::StringPiece;
+using std::string;
+
+namespace net {
+
+namespace test {
+
+// TODO(rtenneti): Implement NSS support ChannelIDSigner. Convert Sign() to be
+// asynchronous using completion callback. After porting TestChannelIDSigner,
+// implement real ChannelIDSigner.
+class TestChannelIDSigner : public ChannelIDSigner {
+ public:
+ virtual ~TestChannelIDSigner() { }
+
+ // ChannelIDSigner implementation.
+
+ virtual bool Sign(const string& hostname,
+ StringPiece signed_data,
+ string* out_key,
+ string* out_signature) OVERRIDE {
+ string key(HostnameToKey(hostname));
+
+ *out_key = SerializeKey(key);
+ if (out_key->empty()) {
+ return false;
+ }
+
+ *out_signature = signed_data.as_string();
+
+ return true;
+ }
+
+ static string KeyForHostname(const string& hostname) {
+ string key(HostnameToKey(hostname));
+ return SerializeKey(key);
+ }
+
+ private:
+ static string HostnameToKey(const string& hostname) {
+ string ret = hostname;
+ return ret;
+ }
+
+ static string SerializeKey(string& key) {
+ return string(key);
+ }
+};
+
+// static
+ChannelIDSigner* CryptoTestUtils::ChannelIDSignerForTesting() {
+ return new TestChannelIDSigner();
+}
+
+// static
+string CryptoTestUtils::ChannelIDKeyForHostname(const string& hostname) {
+ return TestChannelIDSigner::KeyForHostname(hostname);
+}
+
+} // namespace test
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698