Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <tuple> | 5 #include <tuple> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/numerics/safe_math.h" | 8 #include "base/numerics/safe_math.h" |
| 9 #include "base/time/time.h" | |
| 9 #include "net/der/parse_values.h" | 10 #include "net/der/parse_values.h" |
| 10 | 11 |
| 11 namespace net { | 12 namespace net { |
| 12 | 13 |
| 13 namespace der { | 14 namespace der { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 bool ParseBoolInternal(const Input& in, bool* out, bool relaxed) { | 18 bool ParseBoolInternal(const Input& in, bool* out, bool relaxed) { |
| 18 // According to ITU-T X.690 section 8.2, a bool is encoded as a single octet | 19 // According to ITU-T X.690 section 8.2, a bool is encoded as a single octet |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 } | 377 } |
| 377 uint8_t zulu; | 378 uint8_t zulu; |
| 378 if (!reader.ReadByte(&zulu) || zulu != 'Z' || reader.HasMore()) | 379 if (!reader.ReadByte(&zulu) || zulu != 'Z' || reader.HasMore()) |
| 379 return false; | 380 return false; |
| 380 if (!ValidateGeneralizedTime(time)) | 381 if (!ValidateGeneralizedTime(time)) |
| 381 return false; | 382 return false; |
| 382 *value = time; | 383 *value = time; |
| 383 return true; | 384 return true; |
| 384 } | 385 } |
| 385 | 386 |
| 387 der::GeneralizedTime ConvertBaseUTCTime(const base::Time& time) { | |
| 388 base::Time::Exploded exploded; | |
| 389 time.UTCExplode(&exploded); | |
| 390 | |
| 391 der::GeneralizedTime result; | |
| 392 result.year = exploded.year; | |
| 393 result.month = exploded.month; | |
| 394 result.day = exploded.day_of_month; | |
| 395 result.hours = exploded.hour; | |
| 396 result.minutes = exploded.minute; | |
| 397 result.seconds = exploded.second; | |
| 398 return result; | |
|
svaldez
2016/06/24 13:40:46
Might need a unittest, or at the very least throw
dadrian
2016/06/24 17:16:14
Done.
| |
| 399 } | |
| 400 | |
| 386 } // namespace der | 401 } // namespace der |
| 387 | 402 |
| 388 } // namespace net | 403 } // namespace net |
| OLD | NEW |