OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/base/keygen_handler.h" | 5 #include "net/base/keygen_handler.h" |
6 | 6 |
7 #include "build/build_config.h" // Needs to be imported early for USE_NSS | 7 #include "build/build_config.h" // Needs to be imported early for USE_NSS |
8 | 8 |
9 #if defined(USE_NSS) | 9 #if defined(USE_NSS) |
10 #include <private/pprthred.h> // PR_DetachThread | 10 #include <private/pprthred.h> // PR_DetachThread |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // Challenge String: some challenge | 66 // Challenge String: some challenge |
67 // Signature Algorithm: md5WithRSAEncryption | 67 // Signature Algorithm: md5WithRSAEncryption |
68 // 92:f3:cc:ff:0b:d3:d0:4a:3a:4c:ba:ff:d6:38:7f:a5:4b:b5: ..... | 68 // 92:f3:cc:ff:0b:d3:d0:4a:3a:4c:ba:ff:d6:38:7f:a5:4b:b5: ..... |
69 // Signature OK | 69 // Signature OK |
70 // | 70 // |
71 // The value of |spkac| can be ASN.1-parsed with: | 71 // The value of |spkac| can be ASN.1-parsed with: |
72 // openssl asn1parse -inform DER | 72 // openssl asn1parse -inform DER |
73 } | 73 } |
74 | 74 |
75 TEST_F(KeygenHandlerTest, SmokeTest) { | 75 TEST_F(KeygenHandlerTest, SmokeTest) { |
76 KeygenHandler handler(768, "some challenge"); | 76 KeygenHandler handler(768, "some challenge", GURL("http://www.example.com")); |
77 handler.set_stores_key(false); // Don't leave the key-pair behind | 77 handler.set_stores_key(false); // Don't leave the key-pair behind |
78 std::string result = handler.GenKeyAndSignChallenge(); | 78 std::string result = handler.GenKeyAndSignChallenge(); |
79 LOG(INFO) << "KeygenHandler produced: " << result; | 79 LOG(INFO) << "KeygenHandler produced: " << result; |
80 AssertValidSignedPublicKeyAndChallenge(result, "some challenge"); | 80 AssertValidSignedPublicKeyAndChallenge(result, "some challenge"); |
81 } | 81 } |
82 | 82 |
83 class ConcurrencyTestTask : public Task { | 83 class ConcurrencyTestTask : public Task { |
84 public: | 84 public: |
85 ConcurrencyTestTask(base::WaitableEvent* event, | 85 ConcurrencyTestTask(base::WaitableEvent* event, |
86 const std::string& challenge, std::string* result) | 86 const std::string& challenge, std::string* result) |
87 : event_(event), | 87 : event_(event), |
88 challenge_(challenge), | 88 challenge_(challenge), |
89 result_(result) { | 89 result_(result) { |
90 } | 90 } |
91 | 91 |
92 virtual void Run() { | 92 virtual void Run() { |
93 KeygenHandler handler(768, "some challenge"); | 93 KeygenHandler handler(768, "some challenge", |
| 94 GURL("http://www.example.com")); |
94 handler.set_stores_key(false); // Don't leave the key-pair behind. | 95 handler.set_stores_key(false); // Don't leave the key-pair behind. |
95 *result_ = handler.GenKeyAndSignChallenge(); | 96 *result_ = handler.GenKeyAndSignChallenge(); |
96 event_->Signal(); | 97 event_->Signal(); |
97 #if defined(USE_NSS) | 98 #if defined(USE_NSS) |
98 // Detach the thread from NSPR. | 99 // Detach the thread from NSPR. |
99 // Calling NSS functions attaches the thread to NSPR, which stores | 100 // Calling NSS functions attaches the thread to NSPR, which stores |
100 // the NSPR thread ID in thread-specific data. | 101 // the NSPR thread ID in thread-specific data. |
101 // The threads in our thread pool terminate after we have called | 102 // The threads in our thread pool terminate after we have called |
102 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets | 103 // PR_Cleanup. Unless we detach them from NSPR, net_unittests gets |
103 // segfaults on shutdown when the threads' thread-specific data | 104 // segfaults on shutdown when the threads' thread-specific data |
(...skipping 30 matching lines...) Expand all Loading... |
134 events[i] = NULL; | 135 events[i] = NULL; |
135 | 136 |
136 LOG(INFO) << "KeygenHandler " << i << " produced: " << results[i]; | 137 LOG(INFO) << "KeygenHandler " << i << " produced: " << results[i]; |
137 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); | 138 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); |
138 } | 139 } |
139 } | 140 } |
140 | 141 |
141 } // namespace | 142 } // namespace |
142 | 143 |
143 } // namespace net | 144 } // namespace net |
OLD | NEW |