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

Side by Side Diff: chrome/browser/extensions/api/networking_private/networking_private_crypto.cc

Issue 168643002: Convert scoped_ptr_malloc -> scoped_ptr, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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 "chrome/browser/extensions/api/networking_private/networking_private_cr ypto.h" 5 #include "chrome/browser/extensions/api/networking_private/networking_private_cr ypto.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <cryptohi.h> 8 #include <cryptohi.h>
9 #include <keyhi.h> 9 #include <keyhi.h>
10 #include <keythi.h> 10 #include <keythi.h>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 LOG(ERROR) << "Failed to parse certificate."; 83 LOG(ERROR) << "Failed to parse certificate.";
84 return false; 84 return false;
85 } 85 }
86 SECItem der_cert; 86 SECItem der_cert;
87 der_cert.type = siDERCertBuffer; 87 der_cert.type = siDERCertBuffer;
88 der_cert.data = reinterpret_cast<unsigned char*>( 88 der_cert.data = reinterpret_cast<unsigned char*>(
89 const_cast<char*>(cert_data.c_str())); 89 const_cast<char*>(cert_data.c_str()));
90 der_cert.len = cert_data.length(); 90 der_cert.len = cert_data.length();
91 91
92 // Parse into a certificate structure. 92 // Parse into a certificate structure.
93 typedef scoped_ptr_malloc< 93 typedef scoped_ptr<
94 CERTCertificate, 94 CERTCertificate,
95 crypto::NSSDestroyer<CERTCertificate, 95 crypto::NSSDestroyer<CERTCertificate, CERT_DestroyCertificate> >
96 CERT_DestroyCertificate> > 96 ScopedCERTCertificate;
97 ScopedCERTCertificate;
98 ScopedCERTCertificate cert(CERT_NewTempCertificate( 97 ScopedCERTCertificate cert(CERT_NewTempCertificate(
99 CERT_GetDefaultCertDB(), &der_cert, NULL, PR_FALSE, PR_TRUE)); 98 CERT_GetDefaultCertDB(), &der_cert, NULL, PR_FALSE, PR_TRUE));
100 if (!cert.get()) { 99 if (!cert.get()) {
101 LOG(ERROR) << "Failed to parse certificate."; 100 LOG(ERROR) << "Failed to parse certificate.";
102 return false; 101 return false;
103 } 102 }
104 103
105 // Check that the certificate is signed by trusted CA. 104 // Check that the certificate is signed by trusted CA.
106 SECItem trusted_ca_key_der_item; 105 SECItem trusted_ca_key_der_item;
107 trusted_ca_key_der_item.type = siDERCertBuffer; 106 trusted_ca_key_der_item.type = siDERCertBuffer;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 encrypted_data.length()); 231 encrypted_data.length());
233 if (decrypted != SECSuccess) { 232 if (decrypted != SECSuccess) {
234 LOG(ERROR) << "Error during decryption."; 233 LOG(ERROR) << "Error during decryption.";
235 return false; 234 return false;
236 } 235 }
237 decrypted_output->assign(reinterpret_cast<char*>(rsa_output.get()), 236 decrypted_output->assign(reinterpret_cast<char*>(rsa_output.get()),
238 output_length); 237 output_length);
239 return true; 238 return true;
240 } 239 }
241 240
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698