Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: net/der/parse_values.cc

Issue 2091103002: Add CheckOCSPDateValid() to net/cert/internal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests for ConvertBaseUTCTime Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 DCHECK(ValidateGeneralizedTime(result));
Ryan Sleevi 2016/06/28 17:33:30 Why DCHECK here? A DCHECK signals that there's a c
dadrian 2016/06/28 19:15:27 Presumably we should handle this the same way expl
dadrian 2016/06/29 22:54:02 Nvm, just removed the DCHECK().
399 return result;
400 }
401
386 } // namespace der 402 } // namespace der
387 403
388 } // namespace net 404 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698