| 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_cert_types.h" | 5 #include "net/cert/x509_cert_types.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // |*ok| is set to false if there is an error in parsing the number, but left | 22 // |*ok| is set to false if there is an error in parsing the number, but left |
| 23 // untouched otherwise. Returns the parsed integer. | 23 // untouched otherwise. Returns the parsed integer. |
| 24 int ParseIntAndAdvance(const char** field, size_t field_len, bool* ok) { | 24 int ParseIntAndAdvance(const char** field, size_t field_len, bool* ok) { |
| 25 int result = 0; | 25 int result = 0; |
| 26 *ok &= ParseInt32(base::StringPiece(*field, field_len), | 26 *ok &= ParseInt32(base::StringPiece(*field, field_len), |
| 27 ParseIntFormat::NON_NEGATIVE, &result); | 27 ParseIntFormat::NON_NEGATIVE, &result); |
| 28 *field += field_len; | 28 *field += field_len; |
| 29 return result; | 29 return result; |
| 30 } | 30 } |
| 31 | 31 |
| 32 } | 32 } // anonymous namespace |
| 33 | 33 |
| 34 CertPrincipal::CertPrincipal() { | 34 CertPrincipal::CertPrincipal() { |
| 35 } | 35 } |
| 36 | 36 |
| 37 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {} | 37 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {} |
| 38 | 38 |
| 39 CertPrincipal::~CertPrincipal() { | 39 CertPrincipal::~CertPrincipal() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 std::string CertPrincipal::GetDisplayName() const { | 42 std::string CertPrincipal::GetDisplayName() const { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 70 exploded.second = ParseIntAndAdvance(&field, 2, &valid); | 70 exploded.second = ParseIntAndAdvance(&field, 2, &valid); |
| 71 if (valid && year_length == 2) | 71 if (valid && year_length == 2) |
| 72 exploded.year += exploded.year < 50 ? 2000 : 1900; | 72 exploded.year += exploded.year < 50 ? 2000 : 1900; |
| 73 | 73 |
| 74 if (!valid) | 74 if (!valid) |
| 75 return false; | 75 return false; |
| 76 return base::Time::FromUTCExploded(exploded, time); | 76 return base::Time::FromUTCExploded(exploded, time); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace net | 79 } // namespace net |
| OLD | NEW |