| 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/crypto_utils.h" | 5 #include "net/quic/crypto/crypto_utils.h" |
| 6 | 6 |
| 7 #include "crypto/hkdf.h" | 7 #include "crypto/hkdf.h" |
| 8 #include "crypto/secure_hash.h" |
| 8 #include "net/base/url_util.h" | 9 #include "net/base/url_util.h" |
| 9 #include "net/quic/crypto/crypto_handshake.h" | 10 #include "net/quic/crypto/crypto_handshake.h" |
| 10 #include "net/quic/crypto/crypto_protocol.h" | 11 #include "net/quic/crypto/crypto_protocol.h" |
| 11 #include "net/quic/crypto/quic_decrypter.h" | 12 #include "net/quic/crypto/quic_decrypter.h" |
| 12 #include "net/quic/crypto/quic_encrypter.h" | 13 #include "net/quic/crypto/quic_encrypter.h" |
| 13 #include "net/quic/crypto/quic_random.h" | 14 #include "net/quic/crypto/quic_random.h" |
| 14 #include "net/quic/quic_time.h" | 15 #include "net/quic/quic_time.h" |
| 15 #include "net/quic/quic_utils.h" | 16 #include "net/quic/quic_utils.h" |
| 16 #include "url/url_canon.h" | 17 #include "url/url_canon.h" |
| 17 | 18 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 268 |
| 268 RETURN_STRING_LITERAL(INVALID_EXPECTED_LEAF_CERTIFICATE); | 269 RETURN_STRING_LITERAL(INVALID_EXPECTED_LEAF_CERTIFICATE); |
| 269 RETURN_STRING_LITERAL(MAX_FAILURE_REASON); | 270 RETURN_STRING_LITERAL(MAX_FAILURE_REASON); |
| 270 } | 271 } |
| 271 // Return a default value so that we return this when |reason| doesn't match | 272 // Return a default value so that we return this when |reason| doesn't match |
| 272 // any HandshakeFailureReason.. This can happen when the message by the peer | 273 // any HandshakeFailureReason.. This can happen when the message by the peer |
| 273 // (attacker) has invalid reason. | 274 // (attacker) has invalid reason. |
| 274 return "INVALID_HANDSHAKE_FAILURE_REASON"; | 275 return "INVALID_HANDSHAKE_FAILURE_REASON"; |
| 275 } | 276 } |
| 276 | 277 |
| 278 // static |
| 279 void CryptoUtils::HashHandshakeMessage(const CryptoHandshakeMessage& message, |
| 280 string* output) { |
| 281 const QuicData& serialized = message.GetSerialized(); |
| 282 scoped_ptr<crypto::SecureHash> hash( |
| 283 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); |
| 284 hash->Update(serialized.data(), serialized.length()); |
| 285 uint8_t digest[32]; |
| 286 hash->Finish(digest, sizeof(digest)); |
| 287 output->assign(reinterpret_cast<const char*>(&digest), sizeof(digest)); |
| 288 } |
| 289 |
| 277 } // namespace net | 290 } // namespace net |
| OLD | NEW |