| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 "login_manager/nss_util.h" | 5 #include "login_manager/nss_util.h" |
| 6 | 6 |
| 7 #include <base/basictypes.h> | 7 #include <base/basictypes.h> |
| 8 #include <base/crypto/rsa_private_key.h> | 8 #include <base/crypto/rsa_private_key.h> |
| 9 #include <base/crypto/signature_creator.h> | 9 #include <base/crypto/signature_creator.h> |
| 10 #include <base/crypto/signature_verifier.h> | 10 #include <base/crypto/signature_verifier.h> |
| 11 #include <base/file_path.h> | 11 #include <base/file_path.h> |
| 12 #include <base/logging.h> | 12 #include <base/logging.h> |
| 13 #include <base/nss_util.h> | 13 #include <base/nss_util.h> |
| 14 #include <base/scoped_ptr.h> | 14 #include <base/scoped_ptr.h> |
| 15 #include <cros/chromeos_login.h> | 15 #include <cros/chromeos_login.h> |
| 16 #include <glib/garray.h> | |
| 17 | 16 |
| 18 namespace login_manager { | 17 namespace login_manager { |
| 19 /////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////// |
| 20 // NssUtil | 19 // NssUtil |
| 21 | 20 |
| 22 // static | 21 // static |
| 23 NssUtil::Factory* NssUtil::factory_ = NULL; | 22 NssUtil::Factory* NssUtil::factory_ = NULL; |
| 24 | 23 |
| 25 NssUtil::NssUtil() {} | 24 NssUtil::NssUtil() {} |
| 26 | 25 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 NssUtil* NssUtil::Create() { | 59 NssUtil* NssUtil::Create() { |
| 61 if (!factory_) { | 60 if (!factory_) { |
| 62 return new NssUtilImpl; | 61 return new NssUtilImpl; |
| 63 base::EnsureNSSInit(); | 62 base::EnsureNSSInit(); |
| 64 } else { | 63 } else { |
| 65 return factory_->CreateNssUtil(); | 64 return factory_->CreateNssUtil(); |
| 66 } | 65 } |
| 67 } | 66 } |
| 68 | 67 |
| 69 // static | 68 // static |
| 70 void NssUtil::KeyFromBuffer(const GArray* buf, std::vector<uint8>* out) { | 69 void NssUtil::KeyFromBuffer(const std::string& buf, std::vector<uint8>* out) { |
| 71 out->resize(buf->len); | 70 out->resize(buf.length()); |
| 72 if (buf->len == 0) | 71 if (out->size() == 0) |
| 73 return; | 72 return; |
| 74 memcpy(&(out->at(0)), buf->data, buf->len); | 73 memcpy(&(out->at(0)), buf.c_str(), out->size()); |
| 75 } | 74 } |
| 76 | 75 |
| 77 // We're generating and using 2048-bit RSA keys. | 76 // We're generating and using 2048-bit RSA keys. |
| 78 // static | 77 // static |
| 79 const uint16 NssUtilImpl::kKeySizeInBits = 2048; | 78 const uint16 NssUtilImpl::kKeySizeInBits = 2048; |
| 80 | 79 |
| 81 NssUtilImpl::NssUtilImpl() {} | 80 NssUtilImpl::NssUtilImpl() {} |
| 82 | 81 |
| 83 NssUtilImpl::~NssUtilImpl() {} | 82 NssUtilImpl::~NssUtilImpl() {} |
| 84 | 83 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 std::vector<uint8>* OUT_signature, | 131 std::vector<uint8>* OUT_signature, |
| 133 base::RSAPrivateKey* key) { | 132 base::RSAPrivateKey* key) { |
| 134 scoped_ptr<base::SignatureCreator> signer( | 133 scoped_ptr<base::SignatureCreator> signer( |
| 135 base::SignatureCreator::Create(key)); | 134 base::SignatureCreator::Create(key)); |
| 136 if (!signer->Update(data, data_len)) | 135 if (!signer->Update(data, data_len)) |
| 137 return false; | 136 return false; |
| 138 return signer->Final(OUT_signature); | 137 return signer->Final(OUT_signature); |
| 139 } | 138 } |
| 140 | 139 |
| 141 } // namespace login_manager | 140 } // namespace login_manager |
| OLD | NEW |