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

Side by Side Diff: net/socket/ssl_session_cache_openssl.cc

Issue 604363003: Fix ssl_session_cache_openssl.cc hash function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/socket/ssl_session_cache_openssl.h" 5 #include "net/socket/ssl_session_cache_openssl.h"
6 6
7 #include <list> 7 #include <list>
8 #include <map> 8 #include <map>
9 9
10 #include <openssl/rand.h> 10 #include <openssl/rand.h>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 unsigned id_len; 80 unsigned id_len;
81 size_t hash; 81 size_t hash;
82 82
83 private: 83 private:
84 // Session ID are random strings of bytes. This happens to compute the same 84 // Session ID are random strings of bytes. This happens to compute the same
85 // value as std::hash<std::string> without the extra string copy. See 85 // value as std::hash<std::string> without the extra string copy. See
86 // base/containers/hash_tables.h. Other hashing computations are possible, 86 // base/containers/hash_tables.h. Other hashing computations are possible,
87 // this one is just simple enough to do the job. 87 // this one is just simple enough to do the job.
88 size_t ComputeHash(const unsigned char* id, unsigned id_len) { 88 size_t ComputeHash(const unsigned char* id, unsigned id_len) {
89 size_t result = 0; 89 size_t result = 0;
90 for (unsigned n = 0; n < id_len; ++n) 90 for (unsigned n = 0; n < id_len; ++n) {
91 result += 131 * id[n]; 91 result = (result * 131) + id[n];
92 }
92 return result; 93 return result;
93 } 94 }
94 }; 95 };
95 96
96 } // namespace 97 } // namespace
97 98
98 } // namespace net 99 } // namespace net
99 100
100 namespace BASE_HASH_NAMESPACE { 101 namespace BASE_HASH_NAMESPACE {
101 102
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 return impl_->SSLSessionIsInCache(cache_key); 521 return impl_->SSLSessionIsInCache(cache_key);
521 } 522 }
522 523
523 void SSLSessionCacheOpenSSL::MarkSSLSessionAsGood(SSL* ssl) { 524 void SSLSessionCacheOpenSSL::MarkSSLSessionAsGood(SSL* ssl) {
524 return impl_->MarkSSLSessionAsGood(ssl); 525 return impl_->MarkSSLSessionAsGood(ssl);
525 } 526 }
526 527
527 void SSLSessionCacheOpenSSL::Flush() { impl_->Flush(); } 528 void SSLSessionCacheOpenSSL::Flush() { impl_->Flush(); }
528 529
529 } // namespace net 530 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698