| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 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 |
| 5 #include "net/quic/test_tools/crypto_test_utils.h" |
| 6 |
| 7 #include "net/quic/crypto/channel_id.h" |
| 8 |
| 9 using base::StringPiece; |
| 10 using std::string; |
| 11 |
| 12 namespace net { |
| 13 |
| 14 namespace test { |
| 15 |
| 16 // TODO(rtenneti): Implement NSS support ChannelIDSigner. Convert Sign() to be |
| 17 // asynchronous using completion callback. After porting TestChannelIDSigner, |
| 18 // implement real ChannelIDSigner. |
| 19 class TestChannelIDSigner : public ChannelIDSigner { |
| 20 public: |
| 21 virtual ~TestChannelIDSigner() { } |
| 22 |
| 23 // ChannelIDSigner implementation. |
| 24 |
| 25 virtual bool Sign(const string& hostname, |
| 26 StringPiece signed_data, |
| 27 string* out_key, |
| 28 string* out_signature) OVERRIDE { |
| 29 string key(HostnameToKey(hostname)); |
| 30 |
| 31 *out_key = SerializeKey(key); |
| 32 if (out_key->empty()) { |
| 33 return false; |
| 34 } |
| 35 |
| 36 *out_signature = signed_data.as_string(); |
| 37 |
| 38 return true; |
| 39 } |
| 40 |
| 41 static string KeyForHostname(const string& hostname) { |
| 42 string key(HostnameToKey(hostname)); |
| 43 return SerializeKey(key); |
| 44 } |
| 45 |
| 46 private: |
| 47 static string HostnameToKey(const string& hostname) { |
| 48 string ret = hostname; |
| 49 return ret; |
| 50 } |
| 51 |
| 52 static string SerializeKey(string& key) { |
| 53 return string(key); |
| 54 } |
| 55 }; |
| 56 |
| 57 // static |
| 58 ChannelIDSigner* CryptoTestUtils::ChannelIDSignerForTesting() { |
| 59 return new TestChannelIDSigner(); |
| 60 } |
| 61 |
| 62 // static |
| 63 string CryptoTestUtils::ChannelIDKeyForHostname(const string& hostname) { |
| 64 return TestChannelIDSigner::KeyForHostname(hostname); |
| 65 } |
| 66 |
| 67 } // namespace test |
| 68 |
| 69 } // namespace net |
| OLD | NEW |