OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 FakeDtlsIdentityStore() : should_fail_(false) {} | 89 FakeDtlsIdentityStore() : should_fail_(false) {} |
90 | 90 |
91 void set_should_fail(bool should_fail) { | 91 void set_should_fail(bool should_fail) { |
92 should_fail_ = should_fail; | 92 should_fail_ = should_fail; |
93 } | 93 } |
94 | 94 |
95 void use_original_key() { key_index_ = 0; } | 95 void use_original_key() { key_index_ = 0; } |
96 void use_alternate_key() { key_index_ = 1; } | 96 void use_alternate_key() { key_index_ = 1; } |
97 | 97 |
98 void RequestIdentity( | 98 void RequestIdentity( |
99 rtc::KeyType key_type, | 99 rtc::KeyParams key_params, |
| 100 rtc::Optional<uint64_t> expires, |
100 const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& | 101 const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& |
101 observer) override { | 102 observer) override { |
102 // TODO(hbos): Should be able to generate KT_ECDSA too. | 103 // TODO(hbos): Should be able to generate KT_ECDSA too. |
103 RTC_DCHECK(key_type == rtc::KT_RSA || should_fail_); | 104 RTC_DCHECK((key_params.type() == rtc::KT_RSA && |
| 105 key_params.rsa_params().mod_size == 1024 && |
| 106 key_params.rsa_params().pub_exp == 0x10001) || |
| 107 should_fail_); |
104 MessageData* msg = new MessageData( | 108 MessageData* msg = new MessageData( |
105 rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>(observer)); | 109 rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>(observer)); |
106 rtc::Thread::Current()->Post( | 110 rtc::Thread::Current()->Post( |
107 this, should_fail_ ? MSG_FAILURE : MSG_SUCCESS, msg); | 111 this, should_fail_ ? MSG_FAILURE : MSG_SUCCESS, msg); |
108 } | 112 } |
109 | 113 |
110 static rtc::scoped_refptr<rtc::RTCCertificate> GenerateCertificate() { | 114 static rtc::scoped_refptr<rtc::RTCCertificate> GenerateCertificate() { |
111 std::string cert; | 115 std::string cert; |
112 std::string key; | 116 std::string key; |
113 rtc::SSLIdentity::PemToDer("CERTIFICATE", kKeysAndCerts[0].cert_pem, &cert); | 117 rtc::SSLIdentity::PemToDer("CERTIFICATE", kKeysAndCerts[0].cert_pem, &cert); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 break; | 162 break; |
159 } | 163 } |
160 delete message_data; | 164 delete message_data; |
161 } | 165 } |
162 | 166 |
163 bool should_fail_; | 167 bool should_fail_; |
164 int key_index_ = 0; | 168 int key_index_ = 0; |
165 }; | 169 }; |
166 | 170 |
167 #endif // WEBRTC_API_TEST_FAKEDTLSIDENTITYSERVICE_H_ | 171 #endif // WEBRTC_API_TEST_FAKEDTLSIDENTITYSERVICE_H_ |
OLD | NEW |