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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 Format format); | 382 Format format); |
383 | 383 |
384 // Duplicates (or adds a reference to) an OS certificate handle. | 384 // Duplicates (or adds a reference to) an OS certificate handle. |
385 static OSCertHandle DupOSCertHandle(OSCertHandle cert_handle); | 385 static OSCertHandle DupOSCertHandle(OSCertHandle cert_handle); |
386 | 386 |
387 // Frees (or releases a reference to) an OS certificate handle. | 387 // Frees (or releases a reference to) an OS certificate handle. |
388 static void FreeOSCertHandle(OSCertHandle cert_handle); | 388 static void FreeOSCertHandle(OSCertHandle cert_handle); |
389 | 389 |
390 // Calculates the SHA-1 fingerprint of the certificate. Returns an empty | 390 // Calculates the SHA-1 fingerprint of the certificate. Returns an empty |
391 // (all zero) fingerprint on failure. | 391 // (all zero) fingerprint on failure. |
392 // | |
393 // For calculating fingerprints, prefer SHA-1 for performance when indexing, | |
394 // but callers should use IsSameOSCert() before assuming two certificates are | |
395 // the same. | |
392 static SHA1HashValue CalculateFingerprint(OSCertHandle cert_handle); | 396 static SHA1HashValue CalculateFingerprint(OSCertHandle cert_handle); |
393 | 397 |
394 // Calculates the SHA-1 fingerprint of the intermediate CA certificates. | 398 // Calculates the SHA-1 fingerprint of the intermediate CA certificates. |
395 // Returns an empty (all zero) fingerprint on failure. | 399 // Returns an empty (all zero) fingerprint on failure. |
400 // | |
401 // See SHA-1 caveat on CalculateFingerprint(). | |
396 static SHA1HashValue CalculateCAFingerprint( | 402 static SHA1HashValue CalculateCAFingerprint( |
397 const OSCertHandles& intermediates); | 403 const OSCertHandles& intermediates); |
398 | 404 |
405 // Calculates the SHA-256 fingerprint of the intermediate CA certificates. | |
406 // Returns an empty (all zero) fingerprint on failure. | |
407 // | |
408 // The implementation currently relies on the crypto::SecureHash utilities, | |
wtc
2014/07/28 17:29:52
Nit: it seems that the performance issue is caused
jww
2014/07/28 18:36:14
Done.
| |
409 // which are not as fast as implementing this directly for each platform since | |
410 // the consumers are not expected to be performance critical. If performance | |
411 // is a concern going forward, it may be warranted to implement this on a | |
412 // per-platform basis. | |
413 static SHA256HashValue CalculateCAFingerprint256( | |
414 const OSCertHandles& intermediates); | |
415 | |
416 // Calculates the SHA-256 fingerprint for the complete chain, including the | |
417 // leaf certificate and all intermediate CA certificates. Returns an empty | |
418 // (all zero) fingerprint on failure. | |
419 static SHA256HashValue CalculateChainFingerprint256( | |
wtc
2014/07/28 17:29:52
For a minimal API, this method can be subsumed by
jww
2014/07/28 18:36:13
This would make it inconsistent with the SHA1 API,
| |
420 const OSCertHandle& leaf, | |
wtc
2014/07/28 17:29:52
Please pass a single OSCertHandle by value. It is
jww
2014/07/28 18:36:13
Done.
| |
421 const OSCertHandles& intermediates); | |
422 | |
399 private: | 423 private: |
400 friend class base::RefCountedThreadSafe<X509Certificate>; | 424 friend class base::RefCountedThreadSafe<X509Certificate>; |
401 friend class TestRootCerts; // For unit tests | 425 friend class TestRootCerts; // For unit tests |
402 | 426 |
403 FRIEND_TEST_ALL_PREFIXES(X509CertificateNameVerifyTest, VerifyHostname); | 427 FRIEND_TEST_ALL_PREFIXES(X509CertificateNameVerifyTest, VerifyHostname); |
404 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, SerialNumbers); | 428 FRIEND_TEST_ALL_PREFIXES(X509CertificateTest, SerialNumbers); |
405 | 429 |
406 // Construct an X509Certificate from a handle to the certificate object | 430 // Construct an X509Certificate from a handle to the certificate object |
407 // in the underlying crypto library. | 431 // in the underlying crypto library. |
408 X509Certificate(OSCertHandle cert_handle, | 432 X509Certificate(OSCertHandle cert_handle, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 // based on the type of the certificate. | 509 // based on the type of the certificate. |
486 std::string default_nickname_; | 510 std::string default_nickname_; |
487 #endif | 511 #endif |
488 | 512 |
489 DISALLOW_COPY_AND_ASSIGN(X509Certificate); | 513 DISALLOW_COPY_AND_ASSIGN(X509Certificate); |
490 }; | 514 }; |
491 | 515 |
492 } // namespace net | 516 } // namespace net |
493 | 517 |
494 #endif // NET_CERT_X509_CERTIFICATE_H_ | 518 #endif // NET_CERT_X509_CERTIFICATE_H_ |
OLD | NEW |