| 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 "chrome/browser/chromeos/login/owner_key_utils.h" | 5 #include "chrome/browser/chromeos/login/owner_key_utils.h" |
| 6 | 6 |
| 7 #include <keyhi.h> // SECKEY_CreateSubjectPublicKeyInfo() | |
| 8 #include <pk11pub.h> | |
| 9 #include <prerror.h> // PR_GetError() | |
| 10 #include <secder.h> // DER_Encode() | |
| 11 #include <secmod.h> | |
| 12 | |
| 13 #include <limits> | 7 #include <limits> |
| 14 | 8 |
| 15 #include "base/crypto/rsa_private_key.h" | 9 #include "base/crypto/rsa_private_key.h" |
| 16 #include "base/crypto/signature_creator.h" | 10 #include "base/crypto/signature_creator.h" |
| 17 #include "base/crypto/signature_verifier.h" | 11 #include "base/crypto/signature_verifier.h" |
| 18 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 19 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 20 #include "base/logging.h" | 14 #include "base/logging.h" |
| 21 #include "base/nss_util.h" | |
| 22 #include "base/nss_util_internal.h" | |
| 23 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
| 24 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 25 #include "chrome/browser/chromeos/cros/cros_library.h" | 17 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 26 #include "chrome/browser/chromeos/cros/login_library.h" | 18 #include "chrome/browser/chromeos/cros/login_library.h" |
| 27 #include "chrome/common/extensions/extension_constants.h" | 19 #include "chrome/common/extensions/extension_constants.h" |
| 28 | 20 |
| 29 using base::RSAPrivateKey; | 21 using base::RSAPrivateKey; |
| 30 using extension_misc::kSignatureAlgorithm; | 22 using extension_misc::kSignatureAlgorithm; |
| 31 | 23 |
| 32 namespace chromeos { | 24 namespace chromeos { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return factory_->CreateOwnerKeyUtils(); | 84 return factory_->CreateOwnerKeyUtils(); |
| 93 } | 85 } |
| 94 | 86 |
| 95 // static | 87 // static |
| 96 const char OwnerKeyUtilsImpl::kOwnerKeyFile[] = "/var/lib/whitelist/owner.key"; | 88 const char OwnerKeyUtilsImpl::kOwnerKeyFile[] = "/var/lib/whitelist/owner.key"; |
| 97 | 89 |
| 98 // We're generating and using 2048-bit RSA keys. | 90 // We're generating and using 2048-bit RSA keys. |
| 99 // static | 91 // static |
| 100 const uint16 OwnerKeyUtilsImpl::kKeySizeInBits = 2048; | 92 const uint16 OwnerKeyUtilsImpl::kKeySizeInBits = 2048; |
| 101 | 93 |
| 102 OwnerKeyUtilsImpl::OwnerKeyUtilsImpl() { | 94 OwnerKeyUtilsImpl::OwnerKeyUtilsImpl() {} |
| 103 // Ensure NSS is initialized. | |
| 104 base::EnsureNSSInit(); | |
| 105 } | |
| 106 | 95 |
| 107 OwnerKeyUtilsImpl::~OwnerKeyUtilsImpl() {} | 96 OwnerKeyUtilsImpl::~OwnerKeyUtilsImpl() {} |
| 108 | 97 |
| 109 RSAPrivateKey* OwnerKeyUtilsImpl::GenerateKeyPair() { | 98 RSAPrivateKey* OwnerKeyUtilsImpl::GenerateKeyPair() { |
| 110 return RSAPrivateKey::CreateSensitive(kKeySizeInBits); | 99 return RSAPrivateKey::CreateSensitive(kKeySizeInBits); |
| 111 } | 100 } |
| 112 | 101 |
| 113 bool OwnerKeyUtilsImpl::ExportPublicKeyViaDbus(RSAPrivateKey* pair, | 102 bool OwnerKeyUtilsImpl::ExportPublicKeyViaDbus(RSAPrivateKey* pair, |
| 114 LoginLibrary::Delegate* d) { | 103 LoginLibrary::Delegate* d) { |
| 115 DCHECK(pair); | 104 DCHECK(pair); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 RSAPrivateKey* OwnerKeyUtilsImpl::FindPrivateKey( | 194 RSAPrivateKey* OwnerKeyUtilsImpl::FindPrivateKey( |
| 206 const std::vector<uint8>& key) { | 195 const std::vector<uint8>& key) { |
| 207 return RSAPrivateKey::FindFromPublicKeyInfo(key); | 196 return RSAPrivateKey::FindFromPublicKeyInfo(key); |
| 208 } | 197 } |
| 209 | 198 |
| 210 FilePath OwnerKeyUtilsImpl::GetOwnerKeyFilePath() { | 199 FilePath OwnerKeyUtilsImpl::GetOwnerKeyFilePath() { |
| 211 return FilePath(OwnerKeyUtilsImpl::kOwnerKeyFile); | 200 return FilePath(OwnerKeyUtilsImpl::kOwnerKeyFile); |
| 212 } | 201 } |
| 213 | 202 |
| 214 } // namespace chromeos | 203 } // namespace chromeos |
| OLD | NEW |