OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_BASE_X509_CERTIFICATE_H_ | 5 #ifndef NET_BASE_X509_CERTIFICATE_H_ |
6 #define NET_BASE_X509_CERTIFICATE_H_ | 6 #define NET_BASE_X509_CERTIFICATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 #elif defined(USE_OPENSSL) | 30 #elif defined(USE_OPENSSL) |
31 // Forward declaration; real one in <x509.h> | 31 // Forward declaration; real one in <x509.h> |
32 typedef struct x509_st X509; | 32 typedef struct x509_st X509; |
33 typedef struct x509_store_st X509_STORE; | 33 typedef struct x509_store_st X509_STORE; |
34 #elif defined(USE_NSS) | 34 #elif defined(USE_NSS) |
35 // Forward declaration; real one in <cert.h> | 35 // Forward declaration; real one in <cert.h> |
36 struct CERTCertificateStr; | 36 struct CERTCertificateStr; |
37 #endif | 37 #endif |
38 | 38 |
39 class Pickle; | 39 class Pickle; |
| 40 class PickleIterator; |
40 | 41 |
41 namespace crypto { | 42 namespace crypto { |
42 class RSAPrivateKey; | 43 class RSAPrivateKey; |
43 } // namespace crypto | 44 } // namespace crypto |
44 | 45 |
45 namespace net { | 46 namespace net { |
46 | 47 |
47 class CRLSet; | 48 class CRLSet; |
48 class CertVerifyResult; | 49 class CertVerifyResult; |
49 | 50 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 std::string GetDefaultNickname(CertType type) const; | 175 std::string GetDefaultNickname(CertType type) const; |
175 #endif | 176 #endif |
176 | 177 |
177 // Create an X509Certificate from the representation stored in the given | 178 // Create an X509Certificate from the representation stored in the given |
178 // pickle. The data for this object is found relative to the given | 179 // pickle. The data for this object is found relative to the given |
179 // pickle_iter, which should be passed to the pickle's various Read* methods. | 180 // pickle_iter, which should be passed to the pickle's various Read* methods. |
180 // Returns NULL on failure. | 181 // Returns NULL on failure. |
181 // | 182 // |
182 // The returned pointer must be stored in a scoped_refptr<X509Certificate>. | 183 // The returned pointer must be stored in a scoped_refptr<X509Certificate>. |
183 static X509Certificate* CreateFromPickle(const Pickle& pickle, | 184 static X509Certificate* CreateFromPickle(const Pickle& pickle, |
184 void** pickle_iter, | 185 PickleIterator* pickle_iter, |
185 PickleType type); | 186 PickleType type); |
186 | 187 |
187 // Parses all of the certificates possible from |data|. |format| is a | 188 // Parses all of the certificates possible from |data|. |format| is a |
188 // bit-wise OR of Format, indicating the possible formats the | 189 // bit-wise OR of Format, indicating the possible formats the |
189 // certificates may have been serialized as. If an error occurs, an empty | 190 // certificates may have been serialized as. If an error occurs, an empty |
190 // collection will be returned. | 191 // collection will be returned. |
191 static CertificateList CreateCertificateListFromBytes(const char* data, | 192 static CertificateList CreateCertificateListFromBytes(const char* data, |
192 int length, | 193 int length, |
193 int format); | 194 int format); |
194 | 195 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 static bool IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, | 548 static bool IsSHA1HashInSortedArray(const SHA1Fingerprint& hash, |
548 const uint8* array, | 549 const uint8* array, |
549 size_t array_byte_len); | 550 size_t array_byte_len); |
550 | 551 |
551 // Reads a single certificate from |pickle| and returns a platform-specific | 552 // Reads a single certificate from |pickle| and returns a platform-specific |
552 // certificate handle. The format of the certificate stored in |pickle| is | 553 // certificate handle. The format of the certificate stored in |pickle| is |
553 // not guaranteed to be the same across different underlying cryptographic | 554 // not guaranteed to be the same across different underlying cryptographic |
554 // libraries, nor acceptable to CreateFromBytes(). Returns an invalid | 555 // libraries, nor acceptable to CreateFromBytes(). Returns an invalid |
555 // handle, NULL, on failure. | 556 // handle, NULL, on failure. |
556 static OSCertHandle ReadOSCertHandleFromPickle(const Pickle& pickle, | 557 static OSCertHandle ReadOSCertHandleFromPickle(const Pickle& pickle, |
557 void** pickle_iter); | 558 PickleIterator* pickle_iter); |
558 | 559 |
559 // Writes a single certificate to |pickle|. Returns false on failure. | 560 // Writes a single certificate to |pickle|. Returns false on failure. |
560 static bool WriteOSCertHandleToPickle(OSCertHandle handle, Pickle* pickle); | 561 static bool WriteOSCertHandleToPickle(OSCertHandle handle, Pickle* pickle); |
561 | 562 |
562 // The subject of the certificate. | 563 // The subject of the certificate. |
563 CertPrincipal subject_; | 564 CertPrincipal subject_; |
564 | 565 |
565 // The issuer of the certificate. | 566 // The issuer of the certificate. |
566 CertPrincipal issuer_; | 567 CertPrincipal issuer_; |
567 | 568 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 // (Marked mutable because it's used in a const method.) | 601 // (Marked mutable because it's used in a const method.) |
601 mutable base::Lock verification_lock_; | 602 mutable base::Lock verification_lock_; |
602 #endif | 603 #endif |
603 | 604 |
604 DISALLOW_COPY_AND_ASSIGN(X509Certificate); | 605 DISALLOW_COPY_AND_ASSIGN(X509Certificate); |
605 }; | 606 }; |
606 | 607 |
607 } // namespace net | 608 } // namespace net |
608 | 609 |
609 #endif // NET_BASE_X509_CERTIFICATE_H_ | 610 #endif // NET_BASE_X509_CERTIFICATE_H_ |
OLD | NEW |