| 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 #include "net/cert/x509_certificate.h" | 5 #include "net/cert/x509_certificate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 SHA256HashValue sha256; | 713 SHA256HashValue sha256; |
| 714 memset(sha256.data, 0, sizeof(sha256.data)); | 714 memset(sha256.data, 0, sizeof(sha256.data)); |
| 715 | 715 |
| 716 scoped_ptr<crypto::SecureHash> hash( | 716 scoped_ptr<crypto::SecureHash> hash( |
| 717 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); | 717 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); |
| 718 | 718 |
| 719 for (size_t i = 0; i < intermediates.size(); ++i) { | 719 for (size_t i = 0; i < intermediates.size(); ++i) { |
| 720 std::string der_encoded; | 720 std::string der_encoded; |
| 721 if (!GetDEREncoded(intermediates[i], &der_encoded)) | 721 if (!GetDEREncoded(intermediates[i], &der_encoded)) |
| 722 return sha256; | 722 return sha256; |
| 723 hash->Update(der_encoded.c_str(), der_encoded.length()); | 723 hash->Update(der_encoded.data(), der_encoded.length()); |
| 724 } | 724 } |
| 725 hash->Finish(sha256.data, sizeof(sha256.data)); | 725 hash->Finish(sha256.data, sizeof(sha256.data)); |
| 726 | 726 |
| 727 return sha256; | 727 return sha256; |
| 728 } | 728 } |
| 729 | 729 |
| 730 // static | 730 // static |
| 731 SHA256HashValue X509Certificate::CalculateChainFingerprint256( | 731 SHA256HashValue X509Certificate::CalculateChainFingerprint256( |
| 732 const OSCertHandle& leaf, | 732 OSCertHandle leaf, |
| 733 const OSCertHandles& intermediates) { | 733 const OSCertHandles& intermediates) { |
| 734 OSCertHandles chain; | 734 OSCertHandles chain; |
| 735 chain.push_back(leaf); | 735 chain.push_back(leaf); |
| 736 chain.insert(chain.end(), intermediates.begin(), intermediates.end()); | 736 chain.insert(chain.end(), intermediates.begin(), intermediates.end()); |
| 737 | 737 |
| 738 return CalculateCAFingerprint256(chain); | 738 return CalculateCAFingerprint256(chain); |
| 739 } | 739 } |
| 740 | 740 |
| 741 X509Certificate::X509Certificate(OSCertHandle cert_handle, | 741 X509Certificate::X509Certificate(OSCertHandle cert_handle, |
| 742 const OSCertHandles& intermediates) | 742 const OSCertHandles& intermediates) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 760 RemoveFromCache(cert_handle_); | 760 RemoveFromCache(cert_handle_); |
| 761 FreeOSCertHandle(cert_handle_); | 761 FreeOSCertHandle(cert_handle_); |
| 762 } | 762 } |
| 763 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) { | 763 for (size_t i = 0; i < intermediate_ca_certs_.size(); ++i) { |
| 764 RemoveFromCache(intermediate_ca_certs_[i]); | 764 RemoveFromCache(intermediate_ca_certs_[i]); |
| 765 FreeOSCertHandle(intermediate_ca_certs_[i]); | 765 FreeOSCertHandle(intermediate_ca_certs_[i]); |
| 766 } | 766 } |
| 767 } | 767 } |
| 768 | 768 |
| 769 } // namespace net | 769 } // namespace net |
| OLD | NEW |