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

Side by Side Diff: net/cert/ct_serialization.cc

Issue 1498003003: Remove kint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: INT64_MAX Created 5 years 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
« no previous file with comments | « net/base/backoff_entry.cc ('k') | net/disk_cache/simple/simple_entry_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits>
10
9 #include "base/logging.h" 11 #include "base/logging.h"
10 12
11 namespace net { 13 namespace net {
12 14
13 namespace ct { 15 namespace ct {
14 16
15 namespace { 17 namespace {
16 18
17 // Note: length is always specified in bytes. 19 // Note: length is always specified in bytes.
18 // Signed Certificate Timestamp (SCT) Version length 20 // Signed Certificate Timestamp (SCT) Version length
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 base::StringPiece log_id; 355 base::StringPiece log_id;
354 base::StringPiece extensions; 356 base::StringPiece extensions;
355 if (!ReadFixedBytes(kLogIdLength, input, &log_id) || 357 if (!ReadFixedBytes(kLogIdLength, input, &log_id) ||
356 !ReadUint(kTimestampLength, input, &timestamp) || 358 !ReadUint(kTimestampLength, input, &timestamp) ||
357 !ReadVariableBytes(kExtensionsLengthBytes, input, 359 !ReadVariableBytes(kExtensionsLengthBytes, input,
358 &extensions) || 360 &extensions) ||
359 !DecodeDigitallySigned(input, &result->signature)) { 361 !DecodeDigitallySigned(input, &result->signature)) {
360 return false; 362 return false;
361 } 363 }
362 364
363 if (timestamp > static_cast<uint64_t>(kint64max)) { 365 if (timestamp > static_cast<uint64_t>(std::numeric_limits<int64_t>::max())) {
364 DVLOG(1) << "Timestamp value too big to cast to int64_t: " << timestamp; 366 DVLOG(1) << "Timestamp value too big to cast to int64_t: " << timestamp;
365 return false; 367 return false;
366 } 368 }
367 369
368 log_id.CopyToString(&result->log_id); 370 log_id.CopyToString(&result->log_id);
369 extensions.CopyToString(&result->extensions); 371 extensions.CopyToString(&result->extensions);
370 result->timestamp = 372 result->timestamp =
371 base::Time::UnixEpoch() + 373 base::Time::UnixEpoch() +
372 base::TimeDelta::FromMilliseconds(static_cast<int64_t>(timestamp)); 374 base::TimeDelta::FromMilliseconds(static_cast<int64_t>(timestamp));
373 375
374 output->swap(result); 376 output->swap(result);
375 return true; 377 return true;
376 } 378 }
377 379
378 bool EncodeSCTListForTesting(const base::StringPiece& sct, 380 bool EncodeSCTListForTesting(const base::StringPiece& sct,
379 std::string* output) { 381 std::string* output) {
380 std::string encoded_sct; 382 std::string encoded_sct;
381 return WriteVariableBytes(kSerializedSCTLengthBytes, sct, &encoded_sct) && 383 return WriteVariableBytes(kSerializedSCTLengthBytes, sct, &encoded_sct) &&
382 WriteVariableBytes(kSCTListLengthBytes, encoded_sct, output); 384 WriteVariableBytes(kSCTListLengthBytes, encoded_sct, output);
383 } 385 }
384 386
385 } // namespace ct 387 } // namespace ct
386 388
387 } // namespace net 389 } // namespace net
OLDNEW
« no previous file with comments | « net/base/backoff_entry.cc ('k') | net/disk_cache/simple/simple_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698