OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/api/certificate_provider/certificate_provide
r_api.h" | 5 #include "chrome/browser/extensions/api/certificate_provider/certificate_provide
r_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 size_t public_key_length_in_bits = 0; | 134 size_t public_key_length_in_bits = 0; |
135 net::X509Certificate::PublicKeyType type = | 135 net::X509Certificate::PublicKeyType type = |
136 net::X509Certificate::kPublicKeyTypeUnknown; | 136 net::X509Certificate::kPublicKeyTypeUnknown; |
137 net::X509Certificate::GetPublicKeyInfo( | 137 net::X509Certificate::GetPublicKeyInfo( |
138 out_info->certificate->os_cert_handle(), &public_key_length_in_bits, | 138 out_info->certificate->os_cert_handle(), &public_key_length_in_bits, |
139 &type); | 139 &type); |
140 | 140 |
141 switch (type) { | 141 switch (type) { |
142 case net::X509Certificate::kPublicKeyTypeRSA: | 142 case net::X509Certificate::kPublicKeyTypeRSA: |
143 DCHECK(public_key_length_in_bits); | |
144 | |
145 // Convert bits to bytes. | |
146 out_info->max_signature_length_in_bytes = | |
147 (public_key_length_in_bits + 7) / 8; | |
148 out_info->type = net::SSLPrivateKey::Type::RSA; | |
149 break; | 143 break; |
150 case net::X509Certificate::kPublicKeyTypeECDSA: | 144 case net::X509Certificate::kPublicKeyTypeECDSA: |
151 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_ERROR, | 145 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_ERROR, |
152 kErrorECDSANotSupported); | 146 kErrorECDSANotSupported); |
153 return false; | 147 return false; |
154 default: | 148 default: |
155 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_ERROR, | 149 WriteToConsole(content::CONSOLE_MESSAGE_LEVEL_ERROR, |
156 kErrorUnknownKeyType); | 150 kErrorUnknownKeyType); |
157 return false; | 151 return false; |
158 } | 152 } |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 std::vector<uint8_t> signature; | 340 std::vector<uint8_t> signature; |
347 // If an error occurred, |signature| will not be set. | 341 // If an error occurred, |signature| will not be set. |
348 if (params->signature) | 342 if (params->signature) |
349 signature.assign(params->signature->begin(), params->signature->end()); | 343 signature.assign(params->signature->begin(), params->signature->end()); |
350 | 344 |
351 service->ReplyToSignRequest(extension_id(), params->request_id, signature); | 345 service->ReplyToSignRequest(extension_id(), params->request_id, signature); |
352 return RespondNow(NoArguments()); | 346 return RespondNow(NoArguments()); |
353 } | 347 } |
354 | 348 |
355 } // namespace extensions | 349 } // namespace extensions |
OLD | NEW |