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> |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // Calculates the SHA-1 fingerprint of the intermediate CA certificates. | 398 // Calculates the SHA-1 fingerprint of the intermediate CA certificates. |
399 // Returns an empty (all zero) fingerprint on failure. | 399 // Returns an empty (all zero) fingerprint on failure. |
400 // | 400 // |
401 // See SHA-1 caveat on CalculateFingerprint(). | 401 // See SHA-1 caveat on CalculateFingerprint(). |
402 static SHA1HashValue CalculateCAFingerprint( | 402 static SHA1HashValue CalculateCAFingerprint( |
403 const OSCertHandles& intermediates); | 403 const OSCertHandles& intermediates); |
404 | 404 |
405 // Calculates the SHA-256 fingerprint of the intermediate CA certificates. | 405 // Calculates the SHA-256 fingerprint of the intermediate CA certificates. |
406 // Returns an empty (all zero) fingerprint on failure. | 406 // Returns an empty (all zero) fingerprint on failure. |
407 // | 407 // |
408 // The implementation currently relies on the crypto::SecureHash utilities, | 408 // As part of the cross-platform implementation of this function, it currently |
409 // which are not as fast as implementing this directly for each platform since | 409 // copies the certificate bytes into local variables which makes it |
410 // the consumers are not expected to be performance critical. If performance | 410 // potentially slower than implementing it directly for each platform. For |
411 // is a concern going forward, it may be warranted to implement this on a | 411 // now, the expected consumers are not performance critical, but if |
412 // per-platform basis. | 412 // performance is a concern going forward, it may warrant implementing this on |
| 413 // a per-platform basis. |
413 static SHA256HashValue CalculateCAFingerprint256( | 414 static SHA256HashValue CalculateCAFingerprint256( |
414 const OSCertHandles& intermediates); | 415 const OSCertHandles& intermediates); |
415 | 416 |
416 // Calculates the SHA-256 fingerprint for the complete chain, including the | 417 // Calculates the SHA-256 fingerprint for the complete chain, including the |
417 // leaf certificate and all intermediate CA certificates. Returns an empty | 418 // leaf certificate and all intermediate CA certificates. Returns an empty |
418 // (all zero) fingerprint on failure. | 419 // (all zero) fingerprint on failure. |
419 static SHA256HashValue CalculateChainFingerprint256( | 420 static SHA256HashValue CalculateChainFingerprint256( |
420 const OSCertHandle& leaf, | 421 OSCertHandle leaf, |
421 const OSCertHandles& intermediates); | 422 const OSCertHandles& intermediates); |
422 | 423 |
423 private: | 424 private: |
424 friend class base::RefCountedThreadSafe<X509Certificate>; | 425 friend class base::RefCountedThreadSafe<X509Certificate>; |
425 friend class TestRootCerts; // For unit tests | 426 friend class TestRootCerts; // For unit tests |
426 | 427 |
427 FRIEND_TEST_ALL_PREFIXES(X509CertificateNameVerifyTest, VerifyHostname); | 428 FRIEND_TEST_ALL_PREFIXES(X509CertificateNameVerifyTest, VerifyHostname); |
428 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, SerialNumbers); | 429 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, SerialNumbers); |
429 | 430 |
430 // Construct an X509Certificate from a handle to the certificate object | 431 // Construct an X509Certificate from a handle to the certificate object |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 // based on the type of the certificate. | 510 // based on the type of the certificate. |
510 std::string default_nickname_; | 511 std::string default_nickname_; |
511 #endif | 512 #endif |
512 | 513 |
513 DISALLOW_COPY_AND_ASSIGN(X509Certificate); | 514 DISALLOW_COPY_AND_ASSIGN(X509Certificate); |
514 }; | 515 }; |
515 | 516 |
516 } // namespace net | 517 } // namespace net |
517 | 518 |
518 #endif // NET_CERT_X509_CERTIFICATE_H_ | 519 #endif // NET_CERT_X509_CERTIFICATE_H_ |
OLD | NEW |