OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |