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

Side by Side Diff: net/quic/core/crypto/crypto_utils.cc

Issue 2097913002: Update QuicConnectionLogger to always log missing_packets, even for v34. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test for domain names containing '_', in order to be more accepting of non-standard SNI. Created 4 years, 3 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
« no previous file with comments | « no previous file | net/quic/core/crypto/crypto_utils_test.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/core/crypto/crypto_utils.h" 5 #include "net/quic/core/crypto/crypto_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "crypto/hkdf.h" 9 #include "crypto/hkdf.h"
10 #include "crypto/secure_hash.h" 10 #include "crypto/secure_hash.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 memcpy(&(*nonce)[bytes_written], orbit.data(), orbit.size()); 47 memcpy(&(*nonce)[bytes_written], orbit.data(), orbit.size());
48 bytes_written += orbit.size(); 48 bytes_written += orbit.size();
49 } 49 }
50 50
51 random_generator->RandBytes(&(*nonce)[bytes_written], 51 random_generator->RandBytes(&(*nonce)[bytes_written],
52 kNonceSize - bytes_written); 52 kNonceSize - bytes_written);
53 } 53 }
54 54
55 // static 55 // static
56 bool CryptoUtils::IsValidSNI(StringPiece sni) { 56 bool CryptoUtils::IsValidSNI(StringPiece sni) {
57 // TODO(rtenneti): Support RFC2396 hostname.
58 // NOTE: Microsoft does NOT enforce this spec, so if we throw away hostnames
59 // based on the above spec, we may be losing some hostnames that windows
60 // would consider valid. By far the most common hostname character NOT
61 // accepted by the above spec is '_'.
62 url::CanonHostInfo host_info; 57 url::CanonHostInfo host_info;
63 string canonicalized_host(CanonicalizeHost(sni.as_string(), &host_info)); 58 string canonicalized_host(CanonicalizeHost(sni.as_string(), &host_info));
64 return !host_info.IsIPAddress() && 59 return !host_info.IsIPAddress() &&
65 IsCanonicalizedHostCompliant(canonicalized_host) && 60 IsCanonicalizedHostCompliant(canonicalized_host) &&
66 sni.find_last_of('.') != string::npos; 61 sni.find_last_of('.') != string::npos;
67 } 62 }
68 63
69 // static 64 // static
70 string CryptoUtils::NormalizeHostname(const char* hostname) { 65 string CryptoUtils::NormalizeHostname(const char* hostname) {
71 url::CanonHostInfo host_info; 66 url::CanonHostInfo host_info;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 const QuicData& serialized = message.GetSerialized(); 326 const QuicData& serialized = message.GetSerialized();
332 std::unique_ptr<crypto::SecureHash> hash( 327 std::unique_ptr<crypto::SecureHash> hash(
333 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); 328 crypto::SecureHash::Create(crypto::SecureHash::SHA256));
334 hash->Update(serialized.data(), serialized.length()); 329 hash->Update(serialized.data(), serialized.length());
335 uint8_t digest[32]; 330 uint8_t digest[32];
336 hash->Finish(digest, sizeof(digest)); 331 hash->Finish(digest, sizeof(digest));
337 output->assign(reinterpret_cast<const char*>(&digest), sizeof(digest)); 332 output->assign(reinterpret_cast<const char*>(&digest), sizeof(digest));
338 } 333 }
339 334
340 } // namespace net 335 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/core/crypto/crypto_utils_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698