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

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

Issue 1158923005: Use the exact-width integer types defined in <stdint.h> rather than (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak comments. Exclude mime_sniffer*. Rebase. Created 5 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 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 <stdint.h>
8
8 #include "base/logging.h" 9 #include "base/logging.h"
9 10
10 namespace net { 11 namespace net {
11 12
12 namespace ct { 13 namespace ct {
13 14
14 namespace { 15 namespace {
15 16
16 // Note: length is always specified in bytes. 17 // Note: length is always specified in bytes.
17 // Signed Certificate Timestamp (SCT) Version length 18 // Signed Certificate Timestamp (SCT) Version length
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 new SignedCertificateTimestamp()); 342 new SignedCertificateTimestamp());
342 unsigned version; 343 unsigned version;
343 if (!ReadUint(kVersionLength, input, &version)) 344 if (!ReadUint(kVersionLength, input, &version))
344 return false; 345 return false;
345 if (version != SignedCertificateTimestamp::SCT_VERSION_1) { 346 if (version != SignedCertificateTimestamp::SCT_VERSION_1) {
346 DVLOG(1) << "Unsupported/invalid version " << version; 347 DVLOG(1) << "Unsupported/invalid version " << version;
347 return false; 348 return false;
348 } 349 }
349 350
350 result->version = SignedCertificateTimestamp::SCT_VERSION_1; 351 result->version = SignedCertificateTimestamp::SCT_VERSION_1;
351 uint64 timestamp; 352 uint64_t timestamp;
352 base::StringPiece log_id; 353 base::StringPiece log_id;
353 base::StringPiece extensions; 354 base::StringPiece extensions;
354 if (!ReadFixedBytes(kLogIdLength, input, &log_id) || 355 if (!ReadFixedBytes(kLogIdLength, input, &log_id) ||
355 !ReadUint(kTimestampLength, input, &timestamp) || 356 !ReadUint(kTimestampLength, input, &timestamp) ||
356 !ReadVariableBytes(kExtensionsLengthBytes, input, 357 !ReadVariableBytes(kExtensionsLengthBytes, input,
357 &extensions) || 358 &extensions) ||
358 !DecodeDigitallySigned(input, &result->signature)) { 359 !DecodeDigitallySigned(input, &result->signature)) {
359 return false; 360 return false;
360 } 361 }
361 362
362 if (timestamp > static_cast<uint64>(kint64max)) { 363 if (timestamp > static_cast<uint64_t>(kint64max)) {
363 DVLOG(1) << "Timestamp value too big to cast to int64: " << timestamp; 364 DVLOG(1) << "Timestamp value too big to cast to int64_t: " << timestamp;
364 return false; 365 return false;
365 } 366 }
366 367
367 log_id.CopyToString(&result->log_id); 368 log_id.CopyToString(&result->log_id);
368 extensions.CopyToString(&result->extensions); 369 extensions.CopyToString(&result->extensions);
369 result->timestamp = 370 result->timestamp =
370 base::Time::UnixEpoch() + 371 base::Time::UnixEpoch() +
371 base::TimeDelta::FromMilliseconds(static_cast<int64>(timestamp)); 372 base::TimeDelta::FromMilliseconds(static_cast<int64_t>(timestamp));
372 373
373 output->swap(result); 374 output->swap(result);
374 return true; 375 return true;
375 } 376 }
376 377
377 bool EncodeSCTListForTesting(const base::StringPiece& sct, 378 bool EncodeSCTListForTesting(const base::StringPiece& sct,
378 std::string* output) { 379 std::string* output) {
379 std::string encoded_sct; 380 std::string encoded_sct;
380 return WriteVariableBytes(kSerializedSCTLengthBytes, sct, &encoded_sct) && 381 return WriteVariableBytes(kSerializedSCTLengthBytes, sct, &encoded_sct) &&
381 WriteVariableBytes(kSCTListLengthBytes, encoded_sct, output); 382 WriteVariableBytes(kSCTListLengthBytes, encoded_sct, output);
382 } 383 }
383 384
384 } // namespace ct 385 } // namespace ct
385 386
386 } // namespace net 387 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698