| OLD | NEW |
| 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/numerics/safe_conversions.h" | 8 #include "base/numerics/safe_conversions.h" |
| 9 #include "base/sys_byteorder.h" | 9 #include "base/sys_byteorder.h" |
| 10 | 10 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 return string(&result[0], result_size); | 147 return string(&result[0], result_size); |
| 148 } | 148 } |
| 149 | 149 |
| 150 KeyExchange* P256KeyExchange::NewKeyPair(QuicRandom* /*rand*/) const { | 150 KeyExchange* P256KeyExchange::NewKeyPair(QuicRandom* /*rand*/) const { |
| 151 // TODO(agl): avoid the serialisation/deserialisation in this function. | 151 // TODO(agl): avoid the serialisation/deserialisation in this function. |
| 152 const string private_value = NewPrivateKey(); | 152 const string private_value = NewPrivateKey(); |
| 153 return P256KeyExchange::New(private_value); | 153 return P256KeyExchange::New(private_value); |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool P256KeyExchange::CalculateSharedKey(const StringPiece& peer_public_value, | 156 bool P256KeyExchange::CalculateSharedKey(StringPiece peer_public_value, |
| 157 string* out_result) const { | 157 string* out_result) const { |
| 158 if (peer_public_value.size() != kUncompressedP256PointBytes || | 158 if (peer_public_value.size() != kUncompressedP256PointBytes || |
| 159 peer_public_value[0] != kUncompressedECPointForm) { | 159 peer_public_value[0] != kUncompressedECPointForm) { |
| 160 DVLOG(1) << "Peer public value is invalid."; | 160 DVLOG(1) << "Peer public value is invalid."; |
| 161 return false; | 161 return false; |
| 162 } | 162 } |
| 163 | 163 |
| 164 DCHECK(key_pair_.get()); | 164 DCHECK(key_pair_.get()); |
| 165 DCHECK(key_pair_->public_key()); | 165 DCHECK(key_pair_->public_key()); |
| 166 | 166 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 StringPiece P256KeyExchange::public_value() const { | 215 StringPiece P256KeyExchange::public_value() const { |
| 216 return StringPiece(reinterpret_cast<const char*>(public_key_), | 216 return StringPiece(reinterpret_cast<const char*>(public_key_), |
| 217 sizeof(public_key_)); | 217 sizeof(public_key_)); |
| 218 } | 218 } |
| 219 | 219 |
| 220 QuicTag P256KeyExchange::tag() const { | 220 QuicTag P256KeyExchange::tag() const { |
| 221 return kP256; | 221 return kP256; |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace net | 224 } // namespace net |
| OLD | NEW |