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

Side by Side Diff: components/webcrypto/algorithms/ecdh.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 | « components/webcrypto/algorithms/ec.cc ('k') | components/webcrypto/algorithms/ecdsa.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 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 <openssl/ec.h> 5 #include <openssl/ec.h>
6 #include <openssl/ecdh.h> 6 #include <openssl/ecdh.h>
7 #include <openssl/evp.h> 7 #include <openssl/evp.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h"
11 #include "components/webcrypto/algorithm_implementation.h" 10 #include "components/webcrypto/algorithm_implementation.h"
12 #include "components/webcrypto/algorithms/ec.h" 11 #include "components/webcrypto/algorithms/ec.h"
13 #include "components/webcrypto/algorithms/util.h" 12 #include "components/webcrypto/algorithms/util.h"
14 #include "components/webcrypto/blink_key_handle.h" 13 #include "components/webcrypto/blink_key_handle.h"
15 #include "components/webcrypto/crypto_data.h" 14 #include "components/webcrypto/crypto_data.h"
16 #include "components/webcrypto/generate_key_result.h" 15 #include "components/webcrypto/generate_key_result.h"
17 #include "components/webcrypto/status.h" 16 #include "components/webcrypto/status.h"
18 #include "crypto/openssl_util.h" 17 #include "crypto/openssl_util.h"
19 #include "crypto/scoped_openssl_types.h" 18 #include "crypto/scoped_openssl_types.h"
20 #include "crypto/secure_util.h" 19 #include "crypto/secure_util.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return Status::Success(); 104 return Status::Success();
106 } 105 }
107 106
108 if (length_bits > static_cast<unsigned int>(field_size_bytes * 8)) 107 if (length_bits > static_cast<unsigned int>(field_size_bytes * 8))
109 return Status::ErrorEcdhLengthTooBig(field_size_bytes * 8); 108 return Status::ErrorEcdhLengthTooBig(field_size_bytes * 8);
110 109
111 // Resize to target length in bytes (BoringSSL can operate on a shorter 110 // Resize to target length in bytes (BoringSSL can operate on a shorter
112 // buffer than field_size_bytes). 111 // buffer than field_size_bytes).
113 derived_bytes->resize(NumBitsToBytes(length_bits)); 112 derived_bytes->resize(NumBitsToBytes(length_bits));
114 113
115 int result = 114 int result = ECDH_compute_key(derived_bytes->data(), derived_bytes->size(),
116 ECDH_compute_key(vector_as_array(derived_bytes), derived_bytes->size(), 115 public_key_point, private_key_ec.get(), 0);
117 public_key_point, private_key_ec.get(), 0);
118 if (result < 0 || static_cast<size_t>(result) != derived_bytes->size()) 116 if (result < 0 || static_cast<size_t>(result) != derived_bytes->size())
119 return Status::OperationError(); 117 return Status::OperationError();
120 118
121 TruncateToBitLength(length_bits, derived_bytes); 119 TruncateToBitLength(length_bits, derived_bytes);
122 return Status::Success(); 120 return Status::Success();
123 } 121 }
124 }; 122 };
125 123
126 } // namespace 124 } // namespace
127 125
128 scoped_ptr<AlgorithmImplementation> CreateEcdhImplementation() { 126 scoped_ptr<AlgorithmImplementation> CreateEcdhImplementation() {
129 return make_scoped_ptr(new EcdhImplementation); 127 return make_scoped_ptr(new EcdhImplementation);
130 } 128 }
131 129
132 } // namespace webcrypto 130 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/ec.cc ('k') | components/webcrypto/algorithms/ecdsa.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698