| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ec_private_key.h" | 5 #include "crypto/ec_private_key.h" |
| 6 | 6 |
| 7 extern "C" { | 7 extern "C" { |
| 8 // Work around NSS missing SEC_BEGIN_PROTOS in secmodt.h. This must come before | 8 // Work around NSS missing SEC_BEGIN_PROTOS in secmodt.h. This must come before |
| 9 // other NSS headers. | 9 // other NSS headers. |
| 10 #include <secmodt.h> | 10 #include <secmodt.h> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 return crypto::GetPublicNSSKeySlot(); | 29 return crypto::GetPublicNSSKeySlot(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 class EllipticCurveSupportChecker { | 32 class EllipticCurveSupportChecker { |
| 33 public: | 33 public: |
| 34 EllipticCurveSupportChecker() { | 34 EllipticCurveSupportChecker() { |
| 35 // NOTE: we can do this check here only because we use the NSS internal | 35 // NOTE: we can do this check here only because we use the NSS internal |
| 36 // slot. If we support other slots in the future, checking whether they | 36 // slot. If we support other slots in the future, checking whether they |
| 37 // support ECDSA may block NSS, and the value may also change as devices are | 37 // support ECDSA may block NSS, and the value may also change as devices are |
| 38 // inserted/removed, so we would need to re-check on every use. | 38 // inserted/removed, so we would need to re-check on every use. |
| 39 LOG(ERROR) << "HIIIIIIIIIIIIIIIIIIIIIIIIIII"; |
| 39 crypto::EnsureNSSInit(); | 40 crypto::EnsureNSSInit(); |
| 40 crypto::ScopedPK11Slot slot(GetKeySlot()); | 41 crypto::ScopedPK11Slot slot(GetKeySlot()); |
| 41 supported_ = PK11_DoesMechanism(slot.get(), CKM_EC_KEY_PAIR_GEN) && | 42 supported_ = PK11_DoesMechanism(slot.get(), CKM_EC_KEY_PAIR_GEN) && |
| 42 PK11_DoesMechanism(slot.get(), CKM_ECDSA); | 43 PK11_DoesMechanism(slot.get(), CKM_ECDSA); |
| 43 } | 44 } |
| 44 | 45 |
| 45 bool Supported() { | 46 bool Supported() { |
| 46 return supported_; | 47 return supported_; |
| 47 } | 48 } |
| 48 | 49 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 return result.release(); | 322 return result.release(); |
| 322 } | 323 } |
| 323 | 324 |
| 324 // static | 325 // static |
| 325 ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfoWithParams( | 326 ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfoWithParams( |
| 326 const std::string& password, | 327 const std::string& password, |
| 327 const std::vector<uint8>& encrypted_private_key_info, | 328 const std::vector<uint8>& encrypted_private_key_info, |
| 328 const std::vector<uint8>& subject_public_key_info, | 329 const std::vector<uint8>& subject_public_key_info, |
| 329 bool permanent, | 330 bool permanent, |
| 330 bool sensitive) { | 331 bool sensitive) { |
| 332 LOG(ERROR) << "HIIIIIIIIIIIIIIIIIIIIIIIIIII"; |
| 331 EnsureNSSInit(); | 333 EnsureNSSInit(); |
| 332 | 334 |
| 333 scoped_ptr<ECPrivateKey> result(new ECPrivateKey); | 335 scoped_ptr<ECPrivateKey> result(new ECPrivateKey); |
| 334 | 336 |
| 335 SECItem encoded_spki = { | 337 SECItem encoded_spki = { |
| 336 siBuffer, | 338 siBuffer, |
| 337 const_cast<unsigned char*>(&subject_public_key_info[0]), | 339 const_cast<unsigned char*>(&subject_public_key_info[0]), |
| 338 static_cast<unsigned>(subject_public_key_info.size()) | 340 static_cast<unsigned>(subject_public_key_info.size()) |
| 339 }; | 341 }; |
| 340 CERTSubjectPublicKeyInfo* decoded_spki = SECKEY_DecodeDERSubjectPublicKeyInfo( | 342 CERTSubjectPublicKeyInfo* decoded_spki = SECKEY_DecodeDERSubjectPublicKeyInfo( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 356 | 358 |
| 357 SECKEY_DestroySubjectPublicKeyInfo(decoded_spki); | 359 SECKEY_DestroySubjectPublicKeyInfo(decoded_spki); |
| 358 | 360 |
| 359 if (success) | 361 if (success) |
| 360 return result.release(); | 362 return result.release(); |
| 361 | 363 |
| 362 return NULL; | 364 return NULL; |
| 363 } | 365 } |
| 364 | 366 |
| 365 } // namespace crypto | 367 } // namespace crypto |
| OLD | NEW |