| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/ownership/owner_settings_service.h" | 5 #include "components/ownership/owner_settings_service.h" |
| 6 | 6 |
| 7 #include <cryptohi.h> | 7 #include <cryptohi.h> |
| 8 #include <keyhi.h> | 8 #include <keyhi.h> |
| 9 #include <stdint.h> |
| 9 | 10 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/task_runner.h" | 16 #include "base/task_runner.h" |
| 17 #include "base/task_runner_util.h" | 17 #include "base/task_runner_util.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/ownership/owner_key_util.h" | 19 #include "components/ownership/owner_key_util.h" |
| 20 #include "crypto/scoped_nss_types.h" | 20 #include "crypto/scoped_nss_types.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 43 ScopedSGNContext sign_context( | 43 ScopedSGNContext sign_context( |
| 44 SGN_NewContext(SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION, private_key)); | 44 SGN_NewContext(SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION, private_key)); |
| 45 if (!sign_context) { | 45 if (!sign_context) { |
| 46 NOTREACHED(); | 46 NOTREACHED(); |
| 47 return nullptr; | 47 return nullptr; |
| 48 } | 48 } |
| 49 | 49 |
| 50 SECItem signature_item; | 50 SECItem signature_item; |
| 51 if (SGN_Begin(sign_context.get()) != SECSuccess || | 51 if (SGN_Begin(sign_context.get()) != SECSuccess || |
| 52 SGN_Update(sign_context.get(), | 52 SGN_Update(sign_context.get(), |
| 53 reinterpret_cast<const uint8*>( | 53 reinterpret_cast<const uint8_t*>( |
| 54 policy_response->policy_data().c_str()), | 54 policy_response->policy_data().c_str()), |
| 55 policy_response->policy_data().size()) != SECSuccess || | 55 policy_response->policy_data().size()) != SECSuccess || |
| 56 SGN_End(sign_context.get(), &signature_item) != SECSuccess) { | 56 SGN_End(sign_context.get(), &signature_item) != SECSuccess) { |
| 57 LOG(ERROR) << "Failed to create policy signature."; | 57 LOG(ERROR) << "Failed to create policy signature."; |
| 58 return nullptr; | 58 return nullptr; |
| 59 } | 59 } |
| 60 | 60 |
| 61 policy_response->mutable_policy_data_signature()->assign( | 61 policy_response->mutable_policy_data_signature()->assign( |
| 62 reinterpret_cast<const char*>(signature_item.data), signature_item.len); | 62 reinterpret_cast<const char*>(signature_item.data), signature_item.len); |
| 63 SECITEM_FreeItem(&signature_item, PR_FALSE); | 63 SECITEM_FreeItem(&signature_item, PR_FALSE); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 for (std::vector<IsOwnerCallback>::iterator it(is_owner_callbacks.begin()); | 159 for (std::vector<IsOwnerCallback>::iterator it(is_owner_callbacks.begin()); |
| 160 it != is_owner_callbacks.end(); | 160 it != is_owner_callbacks.end(); |
| 161 ++it) { | 161 ++it) { |
| 162 it->Run(is_owner); | 162 it->Run(is_owner); |
| 163 } | 163 } |
| 164 | 164 |
| 165 OnPostKeypairLoadedActions(); | 165 OnPostKeypairLoadedActions(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace ownership | 168 } // namespace ownership |
| OLD | NEW |