| 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_CERT_X509_CERTIFICATE_H_ | 5 #ifndef NET_CERT_X509_CERTIFICATE_H_ |
| 6 #define NET_CERT_X509_CERTIFICATE_H_ | 6 #define NET_CERT_X509_CERTIFICATE_H_ |
| 7 | 7 |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "net/base/net_export.h" | 17 #include "net/base/net_export.h" |
| 18 #include "net/cert/cert_type.h" | 18 #include "net/cert/cert_type.h" |
| 19 #include "net/cert/x509_cert_types.h" | 19 #include "net/cert/x509_cert_types.h" |
| 20 | 20 |
| 21 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 22 #include <windows.h> | 22 #include <windows.h> |
| 23 #include <wincrypt.h> | 23 #include "crypto/wincrypt_shim.h" |
| 24 #elif defined(OS_MACOSX) | 24 #elif defined(OS_MACOSX) |
| 25 #include <CoreFoundation/CFArray.h> | 25 #include <CoreFoundation/CFArray.h> |
| 26 #include <Security/SecBase.h> | 26 #include <Security/SecBase.h> |
| 27 | |
| 28 #elif defined(USE_OPENSSL_CERTS) | 27 #elif defined(USE_OPENSSL_CERTS) |
| 29 // Forward declaration; real one in <x509.h> | 28 // Forward declaration; real one in <x509.h> |
| 30 typedef struct x509_st X509; | 29 typedef struct x509_st X509; |
| 31 typedef struct x509_store_st X509_STORE; | 30 typedef struct x509_store_st X509_STORE; |
| 32 #elif defined(USE_NSS) | 31 #elif defined(USE_NSS) |
| 33 // Forward declaration; real one in <cert.h> | 32 // Forward declaration; real one in <cert.h> |
| 34 struct CERTCertificateStr; | 33 struct CERTCertificateStr; |
| 35 #endif | 34 #endif |
| 36 | 35 |
| 37 class Pickle; | 36 class Pickle; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 static SHA256HashValue CalculateCAFingerprint256( | 417 static SHA256HashValue CalculateCAFingerprint256( |
| 419 const OSCertHandles& intermediates); | 418 const OSCertHandles& intermediates); |
| 420 | 419 |
| 421 // Calculates the SHA-256 fingerprint for the complete chain, including the | 420 // Calculates the SHA-256 fingerprint for the complete chain, including the |
| 422 // leaf certificate and all intermediate CA certificates. Returns an empty | 421 // leaf certificate and all intermediate CA certificates. Returns an empty |
| 423 // (all zero) fingerprint on failure. | 422 // (all zero) fingerprint on failure. |
| 424 static SHA256HashValue CalculateChainFingerprint256( | 423 static SHA256HashValue CalculateChainFingerprint256( |
| 425 OSCertHandle leaf, | 424 OSCertHandle leaf, |
| 426 const OSCertHandles& intermediates); | 425 const OSCertHandles& intermediates); |
| 427 | 426 |
| 427 // Returns true if the certificate is self-signed. |
| 428 static bool IsSelfSigned(OSCertHandle cert_handle); |
| 429 |
| 428 private: | 430 private: |
| 429 friend class base::RefCountedThreadSafe<X509Certificate>; | 431 friend class base::RefCountedThreadSafe<X509Certificate>; |
| 430 friend class TestRootCerts; // For unit tests | 432 friend class TestRootCerts; // For unit tests |
| 431 | 433 |
| 432 FRIEND_TEST_ALL_PREFIXES(X509CertificateNameVerifyTest, VerifyHostname); | 434 FRIEND_TEST_ALL_PREFIXES(X509CertificateNameVerifyTest, VerifyHostname); |
| 433 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, SerialNumbers); | 435 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, SerialNumbers); |
| 434 | 436 |
| 435 // Construct an X509Certificate from a handle to the certificate object | 437 // Construct an X509Certificate from a handle to the certificate object |
| 436 // in the underlying crypto library. | 438 // in the underlying crypto library. |
| 437 X509Certificate(OSCertHandle cert_handle, | 439 X509Certificate(OSCertHandle cert_handle, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 // based on the type of the certificate. | 516 // based on the type of the certificate. |
| 515 std::string default_nickname_; | 517 std::string default_nickname_; |
| 516 #endif | 518 #endif |
| 517 | 519 |
| 518 DISALLOW_COPY_AND_ASSIGN(X509Certificate); | 520 DISALLOW_COPY_AND_ASSIGN(X509Certificate); |
| 519 }; | 521 }; |
| 520 | 522 |
| 521 } // namespace net | 523 } // namespace net |
| 522 | 524 |
| 523 #endif // NET_CERT_X509_CERTIFICATE_H_ | 525 #endif // NET_CERT_X509_CERTIFICATE_H_ |
| OLD | NEW |