| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "crypto/ec_private_key.h" | 5 #include "crypto/ec_private_key.h" |
| 6 | 6 |
| 7 extern "C" { | 7 extern "C" { |
| 8 // Work around NSS missing SEC_BEGIN_PROTOS in secmodt.h. This must come before | 8 // Work around NSS missing SEC_BEGIN_PROTOS in secmodt.h. This must come before |
| 9 // other NSS headers. | 9 // other NSS headers. |
| 10 #include <secmodt.h> | 10 #include <secmodt.h> |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // In addition to the oid data, the encoding requires one byte for the ASN.1 | 333 // In addition to the oid data, the encoding requires one byte for the ASN.1 |
| 334 // tag and one byte for the length (assuming the length is <= 127). | 334 // tag and one byte for the length (assuming the length is <= 127). |
| 335 DCHECK_LE(oid_data->oid.len, 127U); | 335 DCHECK_LE(oid_data->oid.len, 127U); |
| 336 std::vector<unsigned char> parameters_buf(2 + oid_data->oid.len); | 336 std::vector<unsigned char> parameters_buf(2 + oid_data->oid.len); |
| 337 SECKEYECParams ec_parameters = { | 337 SECKEYECParams ec_parameters = { |
| 338 siDEROID, ¶meters_buf[0], | 338 siDEROID, ¶meters_buf[0], |
| 339 static_cast<unsigned>(parameters_buf.size()) | 339 static_cast<unsigned>(parameters_buf.size()) |
| 340 }; | 340 }; |
| 341 | 341 |
| 342 ec_parameters.data[0] = SEC_ASN1_OBJECT_ID; | 342 ec_parameters.data[0] = SEC_ASN1_OBJECT_ID; |
| 343 ec_parameters.data[1] = oid_data->oid.len; | 343 ec_parameters.data[1] = static_cast<unsigned char>(oid_data->oid.len); |
| 344 memcpy(ec_parameters.data + 2, oid_data->oid.data, oid_data->oid.len); | 344 memcpy(ec_parameters.data + 2, oid_data->oid.data, oid_data->oid.len); |
| 345 | 345 |
| 346 result->key_ = PK11_GenerateKeyPair(slot, | 346 result->key_ = PK11_GenerateKeyPair(slot, |
| 347 CKM_EC_KEY_PAIR_GEN, | 347 CKM_EC_KEY_PAIR_GEN, |
| 348 &ec_parameters, | 348 &ec_parameters, |
| 349 &result->public_key_, | 349 &result->public_key_, |
| 350 permanent, | 350 permanent, |
| 351 sensitive, | 351 sensitive, |
| 352 NULL); | 352 NULL); |
| 353 if (!result->key_) { | 353 if (!result->key_) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 396 |
| 397 if (success) { | 397 if (success) { |
| 398 CHECK_EQ(ecKey, SECKEY_GetPublicKeyType(result->public_key_)); | 398 CHECK_EQ(ecKey, SECKEY_GetPublicKeyType(result->public_key_)); |
| 399 return result.release(); | 399 return result.release(); |
| 400 } | 400 } |
| 401 | 401 |
| 402 return NULL; | 402 return NULL; |
| 403 } | 403 } |
| 404 | 404 |
| 405 } // namespace crypto | 405 } // namespace crypto |
| OLD | NEW |