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

Side by Side Diff: net/base/x509_util_nss_unittest.cc

Issue 8588015: Fix leak in X509UtilNSSTest VerifyCertificateSignature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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
« 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 (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 "net/base/x509_util.h" 5 #include "net/base/x509_util.h"
6 #include "net/base/x509_util_nss.h" 6 #include "net/base/x509_util_nss.h"
7 7
8 #include <cert.h> 8 #include <cert.h>
9 #include <secoid.h> 9 #include <secoid.h>
10 10
(...skipping 16 matching lines...) Expand all
27 der_cert.len = length; 27 der_cert.len = length;
28 der_cert.type = siDERCertBuffer; 28 der_cert.type = siDERCertBuffer;
29 29
30 // Parse into a certificate structure. 30 // Parse into a certificate structure.
31 return CERT_NewTempCertificate(CERT_GetDefaultCertDB(), &der_cert, NULL, 31 return CERT_NewTempCertificate(CERT_GetDefaultCertDB(), &der_cert, NULL,
32 PR_FALSE, PR_TRUE); 32 PR_FALSE, PR_TRUE);
33 } 33 }
34 34
35 void VerifyCertificateSignature(const std::string& der_cert, 35 void VerifyCertificateSignature(const std::string& der_cert,
36 const std::vector<uint8>& der_spki) { 36 const std::vector<uint8>& der_spki) {
37 crypto::ScopedPLArenaPool arena; 37 crypto::ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE));
38 38
39 CERTSignedData sd; 39 CERTSignedData sd;
40 memset(&sd, 0, sizeof(sd)); 40 memset(&sd, 0, sizeof(sd));
41 41
42 SECItem der_cert_item = { 42 SECItem der_cert_item = {
43 siDERCertBuffer, 43 siDERCertBuffer,
44 reinterpret_cast<unsigned char*>(const_cast<char*>(der_cert.data())), 44 reinterpret_cast<unsigned char*>(const_cast<char*>(der_cert.data())),
45 der_cert.size() 45 der_cert.size()
46 }; 46 };
47 SECStatus rv = SEC_ASN1DecodeItem(arena.get(), &sd, 47 SECStatus rv = SEC_ASN1DecodeItem(arena.get(), &sd,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 #if !defined(OS_WIN) && !defined(OS_MACOSX) 179 #if !defined(OS_WIN) && !defined(OS_MACOSX)
180 // signature_verifier_win and signature_verifier_mac can't handle EC certs. 180 // signature_verifier_win and signature_verifier_mac can't handle EC certs.
181 std::vector<uint8> spki; 181 std::vector<uint8> spki;
182 ASSERT_TRUE(private_key->ExportPublicKey(&spki)); 182 ASSERT_TRUE(private_key->ExportPublicKey(&spki));
183 VerifyCertificateSignature(der_cert, spki); 183 VerifyCertificateSignature(der_cert, spki);
184 #endif 184 #endif
185 } 185 }
186 186
187 } // namespace net 187 } // 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