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

Side by Side Diff: net/quic/crypto/p256_key_exchange_nss.cc

Issue 14816006: Land Recent QUIC changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_PRIVATE_EXPORT to QuicWallTime Created 7 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/crypto/p256_key_exchange.h ('k') | net/quic/crypto/p256_key_exchange_openssl.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "net/quic/crypto/p256_key_exchange.h" 5 #include "net/quic/crypto/p256_key_exchange.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/sys_byteorder.h" 8 #include "base/sys_byteorder.h"
9 9
10 using base::StringPiece; 10 using base::StringPiece;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 private_key_size = base::ByteSwapToLE16(private_key_size); 142 private_key_size = base::ByteSwapToLE16(private_key_size);
143 memcpy(resultp, &private_key_size, sizeof(private_key_size)); 143 memcpy(resultp, &private_key_size, sizeof(private_key_size));
144 resultp += sizeof(private_key_size); 144 resultp += sizeof(private_key_size);
145 memcpy(resultp, &private_key[0], private_key.size()); 145 memcpy(resultp, &private_key[0], private_key.size());
146 resultp += private_key.size(); 146 resultp += private_key.size();
147 memcpy(resultp, &public_key[0], public_key.size()); 147 memcpy(resultp, &public_key[0], public_key.size());
148 148
149 return string(&result[0], result_size); 149 return string(&result[0], result_size);
150 } 150 }
151 151
152 bool P256KeyExchange::CalculateSharedKey( 152 KeyExchange* P256KeyExchange::NewKeyPair(QuicRandom* /*rand*/) const {
153 const StringPiece& peer_public_value, 153 // TODO(agl): avoid the serialisation/deserialisation in this function.
154 string* out_result) const { 154 const string private_value = NewPrivateKey();
155 return P256KeyExchange::New(private_value);
156 }
157
158 bool P256KeyExchange::CalculateSharedKey(const StringPiece& peer_public_value,
159 string* out_result) const {
155 if (peer_public_value.size() != kUncompressedP256PointBytes || 160 if (peer_public_value.size() != kUncompressedP256PointBytes ||
156 peer_public_value[0] != kUncompressedECPointForm) { 161 peer_public_value[0] != kUncompressedECPointForm) {
157 DLOG(INFO) << "Peer public value is invalid."; 162 DLOG(INFO) << "Peer public value is invalid.";
158 return false; 163 return false;
159 } 164 }
160 165
161 DCHECK(key_pair_.get()); 166 DCHECK(key_pair_.get());
162 DCHECK(key_pair_->public_key()); 167 DCHECK(key_pair_->public_key());
163 168
164 SECKEYPublicKey peer_public_key; 169 SECKEYPublicKey peer_public_key;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 220
216 out_result->assign(reinterpret_cast<char*>(key_data->data), key_data->len); 221 out_result->assign(reinterpret_cast<char*>(key_data->data), key_data->len);
217 return true; 222 return true;
218 } 223 }
219 224
220 StringPiece P256KeyExchange::public_value() const { 225 StringPiece P256KeyExchange::public_value() const {
221 return StringPiece(reinterpret_cast<const char*>(public_key_), 226 return StringPiece(reinterpret_cast<const char*>(public_key_),
222 sizeof(public_key_)); 227 sizeof(public_key_));
223 } 228 }
224 229
225 CryptoTag P256KeyExchange::tag() const { 230 QuicTag P256KeyExchange::tag() const { return kP256; }
226 return kP256;
227 }
228 231
229 } // namespace net 232 } // namespace net
230 233
OLDNEW
« no previous file with comments | « net/quic/crypto/p256_key_exchange.h ('k') | net/quic/crypto/p256_key_exchange_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698