OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "crypto/rsa_private_key.h" | 5 #include "crypto/rsa_private_key.h" |
6 | 6 |
7 #include <cryptohi.h> | 7 #include <cryptohi.h> |
8 #include <keyhi.h> | 8 #include <keyhi.h> |
9 #include <pk11pub.h> | 9 #include <pk11pub.h> |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 return NULL; | 112 return NULL; |
113 } | 113 } |
114 | 114 |
115 ScopedSECItem ck_id( | 115 ScopedSECItem ck_id( |
116 PK11_MakeIDFromPubKey(&(result->public_key_->u.rsa.modulus))); | 116 PK11_MakeIDFromPubKey(&(result->public_key_->u.rsa.modulus))); |
117 if (!ck_id.get()) { | 117 if (!ck_id.get()) { |
118 NOTREACHED(); | 118 NOTREACHED(); |
119 return NULL; | 119 return NULL; |
120 } | 120 } |
121 | 121 |
122 ScopedPK11Slot slot(GetPrivateNSSKeySlot()); | 122 ScopedPK11Slot slot(GetPublicNSSKeySlot()); |
123 if (!slot.get()) { | 123 if (!slot.get()) { |
124 NOTREACHED(); | 124 NOTREACHED(); |
125 return NULL; | 125 return NULL; |
wtc
2011/06/03 18:31:56
I wonder if this is the bug. Compare this with yo
| |
126 } | 126 } |
127 | 127 |
128 // Finally...Look for the key! | 128 // Finally...Look for the key! |
129 result->key_ = PK11_FindKeyByKeyID(slot.get(), ck_id.get(), NULL); | 129 result->key_ = PK11_FindKeyByKeyID(slot.get(), ck_id.get(), NULL); |
130 | 130 |
131 // If we don't find the matching key in the private slot, then we | 131 // If we don't find the matching key in the public slot, then we |
132 // look in the public slot. | 132 // look in the private slot. |
wtc
2011/06/03 18:31:56
Recall that both rsleevi and I suggested that this
Greg Spencer (Chromium)
2011/06/06 22:40:58
OK, I've changed the code to search all slots. It
| |
133 if (!result->key_) { | 133 if (!result->key_) { |
134 slot.reset(GetPublicNSSKeySlot()); | 134 slot.reset(GetPrivateNSSKeySlot()); |
135 if (!slot.get()) { | 135 |
136 NOTREACHED(); | 136 // If we don't have a TPM, this could happen. |
137 if (!slot.get()) | |
137 return NULL; | 138 return NULL; |
Chris Masone
2011/06/03 18:12:45
Might we worth logging a WARNING here, at least.
| |
138 } | 139 |
139 result->key_ = PK11_FindKeyByKeyID(slot.get(), ck_id.get(), NULL); | 140 result->key_ = PK11_FindKeyByKeyID(slot.get(), ck_id.get(), NULL); |
140 } | 141 } |
141 | 142 |
142 // If we didn't find it, that's ok. | 143 // If we didn't find it, that's ok. |
143 if (!result->key_) | 144 if (!result->key_) |
144 return NULL; | 145 return NULL; |
145 | 146 |
146 return result.release(); | 147 return result.release(); |
147 } | 148 } |
148 | 149 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 result->public_key_ = SECKEY_ConvertToPublicKey(result->key_); | 247 result->public_key_ = SECKEY_ConvertToPublicKey(result->key_); |
247 if (!result->public_key_) { | 248 if (!result->public_key_) { |
248 NOTREACHED(); | 249 NOTREACHED(); |
249 return NULL; | 250 return NULL; |
250 } | 251 } |
251 | 252 |
252 return result.release(); | 253 return result.release(); |
253 } | 254 } |
254 | 255 |
255 } // namespace crypto | 256 } // namespace crypto |
OLD | NEW |