Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: components/gcm_driver/crypto/p256_key_util.cc

Issue 1461703009: Switch //components from vector_as_array to vector::data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: eroman comment Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/html_viewer/blink_platform_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/gcm_driver/crypto/p256_key_util.h" 5 #include "components/gcm_driver/crypto/p256_key_util.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/stl_util.h"
13 #include "crypto/ec_private_key.h" 12 #include "crypto/ec_private_key.h"
14 13
15 namespace gcm { 14 namespace gcm {
16 15
17 namespace { 16 namespace {
18 17
19 // The first byte in an uncompressed P-256 point per SEC1 2.3.3. 18 // The first byte in an uncompressed P-256 point per SEC1 2.3.3.
20 const char kUncompressedPointForm = 0x04; 19 const char kUncompressedPointForm = 0x04;
21 20
22 // A P-256 field element consists of 32 bytes. 21 // A P-256 field element consists of 32 bytes.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 std::vector<uint8_t> public_key_x509; 64 std::vector<uint8_t> public_key_x509;
66 65
67 // Export the public key to an X.509 SubjectPublicKeyInfo for enabling NSS to 66 // Export the public key to an X.509 SubjectPublicKeyInfo for enabling NSS to
68 // import the key material when computing a shared secret. 67 // import the key material when computing a shared secret.
69 if (!key_pair->ExportPublicKey(&public_key_x509)) { 68 if (!key_pair->ExportPublicKey(&public_key_x509)) {
70 DLOG(ERROR) << "Unable to export the public key as an X.509 " 69 DLOG(ERROR) << "Unable to export the public key as an X.509 "
71 << "SubjectPublicKeyInfo block."; 70 << "SubjectPublicKeyInfo block.";
72 return false; 71 return false;
73 } 72 }
74 73
75 out_private_key->assign( 74 out_private_key->assign(reinterpret_cast<const char*>(private_key.data()),
76 reinterpret_cast<const char*>(vector_as_array(&private_key)), 75 private_key.size());
77 private_key.size());
78 out_public_key_x509->assign( 76 out_public_key_x509->assign(
79 reinterpret_cast<const char*>(vector_as_array(&public_key_x509)), 77 reinterpret_cast<const char*>(public_key_x509.data()),
80 public_key_x509.size()); 78 public_key_x509.size());
81 79
82 // Concatenate the leading 0x04 byte and the two uncompressed points. 80 // Concatenate the leading 0x04 byte and the two uncompressed points.
83 out_public_key->reserve(kUncompressedPointBytes); 81 out_public_key->reserve(kUncompressedPointBytes);
84 out_public_key->push_back(kUncompressedPointForm); 82 out_public_key->push_back(kUncompressedPointForm);
85 out_public_key->append(candidate_public_key); 83 out_public_key->append(candidate_public_key);
86 84
87 return true; 85 return true;
88 } 86 }
89 87
90 } // namespace gcm 88 } // namespace gcm
OLDNEW
« no previous file with comments | « no previous file | components/html_viewer/blink_platform_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698