| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/cert_verify_result.h" | 5 #include "net/cert/cert_verify_result.h" |
| 6 | 6 |
| 7 #include "net/cert/x509_certificate.h" | 7 #include "net/cert/x509_certificate.h" |
| 8 | 8 |
| 9 namespace net { | 9 namespace net { |
| 10 | 10 |
| 11 CertVerifyResult::CertVerifyResult() { | 11 CertVerifyResult::CertVerifyResult() { |
| 12 Reset(); | 12 Reset(); |
| 13 } | 13 } |
| 14 | 14 |
| 15 CertVerifyResult::CertVerifyResult(const CertVerifyResult& other) = default; | 15 CertVerifyResult::CertVerifyResult(const CertVerifyResult& other) = default; |
| 16 | 16 |
| 17 CertVerifyResult::~CertVerifyResult() { | 17 CertVerifyResult::~CertVerifyResult() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 bool CertVerifyResult::Persist(base::Pickle* pickle) const { |
| 21 if (!pickle->WriteUInt32(cert_status) || !pickle->WriteBool(has_md2) || |
| 22 !pickle->WriteBool(has_md4) || !pickle->WriteBool(has_md5) || |
| 23 !pickle->WriteBool(has_sha1) || !pickle->WriteBool(has_sha1_leaf) || |
| 24 !pickle->WriteBool(is_issued_by_known_root) || |
| 25 !pickle->WriteBool(is_issued_by_additional_trust_anchor) || |
| 26 !pickle->WriteBool(common_name_fallback_used) || |
| 27 !pickle->WriteUInt64(public_key_hashes.size())) { |
| 28 return false; |
| 29 } |
| 30 for (const HashValue& value : public_key_hashes) { |
| 31 if (!pickle->WriteString(value.ToString())) |
| 32 return false; |
| 33 } |
| 34 verified_cert->Persist(pickle); |
| 35 return true; |
| 36 } |
| 37 |
| 38 // static |
| 39 bool CertVerifyResult::CreateFromPickle(base::PickleIterator* iter, |
| 40 CertVerifyResult* result) { |
| 41 uint64_t public_key_hashes_size; |
| 42 if (!iter->ReadUInt32(&result->cert_status) || |
| 43 !iter->ReadBool(&result->has_md2) || !iter->ReadBool(&result->has_md4) || |
| 44 !iter->ReadBool(&result->has_md5) || !iter->ReadBool(&result->has_sha1) || |
| 45 !iter->ReadBool(&result->has_sha1_leaf) || |
| 46 !iter->ReadBool(&result->is_issued_by_known_root) || |
| 47 !iter->ReadBool(&result->is_issued_by_additional_trust_anchor) || |
| 48 !iter->ReadBool(&result->common_name_fallback_used) || |
| 49 !iter->ReadUInt64(&public_key_hashes_size)) { |
| 50 return false; |
| 51 } |
| 52 for (uint64_t index = 0u; index < public_key_hashes_size; ++index) { |
| 53 HashValue hash; |
| 54 std::string hash_value; |
| 55 if ((!iter->ReadString(&hash_value)) || (!hash.FromString(hash_value))) |
| 56 return false; |
| 57 result->public_key_hashes.push_back(hash); |
| 58 } |
| 59 result->verified_cert = X509Certificate::CreateFromPickle( |
| 60 iter, X509Certificate::PICKLETYPE_CERTIFICATE_CHAIN_V3); |
| 61 return result->verified_cert != NULL; |
| 62 } |
| 63 |
| 20 void CertVerifyResult::Reset() { | 64 void CertVerifyResult::Reset() { |
| 21 verified_cert = NULL; | 65 verified_cert = NULL; |
| 22 cert_status = 0; | 66 cert_status = 0; |
| 23 has_md2 = false; | 67 has_md2 = false; |
| 24 has_md4 = false; | 68 has_md4 = false; |
| 25 has_md5 = false; | 69 has_md5 = false; |
| 26 has_sha1 = false; | 70 has_sha1 = false; |
| 27 has_sha1_leaf = false; | 71 has_sha1_leaf = false; |
| 28 is_issued_by_known_root = false; | 72 is_issued_by_known_root = false; |
| 29 is_issued_by_additional_trust_anchor = false; | 73 is_issued_by_additional_trust_anchor = false; |
| 30 common_name_fallback_used = false; | 74 common_name_fallback_used = false; |
| 31 | 75 |
| 32 public_key_hashes.clear(); | 76 public_key_hashes.clear(); |
| 33 } | 77 } |
| 34 | 78 |
| 35 } // namespace net | 79 } // namespace net |
| OLD | NEW |