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

Side by Side Diff: crypto/rsa_private_key_openssl.cc

Issue 1129083007: Replace EVP_PKEY_dup calls with EVP_PKEY_up_ref. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « crypto/ec_private_key_openssl.cc ('k') | net/base/openssl_private_key_store_memory.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "crypto/rsa_private_key.h" 5 #include "crypto/rsa_private_key.h"
6 6
7 #include <openssl/bio.h> 7 #include <openssl/bio.h>
8 #include <openssl/bn.h> 8 #include <openssl/bn.h>
9 #include <openssl/evp.h> 9 #include <openssl/evp.h>
10 #include <openssl/pkcs12.h> 10 #include <openssl/pkcs12.h>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 return result.release(); 97 return result.release();
98 } 98 }
99 99
100 // static 100 // static
101 RSAPrivateKey* RSAPrivateKey::CreateFromKey(EVP_PKEY* key) { 101 RSAPrivateKey* RSAPrivateKey::CreateFromKey(EVP_PKEY* key) {
102 DCHECK(key); 102 DCHECK(key);
103 if (EVP_PKEY_type(key->type) != EVP_PKEY_RSA) 103 if (EVP_PKEY_type(key->type) != EVP_PKEY_RSA)
104 return NULL; 104 return NULL;
105 RSAPrivateKey* copy = new RSAPrivateKey(); 105 RSAPrivateKey* copy = new RSAPrivateKey();
106 copy->key_ = EVP_PKEY_dup(key); 106 copy->key_ = EVP_PKEY_up_ref(key);
107 return copy; 107 return copy;
108 } 108 }
109 109
110 RSAPrivateKey::RSAPrivateKey() 110 RSAPrivateKey::RSAPrivateKey()
111 : key_(NULL) { 111 : key_(NULL) {
112 } 112 }
113 113
114 RSAPrivateKey::~RSAPrivateKey() { 114 RSAPrivateKey::~RSAPrivateKey() {
115 if (key_) 115 if (key_)
116 EVP_PKEY_free(key_); 116 EVP_PKEY_free(key_);
(...skipping 12 matching lines...) Expand all
129 129
130 bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) const { 130 bool RSAPrivateKey::ExportPrivateKey(std::vector<uint8>* output) const {
131 return ExportKey(key_, i2d_PKCS8PrivateKeyInfo_bio, output); 131 return ExportKey(key_, i2d_PKCS8PrivateKeyInfo_bio, output);
132 } 132 }
133 133
134 bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) const { 134 bool RSAPrivateKey::ExportPublicKey(std::vector<uint8>* output) const {
135 return ExportKey(key_, i2d_PUBKEY_bio, output); 135 return ExportKey(key_, i2d_PUBKEY_bio, output);
136 } 136 }
137 137
138 } // namespace crypto 138 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/ec_private_key_openssl.cc ('k') | net/base/openssl_private_key_store_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698