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 "content/common/ssl_status_serialization.h" | 5 #include "content/common/ssl_status_serialization.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 std::string SerializeSecurityInfo( | 12 std::string SerializeSecurityInfo( |
13 int cert_id, | 13 int cert_id, |
14 net::CertStatus cert_status, | 14 net::CertStatus cert_status, |
15 int security_bits, | 15 int security_bits, |
16 int ssl_connection_status, | 16 int ssl_connection_status, |
17 const SignedCertificateTimestampIDStatusList& | 17 const SignedCertificateTimestampIDStatusList& |
18 signed_certificate_timestamp_ids) { | 18 signed_certificate_timestamp_ids) { |
19 Pickle pickle; | 19 base::Pickle pickle; |
20 pickle.WriteInt(cert_id); | 20 pickle.WriteInt(cert_id); |
21 pickle.WriteUInt32(cert_status); | 21 pickle.WriteUInt32(cert_status); |
22 pickle.WriteInt(security_bits); | 22 pickle.WriteInt(security_bits); |
23 pickle.WriteInt(ssl_connection_status); | 23 pickle.WriteInt(ssl_connection_status); |
24 pickle.WriteInt(signed_certificate_timestamp_ids.size()); | 24 pickle.WriteInt(signed_certificate_timestamp_ids.size()); |
25 for (SignedCertificateTimestampIDStatusList::const_iterator iter = | 25 for (SignedCertificateTimestampIDStatusList::const_iterator iter = |
26 signed_certificate_timestamp_ids.begin(); | 26 signed_certificate_timestamp_ids.begin(); |
27 iter != signed_certificate_timestamp_ids.end(); ++iter) { | 27 iter != signed_certificate_timestamp_ids.end(); ++iter) { |
28 pickle.WriteInt(iter->id); | 28 pickle.WriteInt(iter->id); |
29 pickle.WriteUInt16(iter->status); | 29 pickle.WriteUInt16(iter->status); |
(...skipping 14 matching lines...) Expand all Loading... |
44 // No SSL used. | 44 // No SSL used. |
45 *cert_id = 0; | 45 *cert_id = 0; |
46 // The following are not applicable and are set to the default values. | 46 // The following are not applicable and are set to the default values. |
47 *cert_status = 0; | 47 *cert_status = 0; |
48 *security_bits = -1; | 48 *security_bits = -1; |
49 *ssl_connection_status = 0; | 49 *ssl_connection_status = 0; |
50 signed_certificate_timestamp_ids->clear(); | 50 signed_certificate_timestamp_ids->clear(); |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 Pickle pickle(state.data(), static_cast<int>(state.size())); | 54 base::Pickle pickle(state.data(), static_cast<int>(state.size())); |
55 PickleIterator iter(pickle); | 55 base::PickleIterator iter(pickle); |
56 int num_scts_to_read; | 56 int num_scts_to_read; |
57 if (!iter.ReadInt(cert_id) || | 57 if (!iter.ReadInt(cert_id) || |
58 !iter.ReadUInt32(cert_status) || | 58 !iter.ReadUInt32(cert_status) || |
59 !iter.ReadInt(security_bits) || | 59 !iter.ReadInt(security_bits) || |
60 !iter.ReadInt(ssl_connection_status) || | 60 !iter.ReadInt(ssl_connection_status) || |
61 !iter.ReadInt(&num_scts_to_read)) | 61 !iter.ReadInt(&num_scts_to_read)) |
62 return false; | 62 return false; |
63 | 63 |
64 for (; num_scts_to_read > 0; --num_scts_to_read) { | 64 for (; num_scts_to_read > 0; --num_scts_to_read) { |
65 int id; | 65 int id; |
66 uint16 status; | 66 uint16 status; |
67 if (!iter.ReadInt(&id) || !iter.ReadUInt16(&status)) | 67 if (!iter.ReadInt(&id) || !iter.ReadUInt16(&status)) |
68 return false; | 68 return false; |
69 signed_certificate_timestamp_ids->push_back( | 69 signed_certificate_timestamp_ids->push_back( |
70 SignedCertificateTimestampIDAndStatus( | 70 SignedCertificateTimestampIDAndStatus( |
71 id, | 71 id, |
72 static_cast<net::ct::SCTVerifyStatus>(status))); | 72 static_cast<net::ct::SCTVerifyStatus>(status))); |
73 } | 73 } |
74 | 74 |
75 return true; | 75 return true; |
76 } | 76 } |
77 | 77 |
78 } // namespace content | 78 } // namespace content |
OLD | NEW |