| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ct_serialization.h" | 5 #include "net/cert/ct_serialization.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 case DigitallySigned::SIG_ALGO_DSA: | 162 case DigitallySigned::SIG_ALGO_DSA: |
| 163 case DigitallySigned::SIG_ALGO_ECDSA: | 163 case DigitallySigned::SIG_ALGO_ECDSA: |
| 164 break; | 164 break; |
| 165 default: | 165 default: |
| 166 return false; | 166 return false; |
| 167 } | 167 } |
| 168 *out = static_cast<DigitallySigned::SignatureAlgorithm>(in); | 168 *out = static_cast<DigitallySigned::SignatureAlgorithm>(in); |
| 169 return true; | 169 return true; |
| 170 } | 170 } |
| 171 | 171 |
| 172 // Checks and converts a log entry type. | |
| 173 // |in| the numeric representation of the log type. | |
| 174 // If the log type is 0 (X.509 cert) or 1 (PreCertificate), fills in |out| and | |
| 175 // returns true. Otherwise, returns false. | |
| 176 bool ConvertLogEntryType(int in, LogEntry::Type* out) { | |
| 177 switch (in) { | |
| 178 case LogEntry::LOG_ENTRY_TYPE_X509: | |
| 179 case LogEntry::LOG_ENTRY_TYPE_PRECERT: | |
| 180 break; | |
| 181 default: | |
| 182 return false; | |
| 183 } | |
| 184 *out = static_cast<LogEntry::Type>(in); | |
| 185 return true; | |
| 186 } | |
| 187 | |
| 188 // Writes a TLS-encoded variable length unsigned integer to |output|. | 172 // Writes a TLS-encoded variable length unsigned integer to |output|. |
| 189 // |length| indicates the size (in bytes) of the integer. | 173 // |length| indicates the size (in bytes) of the integer. |
| 190 // |value| the value itself to be written. | 174 // |value| the value itself to be written. |
| 191 template <typename T> | 175 template <typename T> |
| 192 void WriteUint(size_t length, T value, std::string* output) { | 176 void WriteUint(size_t length, T value, std::string* output) { |
| 193 DCHECK_LE(length, sizeof(T)); | 177 DCHECK_LE(length, sizeof(T)); |
| 194 DCHECK(length == sizeof(T) || value >> (length * 8) == 0); | 178 DCHECK(length == sizeof(T) || value >> (length * 8) == 0); |
| 195 | 179 |
| 196 for (; length > 0; --length) { | 180 for (; length > 0; --length) { |
| 197 output->push_back((value >> ((length - 1)* 8)) & 0xFF); | 181 output->push_back((value >> ((length - 1)* 8)) & 0xFF); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 base::Time::UnixEpoch() + | 350 base::Time::UnixEpoch() + |
| 367 base::TimeDelta::FromMilliseconds(static_cast<int64>(timestamp)); | 351 base::TimeDelta::FromMilliseconds(static_cast<int64>(timestamp)); |
| 368 | 352 |
| 369 *output = result; | 353 *output = result; |
| 370 return true; | 354 return true; |
| 371 } | 355 } |
| 372 | 356 |
| 373 } // namespace ct | 357 } // namespace ct |
| 374 | 358 |
| 375 } // namespace net | 359 } // namespace net |
| OLD | NEW |