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

Side by Side Diff: net/ssl/openssl_client_key_store.cc

Issue 610533003: Allow custom deleters to opt out of self reset checks for scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sigh android 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 | « net/ssl/openssl_client_key_store.h ('k') | 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 (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/ssl/openssl_client_key_store.h" 5 #include "net/ssl/openssl_client_key_store.h"
6 6
7 #include <openssl/evp.h> 7 #include <openssl/evp.h>
8 #include <openssl/x509.h> 8 #include <openssl/x509.h>
9 #include <algorithm>
9 10
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
12 #include "net/cert/x509_certificate.h" 13 #include "net/cert/x509_certificate.h"
13 14
14 namespace net { 15 namespace net {
15 16
16 namespace { 17 namespace {
17 18
18 // Return the EVP_PKEY holding the public key of a given certificate. 19 // Return the EVP_PKEY holding the public key of a given certificate.
(...skipping 24 matching lines...) Expand all
43 } 44 }
44 45
45 OpenSSLClientKeyStore::KeyPair::~KeyPair() { 46 OpenSSLClientKeyStore::KeyPair::~KeyPair() {
46 } 47 }
47 48
48 OpenSSLClientKeyStore::KeyPair::KeyPair(const KeyPair& other) 49 OpenSSLClientKeyStore::KeyPair::KeyPair(const KeyPair& other)
49 : public_key(EVP_PKEY_dup(other.public_key.get())), 50 : public_key(EVP_PKEY_dup(other.public_key.get())),
50 private_key(EVP_PKEY_dup(other.private_key.get())) { 51 private_key(EVP_PKEY_dup(other.private_key.get())) {
51 } 52 }
52 53
53 void OpenSSLClientKeyStore::KeyPair::operator=(const KeyPair& other) { 54 void OpenSSLClientKeyStore::KeyPair::operator=(KeyPair other) {
54 // Use a temporary ScopedEVP_PKEY because scoped_ptr does not allow resetting 55 swap(other);
55 // to the current value, even though it's safe here. 56 }
56 crypto::ScopedEVP_PKEY public_key_tmp(EVP_PKEY_dup(other.public_key.get())); 57
57 crypto::ScopedEVP_PKEY private_key_tmp(EVP_PKEY_dup(other.private_key.get())); 58 void OpenSSLClientKeyStore::KeyPair::swap(KeyPair& other) {
58 public_key.reset(); 59 using std::swap;
59 public_key = public_key_tmp.Pass(); 60 swap(public_key, other.public_key);
60 private_key.reset(); 61 swap(private_key, other.private_key);
61 private_key = private_key_tmp.Pass();
62 } 62 }
63 63
64 int OpenSSLClientKeyStore::FindKeyPairIndex(EVP_PKEY* public_key) { 64 int OpenSSLClientKeyStore::FindKeyPairIndex(EVP_PKEY* public_key) {
65 if (!public_key) 65 if (!public_key)
66 return -1; 66 return -1;
67 for (size_t n = 0; n < pairs_.size(); ++n) { 67 for (size_t n = 0; n < pairs_.size(); ++n) {
68 if (EVP_PKEY_cmp(pairs_[n].public_key.get(), public_key) == 1) 68 if (EVP_PKEY_cmp(pairs_[n].public_key.get(), public_key) == 1)
69 return static_cast<int>(n); 69 return static_cast<int>(n);
70 } 70 }
71 return -1; 71 return -1;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 pairs_.clear(); 116 pairs_.clear();
117 } 117 }
118 118
119 OpenSSLClientKeyStore* OpenSSLClientKeyStore::GetInstance() { 119 OpenSSLClientKeyStore* OpenSSLClientKeyStore::GetInstance() {
120 return Singleton<OpenSSLClientKeyStore>::get(); 120 return Singleton<OpenSSLClientKeyStore>::get();
121 } 121 }
122 122
123 } // namespace net 123 } // namespace net
124 124
125 125
OLDNEW
« no previous file with comments | « net/ssl/openssl_client_key_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698