OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 NssUtil* NssUtil::Create() { | 59 NssUtil* NssUtil::Create() { |
60 if (!factory_) { | 60 if (!factory_) { |
61 return new NssUtilImpl; | 61 return new NssUtilImpl; |
62 base::EnsureNSSInit(); | 62 base::EnsureNSSInit(); |
63 } else { | 63 } else { |
64 return factory_->CreateNssUtil(); | 64 return factory_->CreateNssUtil(); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 // static | 68 // static |
69 void NssUtil::KeyFromBuffer(const std::string& buf, std::vector<uint8>* out) { | 69 void NssUtil::BlobFromBuffer(const std::string& buf, std::vector<uint8>* out) { |
70 out->resize(buf.length()); | 70 out->resize(buf.length()); |
71 if (out->size() == 0) | 71 if (out->size() == 0) |
72 return; | 72 return; |
73 memcpy(&(out->at(0)), buf.c_str(), out->size()); | 73 memcpy(&(out->at(0)), buf.c_str(), out->size()); |
74 } | 74 } |
75 | 75 |
76 // We're generating and using 2048-bit RSA keys. | 76 // We're generating and using 2048-bit RSA keys. |
77 // static | 77 // static |
78 const uint16 NssUtilImpl::kKeySizeInBits = 2048; | 78 const uint16 NssUtilImpl::kKeySizeInBits = 2048; |
79 | 79 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 std::vector<uint8>* OUT_signature, | 131 std::vector<uint8>* OUT_signature, |
132 base::RSAPrivateKey* key) { | 132 base::RSAPrivateKey* key) { |
133 scoped_ptr<base::SignatureCreator> signer( | 133 scoped_ptr<base::SignatureCreator> signer( |
134 base::SignatureCreator::Create(key)); | 134 base::SignatureCreator::Create(key)); |
135 if (!signer->Update(data, data_len)) | 135 if (!signer->Update(data, data_len)) |
136 return false; | 136 return false; |
137 return signer->Final(OUT_signature); | 137 return signer->Final(OUT_signature); |
138 } | 138 } |
139 | 139 |
140 } // namespace login_manager | 140 } // namespace login_manager |
OLD | NEW |